From 7f2d7515e068c2ba072d4f3b4cf0997e06ae8460 Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Thu, 14 Jun 2018 21:20:59 +0200 Subject: Support py3 in uncovered packages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It has to be noted that cloudify_rest_client doesn't support py3 then next unit tests vs cloudify-based testcases would be excluded. Change-Id: I0b0e64929d1238665c778ce51fd6abd5ccf06b6c Signed-off-by: Cédric Ollivier --- functest/opnfv_tests/vnf/epc/juju_epc.py | 17 +++++++++-------- functest/opnfv_tests/vnf/ims/cloudify_ims.py | 10 +++++----- functest/opnfv_tests/vnf/ims/cloudify_ims_perf.py | 2 +- .../opnfv_tests/vnf/ims/ixia/utils/IxChassisUtils.py | 14 +++++++------- functest/opnfv_tests/vnf/ims/ixia/utils/IxLoadUtils.py | 6 +++--- functest/opnfv_tests/vnf/ims/ixia/utils/IxRestUtils.py | 7 +++++-- functest/opnfv_tests/vnf/router/cloudify_vrouter.py | 5 ++++- 7 files changed, 34 insertions(+), 27 deletions(-) (limited to 'functest/opnfv_tests/vnf') diff --git a/functest/opnfv_tests/vnf/epc/juju_epc.py b/functest/opnfv_tests/vnf/epc/juju_epc.py index 224d71114..54eeeac8a 100644 --- a/functest/opnfv_tests/vnf/epc/juju_epc.py +++ b/functest/opnfv_tests/vnf/epc/juju_epc.py @@ -18,15 +18,10 @@ import subprocess import sys import uuid from copy import deepcopy -from urlparse import urljoin import pkg_resources import yaml -from functest.core import vnf -from functest.opnfv_tests.openstack.snaps import snaps_utils -from functest.utils import config -from functest.utils import env - +import six from snaps.config.flavor import FlavorConfig from snaps.config.image import ImageConfig from snaps.config.network import NetworkConfig, SubnetConfig @@ -43,6 +38,11 @@ from snaps.openstack.create_user import OpenStackUser from snaps.openstack.utils import keystone_utils from snaps.openstack.utils import nova_utils +from functest.core import vnf +from functest.opnfv_tests.openstack.snaps import snaps_utils +from functest.utils import config +from functest.utils import env + __author__ = "Amarendra Meher " __author__ = "Soumaya K Nayek " @@ -227,7 +227,8 @@ class JujuEpc(vnf.VnfOnBoarding): # it enforces a versioned public identity endpoint as juju simply # adds /auth/tokens wich fails vs an unversioned endpoint. if not self.public_auth_url.endswith(('v3', 'v3/', 'v2.0', 'v2.0/')): - self.public_auth_url = urljoin(self.public_auth_url, 'v3') + self.public_auth_url = six.moves.urllib.parse.urljoin( + self.public_auth_url, 'v3') self._register_cloud() if self.snaps_creds.identity_api_version == 3: self._register_credentials_v3() @@ -286,7 +287,7 @@ class JujuEpc(vnf.VnfOnBoarding): self.__logger.info("Upload some OS images if it doesn't exist") images = get_config("tenant_images", self.config_file) self.__logger.info("Images needed for vEPC: %s", images) - for image_name, image_file in images.iteritems(): + for image_name, image_file in six.iteritems(images): self.__logger.info("image: %s, file: %s", image_name, image_file) if image_file and image_name: image_creator = OpenStackImage(self.snaps_creds, ImageConfig( diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.py b/functest/opnfv_tests/vnf/ims/cloudify_ims.py index bc4242235..71aaa3008 100644 --- a/functest/opnfv_tests/vnf/ims/cloudify_ims.py +++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.py @@ -19,8 +19,7 @@ import uuid from cloudify_rest_client import CloudifyClient from cloudify_rest_client.executions import Execution from scp import SCPClient -import yaml - +import six from snaps.config.flavor import FlavorConfig from snaps.config.image import ImageConfig from snaps.config.keypair import KeypairConfig @@ -40,9 +39,10 @@ from snaps.openstack.create_security_group import OpenStackSecurityGroup from snaps.openstack.create_user import OpenStackUser from snaps.openstack.utils import keystone_utils from xtesting.energy import energy +import yaml from functest.opnfv_tests.openstack.snaps import snaps_utils -import functest.opnfv_tests.vnf.ims.clearwater_ims_base as clearwater_ims_base +from functest.opnfv_tests.vnf.ims import clearwater_ims_base from functest.utils import config from functest.utils import env @@ -165,7 +165,7 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase): # needs some images self.__logger.info("Upload some OS images if it doesn't exist") - for image_name, image_file in self.images.iteritems(): + for image_name, image_file in six.iteritems(self.images): self.__logger.info("image: %s, file: %s", image_name, image_file) if image_file and image_name: image_creator = OpenStackImage( @@ -274,7 +274,7 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase): raise Exception("Cloudify Manager isn't up and running") self.__logger.info("Put OpenStack creds in manager") secrets_list = cfy_client.secrets.list() - for k, val in cfy_creds.iteritems(): + for k, val in six.iteritems(cfy_creds): if not any(d.get('key', None) == k for d in secrets_list): cfy_client.secrets.create(k, val) else: diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims_perf.py b/functest/opnfv_tests/vnf/ims/cloudify_ims_perf.py index 37148c918..376138bb9 100644 --- a/functest/opnfv_tests/vnf/ims/cloudify_ims_perf.py +++ b/functest/opnfv_tests/vnf/ims/cloudify_ims_perf.py @@ -358,7 +358,7 @@ class CloudifyImsPerf(cloudify_ims.CloudifyIms): i = 0 for rdata in result: i = i + 1 - print rdata.address + print(rdata.address) iplistims += str(rdata.address) if i != len(result): iplistims += ';' diff --git a/functest/opnfv_tests/vnf/ims/ixia/utils/IxChassisUtils.py b/functest/opnfv_tests/vnf/ims/ixia/utils/IxChassisUtils.py index 973e0264d..301a0c7bc 100644 --- a/functest/opnfv_tests/vnf/ims/ixia/utils/IxChassisUtils.py +++ b/functest/opnfv_tests/vnf/ims/ixia/utils/IxChassisUtils.py @@ -55,7 +55,7 @@ class ChassisRestAPI: headers=urlHeadersJson) logger.debug(response) logger.debug(content) - except Exception, e: + except Exception as e: raise Exception('Got an error code: ', e) return content @@ -74,7 +74,7 @@ class ChassisRestAPI: (response, content) = h.request(loginUrl, 'POST', body=payload, headers=urlHeadersJson) - except Exception, e: + except Exception as e: raise Exception('Got an error code: ', e) return content @@ -95,7 +95,7 @@ class ChassisRestAPI: (response, content) = h.request(url, 'POST', json.dumps(payload), headers=urlHeadersJson) - except Exception, e: + except Exception as e: raise Exception('Got an error code: ', e) return content @@ -111,9 +111,9 @@ class ChassisRestAPI: (response, content) = h.request(url, 'PATCH', json.dumps(payload), urlHeadersJson) - except Exception, e: + except Exception as e: - # print (response, content) + # print((response, content)) raise Exception('Got an error code: ', e) return content @@ -127,7 +127,7 @@ class ChassisRestAPI: disable_ssl_certificate_validation=True) (response, content) = h.request(url, 'DELETE', '', urlHeadersJson) logger.debug('DELETE: ' + url) - except Exception, e: + except Exception as e: raise Exception('Got an error code: ', e) if response.status not in okStates: raise TestFailedError(json.loads(content)['error']) @@ -142,7 +142,7 @@ class ChassisRestAPI: disable_ssl_certificate_validation=True) logger.debug('GET: ' + url) (response, content) = h.request(url, 'GET', '', urlHeadersJson) - except Exception, e: + except Exception as e: raise Exception('Got an error code: ', e) if response.status not in okStates: raise TestFailedError(json.loads(content)['error']) diff --git a/functest/opnfv_tests/vnf/ims/ixia/utils/IxLoadUtils.py b/functest/opnfv_tests/vnf/ims/ixia/utils/IxLoadUtils.py index bc71a38cf..93da2018c 100644 --- a/functest/opnfv_tests/vnf/ims/ixia/utils/IxLoadUtils.py +++ b/functest/opnfv_tests/vnf/ims/ixia/utils/IxLoadUtils.py @@ -70,7 +70,7 @@ def waitForActionToFinish(connection, replyObj, actionUrl): if actionStatusObj.status == kActionStatusError: errorMsg += actionStatusObj.error - print errorMsg + print(errorMsg) sys.exit(1) else: @@ -172,13 +172,13 @@ def uploadFile(connection, url, fileName, uploadPath, overwrite=True): with open(fileName, 'rb') as f: resp = requests.post(url, data=f, params=params, headers=headers) - except requests.exceptions.ConnectionError, e: + except requests.exceptions.ConnectionError as e: raise Exception('Upload file failed. Received connection error. \ One common cause for this error is the size of the \ file to be uploaded.The web server sets a limit of 1GB\ for the uploaded file size. \ Received the following error: %s' % str(e)) - except IOError, e: + except IOError as e: raise Exception('Upload file failed. Received IO error: %s' % str(e)) except Exception: diff --git a/functest/opnfv_tests/vnf/ims/ixia/utils/IxRestUtils.py b/functest/opnfv_tests/vnf/ims/ixia/utils/IxRestUtils.py index 41c23dc53..9148dd20a 100644 --- a/functest/opnfv_tests/vnf/ims/ixia/utils/IxRestUtils.py +++ b/functest/opnfv_tests/vnf/ims/ixia/utils/IxRestUtils.py @@ -7,10 +7,13 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 -from urlparse import urljoin import requests +import six +from six.moves.urllib.parse import urljoin + + def getConnection(server, port): """ Gets a Connection instance, that will be used to @@ -180,7 +183,7 @@ class WebObject(object): """ self.jsonOptions = {} - for (key, value) in entries.iteritems(): + for (key, value) in six.iteritems(entries): webObj = _WebObject(value) self.jsonOptions[key] = webObj self.__dict__[key] = webObj diff --git a/functest/opnfv_tests/vnf/router/cloudify_vrouter.py b/functest/opnfv_tests/vnf/router/cloudify_vrouter.py index 194549022..c5c72e05c 100644 --- a/functest/opnfv_tests/vnf/router/cloudify_vrouter.py +++ b/functest/opnfv_tests/vnf/router/cloudify_vrouter.py @@ -50,6 +50,9 @@ import snaps.openstack.utils.glance_utils as glance_utils from snaps.openstack.utils import keystone_utils +import six + + __author__ = "Shuya Nakama " @@ -180,7 +183,7 @@ class CloudifyVrouter(vrouter_base.VrouterOnBoardingBase): self.created_object.append(keypair_creator) self.__logger.info("Upload some OS images if it doesn't exist") - for image_name, image_file in self.images.iteritems(): + for image_name, image_file in six.iteritems(self.images): self.__logger.info("image: %s, file: %s", image_name, image_file) if image_file and image_name: image_creator = OpenStackImage( -- cgit 1.2.3-korg