From bbe03a2feca9eb6e3d3f20a213ec8838f8b014f5 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Mon, 24 Sep 2018 01:45:04 -0400 Subject: [PATCH] Fix some bugs with secondary/primary states --- router-daemon/pvcrd/RouterInstance.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/router-daemon/pvcrd/RouterInstance.py b/router-daemon/pvcrd/RouterInstance.py index fff2e082..00f0f258 100644 --- a/router-daemon/pvcrd/RouterInstance.py +++ b/router-daemon/pvcrd/RouterInstance.py @@ -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 @@ -189,7 +190,11 @@ class RouterInstance(): self.inactive_router_list.remove(router_name) 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')