summaryrefslogtreecommitdiffstats
path: root/odl-pipeline/lib/odl_reinstaller
diff options
context:
space:
mode:
authorNiko Hermanns <nikolas.hermanns@ericsson.com>2016-11-30 11:59:44 +0100
committerNikolas Hermanns <nikolas.hermanns@ericsson.com>2016-12-13 11:26:00 +0100
commit416f9cf177801cecfe39f5249d73e3a4a85f0bbd (patch)
treebea48ec45edc10489aa76d348b0dbfbb1cf4d7ab /odl-pipeline/lib/odl_reinstaller
parentb9eb7024b014cba0d299b1cf3b01e179c7d0482e (diff)
adding odl-pipeline
Change-Id: I1c08883f0d68a61ce9e10c5596aec1a259eed71f Signed-off-by: Nikolas Hermanns <nikolas.hermanns@ericsson.com>
Diffstat (limited to 'odl-pipeline/lib/odl_reinstaller')
-rwxr-xr-xodl-pipeline/lib/odl_reinstaller/__init__.py0
-rwxr-xr-xodl-pipeline/lib/odl_reinstaller/install_odl.pp15
-rwxr-xr-xodl-pipeline/lib/odl_reinstaller/odl_reinstaller.py86
3 files changed, 101 insertions, 0 deletions
diff --git a/odl-pipeline/lib/odl_reinstaller/__init__.py b/odl-pipeline/lib/odl_reinstaller/__init__.py
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/odl-pipeline/lib/odl_reinstaller/__init__.py
diff --git a/odl-pipeline/lib/odl_reinstaller/install_odl.pp b/odl-pipeline/lib/odl_reinstaller/install_odl.pp
new file mode 100755
index 0000000..97a00bd
--- /dev/null
+++ b/odl-pipeline/lib/odl_reinstaller/install_odl.pp
@@ -0,0 +1,15 @@
+include ::tripleo::packages
+
+if count(hiera('ntp::servers')) > 0 {
+ include ::ntp
+}
+
+class {"opendaylight":
+ extra_features => any2array(hiera('opendaylight::extra_features', 'odl-netvirt-openstack')),
+ odl_rest_port => hiera('opendaylight::odl_rest_port'),
+ enable_l3 => hiera('opendaylight::enable_l3', 'no'),
+ #tarball_url => 'file:///home/heat-admin/distribution-karaf-0.6.0-SNAPSHOT.tar.gz',
+ #unitfile_url => 'file:///home/heat-admin/opendaylight-unitfile.tar.gz'
+}
+
+
diff --git a/odl-pipeline/lib/odl_reinstaller/odl_reinstaller.py b/odl-pipeline/lib/odl_reinstaller/odl_reinstaller.py
new file mode 100755
index 0000000..190abcf
--- /dev/null
+++ b/odl-pipeline/lib/odl_reinstaller/odl_reinstaller.py
@@ -0,0 +1,86 @@
+#!/bin/python
+import os
+from utils.utils_log import LOG, for_all_methods, log_enter_exit
+from utils.service import Service
+from utils.node_manager import NodeManager
+from utils.ssh_util import SSH_CONFIG
+
+
+@for_all_methods(log_enter_exit)
+class ODLReInstaller(Service):
+
+ def run(self, sys_args, config):
+ SSH_CONFIG['ID_RSA_PATH'] = sys_args.id_rsa
+ # copy ODL to all nodes where it need to be copied
+ self.nodes = NodeManager(config['servers']).get_nodes()
+ for node in self.nodes:
+ LOG.info('Disconnecting OpenVSwitch from controller on node %s'
+ % node.name)
+ node.execute('ovs-vsctl del-controller br-int', as_root=True)
+
+ for node in self.nodes:
+ if 'ODL' in node.config:
+ tar_tmp_path = '/tmp/odl-artifact/'
+ if node.config['ODL'].get('active'):
+ tarball_name = os.path.basename(sys_args.odl_artifact)
+ node.copy('to', sys_args.odl_artifact,
+ '/tmp/odl-artifact/' + tarball_name)
+ 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'
+ % (tarball_name, node.name))
+ node.execute('tar -zxf %s --strip-components=1 -C '
+ '/opt/opendaylight/'
+ % (tar_tmp_path + tarball_name), as_root=True)
+ node.execute('chown -R odl:odl /opt/opendaylight',
+ as_root=True)
+ node.execute('rm -rf ' + tar_tmp_path, as_root=True)
+ LOG.info('Installing and Starting Opendaylight on node %s'
+ % node.name)
+ node.copy('to', 'odl_reinstaller/install_odl.pp',
+ tar_tmp_path)
+ node.execute('puppet apply --modulepath='
+ '/etc/puppet/modules/ %sinstall_odl.pp '
+ '--verbose --debug --trace '
+ '--detailed-exitcodes'
+ % tar_tmp_path, check_exit_code=[2],
+ as_root=True)
+ # --detailed-exitcodes: Provide extra information about the run via
+ # exit codes. If enabled, 'puppet apply' will use the following exit
+ # codes:
+ # 0: The run succeeded with no changes or failures; the system was
+ # already in the desired state.
+ # 1: The run failed.
+ # 2: The run succeeded, and some resources were changed.
+ # 4: The run succeeded, and some resources failed.
+ # 6: The run succeeded, and included both changes and failures.
+
+ for node in self.nodes:
+ LOG.info('Connecting OpenVSwitch to controller on node %s'
+ % node.name)
+ ovs_controller = node.config.get('ovs-controller')
+ if ovs_controller:
+ node.execute('ovs-vsctl set-controller br-int %s'
+ % ovs_controller, as_root=True)
+
+ def create_cli_parser(self, parser):
+ parser.add_argument('-c', '--config',
+ help=("Give the path to the node config file "
+ "(node.yaml)"),
+ required=True)
+ parser.add_argument('--odl-artifact',
+ help=("Path to Opendaylight tarball"),
+ required=True)
+ parser.add_argument('--id-rsa',
+ help=("Path to the identity file which can "
+ "be used to connect to the overcloud"),
+ required=True)
+ return parser
+
+
+def main():
+ main = ODLReInstaller()
+ main.start()
+
+if __name__ == '__main__':
+ main()