Fix up some logic errors with function calls

This commit is contained in:
Joshua Boniface 2018-09-23 15:57:46 -04:00
parent 8266443966
commit 106a2327ed
1 changed files with 9 additions and 7 deletions

View File

@ -42,7 +42,7 @@ class VXNetworkInstance():
self.watch_change = False self.watch_change = False
self.update_timer = apscheduler.schedulers.background.BackgroundScheduler() self.update_timer = apscheduler.schedulers.background.BackgroundScheduler()
self.update_timer.add_job(updateCorosyncResource, 'interval', seconds=1) self.update_timer.add_job(self.updateCorosyncResource, 'interval', seconds=1)
# Zookeper handlers for changed states # Zookeper handlers for changed states
@zk_conn.DataWatch('/networks/{}/description'.format(self.vni)) @zk_conn.DataWatch('/networks/{}/description'.format(self.vni))
@ -86,7 +86,6 @@ class VXNetworkInstance():
self.watch_change = True self.watch_change = True
def createCorosyncResource(self): def createCorosyncResource(self):
self.corosync_provisioned = True
ansiiprint.echo('Creating Corosync resource for gateway {} on interface {}'.format(self.ip_gateway, self.vni), '', 'o') ansiiprint.echo('Creating Corosync resource for gateway {} on interface {}'.format(self.ip_gateway, self.vni), '', 'o')
os.system( os.system(
""" """
@ -105,6 +104,7 @@ class VXNetworkInstance():
self.bridge_nic self.bridge_nic
) )
) )
self.corosync_provisioned = True
def removeCorosyncResource(self): def removeCorosyncResource(self):
ansiiprint.echo('Removing Corosync resource for gateway {} on interface {}'.format(self.ip_gateway, self.vni), '', 'o') ansiiprint.echo('Removing Corosync resource for gateway {} on interface {}'.format(self.ip_gateway, self.vni), '', 'o')
@ -186,15 +186,17 @@ class VXNetworkInstance():
def updateCorosyncResource(self): def updateCorosyncResource(self):
if self.corosync_provisioned and self.watch_change: if self.corosync_provisioned and self.watch_change:
self.watch_change = False
# Rebuild the resource # Rebuild the resource
removeCorosyncResource() self.removeCorosyncResource()
createCorosyncResource() self.createCorosyncResource()
def provision(self): def provision(self):
createNetwork() self.createNetwork()
createCorosyncConfig() self.createCorosyncResource()
self.update_timer.start() self.update_timer.start()
def deprovision(self): def deprovision(self):
self.update_timer.shutdown() self.update_timer.shutdown()
removeCorosyncConfig() removeCorosyncResource()
removeNetwork()