summaryrefslogtreecommitdiffstats
path: root/robotframework-onap/eteutils
diff options
context:
space:
mode:
Diffstat (limited to 'robotframework-onap/eteutils')
-rw-r--r--robotframework-onap/eteutils/DNSUtils.py6
-rw-r--r--robotframework-onap/eteutils/EteGatherDataListener.py8
-rw-r--r--robotframework-onap/eteutils/HEATUtils.py32
-rw-r--r--robotframework-onap/eteutils/HTTPUtils.py4
-rw-r--r--robotframework-onap/eteutils/JSONUtils.py4
-rw-r--r--robotframework-onap/eteutils/OpenstackLibrary.py12
-rw-r--r--robotframework-onap/eteutils/StringTemplater.py1
-rw-r--r--robotframework-onap/eteutils/TemplatingEngine.py3
-rw-r--r--robotframework-onap/eteutils/UUID.py2
9 files changed, 36 insertions, 36 deletions
diff --git a/robotframework-onap/eteutils/DNSUtils.py b/robotframework-onap/eteutils/DNSUtils.py
index 65ae68b..fd0cec3 100644
--- a/robotframework-onap/eteutils/DNSUtils.py
+++ b/robotframework-onap/eteutils/DNSUtils.py
@@ -7,11 +7,11 @@ class DNSUtils:
def dns_request(self, domain, ns):
""" return the ip address of the given domain name from the given nameserver """
- request = dns.message.make_query(domain, dns.rdatatype.A);
- request.flags |= dns.flags.AD;
+ request = dns.message.make_query(domain, dns.rdatatype.A)
+ request.flags |= dns.flags.AD
request.find_rrset(request.additional, dns.name.root, 65535, dns.rdatatype.OPT, create=True, force_unique=True)
response = dns.query.udp(request, ns)
for answer in response.answer:
for item in answer.items:
- return item \ No newline at end of file
+ return item
diff --git a/robotframework-onap/eteutils/EteGatherDataListener.py b/robotframework-onap/eteutils/EteGatherDataListener.py
index 79c02b4..a99364b 100644
--- a/robotframework-onap/eteutils/EteGatherDataListener.py
+++ b/robotframework-onap/eteutils/EteGatherDataListener.py
@@ -62,7 +62,7 @@ class EteGatherDataListener(object):
self.folder= ''
self.keyfile = keyfile
self.local_gather_data_sh = shell
- print "EteGatherDataListener instantiated"
+ print("EteGatherDataListener instantiated")
def end_test(self, name, attrs):
if attrs['status'] == 'PASS':
@@ -74,16 +74,16 @@ class EteGatherDataListener(object):
if (self.folder != ''):
return
self.folder = os.path.dirname(path)
- print(self.folder)
+ print((self.folder))
def close(self):
- print "EteGatherDataListener tests failed=" + str(self.tests_failed)
+ print("EteGatherDataListener tests failed=" + str(self.tests_failed))
if (self.tests_failed > 0):
self.gather_debug_data()
def gather_debug_data(self):
- for application in self.APPLICATIONS.keys():
+ for application in list(self.APPLICATIONS.keys()):
self.gather_application_data(application, self.APPLICATIONS.get(application))
def gather_application_data(self, application, ip):
diff --git a/robotframework-onap/eteutils/HEATUtils.py b/robotframework-onap/eteutils/HEATUtils.py
index 15c5689..93d556a 100644
--- a/robotframework-onap/eteutils/HEATUtils.py
+++ b/robotframework-onap/eteutils/HEATUtils.py
@@ -1,51 +1,52 @@
import json
import yaml
-import StringIO
+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, basestring):
+ if isinstance(template_file, str):
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):
+ if isinstance(template_file, str):
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()
+ 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, basestring):
+ if isinstance(template_file, str):
fin = open(template_file, 'r')
yamlobj = yaml.load(fin)
fin.close()
if 'parameters' in yamlobj:
- fout = StringIO.StringIO()
+ 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 = {}
@@ -56,24 +57,23 @@ class HEATUtils:
d['id'] = s['id']
d['name'] = s['stack_name']
d['stack_status'] = s['stack_status']
- return d
-
-
+ 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]))
+ printableFingerprint = ':'.join(a + b for a, b in zip(keybytes[::2], keybytes[1::2]))
return printableFingerprint == fingerprint.__str__()
except PasswordRequiredException:
- return False
-
+ 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:
diff --git a/robotframework-onap/eteutils/HTTPUtils.py b/robotframework-onap/eteutils/HTTPUtils.py
index 9324af7..624efd1 100644
--- a/robotframework-onap/eteutils/HTTPUtils.py
+++ b/robotframework-onap/eteutils/HTTPUtils.py
@@ -1,6 +1,8 @@
+from six.moves.urllib.parse import urlparse
+
import urllib
import urllib3
-import urlparse
+
class HTTPUtils:
"""HTTPUtils is common resource for simple http helper keywords."""
diff --git a/robotframework-onap/eteutils/JSONUtils.py b/robotframework-onap/eteutils/JSONUtils.py
index de5da6b..e5de182 100644
--- a/robotframework-onap/eteutils/JSONUtils.py
+++ b/robotframework-onap/eteutils/JSONUtils.py
@@ -7,11 +7,11 @@ class JSONUtils:
def json_equals(self, left, right):
"""JSON Equals takes in two strings or json objects, converts them into json if needed and then compares them, returning if they are equal or not."""
- if isinstance(left, basestring):
+ if isinstance(left, str):
left_json = json.loads(left);
else:
left_json = left;
- if isinstance(right, basestring):
+ if isinstance(right, str):
right_json = json.loads(right);
else:
right_json = right;
diff --git a/robotframework-onap/eteutils/OpenstackLibrary.py b/robotframework-onap/eteutils/OpenstackLibrary.py
index adb12db..8791450 100644
--- a/robotframework-onap/eteutils/OpenstackLibrary.py
+++ b/robotframework-onap/eteutils/OpenstackLibrary.py
@@ -23,7 +23,7 @@ class OpenstackLibrary:
def get_openstack_token(self, alias):
"""Get Openstack auth token from the current alias"""
response = self._cache.switch(alias)
- if isinstance(response, basestring):
+ if isinstance(response, str):
jsonResponse = json.loads(response);
else:
jsonResponse = response;
@@ -35,7 +35,7 @@ class OpenstackLibrary:
def get_openstack_catalog(self, alias):
"""Get Openstack service catalog from the current alias"""
response = self._cache.switch(alias)
- if isinstance(response, basestring):
+ if isinstance(response, str):
jsonResponse = json.loads(response);
else:
jsonResponse = response;
@@ -48,7 +48,7 @@ class OpenstackLibrary:
def get_current_openstack_tenant(self, alias):
"""Get Openstack tenant from the current alias"""
response = self._cache.switch(alias)
- if isinstance(response, basestring):
+ if isinstance(response, str):
jsonResponse = json.loads(response);
else:
jsonResponse = response;
@@ -65,7 +65,7 @@ class OpenstackLibrary:
def get_openstack_regions(self, alias):
"""Get all Openstack regions from the current alias"""
response = self._cache.switch(alias)
- if isinstance(response, basestring):
+ if isinstance(response, str):
jsonResponse = json.loads(response);
else:
jsonResponse = response;
@@ -85,7 +85,7 @@ class OpenstackLibrary:
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, basestring):
+ if isinstance(response, str):
jsonResponse = json.loads(response);
else:
jsonResponse = response;
@@ -103,7 +103,7 @@ class OpenstackLibrary:
# 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)];
+ 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:
diff --git a/robotframework-onap/eteutils/StringTemplater.py b/robotframework-onap/eteutils/StringTemplater.py
index 43d107e..b2d99ce 100644
--- a/robotframework-onap/eteutils/StringTemplater.py
+++ b/robotframework-onap/eteutils/StringTemplater.py
@@ -1,4 +1,3 @@
-import json
from string import Template
class StringTemplater:
diff --git a/robotframework-onap/eteutils/TemplatingEngine.py b/robotframework-onap/eteutils/TemplatingEngine.py
index 0f579e7..5e701a7 100644
--- a/robotframework-onap/eteutils/TemplatingEngine.py
+++ b/robotframework-onap/eteutils/TemplatingEngine.py
@@ -29,6 +29,5 @@ class TemplatingEngine:
def apply_template(self, template_location, values):
"""returns a string that is the jinja template in template_location filled in via the dictionary in values """
- print
template = self.jinja_env.get_template(template_location)
- return template.render(values) \ No newline at end of file
+ return template.render(values)
diff --git a/robotframework-onap/eteutils/UUID.py b/robotframework-onap/eteutils/UUID.py
index 35c26a7..1500076 100644
--- a/robotframework-onap/eteutils/UUID.py
+++ b/robotframework-onap/eteutils/UUID.py
@@ -12,4 +12,4 @@ class UUID:
def generate_MilliTimestamp_UUID(self):
"""generate a millisecond timestamp uuid"""
then = datetime.datetime.now()
- return int(time.mktime(then.timetuple())*1e3 + then.microsecond/1e3) \ No newline at end of file
+ return int(time.mktime(then.timetuple())*1e3 + then.microsecond/1e3)