CLOUDSTACK-8952 - Do not rely in the router state on the json file to report back to ACS

- If we stop/start a router, the state in the file will still say MASTER, when it is actually not
   - Checking the state based on the interface (eth1) state
   - Once master.py is called by keepalived, save the state in the json file to BACKUP just to make sure it's also written there
This commit is contained in:
Wilder Rodrigues 2015-10-17 08:09:52 +02:00
parent 41f4d8b58a
commit 5b3c99031f
3 changed files with 12 additions and 8 deletions

View File

@ -16,9 +16,10 @@
# specific language governing permissions and limitations
# under the License.
STATUS=$(cat /etc/cloudstack/cmdline.json | grep redundant_state | awk '{print $2;}' | sed -e 's/[,\"]//g')
if [ "$?" -ne "0" ]
STATUS=BACKUP
ETH1_STATE=$(ip addr | grep eth1 | grep state | awk '{print $9;}')
if [ $ETH1_STATE = "UP" ]
then
STATUS=MASTER
STATUS=MASTER
fi
echo "Status: ${STATUS}"
echo "Status: ${STATUS}"

View File

@ -42,7 +42,9 @@ logging.basicConfig(filename=config.get_logger(),
format=config.get_format())
config.cmdline()
cl = CsCmdLine("cmdline", config)
#Update the configuration to set state as backup and let keepalived decide who is the real Master
cl.set_master_state(False)
cl.save()
config.set_address()
red = CsRedundant(config)

View File

@ -16,9 +16,10 @@
# specific language governing permissions and limitations
# under the License.
STATUS=$(cat /etc/cloudstack/cmdline.json | grep redundant_state | awk '{print $2;}' | sed -e 's/[,\"]//g')
if [ "$?" -ne "0" ]
STATUS=BACKUP
ETH1_STATE=$(ip addr | grep eth1 | grep state | awk '{print $9;}')
if [ $ETH1_STATE = "UP" ]
then
STATUS=MASTER
STATUS=MASTER
fi
echo "Status: ${STATUS}"
echo "Status: ${STATUS}"