Fix some bugs with secondary/primary states

This commit is contained in:
Joshua Boniface 2018-09-24 01:45:04 -04:00
parent 6ba831d1bc
commit bbe03a2fec
1 changed files with 7 additions and 2 deletions

View File

@ -41,7 +41,7 @@ class RouterInstance():
self.this_router = this_router
self.name = name
self.daemon_state = 'stop'
self.network_state = 'primary'
self.network_state = 'secondary'
self.t_router = t_router
self.primary_router_list = []
self.secondary_router_list = []
@ -77,6 +77,7 @@ class RouterInstance():
if router.getname() != self.name:
router.set_secondary()
# Get value functions
def getname(self):
return self.name
@ -190,6 +191,10 @@ class RouterInstance():
except ValueError:
pass
# Try to set ourself primary if there is no primary
if not self.primary_router_list:
self.set_primary()
# Display cluster information to the terminal
ansiiprint.echo('{}Cluster status{}'.format(ansiiprint.purple(), ansiiprint.end()), '', 't')
ansiiprint.echo('{}Primary router:{} {}'.format(ansiiprint.bold(), ansiiprint.end(), ' '.join(self.primary_router_list)), '', 'c')