Commit 79623aa9 authored by Elena Grandi's avatar Elena Grandi
Browse files

Remove deprecated versions of check_(mac|ip|hostname)

parent 98e760ca
......@@ -3,7 +3,7 @@ import logging
import os
from .base import DataSource, MachineDataSourceMixin
from .. import events, compat
from .. import events, compat, utils
from .inotifywait import Inotifywait
......@@ -60,7 +60,7 @@ class ArpwatchDataSource(MachineDataSourceMixin, DataSource):
ts = int(parts[2])
mac = parts[0]
ip = parts[1]
if self.check_ip(ip) and self.check_mac(mac):
if utils.check_ip(ip) and utils.check_mac(mac):
await self.event_hub.publish(
events.HostSeenEvent(
self, mac=mac, ip=ip, timestamp=ts,
......
......@@ -70,24 +70,3 @@ class MachineDataSourceMixin:
def seen_name(self, name):
if name not in self.names:
self.names.append(name)
def check_mac(self, s):
"""
Check that a string looks like a macaddress
"""
raise DeprecationWarning("Use utils.check_mac instead.")
return utils.check_mac(s)
def check_ip(self, s):
"""
Check that a string looks like an ipv4 address
"""
raise DeprecationWarning("Use utils.check_ip instead.")
return utils.check_ip(s)
def check_hostname(self, s):
"""
Check that a string looks like an hostname.
"""
raise DeprecationWarning("Use utils.check_hostname instead.")
return utils.check_hostname(s)
......@@ -4,7 +4,7 @@ import logging
import dateutil.parser
from .. import events
from .. import events, utils
from .base import MachineDataSourceMixin
from .command import CommandDataSource
......@@ -36,7 +36,7 @@ class DhcpdDataSource(MachineDataSourceMixin, CommandDataSource):
message = b' '.join(split_line[5:])
if message.startswith(b'DHCPDISCOVER'):
mac = message.split()[2].decode()
if self.check_mac(mac):
if utils.check_mac(mac):
await self.event_hub.publish(
events.HostSeenEvent(
self, mac=mac, timestamp=timestamp,
......@@ -49,7 +49,7 @@ class DhcpdDataSource(MachineDataSourceMixin, CommandDataSource):
elif message.startswith(b'DHCPACK'):
mac = message.split()[4].decode()
ip = message.split()[2].decode()
if self.check_mac(mac) and self.check_ip(ip):
if utils.check_mac(mac) and utils.check_ip(ip):
await self.event_hub.publish(
events.HostSeenEvent(
self, mac=mac, ip=ip, timestamp=timestamp,
......@@ -62,7 +62,7 @@ class DhcpdDataSource(MachineDataSourceMixin, CommandDataSource):
elif message.startswith(b'Added new forward map'):
ip = message.split()[7].decode()
name = message.split()[5].decode()
if self.check_ip(ip) and self.check_hostname(name):
if utils.check_ip(ip) and utils.check_hostname(name):
await self.event_hub.publish(
events.HostSeenEvent(
self, ip=ip, name=name, timestamp=timestamp,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment