diff options
author | Tim Rozet <trozet@redhat.com> | 2017-01-12 12:27:41 -0500 |
---|---|---|
committer | Tim Rozet <trozet@redhat.com> | 2017-01-30 14:36:24 -0500 |
commit | c7cbf47421382ef5db5ad8a2f470def52640b21f (patch) | |
tree | 78474dd4298b163b7816e038533f50a586df9e8c /odl-pipeline/lib/utils/tripleo_helper.py | |
parent | ced7ceab968ee2542b5d4d4255195d971aa61fea (diff) |
Updates ODL Pipeline scripts for CSIT
Changes Include:
- Change to TripleOInspector which only introspect a
current Apex deployment and dump yaml config to be bundled with
snapshots.
- Add TripleOHelper which consists of all tripleO helper functions.
Many this are done to virsh so the idea is to have at.
Some point in time a libvirtHelper, or use another libvirt
python lib. Thatsway it is a class so that we can inherit
later on.
- New argument for passing the SSH private key to use to connect to
nodes is added to the service utils.
- Some general clean up and consolidation of logic
JIRA: APEX-363
Change-Id: I792db0fac3f4e81969fe85c05fc298fe5af02537
Signed-off-by: Tim Rozet <trozet@redhat.com>
Diffstat (limited to 'odl-pipeline/lib/utils/tripleo_helper.py')
-rw-r--r-- | odl-pipeline/lib/utils/tripleo_helper.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/odl-pipeline/lib/utils/tripleo_helper.py b/odl-pipeline/lib/utils/tripleo_helper.py new file mode 100644 index 0000000..702e811 --- /dev/null +++ b/odl-pipeline/lib/utils/tripleo_helper.py @@ -0,0 +1,53 @@ +import re +import processutils +from processutils import execute +from utils.node import Node + + +class TripleoHelper(): + + @staticmethod + def find_overcloud_ips(): + try: + res, _ = TripleoHelper.get_undercloud().execute( + "'source /home/stack/stackrc; nova list'", + shell=True) + except processutils.ProcessExecutionError as e: + raise TripleOHelperException( + "Error unable to issue nova list " + "on undercloud. Please verify " + "undercloud is up. Full error: {" + "}".format(e.message)) + return re.findall('ctlplane=([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)', res) + + @staticmethod + def get_virtual_node_name_from_mac(mac): + vnode_names, _ = execute('virsh list|awk \'{print ' + '$2}\'', shell=True) + for node in vnode_names.split('\n'): + if 'baremetal' in node: + admin_net_mac, _ = execute( + 'virsh domiflist %s |grep admin |awk \'{print $5}\'' + % node, shell=True) + if admin_net_mac.replace('\n', '') == mac: + return node + raise Exception('Could not find corresponding virtual node for MAC: %s' + % mac) + + @staticmethod + def get_undercloud_ip(): + out, _ = execute('virsh domifaddr undercloud', shell=True) + return re.findall('([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)', out)[0] + + @staticmethod + def get_undercloud(): + return Node('undercloud', address=TripleoHelper.get_undercloud_ip(), + user='stack') + + +class TripleOHelperException(Exception): + def __init__(self, value): + self.value = value + + def __str__(self): + return self.value |