From 7ebc8ddb740ac7a9ea5c2b48565fec46b03d8776 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Sun, 30 Sep 2018 13:05:21 -0400 Subject: [PATCH] Add message when starting DHCP server --- router-daemon/pvcrd/DHCPServer.py | 5 ++++- router-daemon/pvcrd/VXNetworkInstance.py | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/router-daemon/pvcrd/DHCPServer.py b/router-daemon/pvcrd/DHCPServer.py index d7de801f..81cd0a52 100644 --- a/router-daemon/pvcrd/DHCPServer.py +++ b/router-daemon/pvcrd/DHCPServer.py @@ -39,6 +39,7 @@ import select import ipaddress from socket import * +import daemon_lib.ansiiprint as ansiiprint import daemon_lib.zkhandler as zkhandler # see https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol @@ -715,7 +716,8 @@ class HostDatabase(object): return list(map(Host.from_tuple, self.db.get(pattern))) def add(self, host): - self.db.add(host.to_tuple()) + host_tuple = host.to_tuple() + self.db.add(host_tuple) def delete(self, host = None, **kw): if host is None: @@ -833,6 +835,7 @@ class DHCPServer(object): if not any([host.ip == ip for host in known_hosts]): print('add', mac_address, ip, packet.host_name) self.hosts.replace(Host(mac_address, ip, packet.host_name or '', time.time())) + ansiiprint.echo('DHCP client allocated - {} {} {}'.format(mac_address, ip, packet.host_name), '', 'i') return ip @property diff --git a/router-daemon/pvcrd/VXNetworkInstance.py b/router-daemon/pvcrd/VXNetworkInstance.py index a85a92a6..60af7ed5 100644 --- a/router-daemon/pvcrd/VXNetworkInstance.py +++ b/router-daemon/pvcrd/VXNetworkInstance.py @@ -78,6 +78,7 @@ class VXNetworkInstance(): if data != None and self.dhcp_flag != data.decode('ascii'): self.dhcp_flag = ( data.decode('ascii') == 'True' ) if self.dhcp_flag: + ansiiprint.echo('Starting DHCP server for network "{}".'.format(self.ip_network), '', 'o') dhcp_config = DHCPServer.DHCPServerConfiguration( zk_conn=self.zk_conn, ipaddr=self.ip_gateway, @@ -88,8 +89,9 @@ class VXNetworkInstance(): dns_servers=[] ) self.dhcp_instance = DHCPServer.DHCPServer(dhcp_config) + self.dhcp_instance.start() else: - self.dhcp_instance.remove() + self.dhcp_instance.close() self.dhcp_instance = None