Tweaks to startup and shutdown

This commit is contained in:
Joshua Boniface 2018-09-30 20:06:29 -04:00
parent 4612c8086f
commit a5257e75b0
3 changed files with 12 additions and 2 deletions

View File

@ -243,12 +243,16 @@ def updatenetworks(new_network_list):
for network in new_network_list:
if not network in s_network:
s_network[network] = VXNetworkInstance.VXNetworkInstance(network, zk_conn, config, t_router[myhostname])
if this_router.network_state == 'primary':
s_network[network].createGatewayAddress()
s_network[network].startDHCPServer()
for network in network_list:
if not network in new_network_list:
if this_router.network_state == 'primary':
s_network[network].stopDHCPServer()
s_network[network].removeGatewayAddress()
s_network[network].removeNetwork()
del(s_network[network])
network_list = new_network_list
for router in router_list:
if router in t_router:

View File

@ -155,6 +155,12 @@ class RouterInstance():
else:
self.daemon_state = 'run'
# Ensure the master key is properly set at a keepalive
if self.name == self.this_router:
if self.network_state == 'primary':
if zkhandler.readdata(self.zk_conn, '/routers') == 'none':
zkhandler.writedata(self.zk_conn, {'/routers': self.name})
# Set our information in zookeeper
cpuload = os.getloadavg()[0]
keepalive_time = int(time.time())

View File

@ -40,10 +40,10 @@ class VXNetworkInstance():
self.old_description = None
self.description = None
self.domain = None
self.ip_gateway = None
self.ip_gateway = zkhandler.readdata(self.zk_conn, '/networks/{}/ip_gateway'.format(self.vni))
self.ip_network = None
self.ip_cidrnetmask = None
self.dhcp_flag = None
self.dhcp_flag = zkhandler.readdata(self.zk_conn, '/networks/{}/dhcp_flag'.format(self.vni))
self.dhcp_start = None
self.dhcp_end = None