From 40e6368775836d58dd3b83c197b9ff8efc462262 Mon Sep 17 00:00:00 2001
From: Nikolas Hermanns <nikolas.hermanns@ericsson.com>
Date: Wed, 3 May 2017 16:23:02 +0200
Subject: Stop and start quagga when reinstalling

Change-Id: Iba9a5980de0cbdf9c04bdd4dad704c12abb55048
Signed-off-by: Nikolas Hermanns <nikolas.hermanns@ericsson.com>
---
 .../lib/odl_reinstaller/odl_reinstaller.py         | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

(limited to 'odl-pipeline/lib')

diff --git a/odl-pipeline/lib/odl_reinstaller/odl_reinstaller.py b/odl-pipeline/lib/odl_reinstaller/odl_reinstaller.py
index 053e022..c0cf075 100644
--- a/odl-pipeline/lib/odl_reinstaller/odl_reinstaller.py
+++ b/odl-pipeline/lib/odl_reinstaller/odl_reinstaller.py
@@ -52,6 +52,11 @@ class ODLReInstaller(Service):
                 self.odl_node = node
                 LOG.info("ODL node found: {}".format(self.odl_node.name))
                 node.execute('systemctl stop opendaylight', as_root=True)
+                # rc 5 means the service is not there.
+                node.execute('systemctl stop bgpd', as_root=True,
+                             check_exit_code=[0, 5])
+                node.execute('systemctl stop zrpcd', as_root=True,
+                             check_exit_code=[0, 5])
 
             self.disconnect_ovs(node)
 
@@ -90,8 +95,21 @@ class ODLReInstaller(Service):
             self.validate_ovs(node)
         LOG.info("OpenDaylight Upgrade Successful!")
 
-    @staticmethod
-    def reinstall_odl(node, odl_artifact):
+    def _start_service_if_enabled(self, node, service):
+        # rc 3 means service inactive
+        # rc 5 mean no service available
+        status, _ = node.execute('systemctl status {}'.
+                                 format(service), check_exit_code=[0, 3, 5])
+        if 'service; enabled' in status:
+            LOG.info('Starting {}'.format(service))
+            node.execute('systemctl start {}'.format(service), as_root=True)
+
+    def reinstall_odl(self, node, odl_artifact):
+        # Check for Quagga
+        self._start_service_if_enabled(node, 'zrpcd')
+        self._start_service_if_enabled(node, 'bgpd')
+
+        # Install odl
         tar_tmp_path = '/tmp/odl-artifact/'
         node.copy('to', odl_artifact, tar_tmp_path + odl_artifact)
         node.execute('rm -rf /opt/opendaylight/', as_root=True)
-- 
cgit