diff options
Diffstat (limited to 'robotframework-onap/vcpeutils')
-rwxr-xr-x | robotframework-onap/vcpeutils/SoUtils.py | 19 | ||||
-rwxr-xr-x | robotframework-onap/vcpeutils/csar_parser.py | 12 | ||||
-rwxr-xr-x | robotframework-onap/vcpeutils/preload.py | 28 | ||||
-rwxr-xr-x | robotframework-onap/vcpeutils/vcpecommon.py | 12 |
4 files changed, 29 insertions, 42 deletions
diff --git a/robotframework-onap/vcpeutils/SoUtils.py b/robotframework-onap/vcpeutils/SoUtils.py index 1248613..c52006d 100755 --- a/robotframework-onap/vcpeutils/SoUtils.py +++ b/robotframework-onap/vcpeutils/SoUtils.py @@ -1,15 +1,10 @@ #! /usr/bin/python -import sys -import logging -import requests -import json -from datetime import datetime -#import progressbar import time -import csar_parser -import preload -from vcpecommon import * + +from .csar_parser import * +from .preload import * +from .vcpecommon import * from robot.api import logger @@ -212,7 +207,7 @@ class SoUtils: return {'requestDetails': req_details} def create_custom_service(self, csar_file, brg_mac, name_suffix=None): - parser = csar_parser.CsarParser() + parser = CsarParser() if not parser.parse_csar(csar_file): return False @@ -259,7 +254,7 @@ class SoUtils: self.tenant_id=tenant_id self.logger.info('\n----------------------------------------------------------------------------------') self.logger.info('Start to create entire service defined in csar: {0}'.format(csar_file)) - parser = csar_parser.CsarParser() + parser = CsarParser() self.logger.info('Parsing csar ...') if not parser.parse_csar(csar_file): self.logger.error('Cannot parse csar: {0}'.format(csar_file)) @@ -337,7 +332,7 @@ class SoUtils: # SDNC Preload - preloader = preload.Preload(self.vcpecommon) + preloader = Preload(self.vcpecommon) preloader.preload_vfmodule(vnf_template_file, svc_instance_id, parser.vnf_models[0], parser.vfmodule_models[0], preload_dict, name_suffix) diff --git a/robotframework-onap/vcpeutils/csar_parser.py b/robotframework-onap/vcpeutils/csar_parser.py index f101364..7440310 100755 --- a/robotframework-onap/vcpeutils/csar_parser.py +++ b/robotframework-onap/vcpeutils/csar_parser.py @@ -115,7 +115,7 @@ class CsarParser: }, """ node_dic = svc_template['topology_template']['node_templates'] - for node_name, v in node_dic.items(): + for node_name, v in list(node_dic.items()): model = { 'modelInvariantId': v['metadata']['invariantUUID'], 'modelVersionId': v['metadata']['UUID'], @@ -177,7 +177,7 @@ class CsarParser: }, """ node_dic = svc_template['topology_template']['groups'] - for node_name, v in node_dic.items(): + for node_name, v in list(node_dic.items()): if v['type'].startswith('org.openecomp.groups.VfModule'): model = { 'modelType': 'vfModule', @@ -212,19 +212,19 @@ class CsarParser: def print_models(self): print('---------Service Model----------') - print(json.dumps(self.svc_model, indent=2, sort_keys=True)) + print((json.dumps(self.svc_model, indent=2, sort_keys=True))) print('---------Network Model(s)----------') for model in self.net_models: - print(json.dumps(model, indent=2, sort_keys=True)) + print((json.dumps(model, indent=2, sort_keys=True))) print('---------VNF Model(s)----------') for model in self.vnf_models: - print(json.dumps(model, indent=2, sort_keys=True)) + print((json.dumps(model, indent=2, sort_keys=True))) print('---------VF Module Model(s)----------') for model in self.vfmodule_models: - print(json.dumps(model, indent=2, sort_keys=True)) + print((json.dumps(model, indent=2, sort_keys=True))) def test(self): self.parse_csar('csar/service-Vcpesvcinfra111601-csar.csar') diff --git a/robotframework-onap/vcpeutils/preload.py b/robotframework-onap/vcpeutils/preload.py index aab28f9..6ccc689 100755 --- a/robotframework-onap/vcpeutils/preload.py +++ b/robotframework-onap/vcpeutils/preload.py @@ -1,12 +1,8 @@ #! /usr/bin/python -import requests -import json -import sys from datetime import datetime -from vcpecommon import * -import csar_parser -#import logging +from .vcpecommon import * +from .csar_parser import * from robot.api import logger import base64 @@ -18,7 +14,7 @@ class Preload: self.vcpecommon = vcpecommon def replace(self, sz, replace_dict): - for old_string, new_string in replace_dict.items(): + for old_string, new_string in list(replace_dict.items()): sz = sz.replace(old_string, new_string) if self.vcpecommon.template_variable_symbol in sz: self.logger.error('Error! Cannot find a value to replace ' + sz) @@ -30,12 +26,12 @@ class Preload: stk = [json_data] while len(stk) > 0: data = stk.pop() - for k, v in data.items(): + for k, v in list(data.items()): if type(v) is dict: stk.append(v) elif type(v) is list: stk.extend(v) - elif type(v) is str or type(v) is unicode: + elif type(v) is str or type(v) is str: if self.vcpecommon.template_variable_symbol in v: data[k] = self.replace(v, replace_dict) else: @@ -166,8 +162,8 @@ class Preload: return self.preload(template_file, replace_dict, self.vcpecommon.sdnc_preload_vnf_url) def preload_all_networks(self, template_file, name_suffix): - common_dict = {'${' + k + '}': v for k, v in self.vcpecommon.common_preload_config.items()} - for network, v in self.vcpecommon.preload_network_config.items(): + common_dict = {'${' + k + '}': v for k, v in list(self.vcpecommon.common_preload_config.items())} + for network, v in list(self.vcpecommon.preload_network_config.items()): subnet_start_ip, subnet_gateway_ip = v if not self.preload_network(template_file, network, subnet_start_ip, subnet_gateway_ip, common_dict, name_suffix): @@ -180,15 +176,15 @@ class Preload: vcpecommon = VcpeCommon() preloader = Preload(vcpecommon) - network_dict = {'${' + k + '}': v for k, v in self.vcpecommon.common_preload_config.items()} + network_dict = {'${' + k + '}': v for k, v in list(self.vcpecommon.common_preload_config.items())} template_file = 'preload_templates/template.network.json' - for k, v in self.vcpecommon.preload_network_config.items(): + for k, v in list(self.vcpecommon.preload_network_config.items()): if not preloader.preload_network(template_file, k, v[0], v[1], network_dict, name_suffix): break print('---------------------------------------------------------------') print('Network related replacement dictionary:') - print(json.dumps(network_dict, indent=4, sort_keys=True)) + print((json.dumps(network_dict, indent=4, sort_keys=True))) print('---------------------------------------------------------------') keys = ['infra', 'bng', 'gmux', 'brg'] @@ -196,7 +192,7 @@ class Preload: csar_file = self.vcpecommon.find_file(key, 'csar', 'csar') template_file = self.vcpecommon.find_file(key, 'json', 'preload_templates') if csar_file and template_file: - parser = csar_parser.CsarParser() + parser = CsarParser() parser.parse_csar(csar_file) service_instance_id = 'test112233' preloader.preload_vfmodule(template_file, service_instance_id, parser.vnf_models[0], @@ -207,7 +203,7 @@ class Preload: template_sniro_request = self.vcpecommon.find_file('sniro_request', 'json', 'preload_templates') vcperescust_csar = self.vcpecommon.find_file('rescust', 'csar', 'csar') - parser = csar_parser.CsarParser() + parser = CsarParser() parser.parse_csar(vcperescust_csar) tunnelxconn_ar_name = None brg_ar_name = None diff --git a/robotframework-onap/vcpeutils/vcpecommon.py b/robotframework-onap/vcpeutils/vcpecommon.py index 95b5bbe..0d45ee3 100755 --- a/robotframework-onap/vcpeutils/vcpecommon.py +++ b/robotframework-onap/vcpeutils/vcpecommon.py @@ -7,10 +7,6 @@ import sys import ipaddress import requests -import commands -import time -from novaclient import client as openstackclient -from netaddr import IPAddress, IPNetwork class VcpeCommon: ############################################################################################# @@ -212,7 +208,7 @@ class VcpeCommon: return '_'.join(fields) def set_network_name(self, network_name): - param = ' '.join([k + ' ' + v for k, v in self.cloud.items()]) + param = ' '.join([k + ' ' + v for k, v in list(self.cloud.items())]) openstackcmd = 'openstack ' + param cmd = ' '.join([openstackcmd, 'network set --name', network_name, 'ONAP-NW1']) os.popen(cmd) @@ -223,7 +219,7 @@ class VcpeCommon: set subnet name to vcpe_net_cpe_signal_subnet_201711281221 :return: """ - param = ' '.join([k + ' ' + v for k, v in self.cloud.items()]) + param = ' '.join([k + ' ' + v for k, v in list(self.cloud.items())]) openstackcmd = 'openstack ' + param # expected results: | subnets | subnet_id | @@ -271,10 +267,10 @@ class VcpeCommon: :param sz: a string :return: the first IP address matching the network, e.g. 10.5.12.3 """ - network = ipaddress.ip_network(unicode('{0}/{1}'.format(net_addr, net_addr_len)), strict=False) + network = ipaddress.ip_network(str('{0}/{1}'.format(net_addr, net_addr_len)), strict=False) ip_list = re.findall(r'[0-9]+(?:\.[0-9]+){3}', sz) for ip in ip_list: - this_net = ipaddress.ip_network(unicode('{0}/{1}'.format(ip, net_addr_len)), strict=False) + this_net = ipaddress.ip_network(str('{0}/{1}'.format(ip, net_addr_len)), strict=False) if this_net == network: return str(ip) return None |