summaryrefslogtreecommitdiffstats
path: root/robotframework-onap
diff options
context:
space:
mode:
authorDR695H <dr695h@att.com>2019-06-18 17:26:43 -0400
committerDR695H <dr695h@att.com>2019-06-18 17:28:09 -0400
commit42a82cbaf32ce8dffafdcec71cbbe250ab8eb58c (patch)
tree9ad2a3495afe4a2fbdbc45d80ac0e4d4d0e0dcc6 /robotframework-onap
parentb8a725cbb580dc1e1df89a9c36cb27f1d8ce9d6c (diff)
removing unused libraries
openstacklib and heatutils have been moved to the new keyword structure so remvoing the old one as csit and testsuite have moved Change-Id: I18b3ac7afc714174da4bebf5bacd5c7297b3dd59 Issue-ID: TEST-158 Signed-off-by: DR695H <dr695h@att.com>
Diffstat (limited to 'robotframework-onap')
-rw-r--r--robotframework-onap/eteutils/HEATUtils.py88
-rw-r--r--robotframework-onap/eteutils/OpenstackLibrary.py124
2 files changed, 0 insertions, 212 deletions
diff --git a/robotframework-onap/eteutils/HEATUtils.py b/robotframework-onap/eteutils/HEATUtils.py
deleted file mode 100644
index 69c026e..0000000
--- a/robotframework-onap/eteutils/HEATUtils.py
+++ /dev/null
@@ -1,88 +0,0 @@
-import json
-import yaml
-import io
-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, str) or isinstance(template_file, unicode):
- 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"""
- contents = None
- if isinstance(template_file, str) or isinstance(template_file, unicode):
- 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 = io.BytesIO()
- 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, str) or isinstance(template_file, unicode):
- fin = open(template_file, 'r')
- yamlobj = yaml.load(fin)
- fin.close()
- if 'parameters' in yamlobj:
- fout = io.BytesIO()
- 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
diff --git a/robotframework-onap/eteutils/OpenstackLibrary.py b/robotframework-onap/eteutils/OpenstackLibrary.py
deleted file mode 100644
index 8791450..0000000
--- a/robotframework-onap/eteutils/OpenstackLibrary.py
+++ /dev/null
@@ -1,124 +0,0 @@
-from robot.libraries.BuiltIn import BuiltIn
-import robot.utils
-import json
-
-class OpenstackLibrary:
- """OpenstackLibrary manages the connection state and service catalog of an openstack instance."""
-
- ROBOT_LIBRARY_SCOPE = 'Global'
-
-
- def __init__(self):
- self._cache = robot.utils.ConnectionCache('No connections created')
- self.builtin = BuiltIn()
-
- def save_openstack_auth(self, alias, response,token, version='v2.0'):
- """Save Openstack Auth takes in an openstack auth response and saves it to allow easy retrival of token and service catalog"""
- self.builtin.log('Creating connection: %s' % alias, 'DEBUG')
- jsonResponse = json.loads(response);
- jsonResponse['auth_token'] = token
- jsonResponse['keystone_api_version'] = version
- self._cache.register(jsonResponse, alias=alias)
-
- def get_openstack_token(self, alias):
- """Get Openstack auth token from the current alias"""
- response = self._cache.switch(alias)
- if isinstance(response, str):
- jsonResponse = json.loads(response);
- else:
- jsonResponse = response;
- if jsonResponse['keystone_api_version'] == 'v2.0':
- return jsonResponse['access']['token']['id']
- else:
- return jsonResponse['auth_token']
-
- def get_openstack_catalog(self, alias):
- """Get Openstack service catalog from the current alias"""
- response = self._cache.switch(alias)
- if isinstance(response, str):
- jsonResponse = json.loads(response);
- else:
- jsonResponse = response;
- if jsonResponse['keystone_api_version'] == 'v2.0':
- return jsonResponse['access']['serviceCatalog']
- else:
- return jsonResponse['token']['catalog']
-
-
- def get_current_openstack_tenant(self, alias):
- """Get Openstack tenant from the current alias"""
- response = self._cache.switch(alias)
- if isinstance(response, str):
- jsonResponse = json.loads(response);
- else:
- jsonResponse = response;
- if jsonResponse['keystone_api_version'] == 'v2.0':
- return jsonResponse['access']['token']['tenant']
- else:
- return jsonResponse['token']['project']
-
- def get_current_openstack_tenant_id(self, alias):
- """Get Openstack tenant id from the current alias"""
- tenant = self.get_current_openstack_tenant(alias);
- return tenant['id']
-
- def get_openstack_regions(self, alias):
- """Get all Openstack regions from the current alias"""
- response = self._cache.switch(alias)
- if isinstance(response, str):
- jsonResponse = json.loads(response);
- else:
- jsonResponse = response;
- regions = [];
- if jsonResponse['keystone_api_version'] == 'v2.0':
- resp = jsonResponse['access']['serviceCatalog']
- else:
- resp = jsonResponse['token']['catalog']
- for catalogEntry in resp:
- listOfEndpoints = catalogEntry['endpoints'];
- for endpoint in listOfEndpoints:
- if 'region'in endpoint:
- if endpoint['region'] not in regions:
- regions.append(endpoint['region'])
- return regions;
-
- def get_openstack_service_url(self, alias, servicetype, region = None, tenant_id = None):
- """Get Openstack service catalog from the current alias"""
- response = self._cache.switch(alias)
- if isinstance(response, str):
- jsonResponse = json.loads(response);
- else:
- jsonResponse = response;
- endPoint = None;
- if jsonResponse['keystone_api_version'] == 'v2.0':
- resp = jsonResponse['access']['serviceCatalog']
- else:
- resp = jsonResponse['token']['catalog']
- for catalogEntry in resp:
- if self.__determine_match(catalogEntry['type'], servicetype):
- listOfEndpoints = catalogEntry['endpoints'];
- # filter out non matching regions if provided
- listOfEndpoints[:] = [x for x in listOfEndpoints if self.__determine_match(x['region'], region)];
- # filter out non matching tenants if provided
- # Only provide tenant id when authorizing without qualifying with tenant id
- # WindRiver does not return the tenantId on the endpoint in this case.
- if tenant_id is not None:
- listOfEndpoints[:] = [y for y in listOfEndpoints if self.__determine_match(y['tenantId'], tenant_id)];
- if jsonResponse['keystone_api_version'] == 'v3':
- listOfEndpoints[:] = [z for z in listOfEndpoints if self.__determine_match(z['interface'], 'public')];
- if len(listOfEndpoints) > 0:
- if jsonResponse['keystone_api_version'] == 'v2.0':
- endPoint = listOfEndpoints[0]['publicURL'];
- else:
- endPoint = listOfEndpoints[0]['url'];
- if endPoint == None:
- self.builtin.should_not_be_empty("", "Service Endpoint Url should not be empty")
- return endPoint;
-
- def __determine_match(self, listItem, item):
- if item is None:
- return True;
- elif listItem == item:
- return True;
- else:
- return False; \ No newline at end of file