Properly handle creating gateways and DHCP servers

This commit is contained in:
Joshua Boniface 2018-09-30 13:42:04 -04:00
parent 3e937362cd
commit ce6d863424
2 changed files with 8 additions and 5 deletions

View File

@ -71,14 +71,17 @@ class VXNetworkInstance():
@zk_conn.DataWatch('/networks/{}/ip_gateway'.format(self.vni)) @zk_conn.DataWatch('/networks/{}/ip_gateway'.format(self.vni))
def watch_network_gateway(data, stat, event=''): def watch_network_gateway(data, stat, event=''):
if data != None and self.ip_gateway != data.decode('ascii'): if data != None and self.ip_gateway != data.decode('ascii'):
self.removeAddress() if self.this_router.isprimary():
self.removeGatewayAddress()
self.ip_gateway = data.decode('ascii') self.ip_gateway = data.decode('ascii')
self.addAddress() self.createGatewayAddress()
@zk_conn.DataWatch('/networks/{}/dhcp_flag'.format(self.vni)) @zk_conn.DataWatch('/networks/{}/dhcp_flag'.format(self.vni))
def watch_network_dhcp_status(data, stat, event=''): def watch_network_dhcp_status(data, stat, event=''):
if data != None and self.dhcp_flag != data.decode('ascii'): if data != None and self.dhcp_flag != data.decode('ascii'):
self.dhcp_flag = ( data.decode('ascii') == 'True' ) self.dhcp_flag = ( data.decode('ascii') == 'True' )
if self.dhcp_flag and self.this_router.isprimary():
createDHCPServer()
def getvni(self): def getvni(self):
return self.vni return self.vni