summaryrefslogtreecommitdiffstats
path: root/odl-pipeline/lib/odl_reinstaller/odl_reinstaller.py
diff options
context:
space:
mode:
Diffstat (limited to 'odl-pipeline/lib/odl_reinstaller/odl_reinstaller.py')
-rw-r--r--odl-pipeline/lib/odl_reinstaller/odl_reinstaller.py31
1 files changed, 22 insertions, 9 deletions
diff --git a/odl-pipeline/lib/odl_reinstaller/odl_reinstaller.py b/odl-pipeline/lib/odl_reinstaller/odl_reinstaller.py
index 655f816..34a6732 100644
--- a/odl-pipeline/lib/odl_reinstaller/odl_reinstaller.py
+++ b/odl-pipeline/lib/odl_reinstaller/odl_reinstaller.py
@@ -40,7 +40,11 @@ class ODLReInstaller(Service):
self.nodes = NodeManager(node_config['servers']).get_nodes()
for node in self.nodes:
node.execute('ovs-vsctl del-controller br-int', as_root=True)
+ first_controller = None
for node in self.nodes:
+ if not first_controller:
+ if 'controller' in node.execute('echo $HOSTNAME')[0]:
+ first_controller = node
# Check if ODL runs on this node
rv, _ = node.execute('ps aux |grep -v grep |grep karaf',
as_root=True, check_exit_code=[0, 1])
@@ -52,6 +56,8 @@ class ODLReInstaller(Service):
self.disconnect_ovs(node)
# Upgrade ODL
+ if not self.odl_node:
+ self.odl_node = first_controller
self.reinstall_odl(self.odl_node, odl_artifact)
# Wait for ODL to come back up
@@ -85,19 +91,26 @@ class ODLReInstaller(Service):
LOG.info("OpenDaylight Upgrade Successful!")
@staticmethod
- def reinstall_odl(node, odl_tarball):
+ def reinstall_odl(node, odl_artifact):
tar_tmp_path = '/tmp/odl-artifact/'
- node.copy('to', odl_tarball, tar_tmp_path + odl_tarball)
+ node.copy('to', odl_artifact, tar_tmp_path + odl_artifact)
node.execute('rm -rf /opt/opendaylight/*', as_root=True)
node.execute('mkdir -p /opt/opendaylight/*', as_root=True)
- LOG.info('Extracting %s to /opt/opendaylight/ on node %s'
- % (odl_tarball, node.name))
- node.execute('tar -zxf %s --strip-components=1 -C '
- '/opt/opendaylight/'
- % (tar_tmp_path + odl_tarball), as_root=True)
- node.execute('chown -R odl:odl /opt/opendaylight', as_root=True)
+ if 'tar.gz' in odl_artifact:
+ LOG.info('Extracting %s to /opt/opendaylight/ on node %s'
+ % (odl_artifact, node.name))
+ node.execute('tar -zxf %s --strip-components=1 -C '
+ '/opt/opendaylight/'
+ % (tar_tmp_path + odl_artifact), as_root=True)
+ node.execute('chown -R odl:odl /opt/opendaylight', as_root=True)
+ if '.rpm' in odl_artifact:
+ LOG.info('Installing %s on node %s'
+ % (odl_artifact, node.name))
+ node.execute('yum remove -y opendaylight', as_root=True)
+ node.execute('yum install -y %s'
+ % (tar_tmp_path + odl_artifact), as_root=True)
node.execute('rm -rf ' + tar_tmp_path, as_root=True)
- LOG.info('Installing and Starting Opendaylight on node %s' % node.name)
+ LOG.info('Starting Opendaylight on node %s' % node.name)
node.execute('puppet apply -e "include opendaylight" '
'--modulepath=/etc/puppet/modules/ '
'--verbose --debug --trace --detailed-exitcodes',