summaryrefslogtreecommitdiffstats
path: root/eteutils/HEATUtils.py
diff options
context:
space:
mode:
authorDR695H <dr695h@att.com>2019-04-18 10:56:38 -0400
committerGary Wu <gary.i.wu@huawei.com>2019-04-23 10:34:04 -0700
commitd050b58d3fde6a049104d8287f8d8cfbe3013d5d (patch)
tree7563bfffabfc4f713996b1f12e52b5f2317fc6e2 /eteutils/HEATUtils.py
parent5709f89501b9ecf93fcb1667de017e1736c8919f (diff)
move robotframeworkonap to subdirectory
i also moved the build to maven based, although that isnt needed to work right now. Change-Id: Ib18d70e3ea4858cc4b9d51fdc2046b59202640ab Issue-ID: TEST-141 Signed-off-by: DR695H <dr695h@att.com> Signed-off-by: Gary Wu <gary.i.wu@huawei.com>
Diffstat (limited to 'eteutils/HEATUtils.py')
-rw-r--r--eteutils/HEATUtils.py87
1 files changed, 0 insertions, 87 deletions
diff --git a/eteutils/HEATUtils.py b/eteutils/HEATUtils.py
deleted file mode 100644
index 15c5689..0000000
--- a/eteutils/HEATUtils.py
+++ /dev/null
@@ -1,87 +0,0 @@
-import json
-import yaml
-import StringIO
-import copy
-from hashlib import md5
-from paramiko import RSAKey
-from paramiko.ssh_exception import PasswordRequiredException
-
-class HEATUtils:
- """ Utilities useful for constructing OpenStack HEAT requests """
-
- def get_yaml(self, template_file):
- """Template Yaml To Json reads a YAML Heat template file returns a JSON string that can be used included in an Openstack Add Stack Request"""
- if isinstance(template_file, basestring):
- fin = open(template_file, 'r')
- yamlobj = yaml.load(fin)
- return yamlobj
- return None
-
- def template_yaml_to_json(self, template_file):
- """Template Yaml To Json reads a YAML Heat template file returns a JSON string that can be used included in an Openstack Add Stack Request"""
- if isinstance(template_file, basestring):
- fin = open(template_file, 'r')
- yamlobj = yaml.load(fin)
- fin.close()
- if 'heat_template_version' in yamlobj:
- datetime = yamlobj['heat_template_version']
- yamlobj['heat_template_version'] = str(datetime)
- fout = StringIO.StringIO()
- json.dump(yamlobj, fout)
- contents = fout.getvalue()
- fout.close()
- return contents
-
- def env_yaml_to_json(self, template_file):
- """Env Yaml To JSon reads a YAML Heat env file and returns a JSON string that can be used included in an Openstack Add Stack Request"""
- if isinstance(template_file, basestring):
- fin = open(template_file, 'r')
- yamlobj = yaml.load(fin)
- fin.close()
- if 'parameters' in yamlobj:
- fout = StringIO.StringIO()
- json.dump(yamlobj['parameters'], fout)
- contents = fout.getvalue()
- fout.close()
- return contents
- return None
-
- def stack_info_parse(self, stack_info):
- """ returns a flattened version of the Openstack Find Stack results """
- d = {}
- if isinstance(stack_info, dict):
- s = stack_info['stack']
- p = s['parameters']
- d = copy.deepcopy(p)
- d['id'] = s['id']
- d['name'] = s['stack_name']
- d['stack_status'] = s['stack_status']
- return d
-
-
- def match_fingerprint(self, pvt_file, pw, fingerprint):
- try:
- sshKey = RSAKey.from_private_key_file(pvt_file, pw)
- keybytes = md5(sshKey.asbytes()).hexdigest()
- printableFingerprint = ':'.join(a+b for a,b in zip(keybytes[::2], keybytes[1::2]))
- return printableFingerprint == fingerprint.__str__()
- except PasswordRequiredException:
- return False
-
- def match_private_key_file_to_keypair(self, files, keypair):
- for keyfile in files:
- if (self.match_fingerprint(keyfile, None, keypair['keypair']['fingerprint'])):
- return keyfile
- return None
-
- def get_openstack_server_ip(self, server, network_name="public", ipversion=4):
- ipaddr = None
- try:
- versions = server['addresses'][network_name]
- for version in versions:
- if version['version'] == ipversion:
- ipaddr = version['addr']
- break;
- except ValueError:
- return ipaddr
- return ipaddr \ No newline at end of file