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

@ -207,8 +207,8 @@ class RouterInstance():
except ValueError:
pass
# toggle state management of this router
if s_network != {} and not self.active: # If there's no network list, we're too early in startup
# toggle state management of this router
if s_network != {} and not self.active: # If there's no network list, we're too early in startup
if self.name == self.this_router:
if self.network_state == 'secondary':
self.become_secondary()

View File

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