diff options
author | Nikolas Hermanns <nikolas.hermanns@ericsson.com> | 2017-01-31 14:45:54 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-01-31 14:45:54 +0000 |
commit | 192e6af198cf94a678edece8ad4bb123132e9ce2 (patch) | |
tree | c9ed8b238a1b4d5c82dcf8dc26f597cc92a6adaa /odl-pipeline/lib/utils/tripleo_helper.py | |
parent | 4182a4715e55969868f17b11e5e3ac79fc3c7555 (diff) | |
parent | c7cbf47421382ef5db5ad8a2f470def52640b21f (diff) |
Merge "Updates ODL Pipeline scripts for CSIT"
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 |