diff options
Diffstat (limited to 'vio')
62 files changed, 435 insertions, 2957 deletions
diff --git a/vio/tox.ini b/vio/tox.ini index cc9e5ad..bf5d800 100644 --- a/vio/tox.ini +++ b/vio/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27 +envlist = py27,pep8 skipsdist = true [tox:jenkins] @@ -8,3 +8,7 @@ downloadcache = ~/cache/pip [testenv] deps = -r{toxinidir}/requirements.txt commands = coverage run --branch manage.py test vio + +[testenv:pep8] +deps=flake8 +commands=flake8 diff --git a/vio/vio/pub/config/config.py b/vio/vio/pub/config/config.py index e00351b..a31d63c 100644 --- a/vio/vio/pub/config/config.py +++ b/vio/vio/pub/config/config.py @@ -17,7 +17,8 @@ MSB_SERVICE_IP = '127.0.0.1' MSB_SERVICE_PORT = '10080' # [IMAGE LOCAL PATH] -ROOT_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +ROOT_PATH = os.path.dirname(os.path.dirname( + os.path.dirname(os.path.abspath(__file__)))) # [REDIS] REDIS_HOST = '127.0.0.1' diff --git a/vio/vio/pub/database/models.py b/vio/vio/pub/database/models.py index b12510a..c208dbc 100644 --- a/vio/vio/pub/database/models.py +++ b/vio/vio/pub/database/models.py @@ -12,10 +12,12 @@ from django.db import models + class VimInstModel(models.Model): class Meta: db_table = 'vim_inst_type_mapping' - vimid = models.CharField(db_column='VIMID', primary_key=True, max_length=200) + vimid = models.CharField( + db_column='VIMID', primary_key=True, max_length=200) vimtype = models.CharField(db_column="VIMTYPE", max_length=200) viminst_url = models.CharField(db_column="VIMINSTURL", max_length=200) diff --git a/vio/vio/pub/exceptions.py b/vio/vio/pub/exceptions.py index 097d785..d20dab1 100644 --- a/vio/vio/pub/exceptions.py +++ b/vio/vio/pub/exceptions.py @@ -19,6 +19,7 @@ class ClientException(Exception): self.message = message or self.message super(ClientException, self).__init__(self.message) + class ServerException(Exception): message = "ServerException" @@ -29,6 +30,7 @@ class ServerException(Exception): self.status_code = status_code self.content = content + class RetriableConnectionFailure(Exception): pass @@ -50,8 +52,6 @@ class SSLError(ConnectionError): message = "An SSL error occurred." - - class UnknownConnectionError(ConnectionError): def __init__(self, msg, original): @@ -59,10 +59,9 @@ class UnknownConnectionError(ConnectionError): self.original = original - class NotFoundError(ServerException): message = "Cannot find value" + class VimDriverVioException(ServerException): message = "Cannot find vim driver" - diff --git a/vio/vio/pub/msapi/extsys.py b/vio/vio/pub/msapi/extsys.py index 5410c58..19ea80d 100644 --- a/vio/vio/pub/msapi/extsys.py +++ b/vio/vio/pub/msapi/extsys.py @@ -32,6 +32,6 @@ def get_vim_by_id(vim_id): ret = req_by_msb("/openoapi/extsys/v1/vims/%s" % vim_id, "GET") if ret[0] != 0: logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) - raise VimDriverVioException("Failed to query VIM with id (%s) from extsys." % vim_id, - status.HTTP_404_NOT_FOUND) + raise VimDriverVioException("Failed to query VIM with \ + id (%s) from extsys." % vim_id, status.HTTP_404_NOT_FOUND) return json.JSONDecoder().decode(ret[1]) diff --git a/vio/vio/pub/utils/restcall.py b/vio/vio/pub/utils/restcall.py index 0d7fd25..590e52f 100644 --- a/vio/vio/pub/utils/restcall.py +++ b/vio/vio/pub/utils/restcall.py @@ -20,9 +20,12 @@ import httplib2 from vio.pub.config.config import MSB_SERVICE_IP, MSB_SERVICE_PORT rest_no_auth, rest_oneway_auth, rest_bothway_auth = 0, 1, 2 -HTTP_200_OK, HTTP_201_CREATED, HTTP_204_NO_CONTENT, HTTP_202_ACCEPTED = '200', '201', '204', '202' -status_ok_list = [HTTP_200_OK, HTTP_201_CREATED, HTTP_204_NO_CONTENT, HTTP_202_ACCEPTED] -HTTP_404_NOTFOUND, HTTP_403_FORBIDDEN, HTTP_401_UNAUTHORIZED, HTTP_400_BADREQUEST = '404', '403', '401', '400' +HTTP_200_OK, HTTP_201_CREATED = '200', '201' +HTTP_204_NO_CONTENT, HTTP_202_ACCEPTED = '204', '202' +status_ok_list = [HTTP_200_OK, HTTP_201_CREATED, + HTTP_204_NO_CONTENT, HTTP_202_ACCEPTED] +HTTP_404_NOTFOUND, HTTP_403_FORBIDDEN = '404', '403' +HTTP_401_UNAUTHORIZED, HTTP_400_BADREQUEST = '401', '400' logger = logging.getLogger(__name__) @@ -35,17 +38,26 @@ def call_req(base_url, user, passwd, auth_type, resource, method, content=''): resp_status = '' try: full_url = combine_url(base_url, resource) - headers = {'content-type': 'application/json', 'accept': 'application/json'} + headers = {'content-type': 'application/json', + 'accept': 'application/json'} if user: - headers['Authorization'] = 'Basic ' + ('%s:%s' % (user, passwd)).encode("base64") + headers['Authorization'] = 'Basic ' + \ + ('%s:%s' % (user, passwd)).encode("base64") ca_certs = None for retry_times in range(3): - http = httplib2.Http(ca_certs=ca_certs, disable_ssl_certificate_validation=(auth_type == rest_no_auth)) + http = httplib2.Http( + ca_certs=ca_certs, + disable_ssl_certificate_validation=( + auth_type == rest_no_auth)) http.follow_all_redirects = True try: - resp, resp_content = http.request(full_url, method=method.upper(), body=content, headers=headers) - resp_status, resp_body = resp['status'], resp_content.decode('UTF-8') - logger.debug("[%s][%d]status=%s,resp_body=%s)" % (callid, retry_times, resp_status, resp_body)) + resp, resp_content = http.request( + full_url, method=method.upper(), + body=content, headers=headers) + resp_status, resp_body = resp['status'], resp_content.decode( + 'UTF-8') + logger.debug("[%s][%d]status=%s,resp_body=%s)" % + (callid, retry_times, resp_status, resp_body)) if resp_status in status_ok_list: ret = [0, resp_body, resp_status] else: @@ -55,7 +67,8 @@ def call_req(base_url, user, passwd, auth_type, resource, method, content=''): if 'httplib.ResponseNotReady' in str(sys.exc_info()): logger.debug("retry_times=%d", retry_times) logger.error(traceback.format_exc()) - ret = [1, "Unable to connect to %s" % full_url, resp_status] + ret = [1, "Unable to connect to %s" % + full_url, resp_status] continue raise ex except urllib2.URLError as err: @@ -65,7 +78,8 @@ def call_req(base_url, user, passwd, auth_type, resource, method, content=''): logger.error("[%s]ret=%s" % (callid, str(sys.exc_info()))) res_info = str(sys.exc_info()) if 'httplib.ResponseNotReady' in res_info: - res_info = "The URL[%s] request failed or is not responding." % full_url + res_info = "The URL[%s] request failed \ + or is not responding." % full_url ret = [3, res_info, resp_status] except: logger.error(traceback.format_exc()) diff --git a/vio/vio/pub/utils/share_lock.py b/vio/vio/pub/utils/share_lock.py index 10ab225..cf6486b 100755 --- a/vio/vio/pub/utils/share_lock.py +++ b/vio/vio/pub/utils/share_lock.py @@ -20,17 +20,20 @@ from vio.pub.config.config import REDIS_HOST, REDIS_PORT, REDIS_PASSWD class SharedLock: - def __init__(self, lock_key, host=REDIS_HOST, port=REDIS_PORT, password=REDIS_PASSWD, db=9, lock_timeout=5 * 60): + def __init__(self, lock_key, host=REDIS_HOST, port=REDIS_PORT, + password=REDIS_PASSWD, db=9, lock_timeout=5 * 60): self.lock_key = lock_key self.lock_timeout = lock_timeout - self.redis = redis.Redis(host=host, port=port, db=db, password=password) + self.redis = redis.Redis(host=host, port=port, + db=db, password=password) self.acquire_time = -1 def acquire(self): begin = now = int(time.time()) while (now - begin) < self.lock_timeout: - result = self.redis.setnx(self.lock_key, now + self.lock_timeout + 1) + result = self.redis.setnx( + self.lock_key, now + self.lock_timeout + 1) if result == 1 or result is True: self.acquire_time = now return True @@ -43,7 +46,8 @@ class SharedLock: current_lock_timestamp = int(current_lock_timestamp) if now > current_lock_timestamp: - next_lock_timestamp = self.redis.getset(self.lock_key, now + self.lock_timeout + 1) + next_lock_timestamp = self.redis.getset( + self.lock_key, now + self.lock_timeout + 1) if not next_lock_timestamp: time.sleep(1) continue diff --git a/vio/vio/pub/utils/syscomm.py b/vio/vio/pub/utils/syscomm.py index fd99ac6..d98e3e4 100644 --- a/vio/vio/pub/utils/syscomm.py +++ b/vio/vio/pub/utils/syscomm.py @@ -14,35 +14,34 @@ import inspect import json from collections import defaultdict + def fun_name(): return inspect.stack()[1][3] -def jsonResponse(data,encoding='utf-8'): +def jsonResponse(data, encoding='utf-8'): content_type = "application/json" try: - res = json.loads(data,encoding=encoding) - except Exception as e: + res = json.loads(data, encoding=encoding) + except Exception: res = data content_type = "text/plain" - return (res,content_type) + return (res, content_type) class Catalogs(object): def __init__(self): - self.ct=defaultdict(dict) - + self.ct = defaultdict(dict) - def storeEndpoint(self,vimid,endpoints): - self.ct.setdefault(vimid,endpoints) + def storeEndpoint(self, vimid, endpoints): + self.ct.setdefault(vimid, endpoints) - def getEndpointBy(self,vimid,serverType,interface='public'): + def getEndpointBy(self, vimid, serverType, interface='public'): vim = self.ct.get(vimid) - return vim.get(serverType).get(interface,"") if vim else "" - + return vim.get(serverType).get(interface, "") if vim else "" catalog = Catalogs() diff --git a/vio/vio/pub/utils/toscautil.py b/vio/vio/pub/utils/toscautil.py deleted file mode 100644 index 08307a6..0000000 --- a/vio/vio/pub/utils/toscautil.py +++ /dev/null @@ -1,2604 +0,0 @@ -# Copyright (c) 2017 VMware, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - -import json - -def safe_get(key_val, key): - return key_val[key] if key in key_val else "" - - -def find_node_name(node_id, node_list): - for node in node_list: - if node['id'] == node_id: - return node['template_name'] - raise Exception('can not find node(%s).' % node_id) - - -def find_node_type(node_id, node_list): - for node in node_list: - if node['id'] == node_id: - return node['type_name'] - raise Exception('can not find node(%s).' % node_id) - - -def find_related_node(node_id, src_json_model, requirement_name): - related_nodes = [] - for model_tpl in safe_get(src_json_model, "node_templates"): - for rt in safe_get(model_tpl, 'requirement_templates'): - if safe_get(rt, 'name') == requirement_name and \ - safe_get(rt, 'target_node_template_name') == node_id: - related_nodes.append(model_tpl['name']) - return related_nodes - - -def convert_props(src_node, dest_node): - if 'properties' in src_node and src_node['properties']: - for prop_name, prop_info in src_node['properties'].items(): - if 'value' in prop_info: - dest_node['properties'][prop_name] = prop_info['value'] - - -def convert_metadata(src_json): - return src_json['metadata'] if 'metadata' in src_json else {} - - -def convert_inputs(src_json): - inputs = {} - if 'inputs' in src_json: - src_inputs = src_json['inputs'] - for param_name, param_info in src_inputs.items(): - input_param = {} - if 'type_name' in param_info: - input_param['type'] = param_info['type_name'] - if 'description' in param_info: - input_param['description'] = param_info['description'] - if 'value' in param_info: - input_param['value'] = param_info['value'] - inputs[param_name] = input_param - return inputs - - -def convert_vnf_node(src_node, src_json_model): - vnf_node = {'type': src_node['type_name'], 'vnf_id': src_node['template_name'], - 'description': '', 'properties': {}, 'dependencies': [], 'networks': []} - convert_props(src_node, vnf_node) - for model_tpl in safe_get(src_json_model, "node_templates"): - if model_tpl['name'] != vnf_node['vnf_id']: - continue - vnf_node['dependencies'] = [{ - 'key_name': requirement['name'], - 'vl_id': requirement['target_node_template_name']} for \ - requirement in safe_get(model_tpl, 'requirement_templates') if \ - safe_get(requirement, 'target_capability_name') == 'virtual_linkable'] - vnf_node['networks'] = [requirement['target_node_template_name'] for \ - requirement in safe_get(model_tpl, 'requirement_templates') if \ - safe_get(requirement, 'name') == 'dependency'] - return vnf_node - - -def convert_pnf_node(src_node, src_json_model): - pnf_node = {'pnf_id': src_node['template_name'], 'description': '', 'properties': {}} - convert_props(src_node, pnf_node) - pnf_node['cps'] = find_related_node(src_node['id'], src_json_model, 'virtualbinding') - return pnf_node - - -def convert_vl_node(src_node, src_node_list): - vl_node = {'vl_id': src_node['template_name'], 'description': '', 'properties': {}} - convert_props(src_node, vl_node) - vl_node['route_id'] = '' - for relation in safe_get(src_node, 'relationships'): - if safe_get(relation, 'type_name').endswith('.VirtualLinksTo'): - vl_node['route_id'] = find_node_name(relation['target_node_id'], src_node_list) - break - vl_node['route_external'] = (src_node['type_name'].find('.RouteExternalVL') > 0) - return vl_node - - -def convert_cp_node(src_node, src_node_list, model_type='NSD'): - cp_node = {'cp_id': src_node['template_name'], 'description': '', 'properties': {}} - convert_props(src_node, cp_node) - src_relationships = src_node['relationships'] - for relation in src_relationships: - if safe_get(relation, 'name') == 'virtualLink': - cp_node['vl_id'] = find_node_name(relation['target_node_id'], src_node_list) - elif safe_get(relation, 'name') == 'virtualbinding': - node_key = 'pnf_id' if model_type == 'NSD' else 'vdu_id' - cp_node[node_key] = find_node_name(relation['target_node_id'], src_node_list) - return cp_node - - -def convert_router_node(src_node, src_node_list): - router_node = {'router_id': src_node['template_name'], 'description': '', 'properties': {}} - convert_props(src_node, router_node) - for relation in src_node['relationships']: - if safe_get(relation, 'name') != 'external_virtual_link': - continue - router_node['external_vl_id'] = find_node_name(relation['target_node_id'], src_node_list) - router_node['external_ip_addresses'] = [] - if 'properties' not in relation: - continue - for prop_name, prop_info in relation['properties'].items(): - if prop_name == 'router_ip_address': - router_node['external_ip_addresses'].append(prop_info['value']) - break - return router_node - - -def convert_fp_node(src_node, src_node_list, src_json_model): - fp_node = {'fp_id': src_node['template_name'], 'description': '', - 'properties': {}, 'forwarder_list': []} - convert_props(src_node, fp_node) - for relation in safe_get(src_node, 'relationships'): - if safe_get(relation, 'name') != 'forwarder': - continue - forwarder_point = {'type': 'vnf'} - target_node_type = find_node_type(relation['target_node_id'], src_node_list).upper() - if target_node_type.find('.CP.') >= 0 or target_node_type.endswith('.CP'): - forwarder_point['type'] = 'cp' - forwarder_point['node_name'] = find_node_name(relation['target_node_id'], src_node_list) - forwarder_point['capability'] = '' - if forwarder_point['type'] == 'vnf': - for node_tpl in src_json_model["node_templates"]: - if fp_node['fp_id'] != node_tpl["name"]: - continue - for r_tpl in safe_get(node_tpl, "requirement_templates"): - if safe_get(r_tpl, "target_node_template_name") != forwarder_point['node_name']: - continue - forwarder_point['capability'] = safe_get(r_tpl, "target_capability_name") - break - break - fp_node['forwarder_list'].append(forwarder_point) - return fp_node - - -def convert_vnffg_group(src_group, src_group_list, src_node_list): - vnffg = {'vnffg_id': src_group['template_name'], 'description': '', - 'properties': {}, 'members': []} - convert_props(src_group, vnffg) - for member_node_id in src_group['member_node_ids']: - vnffg['members'].append(find_node_name(member_node_id, src_node_list)) - return vnffg - - -def convert_imagefile_node(src_node, src_node_list): - image_node = {'image_file_id': src_node['template_name'], 'description': '', - 'properties': {}} - convert_props(src_node, image_node) - return image_node - - -def convert_localstorage_node(src_node, src_node_list): - localstorage_node = {'local_storage_id': src_node['template_name'], 'description': '', - 'properties': {}} - convert_props(src_node, localstorage_node) - return localstorage_node - - -def convert_vdu_node(src_node, src_node_list, src_json_model): - vdu_node = {'vdu_id': src_node['template_name'], 'description': '', 'properties': {}, - 'image_file': '', 'local_storages': [], 'dependencies': [], 'nfv_compute': {}, - 'vls': [], 'artifacts': []} - convert_props(src_node, vdu_node) - - for relation in src_node['relationships']: - r_id, r_name = safe_get(relation, 'target_node_id'), safe_get(relation, 'name') - if r_name == 'guest_os': - vdu_node['image_file'] = find_node_name(r_id, src_node_list) - elif r_name == 'local_storage': - vdu_node['local_storages'].append(find_node_name(r_id, src_node_list)) - elif r_name.endswith('.AttachesTo'): - nt = find_node_type(r_id, src_node_list) - if nt.endswith('.BlockStorage.Local') or nt.endswith('.LocalStorage'): - vdu_node['local_storages'].append(find_node_name(r_id, src_node_list)) - - for capability in src_node['capabilities']: - if capability['name'] != 'nfv_compute': - continue - for prop_name, prop_info in capability['properties'].items(): - if 'value' in prop_info: - vdu_node['nfv_compute'][prop_name] = prop_info['value'] - - vdu_node['cps'] = find_related_node(src_node['id'], src_json_model, 'virtualbinding') - - for cp_node in vdu_node['cps']: - for src_cp_node in src_node_list: - if src_cp_node['template_name'] != cp_node: - continue - for relation in safe_get(src_cp_node, 'relationships'): - if relation['name'] != 'virtualLink': - continue - vl_node_name = find_node_name(relation['target_node_id'], src_node_list) - if vl_node_name not in vdu_node['vls']: - vdu_node['vls'].append(vl_node_name) - - for item in safe_get(src_node, 'artifacts'): - artifact = {'artifact_name': item['name'], 'type': item['type_name'], - 'file': item['source_path']} - vdu_node['artifacts'].append(artifact) - - return vdu_node - - -def convert_exposed_node(src_json, src_nodes, exposed): - for item in safe_get(safe_get(src_json, 'substitution'), 'requirements'): - exposed['external_cps'].append({'key_name': item['mapped_name'], - "cp_id": find_node_name(item['node_id'], src_nodes)}) - for item in safe_get(safe_get(src_json, 'substitution'), 'capabilities'): - exposed['forward_cps'].append({'key_name': item['mapped_name'], - "cp_id": find_node_name(item['node_id'], src_nodes)}) - - -def convert_vnffgs(src_json_inst, src_nodes): - vnffgs = [] - src_groups = safe_get(src_json_inst, 'groups') - for group in src_groups: - type_name = group['type_name'].upper() - if type_name.find('.VNFFG.') >= 0 or type_name.endswith('.VNFFG'): - vnffgs.append(convert_vnffg_group(group, src_groups, src_nodes)) - return vnffgs - - -def convert_common(src_json, target_json): - if isinstance(src_json, (unicode, str)): - src_json_dict = json.loads(src_json) - else: - src_json_dict = src_json - src_json_inst = src_json_dict["instance"] - src_json_model = src_json_dict["model"] if "model" in src_json_dict else {} - - target_json['metadata'] = convert_metadata(src_json_inst) - target_json['inputs'] = convert_inputs(src_json_inst) - target_json['vls'] = [] - target_json['cps'] = [] - target_json['routers'] = [] - - return src_json_inst, src_json_model - - -def convert_nsd_model(src_json): - target_json = {'vnfs': [], 'pnfs': [], 'fps': []} - src_json_inst, src_json_model = convert_common(src_json, target_json) - - src_nodes = src_json_inst['nodes'] - for node in src_nodes: - type_name = node['type_name'] - if type_name.find('.VNF.') > 0 or type_name.endswith('.VNF'): - target_json['vnfs'].append(convert_vnf_node(node, src_json_model)) - elif type_name.find('.PNF.') > 0 or type_name.endswith('.PNF'): - target_json['pnfs'].append(convert_pnf_node(node, src_json_model)) - elif type_name.find('.VL.') > 0 or type_name.endswith('.VL') \ - or node['type_name'].find('.RouteExternalVL') > 0: - target_json['vls'].append(convert_vl_node(node, src_nodes)) - elif type_name.find('.CP.') > 0 or type_name.endswith('.CP'): - target_json['cps'].append(convert_cp_node(node, src_nodes)) - elif type_name.find('.FP.') > 0 or type_name.endswith('.FP'): - target_json['fps'].append(convert_fp_node(node, src_nodes, src_json_model)) - elif type_name.endswith('.Router'): - target_json['routers'].append(convert_router_node(node, src_nodes)) - - target_json['vnffgs'] = convert_vnffgs(src_json_inst, src_nodes) - - target_json['ns_exposed'] = {'external_cps': [], 'forward_cps': []} - convert_exposed_node(src_json_inst, src_nodes, target_json['ns_exposed']) - return json.dumps(target_json) - - -def convert_vnfd_model(src_json): - target_json = {'image_files': [], 'local_storages': [], 'vdus': []} - src_json_inst, src_json_model = convert_common(src_json, target_json) - - src_nodes = src_json_inst['nodes'] - for node in src_nodes: - type_name = node['type_name'] - if type_name.endswith('.ImageFile'): - target_json['image_files'].append(convert_imagefile_node(node, src_nodes)) - elif type_name.endswith('.BlockStorage.Local') or type_name.endswith('.LocalStorage'): - target_json['local_storages'].append(convert_localstorage_node(node, src_nodes)) - elif type_name.find('.VDU.') > 0 or type_name.endswith('.VDU'): - target_json['vdus'].append(convert_vdu_node(node, src_nodes, src_json_model)) - elif type_name.find('.VL.') > 0 or type_name.endswith('.VL') \ - or node['type_name'].find('.RouteExternalVL') > 0: - target_json['vls'].append(convert_vl_node(node, src_nodes)) - elif type_name.find('.CP.') > 0 or type_name.endswith('.CP'): - target_json['cps'].append(convert_cp_node(node, src_nodes, 'VNFD')) - elif type_name.endswith('.Router'): - target_json['routers'].append(convert_router_node(node, src_nodes)) - - target_json['vnf_exposed'] = {'external_cps': [], 'forward_cps': []} - convert_exposed_node(src_json_inst, src_nodes, target_json['vnf_exposed']) - return json.dumps(target_json) - -if __name__ == '__main__': - src_json = json.dumps( - { - "instance":{ - "metadata":{ - "vendor":"ZTE", - "name":"VCPE_NS", - "csarVersion":"v1.0", - "csarType":"NSAR", - "csarProvider":"ZTE", - "version":1, - "invariant_id":"vcpe_ns_sff_1", - "id":"VCPE_NS", - "description":"vcpe_ns" - }, - "nodes":[ - { - "id":"path2_kgmfqr5ldqs9lj3oscrgxqefc", - "type_name":"tosca.nodes.nfv.ext.FP", - "template_name":"path2", - "properties":{ - "symmetric":{ - "type_name":"boolean", - "value":False - }, - "policy":{ - "type_name":"tosca.datatypes.nfv.ext.FPPolicy", - "value":{ - "type":"ACL", - "criteria":{ - "dest_port_range":"1-100", - "ip_protocol":"tcp", - "source_ip_range":[ - "119.1.1.1-119.1.1.10" - ], - "dest_ip_range":[ - {"get_input":"NatIpRange"} - ], - "dscp":0, - "source_port_range":"1-100" - } - } - } - }, - "interfaces":[ - { - "name":"Standard", - "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.", - "type_name":"tosca.interfaces.node.lifecycle.Standard", - "operations":[ - { - "name":"create", - "description":"Standard lifecycle create operation." - }, - { - "name":"stop", - "description":"Standard lifecycle stop operation." - }, - { - "name":"start", - "description":"Standard lifecycle start operation." - }, - { - "name":"delete", - "description":"Standard lifecycle delete operation." - }, - { - "name":"configure", - "description":"Standard lifecycle configure operation." - } - ] - } - ], - "capabilities":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - } - ], - "relationships":[ - { - "name":"forwarder", - "source_requirement_index":0, - "target_node_id":"m6000_data_out_qeukdtf6g87cnparxi51fa8s6" - }, - { - "name":"forwarder", - "source_requirement_index":1, - "target_node_id":"m600_tunnel_cp_imwfk5l48ljz0g9knc6d68hv5" - }, - { - "name":"forwarder", - "source_requirement_index":2, - "target_node_id":"VNAT_cfdljtspvkp234irka59wgab0", - "target_capability_name":"feature" - } - ] - }, - { - "id":"path1_bv53fblv26hawr8dj4fxe2rsd", - "type_name":"tosca.nodes.nfv.ext.FP", - "template_name":"path1", - "properties":{ - "symmetric":{ - "type_name":"boolean", - "value":True - }, - "policy":{ - "type_name":"tosca.datatypes.nfv.ext.FPPolicy", - "value":{ - "type":"ACL", - "criteria":{ - "dest_port_range":"1-100", - "ip_protocol":"tcp", - "source_ip_range":[ - "1-100" - ], - "dest_ip_range":[ - "1-100" - ], - "dscp":4, - "source_port_range":"1-100" - } - } - } - }, - "interfaces":[ - { - "name":"Standard", - "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.", - "type_name":"tosca.interfaces.node.lifecycle.Standard", - "operations":[ - { - "name":"create", - "description":"Standard lifecycle create operation." - }, - { - "name":"stop", - "description":"Standard lifecycle stop operation." - }, - { - "name":"start", - "description":"Standard lifecycle start operation." - }, - { - "name":"delete", - "description":"Standard lifecycle delete operation." - }, - { - "name":"configure", - "description":"Standard lifecycle configure operation." - } - ] - } - ], - "capabilities":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - } - ], - "relationships":[ - { - "name":"forwarder", - "source_requirement_index":0, - "target_node_id":"m6000_data_in_eldly5txw4frny3cc349uz3nc" - }, - { - "name":"forwarder", - "source_requirement_index":1, - "target_node_id":"m600_tunnel_cp_imwfk5l48ljz0g9knc6d68hv5" - }, - { - "name":"forwarder", - "source_requirement_index":2, - "target_node_id":"VFW_57z0ua89aiyl8ncvw7h7mjf34", - "target_capability_name":"feature" - }, - { - "name":"forwarder", - "source_requirement_index":3, - "target_node_id":"VNAT_cfdljtspvkp234irka59wgab0", - "target_capability_name":"feature" - }, - { - "name":"forwarder", - "source_requirement_index":4, - "target_node_id":"m600_tunnel_cp_imwfk5l48ljz0g9knc6d68hv5" - }, - { - "name":"forwarder", - "source_requirement_index":5, - "target_node_id":"m6000_data_out_qeukdtf6g87cnparxi51fa8s6" - } - ] - }, - { - "id":"m6000_data_out_qeukdtf6g87cnparxi51fa8s6", - "type_name":"tosca.nodes.nfv.ext.zte.CP", - "template_name":"m6000_data_out", - "properties":{ - "direction":{ - "type_name":"string", - "value":"bidirectional" - }, - "vnic_type":{ - "type_name":"string", - "value":"normal" - }, - "bandwidth":{ - "type_name":"integer", - "value":0 - }, - "mac_address":{ - "type_name":"string", - "value":"11-22-33-22-11-44" - }, - "interface_name":{ - "type_name":"string", - "value":"xgei-0/4/1/5" - }, - "ip_address":{ - "type_name":"string", - "value":"176.1.1.2" - }, - "order":{ - "type_name":"integer", - "value":0 - }, - "sfc_encapsulation":{ - "type_name":"string", - "value":"mac" - } - }, - "interfaces":[ - { - "name":"Standard", - "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.", - "type_name":"tosca.interfaces.node.lifecycle.Standard", - "operations":[ - { - "name":"create", - "description":"Standard lifecycle create operation." - }, - { - "name":"stop", - "description":"Standard lifecycle stop operation." - }, - { - "name":"start", - "description":"Standard lifecycle start operation." - }, - { - "name":"delete", - "description":"Standard lifecycle delete operation." - }, - { - "name":"configure", - "description":"Standard lifecycle configure operation." - } - ] - } - ], - "capabilities":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - }, - { - "name":"forwarder", - "type_name":"tosca.capabilities.nfv.Forwarder" - } - ], - "relationships":[ - { - "name":"virtualbinding", - "source_requirement_index":0, - "target_node_id":"m6000_s_7qtzo5nuocyfmebc6kp9raq18", - "target_capability_name":"feature" - }, - { - "name":"virtualLink", - "source_requirement_index":1, - "target_node_id":"path2_kgmfqr5ldqs9lj3oscrgxqefc", - "target_capability_name":"feature" - }, - { - "name":"forwarder", - "source_requirement_index":2, - "target_node_id":"path2_kgmfqr5ldqs9lj3oscrgxqefc", - "target_capability_name":"feature" - } - ] - }, - { - "id":"VFW_57z0ua89aiyl8ncvw7h7mjf34", - "type_name":"tosca.nodes.nfv.ext.zte.VNF.VFW", - "template_name":"VFW", - "properties":{ - "is_shared":{ - "type_name":"boolean", - "value":False - }, - "plugin_info":{ - "type_name":"string", - "value":"vbrasplugin_1.0" - }, - "vendor":{ - "type_name":"string", - "value":"zte" - }, - "request_reclassification":{ - "type_name":"boolean", - "value":False - }, - "vnf_extend_type":{ - "type_name":"string", - "value":"driver" - }, - "name":{ - "type_name":"string", - "value":"VFW" - }, - "version":{ - "type_name":"string", - "value":"1.0" - }, - "cross_dc":{ - "type_name":"boolean", - "value":False - }, - "vnf_type":{ - "type_name":"string", - "value":"VFW" - }, - "vnfd_version":{ - "type_name":"string", - "value":"1.0.0" - }, - "id":{ - "type_name":"string", - "value":"vcpe_vfw_zte_1_0" - }, - "nsh_aware":{ - "type_name":"boolean", - "value":True - }, - "adjust_vnf_capacity":{ - "type_name":"boolean", - "value":True - }, - "vmnumber_overquota_alarm":{ - "type_name":"boolean", - "value":True - }, - "csarProvider":{ - "type_name":"string", - "value":"ZTE" - }, - "csarVersion":{ - "type_name":"string", - "value":"v1.0" - }, - "externalPluginManageNetworkName":{ - "type_name":"string", - "value":"vlan_4007_plugin_net" - }, - "csarType":{ - "type_name":"string", - "value":"NFAR" - } - }, - "interfaces":[ - { - "name":"Standard", - "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.", - "type_name":"tosca.interfaces.node.lifecycle.Standard", - "operations":[ - { - "name":"create", - "description":"Standard lifecycle create operation." - }, - { - "name":"stop", - "description":"Standard lifecycle stop operation." - }, - { - "name":"start", - "description":"Standard lifecycle start operation." - }, - { - "name":"delete", - "description":"Standard lifecycle delete operation." - }, - { - "name":"configure", - "description":"Standard lifecycle configure operation." - } - ] - } - ], - "capabilities":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - }, - { - "name":"forwarder", - "type_name":"tosca.capabilities.nfv.Forwarder" - }, - { - "name":"vfw_fw_inout", - "type_name":"tosca.capabilities.nfv.Forwarder" - } - ], - "relationships":[ - { - "name":"vfw_ctrl_by_manager_cp", - "source_requirement_index":0, - "target_node_id":"ext_mnet_net_au2otee5mcy0dnpqykj487zr3", - "target_capability_name":"feature" - }, - { - "name":"vfw_data_cp", - "source_requirement_index":1, - "target_node_id":"sfc_data_network_vx3pc1oahn0k0pa5q722yafee", - "target_capability_name":"feature" - }, - { - "name":"virtualLink", - "source_requirement_index":2, - "target_node_id":"path2_kgmfqr5ldqs9lj3oscrgxqefc", - "target_capability_name":"feature" - }, - { - "name":"forwarder", - "source_requirement_index":3, - "target_node_id":"path2_kgmfqr5ldqs9lj3oscrgxqefc", - "target_capability_name":"feature" - } - ] - }, - { - "id":"m600_tunnel_cp_imwfk5l48ljz0g9knc6d68hv5", - "type_name":"tosca.nodes.nfv.ext.zte.CP", - "template_name":"m600_tunnel_cp", - "properties":{ - "direction":{ - "type_name":"string", - "value":"bidirectional" - }, - "vnic_type":{ - "type_name":"string", - "value":"normal" - }, - "bandwidth":{ - "type_name":"integer", - "value":0 - }, - "mac_address":{ - "type_name":"string", - "value":"00-11-00-22-33-00" - }, - "interface_name":{ - "type_name":"string", - "value":"gei-0/4/0/13" - }, - "ip_address":{ - "type_name":"string", - "value":"191.167.100.5" - }, - "order":{ - "type_name":"integer", - "value":0 - }, - "sfc_encapsulation":{ - "type_name":"string", - "value":"mac" - } - }, - "interfaces":[ - { - "name":"Standard", - "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.", - "type_name":"tosca.interfaces.node.lifecycle.Standard", - "operations":[ - { - "name":"create", - "description":"Standard lifecycle create operation." - }, - { - "name":"stop", - "description":"Standard lifecycle stop operation." - }, - { - "name":"start", - "description":"Standard lifecycle start operation." - }, - { - "name":"delete", - "description":"Standard lifecycle delete operation." - }, - { - "name":"configure", - "description":"Standard lifecycle configure operation." - } - ] - } - ], - "capabilities":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - }, - { - "name":"forwarder", - "type_name":"tosca.capabilities.nfv.Forwarder" - } - ], - "relationships":[ - { - "name":"virtualLink", - "source_requirement_index":0, - "target_node_id":"ext_datanet_net_qtqzlx5dsthzs883hxjn6hyhd", - "target_capability_name":"feature" - }, - { - "name":"virtualbinding", - "source_requirement_index":1, - "target_node_id":"m6000_s_7qtzo5nuocyfmebc6kp9raq18", - "target_capability_name":"feature" - }, - { - "name":"forwarder", - "source_requirement_index":2, - "target_node_id":"path2_kgmfqr5ldqs9lj3oscrgxqefc", - "target_capability_name":"feature" - } - ] - }, - { - "id":"ext_mnet_net_au2otee5mcy0dnpqykj487zr3", - "type_name":"tosca.nodes.nfv.ext.VL.Vmware", - "template_name":"ext_mnet_net", - "properties":{ - "name":{ - "type_name":"string", - "value":"vlan_4008_mng_net" - }, - "dhcp_enabled":{ - "type_name":"boolean", - "value":True - }, - "location_info":{ - "type_name":"tosca.datatypes.nfv.ext.LocationInfo", - "value":{ - "tenant":"admin", - "vimid":2, - "availability_zone":"nova" - } - }, - "ip_version":{ - "type_name":"integer", - "value":4 - }, - "mtu":{ - "type_name":"integer", - "value":1500 - }, - "network_name":{ - "type_name":"string", - "value":"vlan_4008_mng_net" - }, - "network_type":{ - "type_name":"string", - "value":"vlan" - } - }, - "interfaces":[ - { - "name":"Standard", - "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.", - "type_name":"tosca.interfaces.node.lifecycle.Standard", - "operations":[ - { - "name":"create", - "description":"Standard lifecycle create operation." - }, - { - "name":"stop", - "description":"Standard lifecycle stop operation." - }, - { - "name":"start", - "description":"Standard lifecycle start operation." - }, - { - "name":"delete", - "description":"Standard lifecycle delete operation." - }, - { - "name":"configure", - "description":"Standard lifecycle configure operation." - } - ] - } - ], - "capabilities":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - }, - { - "name":"virtual_linkable", - "type_name":"tosca.capabilities.nfv.VirtualLinkable" - } - ] - }, - { - "id":"m6000_data_in_eldly5txw4frny3cc349uz3nc", - "type_name":"tosca.nodes.nfv.ext.zte.CP", - "template_name":"m6000_data_in", - "properties":{ - "direction":{ - "type_name":"string", - "value":"bidirectional" - }, - "vnic_type":{ - "type_name":"string", - "value":"normal" - }, - "bandwidth":{ - "type_name":"integer", - "value":0 - }, - "mac_address":{ - "type_name":"string", - "value":"11-22-33-22-11-41" - }, - "interface_name":{ - "type_name":"string", - "value":"gei-0/4/0/7" - }, - "ip_address":{ - "type_name":"string", - "value":"1.1.1.1" - }, - "order":{ - "type_name":"integer", - "value":0 - }, - "sfc_encapsulation":{ - "type_name":"string", - "value":"mac" - }, - "bond":{ - "type_name":"string", - "value":"none" - } - }, - "interfaces":[ - { - "name":"Standard", - "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.", - "type_name":"tosca.interfaces.node.lifecycle.Standard", - "operations":[ - { - "name":"create", - "description":"Standard lifecycle create operation." - }, - { - "name":"stop", - "description":"Standard lifecycle stop operation." - }, - { - "name":"start", - "description":"Standard lifecycle start operation." - }, - { - "name":"delete", - "description":"Standard lifecycle delete operation." - }, - { - "name":"configure", - "description":"Standard lifecycle configure operation." - } - ] - } - ], - "capabilities":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - }, - { - "name":"forwarder", - "type_name":"tosca.capabilities.nfv.Forwarder" - } - ], - "relationships":[ - { - "name":"virtualbinding", - "source_requirement_index":0, - "target_node_id":"m6000_s_7qtzo5nuocyfmebc6kp9raq18", - "target_capability_name":"feature" - }, - { - "name":"virtualLink", - "source_requirement_index":1, - "target_node_id":"path2_kgmfqr5ldqs9lj3oscrgxqefc", - "target_capability_name":"feature" - }, - { - "name":"forwarder", - "source_requirement_index":2, - "target_node_id":"path2_kgmfqr5ldqs9lj3oscrgxqefc", - "target_capability_name":"feature" - } - ] - }, - { - "id":"ext_datanet_net_qtqzlx5dsthzs883hxjn6hyhd", - "type_name":"tosca.nodes.nfv.ext.VL.Vmware", - "template_name":"ext_datanet_net", - "properties":{ - "name":{ - "type_name":"string", - "value":"vlan_4004_tunnel_net" - }, - "dhcp_enabled":{ - "type_name":"boolean", - "value":True - }, - "location_info":{ - "type_name":"tosca.datatypes.nfv.ext.LocationInfo", - "value":{ - "tenant":"admin", - "vimid":2, - "availability_zone":"nova" - } - }, - "ip_version":{ - "type_name":"integer", - "value":4 - }, - "mtu":{ - "type_name":"integer", - "value":1500 - }, - "network_name":{ - "type_name":"string", - "value":"vlan_4004_tunnel_net" - }, - "network_type":{ - "type_name":"string", - "value":"vlan" - } - }, - "interfaces":[ - { - "name":"Standard", - "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.", - "type_name":"tosca.interfaces.node.lifecycle.Standard", - "operations":[ - { - "name":"create", - "description":"Standard lifecycle create operation." - }, - { - "name":"stop", - "description":"Standard lifecycle stop operation." - }, - { - "name":"start", - "description":"Standard lifecycle start operation." - }, - { - "name":"delete", - "description":"Standard lifecycle delete operation." - }, - { - "name":"configure", - "description":"Standard lifecycle configure operation." - } - ] - } - ], - "capabilities":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - }, - { - "name":"virtual_linkable", - "type_name":"tosca.capabilities.nfv.VirtualLinkable" - } - ] - }, - { - "id":"m600_mnt_cp_l3488y2a8ilyfdn0l89ni4os7", - "type_name":"tosca.nodes.nfv.ext.zte.CP", - "template_name":"m600_mnt_cp", - "properties":{ - "direction":{ - "type_name":"string", - "value":"bidirectional" - }, - "vnic_type":{ - "type_name":"string", - "value":"normal" - }, - "bandwidth":{ - "type_name":"integer", - "value":0 - }, - "mac_address":{ - "type_name":"string", - "value":"00-11-00-22-33-11" - }, - "interface_name":{ - "type_name":"string", - "value":"gei-0/4/0/1" - }, - "ip_address":{ - "type_name":"string", - "value":"10.46.244.51" - }, - "order":{ - "type_name":"integer", - "value":0 - }, - "sfc_encapsulation":{ - "type_name":"string", - "value":"mac" - }, - "bond":{ - "type_name":"string", - "value":"none" - } - }, - "interfaces":[ - { - "name":"Standard", - "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.", - "type_name":"tosca.interfaces.node.lifecycle.Standard", - "operations":[ - { - "name":"create", - "description":"Standard lifecycle create operation." - }, - { - "name":"stop", - "description":"Standard lifecycle stop operation." - }, - { - "name":"start", - "description":"Standard lifecycle start operation." - }, - { - "name":"delete", - "description":"Standard lifecycle delete operation." - }, - { - "name":"configure", - "description":"Standard lifecycle configure operation." - } - ] - } - ], - "capabilities":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - }, - { - "name":"forwarder", - "type_name":"tosca.capabilities.nfv.Forwarder" - } - ], - "relationships":[ - { - "name":"virtualLink", - "source_requirement_index":0, - "target_node_id":"ext_mnet_net_au2otee5mcy0dnpqykj487zr3", - "target_capability_name":"feature" - }, - { - "name":"virtualbinding", - "source_requirement_index":1, - "target_node_id":"m6000_s_7qtzo5nuocyfmebc6kp9raq18", - "target_capability_name":"feature" - }, - { - "name":"forwarder", - "source_requirement_index":2, - "target_node_id":"path2_kgmfqr5ldqs9lj3oscrgxqefc", - "target_capability_name":"feature" - } - ] - }, - { - "id":"sfc_data_network_vx3pc1oahn0k0pa5q722yafee", - "type_name":"tosca.nodes.nfv.ext.zte.VL", - "template_name":"sfc_data_network", - "properties":{ - "name":{ - "type_name":"string", - "value":"sfc_data_network" - }, - "dhcp_enabled":{ - "type_name":"boolean", - "value":True - }, - "is_predefined":{ - "type_name":"boolean", - "value":False - }, - "location_info":{ - "type_name":"tosca.datatypes.nfv.ext.LocationInfo", - "value":{ - "tenant":"admin", - "vimid":2, - "availability_zone":"nova" - } - }, - "ip_version":{ - "type_name":"integer", - "value":4 - }, - "mtu":{ - "type_name":"integer", - "value":1500 - }, - "network_name":{ - "type_name":"string", - "value":"sfc_data_network" - }, - "network_type":{ - "type_name":"string", - "value":"vlan" - } - }, - "interfaces":[ - { - "name":"Standard", - "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.", - "type_name":"tosca.interfaces.node.lifecycle.Standard", - "operations":[ - { - "name":"create", - "description":"Standard lifecycle create operation." - }, - { - "name":"stop", - "description":"Standard lifecycle stop operation." - }, - { - "name":"start", - "description":"Standard lifecycle start operation." - }, - { - "name":"delete", - "description":"Standard lifecycle delete operation." - }, - { - "name":"configure", - "description":"Standard lifecycle configure operation." - } - ] - } - ], - "capabilities":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - }, - { - "name":"virtual_linkable", - "type_name":"tosca.capabilities.nfv.VirtualLinkable" - } - ] - }, - { - "id":"m6000_s_7qtzo5nuocyfmebc6kp9raq18", - "type_name":"tosca.nodes.nfv.ext.PNF", - "template_name":"m6000_s", - "properties":{ - "vendor":{ - "type_name":"string", - "value":"zte" - }, - "request_reclassification":{ - "type_name":"boolean", - "value":False - }, - "pnf_type":{ - "type_name":"string", - "value":"m6000s" - }, - "version":{ - "type_name":"string", - "value":"1.0" - }, - "management_address":{ - "type_name":"string", - "value":"111111" - }, - "id":{ - "type_name":"string", - "value":"m6000_s" - }, - "nsh_aware":{ - "type_name":"boolean", - "value":False - } - }, - "interfaces":[ - { - "name":"Standard", - "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.", - "type_name":"tosca.interfaces.node.lifecycle.Standard", - "operations":[ - { - "name":"create", - "description":"Standard lifecycle create operation." - }, - { - "name":"stop", - "description":"Standard lifecycle stop operation." - }, - { - "name":"start", - "description":"Standard lifecycle start operation." - }, - { - "name":"delete", - "description":"Standard lifecycle delete operation." - }, - { - "name":"configure", - "description":"Standard lifecycle configure operation." - } - ] - } - ], - "capabilities":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - }, - { - "name":"virtualBinding", - "type_name":"tosca.capabilities.nfv.VirtualBindable" - }, - { - "name":"forwarder", - "type_name":"tosca.capabilities.nfv.Forwarder" - } - ], - "relationships":[ - { - "name":"forwarder", - "source_requirement_index":0, - "target_node_id":"path2_kgmfqr5ldqs9lj3oscrgxqefc", - "target_capability_name":"feature" - } - ] - }, - { - "id":"VNAT_cfdljtspvkp234irka59wgab0", - "type_name":"tosca.nodes.nfv.ext.zte.VNF.VNAT", - "template_name":"VNAT", - "properties":{ - "is_shared":{ - "type_name":"boolean", - "value":False - }, - "plugin_info":{ - "type_name":"string", - "value":"vbrasplugin_1.0" - }, - "vendor":{ - "type_name":"string", - "value":"zte" - }, - "request_reclassification":{ - "type_name":"boolean", - "value":False - }, - "name":{ - "type_name":"string", - "value":"VNAT" - }, - "vnf_extend_type":{ - "type_name":"string", - "value":"driver" - }, - "externalPluginManageNetworkName":{ - "type_name":"string", - "value":"vlan_4007_plugin_net" - }, - "version":{ - "type_name":"string", - "value":"1.0" - }, - "cross_dc":{ - "type_name":"boolean", - "value":False - }, - "vnf_type":{ - "type_name":"string", - "value":"VNAT" - }, - "vnfd_version":{ - "type_name":"string", - "value":"1.0.0" - }, - "id":{ - "type_name":"string", - "value":"vcpe_vnat_zte_1" - }, - "nsh_aware":{ - "type_name":"boolean", - "value":True - }, - "adjust_vnf_capacity":{ - "type_name":"boolean", - "value":True - }, - "vmnumber_overquota_alarm":{ - "type_name":"boolean", - "value":True - }, - "csarProvider":{ - "type_name":"string", - "value":"ZTE" - }, - "NatIpRange":{ - "type_name":"string", - "value":"192.167.0.10-192.168.0.20" - }, - "csarVersion":{ - "type_name":"string", - "value":"v1.0" - }, - "csarType":{ - "type_name":"string", - "value":"NFAR" - } - }, - "interfaces":[ - { - "name":"Standard", - "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.", - "type_name":"tosca.interfaces.node.lifecycle.Standard", - "operations":[ - { - "name":"create", - "description":"Standard lifecycle create operation." - }, - { - "name":"stop", - "description":"Standard lifecycle stop operation." - }, - { - "name":"start", - "description":"Standard lifecycle start operation." - }, - { - "name":"delete", - "description":"Standard lifecycle delete operation." - }, - { - "name":"configure", - "description":"Standard lifecycle configure operation." - } - ] - } - ], - "capabilities":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - }, - { - "name":"forwarder", - "type_name":"tosca.capabilities.nfv.Forwarder" - }, - { - "name":"vnat_fw_inout", - "type_name":"tosca.capabilities.nfv.Forwarder" - } - ], - "relationships":[ - { - "name":"vnat_ctrl_by_manager_cp", - "source_requirement_index":0, - "target_node_id":"ext_mnet_net_au2otee5mcy0dnpqykj487zr3", - "target_capability_name":"feature" - }, - { - "name":"vnat_data_cp", - "source_requirement_index":1, - "target_node_id":"sfc_data_network_vx3pc1oahn0k0pa5q722yafee", - "target_capability_name":"feature" - }, - { - "name":"virtualLink", - "source_requirement_index":2, - "target_node_id":"path2_kgmfqr5ldqs9lj3oscrgxqefc", - "target_capability_name":"feature" - }, - { - "name":"forwarder", - "source_requirement_index":3, - "target_node_id":"path2_kgmfqr5ldqs9lj3oscrgxqefc", - "target_capability_name":"feature" - } - ] - } - ], - "groups":[ - { - "id":"vnffg1_wk1aqhk6exoh5fmds2unu0uyc", - "type_name":"tosca.groups.nfv.VNFFG", - "template_name":"vnffg1", - "properties":{ - "vendor":{ - "type_name":"string", - "value":"zte" - }, - "connection_point":{ - "type_name":"list", - "value":[ - "m6000_data_in", - "m600_tunnel_cp", - "m6000_data_out" - ] - }, - "version":{ - "type_name":"string", - "value":"1.0" - }, - "constituent_vnfs":{ - "type_name":"list", - "value":[ - "VFW", - "VNAT" - ] - }, - "number_of_endpoints":{ - "type_name":"integer", - "value":3 - }, - "dependent_virtual_link":{ - "type_name":"list", - "value":[ - "sfc_data_network", - "ext_datanet_net", - "ext_mnet_net" - ] - } - }, - "interfaces":[ - { - "name":"standard", - "description":"This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.", - "type_name":"tosca.interfaces.node.lifecycle.Standard", - "operations":[ - { - "name":"create", - "description":"Standard lifecycle create operation." - }, - { - "name":"stop", - "description":"Standard lifecycle stop operation." - }, - { - "name":"start", - "description":"Standard lifecycle start operation." - }, - { - "name":"delete", - "description":"Standard lifecycle delete operation." - }, - { - "name":"configure", - "description":"Standard lifecycle configure operation." - } - ] - } - ], - "member_node_ids":[ - "path1_bv53fblv26hawr8dj4fxe2rsd", - "path2_kgmfqr5ldqs9lj3oscrgxqefc" - ] - } - ], - "substitution":{ - "node_type_name":"tosca.nodes.nfv.NS.VCPE_NS" - }, - "inputs":{ - "externalDataNetworkName":{ - "type_name":"string", - "value":"vlan_4004_tunnel_net" - }, - "sfc_data_network":{ - "type_name":"string", - "value":"sfc_data_network" - }, - "NatIpRange":{ - "type_name":"string", - "value":"192.167.0.10-192.168.0.20" - }, - "externalManageNetworkName":{ - "type_name":"string", - "value":"vlan_4008_mng_net" - }, - "externalPluginManageNetworkName":{ - "type_name":"string", - "value":"vlan_4007_plugin_net" - } - } - }, - "model":{ - "metadata":{ - "vendor":"ZTE", - "name":"VCPE_NS", - "csarVersion":"v1.0", - "csarType":"NSAR", - "csarProvider":"ZTE", - "version":1, - "invariant_id":"vcpe_ns_sff_1", - "id":"VCPE_NS", - "description":"vcpe_ns" - }, - "node_templates":[ - { - "name":"path2", - "type_name":"tosca.nodes.nfv.ext.FP", - "default_instances":1, - "min_instances":0, - "properties":{ - "symmetric":{ - "type_name":"boolean", - "value":False - }, - "policy":{ - "type_name":"tosca.datatypes.nfv.ext.FPPolicy", - "value":{ - "type":"ACL", - "criteria":{ - "dest_port_range":"1-100", - "ip_protocol":"tcp", - "source_ip_range":[ - "119.1.1.1-119.1.1.10" - ], - "dest_ip_range":[ - {"get_input":"NatIpRange"} - ], - "dscp":0, - "source_port_range":"1-100" - } - } - } - }, - "interface_templates":[ - "<aria.modeling.model_elements.InterfaceTemplate object at 0x7f8ed0288a10>" - ], - "capability_templates":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - } - ], - "requirement_templates":[ - { - "name":"forwarder", - "target_node_template_name":"m6000_data_out" - }, - { - "name":"forwarder", - "target_node_template_name":"m600_tunnel_cp" - }, - { - "name":"forwarder", - "target_node_template_name":"VNAT", - "target_capability_name":"vnat_fw_inout" - } - ] - }, - { - "name":"path1", - "type_name":"tosca.nodes.nfv.ext.FP", - "default_instances":1, - "min_instances":0, - "properties":{ - "symmetric":{ - "type_name":"boolean", - "value":True - }, - "policy":{ - "type_name":"tosca.datatypes.nfv.ext.FPPolicy", - "value":{ - "type":"ACL", - "criteria":{ - "dest_port_range":"1-100", - "ip_protocol":"tcp", - "source_ip_range":[ - "1-100" - ], - "dest_ip_range":[ - "1-100" - ], - "dscp":4, - "source_port_range":"1-100" - } - } - } - }, - "interface_templates":[ - "<aria.modeling.model_elements.InterfaceTemplate object at 0x7f8ec81df090>" - ], - "capability_templates":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - } - ], - "requirement_templates":[ - { - "name":"forwarder", - "target_node_template_name":"m6000_data_in" - }, - { - "name":"forwarder", - "target_node_template_name":"m600_tunnel_cp" - }, - { - "name":"forwarder", - "target_node_template_name":"VFW", - "target_capability_name":"vfw_fw_inout" - }, - { - "name":"forwarder", - "target_node_template_name":"VNAT", - "target_capability_name":"vnat_fw_inout" - }, - { - "name":"forwarder", - "target_node_template_name":"m600_tunnel_cp" - }, - { - "name":"forwarder", - "target_node_template_name":"m6000_data_out" - } - ] - }, - { - "name":"m6000_data_out", - "type_name":"tosca.nodes.nfv.ext.zte.CP", - "default_instances":1, - "min_instances":0, - "properties":{ - "direction":{ - "type_name":"string", - "value":"bidirectional" - }, - "vnic_type":{ - "type_name":"string", - "value":"normal" - }, - "bandwidth":{ - "type_name":"integer", - "value":0 - }, - "mac_address":{ - "type_name":"string", - "value":"11-22-33-22-11-44" - }, - "interface_name":{ - "type_name":"string", - "value":"xgei-0/4/1/5" - }, - "ip_address":{ - "type_name":"string", - "value":"176.1.1.2" - }, - "order":{ - "type_name":"integer", - "value":0 - }, - "sfc_encapsulation":{ - "type_name":"string", - "value":"mac" - } - }, - "interface_templates":[ - "<aria.modeling.model_elements.InterfaceTemplate object at 0x7f8ec82c6610>" - ], - "capability_templates":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - }, - { - "name":"forwarder", - "type_name":"tosca.capabilities.nfv.Forwarder" - } - ], - "requirement_templates":[ - { - "name":"virtualbinding", - "target_node_template_name":"m6000_s", - "target_capability_name":"virtualBinding" - }, - { - "name":"virtualLink", - "target_node_type_name":"tosca.nodes.Root" - }, - { - "name":"forwarder", - "target_node_type_name":"tosca.nodes.Root" - } - ] - }, - { - "name":"VFW", - "type_name":"tosca.nodes.nfv.ext.zte.VNF.VFW", - "default_instances":1, - "min_instances":0, - "properties":{ - "is_shared":{ - "type_name":"boolean", - "value":False - }, - "plugin_info":{ - "type_name":"string", - "value":"vbrasplugin_1.0" - }, - "vendor":{ - "type_name":"string", - "value":"zte" - }, - "request_reclassification":{ - "type_name":"boolean", - "value":False - }, - "vnf_extend_type":{ - "type_name":"string", - "value":"driver" - }, - "name":{ - "type_name":"string", - "value":"VFW" - }, - "version":{ - "type_name":"string", - "value":"1.0" - }, - "cross_dc":{ - "type_name":"boolean", - "value":False - }, - "vnf_type":{ - "type_name":"string", - "value":"VFW" - }, - "vnfd_version":{ - "type_name":"string", - "value":"1.0.0" - }, - "id":{ - "type_name":"string", - "value":"vcpe_vfw_zte_1_0" - }, - "nsh_aware":{ - "type_name":"boolean", - "value":True - }, - "adjust_vnf_capacity":{ - "type_name":"boolean", - "value":True - }, - "vmnumber_overquota_alarm":{ - "type_name":"boolean", - "value":True - }, - "csarProvider":{ - "type_name":"string", - "value":"ZTE" - }, - "csarVersion":{ - "type_name":"string", - "value":"v1.0" - }, - "externalPluginManageNetworkName":{ - "type_name":"string", - "value":"vlan_4007_plugin_net" - }, - "csarType":{ - "type_name":"string", - "value":"NFAR" - } - }, - "interface_templates":[ - "<aria.modeling.model_elements.InterfaceTemplate object at 0x7f8ec8281950>" - ], - "capability_templates":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - }, - { - "name":"forwarder", - "type_name":"tosca.capabilities.nfv.Forwarder" - }, - { - "name":"vfw_fw_inout", - "type_name":"tosca.capabilities.nfv.Forwarder" - } - ], - "requirement_templates":[ - { - "name":"vfw_ctrl_by_manager_cp", - "target_node_template_name":"ext_mnet_net", - "target_capability_name":"virtual_linkable" - }, - { - "name":"vfw_data_cp", - "target_node_template_name":"sfc_data_network", - "target_capability_name":"virtual_linkable" - }, - { - "name":"virtualLink", - "target_node_type_name":"tosca.nodes.Root" - }, - { - "name":"forwarder", - "target_node_type_name":"tosca.nodes.Root" - } - ] - }, - { - "name":"m600_tunnel_cp", - "type_name":"tosca.nodes.nfv.ext.zte.CP", - "default_instances":1, - "min_instances":0, - "properties":{ - "direction":{ - "type_name":"string", - "value":"bidirectional" - }, - "vnic_type":{ - "type_name":"string", - "value":"normal" - }, - "bandwidth":{ - "type_name":"integer", - "value":0 - }, - "mac_address":{ - "type_name":"string", - "value":"00-11-00-22-33-00" - }, - "interface_name":{ - "type_name":"string", - "value":"gei-0/4/0/13" - }, - "ip_address":{ - "type_name":"string", - "value":"191.167.100.5" - }, - "order":{ - "type_name":"integer", - "value":0 - }, - "sfc_encapsulation":{ - "type_name":"string", - "value":"mac" - } - }, - "interface_templates":[ - "<aria.modeling.model_elements.InterfaceTemplate object at 0x1ae39d0>" - ], - "capability_templates":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - }, - { - "name":"forwarder", - "type_name":"tosca.capabilities.nfv.Forwarder" - } - ], - "requirement_templates":[ - { - "name":"virtualLink", - "target_node_template_name":"ext_datanet_net", - "target_capability_name":"virtual_linkable" - }, - { - "name":"virtualbinding", - "target_node_template_name":"m6000_s", - "target_capability_name":"virtualBinding" - }, - { - "name":"forwarder", - "target_node_type_name":"tosca.nodes.Root" - } - ] - }, - { - "name":"ext_mnet_net", - "type_name":"tosca.nodes.nfv.ext.VL.Vmware", - "default_instances":1, - "min_instances":0, - "properties":{ - "name":{ - "type_name":"string", - "value":"vlan_4008_mng_net" - }, - "dhcp_enabled":{ - "type_name":"boolean", - "value":True - }, - "location_info":{ - "type_name":"tosca.datatypes.nfv.ext.LocationInfo", - "value":{ - "tenant":"admin", - "vimid":2, - "availability_zone":"nova" - } - }, - "ip_version":{ - "type_name":"integer", - "value":4 - }, - "mtu":{ - "type_name":"integer", - "value":1500 - }, - "network_name":{ - "type_name":"string", - "value":"vlan_4008_mng_net" - }, - "network_type":{ - "type_name":"string", - "value":"vlan" - } - }, - "interface_templates":[ - "<aria.modeling.model_elements.InterfaceTemplate object at 0x7f8ed00f89d0>" - ], - "capability_templates":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - }, - { - "name":"virtual_linkable", - "type_name":"tosca.capabilities.nfv.VirtualLinkable" - } - ] - }, - { - "name":"m6000_data_in", - "type_name":"tosca.nodes.nfv.ext.zte.CP", - "default_instances":1, - "min_instances":0, - "properties":{ - "direction":{ - "type_name":"string", - "value":"bidirectional" - }, - "vnic_type":{ - "type_name":"string", - "value":"normal" - }, - "bandwidth":{ - "type_name":"integer", - "value":0 - }, - "mac_address":{ - "type_name":"string", - "value":"11-22-33-22-11-41" - }, - "interface_name":{ - "type_name":"string", - "value":"gei-0/4/0/7" - }, - "ip_address":{ - "type_name":"string", - "value":"1.1.1.1" - }, - "order":{ - "type_name":"integer", - "value":0 - }, - "sfc_encapsulation":{ - "type_name":"string", - "value":"mac" - }, - "bond":{ - "type_name":"string", - "value":"none" - } - }, - "interface_templates":[ - "<aria.modeling.model_elements.InterfaceTemplate object at 0x1745710>" - ], - "capability_templates":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - }, - { - "name":"forwarder", - "type_name":"tosca.capabilities.nfv.Forwarder" - } - ], - "requirement_templates":[ - { - "name":"virtualbinding", - "target_node_template_name":"m6000_s", - "target_capability_name":"virtualBinding" - }, - { - "name":"virtualLink", - "target_node_type_name":"tosca.nodes.Root" - }, - { - "name":"forwarder", - "target_node_type_name":"tosca.nodes.Root" - } - ] - }, - { - "name":"ext_datanet_net", - "type_name":"tosca.nodes.nfv.ext.VL.Vmware", - "default_instances":1, - "min_instances":0, - "properties":{ - "name":{ - "type_name":"string", - "value":"vlan_4004_tunnel_net" - }, - "dhcp_enabled":{ - "type_name":"boolean", - "value":True - }, - "location_info":{ - "type_name":"tosca.datatypes.nfv.ext.LocationInfo", - "value":{ - "tenant":"admin", - "vimid":2, - "availability_zone":"nova" - } - }, - "ip_version":{ - "type_name":"integer", - "value":4 - }, - "mtu":{ - "type_name":"integer", - "value":1500 - }, - "network_name":{ - "type_name":"string", - "value":"vlan_4004_tunnel_net" - }, - "network_type":{ - "type_name":"string", - "value":"vlan" - } - }, - "interface_templates":[ - "<aria.modeling.model_elements.InterfaceTemplate object at 0x7f8eac063990>" - ], - "capability_templates":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - }, - { - "name":"virtual_linkable", - "type_name":"tosca.capabilities.nfv.VirtualLinkable" - } - ] - }, - { - "name":"m600_mnt_cp", - "type_name":"tosca.nodes.nfv.ext.zte.CP", - "default_instances":1, - "min_instances":0, - "properties":{ - "direction":{ - "type_name":"string", - "value":"bidirectional" - }, - "vnic_type":{ - "type_name":"string", - "value":"normal" - }, - "bandwidth":{ - "type_name":"integer", - "value":0 - }, - "mac_address":{ - "type_name":"string", - "value":"00-11-00-22-33-11" - }, - "interface_name":{ - "type_name":"string", - "value":"gei-0/4/0/1" - }, - "ip_address":{ - "type_name":"string", - "value":"10.46.244.51" - }, - "order":{ - "type_name":"integer", - "value":0 - }, - "sfc_encapsulation":{ - "type_name":"string", - "value":"mac" - }, - "bond":{ - "type_name":"string", - "value":"none" - } - }, - "interface_templates":[ - "<aria.modeling.model_elements.InterfaceTemplate object at 0x7f8ec81264d0>" - ], - "capability_templates":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - }, - { - "name":"forwarder", - "type_name":"tosca.capabilities.nfv.Forwarder" - } - ], - "requirement_templates":[ - { - "name":"virtualLink", - "target_node_template_name":"ext_mnet_net", - "target_capability_name":"virtual_linkable" - }, - { - "name":"virtualbinding", - "target_node_template_name":"m6000_s", - "target_capability_name":"virtualBinding" - }, - { - "name":"forwarder", - "target_node_type_name":"tosca.nodes.Root" - } - ] - }, - { - "name":"sfc_data_network", - "type_name":"tosca.nodes.nfv.ext.zte.VL", - "default_instances":1, - "min_instances":0, - "properties":{ - "name":{ - "type_name":"string", - "value":"sfc_data_network" - }, - "dhcp_enabled":{ - "type_name":"boolean", - "value":True - }, - "is_predefined":{ - "type_name":"boolean", - "value":False - }, - "location_info":{ - "type_name":"tosca.datatypes.nfv.ext.LocationInfo", - "value":{ - "tenant":"admin", - "vimid":2, - "availability_zone":"nova" - } - }, - "ip_version":{ - "type_name":"integer", - "value":4 - }, - "mtu":{ - "type_name":"integer", - "value":1500 - }, - "network_name":{ - "type_name":"string", - "value":"sfc_data_network" - }, - "network_type":{ - "type_name":"string", - "value":"vlan" - } - }, - "interface_templates":[ - "<aria.modeling.model_elements.InterfaceTemplate object at 0x7f8ec813c6d0>" - ], - "capability_templates":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - }, - { - "name":"virtual_linkable", - "type_name":"tosca.capabilities.nfv.VirtualLinkable" - } - ] - }, - { - "name":"m6000_s", - "type_name":"tosca.nodes.nfv.ext.PNF", - "default_instances":1, - "min_instances":0, - "properties":{ - "vendor":{ - "type_name":"string", - "value":"zte" - }, - "request_reclassification":{ - "type_name":"boolean", - "value":False - }, - "pnf_type":{ - "type_name":"string", - "value":"m6000s" - }, - "version":{ - "type_name":"string", - "value":"1.0" - }, - "management_address":{ - "type_name":"string", - "value":"111111" - }, - "id":{ - "type_name":"string", - "value":"m6000_s" - }, - "nsh_aware":{ - "type_name":"boolean", - "value":False - } - }, - "interface_templates":[ - "<aria.modeling.model_elements.InterfaceTemplate object at 0x7f8ec8132490>" - ], - "capability_templates":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - }, - { - "name":"virtualBinding", - "type_name":"tosca.capabilities.nfv.VirtualBindable" - }, - { - "name":"forwarder", - "type_name":"tosca.capabilities.nfv.Forwarder" - } - ], - "requirement_templates":[ - { - "name":"forwarder", - "target_node_type_name":"tosca.nodes.Root" - } - ] - }, - { - "name":"VNAT", - "type_name":"tosca.nodes.nfv.ext.zte.VNF.VNAT", - "default_instances":1, - "min_instances":0, - "properties":{ - "is_shared":{ - "type_name":"boolean", - "value":False - }, - "plugin_info":{ - "type_name":"string", - "value":"vbrasplugin_1.0" - }, - "vendor":{ - "type_name":"string", - "value":"zte" - }, - "request_reclassification":{ - "type_name":"boolean", - "value":False - }, - "name":{ - "type_name":"string", - "value":"VNAT" - }, - "vnf_extend_type":{ - "type_name":"string", - "value":"driver" - }, - "externalPluginManageNetworkName":{ - "type_name":"string", - "value":"vlan_4007_plugin_net" - }, - "version":{ - "type_name":"string", - "value":"1.0" - }, - "cross_dc":{ - "type_name":"boolean", - "value":False - }, - "vnf_type":{ - "type_name":"string", - "value":"VNAT" - }, - "vnfd_version":{ - "type_name":"string", - "value":"1.0.0" - }, - "id":{ - "type_name":"string", - "value":"vcpe_vnat_zte_1" - }, - "nsh_aware":{ - "type_name":"boolean", - "value":True - }, - "adjust_vnf_capacity":{ - "type_name":"boolean", - "value":True - }, - "vmnumber_overquota_alarm":{ - "type_name":"boolean", - "value":True - }, - "csarProvider":{ - "type_name":"string", - "value":"ZTE" - }, - "NatIpRange":{ - "type_name":"string", - "value":"192.167.0.10-192.168.0.20" - }, - "csarVersion":{ - "type_name":"string", - "value":"v1.0" - }, - "csarType":{ - "type_name":"string", - "value":"NFAR" - } - }, - "interface_templates":[ - "<aria.modeling.model_elements.InterfaceTemplate object at 0x1bba810>" - ], - "capability_templates":[ - { - "name":"feature", - "type_name":"tosca.capabilities.Node" - }, - { - "name":"forwarder", - "type_name":"tosca.capabilities.nfv.Forwarder" - }, - { - "name":"vnat_fw_inout", - "type_name":"tosca.capabilities.nfv.Forwarder" - } - ], - "requirement_templates":[ - { - "name":"vnat_ctrl_by_manager_cp", - "target_node_template_name":"ext_mnet_net", - "target_capability_name":"virtual_linkable" - }, - { - "name":"vnat_data_cp", - "target_node_template_name":"sfc_data_network", - "target_capability_name":"virtual_linkable" - }, - { - "name":"virtualLink", - "target_node_type_name":"tosca.nodes.Root" - }, - { - "name":"forwarder", - "target_node_type_name":"tosca.nodes.Root" - } - ] - } - ], - "group_templates":[ - { - "name":"vnffg1", - "type_name":"tosca.groups.nfv.VNFFG", - "properties":{ - "vendor":{ - "type_name":"string", - "value":"zte" - }, - "connection_point":{ - "type_name":"list", - "value":[ - "m6000_data_in", - "m600_tunnel_cp", - "m6000_data_out" - ] - }, - "version":{ - "type_name":"string", - "value":"1.0" - }, - "constituent_vnfs":{ - "type_name":"list", - "value":[ - "VFW", - "VNAT" - ] - }, - "number_of_endpoints":{ - "type_name":"integer", - "value":3 - }, - "dependent_virtual_link":{ - "type_name":"list", - "value":[ - "sfc_data_network", - "ext_datanet_net", - "ext_mnet_net" - ] - } - }, - "interface_templates":[ - "<aria.modeling.model_elements.InterfaceTemplate object at 0x7f8ec811cd10>" - ], - "member_node_template_names":[ - "path1", - "path2" - ] - } - ], - "substitution_template":{ - "node_type_name":"tosca.nodes.nfv.NS.VCPE_NS" - }, - "inputs":{ - "externalDataNetworkName":{ - "type_name":"string", - "value":"vlan_4004_tunnel_net" - }, - "sfc_data_network":{ - "type_name":"string", - "value":"sfc_data_network" - }, - "NatIpRange":{ - "type_name":"string", - "value":"192.167.0.10-192.168.0.20" - }, - "externalManageNetworkName":{ - "type_name":"string", - "value":"vlan_4008_mng_net" - }, - "externalPluginManageNetworkName":{ - "type_name":"string", - "value":"vlan_4007_plugin_net" - } - } - } - } - ) - print convert_nsd_model(src_json) - - - - diff --git a/vio/vio/pub/utils/values.py b/vio/vio/pub/utils/values.py index ea705dd..6ede901 100644 --- a/vio/vio/pub/utils/values.py +++ b/vio/vio/pub/utils/values.py @@ -20,4 +20,3 @@ def ignore_case_get(args, key, def_val=""): if old_key.upper() == key.upper(): return args[old_key] return def_val - diff --git a/vio/vio/pub/vim/const.py b/vio/vio/pub/vim/const.py index 47353e7..dd67298 100644 --- a/vio/vio/pub/vim/const.py +++ b/vio/vio/pub/vim/const.py @@ -21,4 +21,3 @@ DEFAULT_MTU = 1500 IPV4 = 4 IPV6 = 6 ENABLE_DHCP = 1 - diff --git a/vio/vio/pub/vim/drivers/base.py b/vio/vio/pub/vim/drivers/base.py index 22402c9..37df030 100644 --- a/vio/vio/pub/vim/drivers/base.py +++ b/vio/vio/pub/vim/drivers/base.py @@ -13,7 +13,6 @@ import copy - class DriverBase(object): '''Base class for all drivers.''' diff --git a/vio/vio/pub/vim/drivers/vimsdk/cinder_v2.py b/vio/vio/pub/vim/drivers/vimsdk/cinder_v2.py index 3776aca..6739ff2 100644 --- a/vio/vio/pub/vim/drivers/vimsdk/cinder_v2.py +++ b/vio/vio/pub/vim/drivers/vimsdk/cinder_v2.py @@ -17,6 +17,7 @@ from vio.pub.vim.drivers.vimsdk import sdk LOG = logging.getLogger(__name__) + class CinderClient(base.DriverBase): '''Cinder V2 driver.''' @@ -30,18 +31,15 @@ class CinderClient(base.DriverBase): volumes = self.conn.block_store.volumes(**query) return volumes - @sdk.translate_exception def create_volume(self, **body): volume_info = self.conn.block_store.create_volume(**body) return volume_info - @sdk.translate_exception def delete_volume(self, volumeid): self.conn.block_store.delete_volume(volumeid) - @sdk.translate_exception def get_volume(self, volumeid): volume_info = self.conn.block_store.get_volume(volumeid) diff --git a/vio/vio/pub/vim/drivers/vimsdk/image_v2.py b/vio/vio/pub/vim/drivers/vimsdk/image_v2.py index 8553adf..6d040c6 100644 --- a/vio/vio/pub/vim/drivers/vimsdk/image_v2.py +++ b/vio/vio/pub/vim/drivers/vimsdk/image_v2.py @@ -39,7 +39,6 @@ class GlanceClient(base.DriverBase): image = self._proxy.get_image(imageid) return image - @sdk.translate_exception def find_image(self, name_or_id): image = self._proxy.find_image(name_or_id, ignore_missing=False) @@ -56,7 +55,8 @@ class GlanceClient(base.DriverBase): container_format = data.pop('container_format') if not all([container_format, disk_format]): - raise Exception("Both container_format and disk_format are required") + raise Exception( + "Both container_format and disk_format are required") img = self._proxy._create(_image.Image, disk_format=disk_format, container_format=container_format, **data) @@ -65,4 +65,4 @@ class GlanceClient(base.DriverBase): @sdk.translate_exception def upload_image(self, data, image): image.data = data - image.upload(self.session)
\ No newline at end of file + image.upload(self.session) diff --git a/vio/vio/pub/vim/drivers/vimsdk/neutron_v2_0.py b/vio/vio/pub/vim/drivers/vimsdk/neutron_v2_0.py index 1446698..0abc795 100644 --- a/vio/vio/pub/vim/drivers/vimsdk/neutron_v2_0.py +++ b/vio/vio/pub/vim/drivers/vimsdk/neutron_v2_0.py @@ -25,7 +25,7 @@ class NeutronClient(base.DriverBase): def subnet_create(self, **args): network = self.conn.network.create_subnet(**args) return network - + @sdk.translate_exception def network_create(self, **args): network = self.conn.network.create_network(**args) @@ -81,5 +81,3 @@ class NeutronClient(base.DriverBase): def ports_get(self, **kwargs): ports = self.conn.network.ports(**kwargs) return ports - - diff --git a/vio/vio/pub/vim/drivers/vimsdk/sdk.py b/vio/vio/pub/vim/drivers/vimsdk/sdk.py index 25ba3bb..c8ef333 100644 --- a/vio/vio/pub/vim/drivers/vimsdk/sdk.py +++ b/vio/vio/pub/vim/drivers/vimsdk/sdk.py @@ -110,7 +110,8 @@ def create_connection(params=None): prof.set_version('image', 'v2') try: - conn = connection.Connection(profile=prof, verify=False, user_agent=USER_AGENT, + conn = connection.Connection(profile=prof, verify=False, + user_agent=USER_AGENT, auth_plugin=auth_plugin, **params) except Exception as ex: raise parse_exception(ex) @@ -129,4 +130,3 @@ def authenticate(**kwargs): } return access_info - diff --git a/vio/vio/pub/vim/vimapi/cinder/OperateVolume.py b/vio/vio/pub/vim/vimapi/cinder/OperateVolume.py index 33224c3..363e416 100644 --- a/vio/vio/pub/vim/vimapi/cinder/OperateVolume.py +++ b/vio/vio/pub/vim/vimapi/cinder/OperateVolume.py @@ -14,7 +14,7 @@ import logging -from vio.pub.msapi import extsys +# from vio.pub.msapi import extsys from vio.pub.vim.vimapi.baseclient import baseclient from vio.swagger import volume_utils @@ -45,4 +45,4 @@ class OperateVolume(baseclient): def delete_vim_volume(self, volume_id): volume = self.cinder(self.param).delete_volume(volume_id) - return volume
\ No newline at end of file + return volume diff --git a/vio/vio/pub/vim/vimapi/glance/OperateImage.py b/vio/vio/pub/vim/vimapi/glance/OperateImage.py index ce9ae75..0de3160 100644 --- a/vio/vio/pub/vim/vimapi/glance/OperateImage.py +++ b/vio/vio/pub/vim/vimapi/glance/OperateImage.py @@ -26,6 +26,7 @@ logger = logging.getLogger(__name__) running_threads = {} running_thread_lock = threading.Lock() + class imageThread(threading.Thread): def __init__(self, vimid, tenantid, image, imagefd): @@ -36,16 +37,15 @@ class imageThread(threading.Thread): self.tenantid = tenantid self.image = image - def run(self): logger.debug("start imagethread") - self.transfer_image(self.vimid, self.tenantid, self.image, self.imagefd) + self.transfer_image(self.vimid, self.tenantid, + self.image, self.imagefd) running_thread_lock.acquire() running_threads.pop(self.imageid) running_thread_lock.release() - def transfer_image(self, vimid, tenantid, image, imagefd): logger.debug("Image----transfer_image") @@ -99,6 +99,6 @@ class OperateImage(baseclient): running_thread_lock.release() try: upload_image_thread.start() - except Exception as ex: + except Exception: pass - return image
\ No newline at end of file + return image diff --git a/vio/vio/pub/vim/vimapi/keystone/OperateTenant.py b/vio/vio/pub/vim/vimapi/keystone/OperateTenant.py index 382bbca..12ffdc7 100644 --- a/vio/vio/pub/vim/vimapi/keystone/OperateTenant.py +++ b/vio/vio/pub/vim/vimapi/keystone/OperateTenant.py @@ -14,13 +14,12 @@ import logging -from vio.pub.msapi import extsys +# from vio.pub.msapi import extsys from vio.pub.vim.vimapi.baseclient import baseclient logger = logging.getLogger(__name__) - class OperateTenant(baseclient): def get_projects(self, data, **query): @@ -44,4 +43,3 @@ class OperateTenant(baseclient): continue projs.append(p) return projs - diff --git a/vio/vio/pub/vim/vimapi/keystone/auth.py b/vio/vio/pub/vim/vimapi/keystone/auth.py index 6bf5848..86741de 100644 --- a/vio/vio/pub/vim/vimapi/keystone/auth.py +++ b/vio/vio/pub/vim/vimapi/keystone/auth.py @@ -14,12 +14,12 @@ import logging -from vio.pub.msapi import extsys -from vio.pub.vim.drivers import base +# from vio.pub.msapi import extsys +# from vio.pub.vim.drivers import base logger = logging.getLogger(__name__) + def login(data): print data - diff --git a/vio/vio/pub/vim/vimapi/network/OperateNetwork.py b/vio/vio/pub/vim/vimapi/network/OperateNetwork.py index 03083cf..8adffcc 100644 --- a/vio/vio/pub/vim/vimapi/network/OperateNetwork.py +++ b/vio/vio/pub/vim/vimapi/network/OperateNetwork.py @@ -39,9 +39,10 @@ class BaseNet(object): def get_vim_info(self, vimid): try: vim_info = get_vim_by_id(vimid) - except VimDriverVioException as e: - raise VimDriverVioException("Failed to query VIM with id (%s) from extsys." % vimid, - status.HTTP_404_NOT_FOUND) + except VimDriverVioException: + raise VimDriverVioException( + "Failed to query VIM with id (%s) from extsys." % vimid, + status.HTTP_404_NOT_FOUND) return vim_info def auth(self, vim_info, tenant_id): diff --git a/vio/vio/pub/vim/vimapi/network/OperatePort.py b/vio/vio/pub/vim/vimapi/network/OperatePort.py index f15ad73..0ca92e0 100644 --- a/vio/vio/pub/vim/vimapi/network/OperatePort.py +++ b/vio/vio/pub/vim/vimapi/network/OperatePort.py @@ -12,8 +12,8 @@ import logging -from vio.pub.msapi.extsys import get_vim_by_id -from vio.pub.vim.drivers.vimsdk import neutron_v2_0 +# from vio.pub.msapi.extsys import get_vim_by_id +# from vio.pub.vim.drivers.vimsdk import neutron_v2_0 from vio.pub.vim.vimapi.network.OperateNetwork import BaseNet, translate diff --git a/vio/vio/pub/vim/vimapi/network/OperateSubnet.py b/vio/vio/pub/vim/vimapi/network/OperateSubnet.py index 598eefa..f43263c 100644 --- a/vio/vio/pub/vim/vimapi/network/OperateSubnet.py +++ b/vio/vio/pub/vim/vimapi/network/OperateSubnet.py @@ -12,9 +12,9 @@ import logging -from vio.pub.msapi.extsys import get_vim_by_id -from vio.pub.vim.drivers.vimsdk import neutron_v2_0 -from vio.pub.vim.vimapi.network.OperateNetwork import BaseNet,translate +# from vio.pub.msapi.extsys import get_vim_by_id +# from vio.pub.vim.drivers.vimsdk import neutron_v2_0 +from vio.pub.vim.vimapi.network.OperateNetwork import BaseNet, translate logger = logging.getLogger(__name__) @@ -54,7 +54,9 @@ class OperateSubnet(BaseNet): network = self.auth(vim_info, tenantid) body = translate(self.keys_mapping, body) subnet = network.subnet_create(**body) - vim_dict = {"vimName": vim_info['name'], "vimId": vim_info['vimId'], "tenantId": tenantid} + vim_dict = { + "vimName": vim_info['name'], "vimId": vim_info['vimId'], + "tenantId": tenantid} resp = self._convert(subnet) resp.update(vim_dict) return resp @@ -65,7 +67,9 @@ class OperateSubnet(BaseNet): subnet = network.subnet_get(subnetid, ignore_missing=ignore_missing) if subnet is None: return subnet - vim_dict = {"vimName": vim_info['name'], "vimId": vim_info['vimId'], "tenantId": tenantid} + vim_dict = { + "vimName": vim_info['name'], "vimId": vim_info['vimId'], + "tenantId": tenantid} resp = self._convert(subnet) resp.update(vim_dict) return resp @@ -80,7 +84,9 @@ class OperateSubnet(BaseNet): network = self.auth(vim_info, tenantid) query.update({"project_id": tenantid}) resp = network.subnets_get(**query) - vim_dict = {"vimName": vim_info['name'], "vimId": vim_info['vimId'], "tenantId": tenantid} + vim_dict = { + "vimName": vim_info['name'], "vimId": vim_info['vimId'], + "tenantId": tenantid} subnets = {'subnets': []} if resp: for subnet in resp: diff --git a/vio/vio/pub/vim/vimapi/nova/OperateFlavors.py b/vio/vio/pub/vim/vimapi/nova/OperateFlavors.py index a1fb897..22fe804 100644 --- a/vio/vio/pub/vim/vimapi/nova/OperateFlavors.py +++ b/vio/vio/pub/vim/vimapi/nova/OperateFlavors.py @@ -48,7 +48,8 @@ class OperateFlavors(OperateNova): return flavor, extra_specs def list_flavors(self, data, project_id, **query): - flavors = self.request('list_flavors', data, project_id=project_id, **query) + flavors = self.request('list_flavors', data, + project_id=project_id, **query) flavors = list(flavors) result = [] for flavor in flavors: @@ -57,7 +58,8 @@ class OperateFlavors(OperateNova): if query.get('name') and flavor.name not in query['name']: continue extra_specs = self.request('get_flavor_extra_specs', data, - project_id=project_id, flavor_id=flavor.id) + project_id=project_id, + flavor_id=flavor.id) result.append((flavor, extra_specs)) return result @@ -66,7 +68,8 @@ class OperateFlavors(OperateNova): flavor = self.request('get_flavor', data, project_id=project_id, flavor_id=flavor_id) extra_specs = self.request('get_flavor_extra_specs', data, - project_id=project_id, flavor_id=flavor_id) + project_id=project_id, + flavor_id=flavor_id) return flavor, extra_specs except exceptions.ResourceNotFound: diff --git a/vio/vio/pub/vim/vimapi/nova/OperateLimits.py b/vio/vio/pub/vim/vimapi/nova/OperateLimits.py index 8c1e878..6796a69 100644 --- a/vio/vio/pub/vim/vimapi/nova/OperateLimits.py +++ b/vio/vio/pub/vim/vimapi/nova/OperateLimits.py @@ -20,4 +20,5 @@ logger = logging.getLogger(__name__) class OperateLimits(OperateNova): def get_limits(self, data, project_id, **kwargs): - return self.request('get_limits', data, project_id=project_id, **kwargs) + return self.request('get_limits', data, + project_id=project_id, **kwargs) diff --git a/vio/vio/pub/vim/vimapi/nova/OperateServers.py b/vio/vio/pub/vim/vimapi/nova/OperateServers.py index f18ea83..03169bc 100644 --- a/vio/vio/pub/vim/vimapi/nova/OperateServers.py +++ b/vio/vio/pub/vim/vimapi/nova/OperateServers.py @@ -69,7 +69,7 @@ class OperateServers(OperateNova): if sg: req['security_groups'] = [] for v in sg: - req['security_groups'].append({'name':v}) + req['security_groups'].append({'name': v}) # todo attach volumes after server created volumes = create_req.get('volumeArray', []) if volumes: diff --git a/vio/vio/pub/vim/vimapi/nova/OperateService.py b/vio/vio/pub/vim/vimapi/nova/OperateService.py index d29779a..79a225a 100644 --- a/vio/vio/pub/vim/vimapi/nova/OperateService.py +++ b/vio/vio/pub/vim/vimapi/nova/OperateService.py @@ -12,7 +12,7 @@ import logging -from openstack import exceptions +# from openstack import exceptions from vio.pub.vim.vimapi.nova.OperateNova import OperateNova diff --git a/vio/vio/pub/vim/vimapi/nova/__init__.py b/vio/vio/pub/vim/vimapi/nova/__init__.py index 8770c43..a8fe66a 100644 --- a/vio/vio/pub/vim/vimapi/nova/__init__.py +++ b/vio/vio/pub/vim/vimapi/nova/__init__.py @@ -9,4 +9,3 @@ # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - diff --git a/vio/vio/samples/tests.py b/vio/vio/samples/tests.py index a3dbf4b..f07b3e9 100644 --- a/vio/vio/samples/tests.py +++ b/vio/vio/samples/tests.py @@ -25,6 +25,7 @@ class SampleViewTest(unittest.TestCase): def test_sample(self): response = self.client.get("/samples/") - self.assertEqual(status.HTTP_200_OK, response.status_code, response.content) + self.assertEqual(status.HTTP_200_OK, + response.status_code, response.content) resp_data = json.loads(response.content) self.assertEqual({"status": "active"}, resp_data) diff --git a/vio/vio/samples/views.py b/vio/vio/samples/views.py index a2ba070..525d9b6 100644 --- a/vio/vio/samples/views.py +++ b/vio/vio/samples/views.py @@ -22,6 +22,7 @@ class SampleList(APIView): """ List all samples. """ + def get(self, request, format=None): logger.debug("get") return Response({"status": "active"}) diff --git a/vio/vio/settings.py b/vio/vio/settings.py index f506872..eebfc60 100644 --- a/vio/vio/settings.py +++ b/vio/vio/settings.py @@ -88,7 +88,8 @@ LOGGING = { 'disable_existing_loggers': True, 'formatters': { 'standard': { - 'format': '%(asctime)s:[%(name)s]:[%(filename)s]-[%(lineno)d] [%(levelname)s]:%(message)s', + 'format': '%(asctime)s:[%(name)s]:[%(filename)s]-[%(lineno)d]\ + [%(levelname)s]:%(message)s', }, }, 'filters': { diff --git a/vio/vio/swagger/image_utils.py b/vio/vio/swagger/image_utils.py index 9f96bc7..ff2ac09 100644 --- a/vio/vio/swagger/image_utils.py +++ b/vio/vio/swagger/image_utils.py @@ -21,14 +21,14 @@ def image_formatter(image): properties['vmware_ostype'] = image.get("vmware_ostype") return { - 'id' : image.get("id"), - 'name' : image.get("name"), - 'imageType' : image.get("disk_format"), - 'status' : image.get("status"), - 'size' : image.get("size"), - 'containerFormat' : image.get("container_format"), - 'visibility' : image.get("visibility"), - 'properties' : properties + 'id': image.get("id"), + 'name': image.get("name"), + 'imageType': image.get("disk_format"), + 'status': image.get("status"), + 'size': image.get("size"), + 'containerFormat': image.get("container_format"), + 'visibility': image.get("visibility"), + 'properties': properties } @@ -52,6 +52,7 @@ def sdk_param_formatter(data): param['project_domain_name'] = 'default' return param + def req_body_formatter(body): param = {} diff --git a/vio/vio/swagger/nova_utils.py b/vio/vio/swagger/nova_utils.py index 816234e..505859d 100644 --- a/vio/vio/swagger/nova_utils.py +++ b/vio/vio/swagger/nova_utils.py @@ -37,11 +37,13 @@ def server_formatter(server, interfaces=[]): # TODO: wait sdk fix block_device_mapping try: if server.attached_volumes: - r["volumeArray"] = [{'volumeId': v['id']} for v in server.attached_volumes] + r["volumeArray"] = [{'volumeId': v['id']} + for v in server.attached_volumes] elif server.block_device_mapping: - r["volumeArray"] = [{'volumeId': v['uuid']} for v in server.block_device_mapping] - except ValueError as e: - r['volumeArray'] = [{'volumeId':""}] + r["volumeArray"] = [{'volumeId': v['uuid']} + for v in server.block_device_mapping] + except ValueError: + r['volumeArray'] = [{'volumeId': ""}] if server.image_id or server.image: r['boot'] = { 'type': 2, diff --git a/vio/vio/swagger/tests.py b/vio/vio/swagger/tests.py index a3f2c3b..21a231d 100644 --- a/vio/vio/swagger/tests.py +++ b/vio/vio/swagger/tests.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. import unittest -import json +# import json from django.test import Client from rest_framework import status @@ -25,6 +25,7 @@ class SampleViewTest(unittest.TestCase): def test_sample(self): response = self.client.get("/api/multicloud-vio/v0/swagger.json") - self.assertEqual(status.HTTP_200_OK, response.status_code, response.content) + self.assertEqual(status.HTTP_200_OK, + response.status_code, response.content) # resp_data = json.loads(response.content) # self.assertEqual({"status": "active"}, resp_data) diff --git a/vio/vio/swagger/urls.py b/vio/vio/swagger/urls.py index 7751e83..920edb7 100644 --- a/vio/vio/swagger/urls.py +++ b/vio/vio/swagger/urls.py @@ -10,7 +10,7 @@ # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -from django.conf.urls import patterns, url +from django.conf.urls import url from rest_framework.urlpatterns import format_suffix_patterns from vio.swagger.views.hypervisor.views import HostView @@ -24,12 +24,14 @@ from vio.swagger.views.volume.views import CreateListVolumeView from vio.swagger.views.volume.views import GetDeleteVolumeView from vio.swagger.views.server.views import ListServersView, GetServerView from vio.swagger.views.flavor.views import FlavorsView, FlavorView -from vio.swagger.views.network.views import CreateNetworkView, DeleteNetworkView +from vio.swagger.views.network.views import CreateNetworkView +from vio.swagger.views.network.views import DeleteNetworkView from vio.swagger.views.subnet.views import CreateSubnetView, DeleteSubnetView from vio.swagger.views.port.views import CreatePortView, DeletePortView -#proxy -from vio.swagger.views.proxyplugin.identity.views import TokenView,IdentityServer +# proxy +from vio.swagger.views.proxyplugin.identity.views import TokenView +from vio.swagger.views.proxyplugin.identity.views import IdentityServer from vio.swagger.views.proxyplugin.nova.views import ComputeServer from vio.swagger.views.proxyplugin.image.views import ImageServer from vio.swagger.views.proxyplugin.neutron.views import NetWorkServer @@ -42,7 +44,7 @@ urlpatterns = [ r'tenants$', ListTenantsView.as_view()), url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-zA-Z_-]+)/' r'(?P<tenantid>[0-9a-zA-Z_-]+)/images$', - CreateListImagesView.as_view()), + CreateListImagesView.as_view()), url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-zA-Z_-]+)/' r'(?P<tenantid>[0-9a-zA-Z_-]+)/images/(?P<imageid>[0-9a-zA-Z_-]+)$', GetDeleteImageView.as_view()), @@ -72,19 +74,25 @@ urlpatterns = [ url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-zA-Z_-]+)/' r'(?P<tenantid>[0-9a-zA-Z]+)/hosts/(?P<hostname>[0-9a-zA-Z_-]+)$', HostView.as_view()), - url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-zA-Z\-\_]+)/(?P<tenantid>[0-9a-zA-Z\-\_]+)/networks$', + url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-zA-Z\-\_]+)\ + /(?P<tenantid>[0-9a-zA-Z\-\_]+)/networks$', CreateNetworkView.as_view()), - url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-zA-Z\-\_]+)/(?P<tenantid>[0-9a-zA-Z\-\_]+)/networks/' + url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-zA-Z\-\_]+)\ + /(?P<tenantid>[0-9a-zA-Z\-\_]+)/networks/' r'(?P<networkid>[0-9a-zA-Z\-\_]+)$', DeleteNetworkView.as_view()), - url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-zA-Z\-\_]+)/(?P<tenantid>[0-9a-zA-Z\-\_]+)/subnets$', + url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-zA-Z\-\_]+)\ + /(?P<tenantid>[0-9a-zA-Z\-\_]+)/subnets$', CreateSubnetView.as_view()), - url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-zA-Z\-\_]+)/(?P<tenantid>[0-9a-zA-Z\-\_]+)/subnets/' + url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-zA-Z\-\_]+)\ + /(?P<tenantid>[0-9a-zA-Z\-\_]+)/subnets/' r'(?P<subnetid>[0-9a-zA-Z\-\_]+)$', DeleteSubnetView.as_view()), - url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-zA-Z\-\_]+)/(?P<tenantid>[0-9a-zA-Z\-\_]+)/ports$', + url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-zA-Z\-\_]+)\ + /(?P<tenantid>[0-9a-zA-Z\-\_]+)/ports$', CreatePortView.as_view()), - url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-zA-Z\-\_]+)/(?P<tenantid>[0-9a-zA-Z\-\_]+)/ports/' + url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-zA-Z\-\_]+)\ + /(?P<tenantid>[0-9a-zA-Z\-\_]+)/ports/' r'(?P<portid>[0-9a-zA-Z\-\_]+)$', DeletePortView.as_view()), @@ -94,36 +102,44 @@ urlpatterns = [ url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-z-A-Z\-\_]+)/identity$', IdentityServer.as_view()), - url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-z-A-Z\-\_]+)/identity/(?P<other>(.*))$', + url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-z-A-Z\-\_]+)\ + /identity/(?P<other>(.*))$', IdentityServer.as_view()), - url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-z-A-Z\-\_]+)/glance/(?P<other>(.*))$', + url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-z-A-Z\-\_]+)\ + /glance/(?P<other>(.*))$', ImageServer.as_view()), url( - r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-z-A-Z\-\_]+)/cinder/(?P<tenantid>[0-9a-z-A-Z\-\_]+)/(?P<other>(.*))$', + r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-z-A-Z\-\_]+)\ + /cinder/(?P<tenantid>[0-9a-z-A-Z\-\_]+)/(?P<other>(.*))$', VolumeServer.as_view()), url( - r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-z-A-Z\-\_]+)/cinderv2/(?P<tenantid>[0-9a-z-A-Z\-\_]+)/(?P<other>(.*))$', + r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-z-A-Z\-\_]+)\ + /cinderv2/(?P<tenantid>[0-9a-z-A-Z\-\_]+)/(?P<other>(.*))$', VolumeServer.as_view()), url( - r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-z-A-Z\-\_]+)/cinderv3/(?P<tenantid>[0-9a-z-A-Z\-\_]+)/(?P<other>(.*))$', + r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-z-A-Z\-\_]+)\ + /cinderv3/(?P<tenantid>[0-9a-z-A-Z\-\_]+)/(?P<other>(.*))$', VolumeServer.as_view()), url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-z-A-Z\-\_]+)/neutron$', NetWorkServer.as_view()), - url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-z-A-Z\-\_]+)/neutron/(?P<other>(.*))$', + url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-z-A-Z\-\_]+)\ + /neutron/(?P<other>(.*))$', NetWorkServer.as_view()), url( - r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-z-A-Z\-\_]+)/heat/(?P<tenantid>[0-9a-z-A-Z\-\_]+)/(?P<other>(.*))$', + r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-z-A-Z\-\_]+)\ + /heat/(?P<tenantid>[0-9a-z-A-Z\-\_]+)/(?P<other>(.*))$', HeatServer.as_view()), url( - r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-z-A-Z\-\_]+)/nova/(?P<tenantid>[0-9a-z-A-Z\-\_]+)/(?P<other>(.*))$', + r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-z-A-Z\-\_]+)\ + /nova/(?P<tenantid>[0-9a-z-A-Z\-\_]+)/(?P<other>(.*))$', ComputeServer.as_view()), ] diff --git a/vio/vio/swagger/views.py b/vio/vio/swagger/views.py index a41b995..c3dd40c 100644 --- a/vio/vio/swagger/views.py +++ b/vio/vio/swagger/views.py @@ -13,78 +13,88 @@ import json import logging import os -import traceback +# import traceback -from rest_framework import status +# from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView -from vio.pub.exceptions import VimDriverVioException +# from vio.pub.exceptions import VimDriverVioException logger = logging.getLogger(__name__) class SwaggerJsonView(APIView): def get(self, request): - json_file = os.path.join(os.path.dirname(__file__), 'multivim.flavor.swagger.json') + json_file = os.path.join(os.path.dirname( + __file__), 'multivim.flavor.swagger.json') f = open(json_file) json_data = json.JSONDecoder().decode(f.read()) f.close() - json_file = os.path.join(os.path.dirname(__file__), 'multivim.image.swagger.json') + json_file = os.path.join(os.path.dirname( + __file__), 'multivim.image.swagger.json') f = open(json_file) json_data_temp = json.JSONDecoder().decode(f.read()) f.close() json_data["paths"].update(json_data_temp["paths"]) json_data["definitions"].update(json_data_temp["definitions"]) - json_file = os.path.join(os.path.dirname(__file__), 'multivim.network.swagger.json') + json_file = os.path.join(os.path.dirname( + __file__), 'multivim.network.swagger.json') f = open(json_file) json_data_temp = json.JSONDecoder().decode(f.read()) f.close() json_data["paths"].update(json_data_temp["paths"]) json_data["definitions"].update(json_data_temp["definitions"]) - json_file = os.path.join(os.path.dirname(__file__), 'multivim.subnet.swagger.json') + json_file = os.path.join(os.path.dirname( + __file__), 'multivim.subnet.swagger.json') f = open(json_file) json_data_temp = json.JSONDecoder().decode(f.read()) f.close() json_data["paths"].update(json_data_temp["paths"]) json_data["definitions"].update(json_data_temp["definitions"]) - json_file = os.path.join(os.path.dirname(__file__), 'multivim.server.swagger.json') + json_file = os.path.join(os.path.dirname( + __file__), 'multivim.server.swagger.json') f = open(json_file) json_data_temp = json.JSONDecoder().decode(f.read()) f.close() json_data["paths"].update(json_data_temp["paths"]) json_data["definitions"].update(json_data_temp["definitions"]) - json_file = os.path.join(os.path.dirname(__file__), 'multivim.volume.swagger.json') + json_file = os.path.join(os.path.dirname( + __file__), 'multivim.volume.swagger.json') f = open(json_file) json_data_temp = json.JSONDecoder().decode(f.read()) f.close() json_data["paths"].update(json_data_temp["paths"]) json_data["definitions"].update(json_data_temp["definitions"]) - json_file = os.path.join(os.path.dirname(__file__), 'multivim.vport.swagger.json') + json_file = os.path.join(os.path.dirname( + __file__), 'multivim.vport.swagger.json') f = open(json_file) json_data_temp = json.JSONDecoder().decode(f.read()) f.close() json_data["paths"].update(json_data_temp["paths"]) json_data["definitions"].update(json_data_temp["definitions"]) - json_file = os.path.join(os.path.dirname(__file__), 'multivim.tenant.swagger.json') + json_file = os.path.join(os.path.dirname( + __file__), 'multivim.tenant.swagger.json') f = open(json_file) json_data_temp = json.JSONDecoder().decode(f.read()) f.close() json_data["paths"].update(json_data_temp["paths"]) json_data["definitions"].update(json_data_temp["definitions"]) - json_file = os.path.join(os.path.dirname(__file__), 'multivim.host.swagger.json') + json_file = os.path.join(os.path.dirname( + __file__), 'multivim.host.swagger.json') f = open(json_file) json_data_temp = json.JSONDecoder().decode(f.read()) f.close() json_data["paths"].update(json_data_temp["paths"]) json_data["definitions"].update(json_data_temp["definitions"]) - json_file = os.path.join(os.path.dirname(__file__), 'multivim.limit.swagger.json') + json_file = os.path.join(os.path.dirname( + __file__), 'multivim.limit.swagger.json') f = open(json_file) json_data_temp = json.JSONDecoder().decode(f.read()) f.close() json_data["paths"].update(json_data_temp["paths"]) json_data["definitions"].update(json_data_temp["definitions"]) json_data["basePath"] = "/api/multicloud-vio/v0/" - json_data["info"]["title"] = "MultiVIM driver of OpenStack VIO Service NBI" + json_data["info"]["title"] = "MultiVIM driver \ + of OpenStack VIO Service NBI" return Response(json_data) - diff --git a/vio/vio/swagger/views/flavor/views.py b/vio/vio/swagger/views/flavor/views.py index b6bc437..373a950 100644 --- a/vio/vio/swagger/views/flavor/views.py +++ b/vio/vio/swagger/views/flavor/views.py @@ -20,6 +20,7 @@ from vio.pub.vim.vimapi.nova import OperateFlavors from vio.swagger import nova_utils from vio.pub.exceptions import VimDriverVioException + class FlavorsView(APIView): def post(self, request, vimid, tenantid): @@ -114,7 +115,8 @@ class FlavorView(APIView): flavors_op = OperateFlavors.OperateFlavors() try: - flavor, extra_specs = flavors_op.get_flavor(data, tenantid, flavorid) + flavor, extra_specs = flavors_op.get_flavor( + data, tenantid, flavorid) flavor_dict = nova_utils.flavor_formatter(flavor, extra_specs) except Exception as e: if hasattr(e, "http_status"): diff --git a/vio/vio/swagger/views/hypervisor/views.py b/vio/vio/swagger/views/hypervisor/views.py index b6b41ea..2982b7b 100644 --- a/vio/vio/swagger/views/hypervisor/views.py +++ b/vio/vio/swagger/views/hypervisor/views.py @@ -18,8 +18,8 @@ from rest_framework.views import APIView from vio.pub.msapi import extsys from vio.pub.exceptions import VimDriverVioException from vio.pub.vim.vimapi.nova import OperateHypervisor -from vio.pub.vim.vimapi.nova import OperateServers -from vio.pub.vim.vimapi.nova import OperateService +# from vio.pub.vim.vimapi.nova import OperateServers +# from vio.pub.vim.vimapi.nova import OperateService from vio.swagger import nova_utils diff --git a/vio/vio/swagger/views/image/views.py b/vio/vio/swagger/views/image/views.py index edc3873..6865549 100644 --- a/vio/vio/swagger/views/image/views.py +++ b/vio/vio/swagger/views/image/views.py @@ -21,6 +21,7 @@ from vio.pub.vim.vimapi.glance import OperateImage from vio.swagger import image_utils from vio.pub.exceptions import VimDriverVioException + class GetDeleteImageView(APIView): def get(self, request, vimid, tenantid, imageid): @@ -64,6 +65,7 @@ class GetDeleteImageView(APIView): return Response(data={'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) + class CreateListImagesView(APIView): def get(self, request, vimid, tenantid): @@ -119,7 +121,8 @@ class CreateListImagesView(APIView): param = image_utils.req_body_formatter(req_body) image = image_instance.create_vim_image(vimid, tenantid, - imagePath=req_body.get('imagePath'), + imagePath=req_body.get( + 'imagePath'), **param) rsp = image_utils.image_formatter(image) diff --git a/vio/vio/swagger/views/limits/views.py b/vio/vio/swagger/views/limits/views.py index 5232f66..47b49a6 100644 --- a/vio/vio/swagger/views/limits/views.py +++ b/vio/vio/swagger/views/limits/views.py @@ -20,6 +20,7 @@ from vio.pub.vim.vimapi.nova import OperateLimits from vio.swagger import nova_utils from vio.pub.exceptions import VimDriverVioException + class LimitsView(APIView): def get(self, request, vimid, tenantid): diff --git a/vio/vio/swagger/views/network/views.py b/vio/vio/swagger/views/network/views.py index 0e6de17..599a67b 100644 --- a/vio/vio/swagger/views/network/views.py +++ b/vio/vio/swagger/views/network/views.py @@ -37,8 +37,8 @@ class CreateNetworkView(APIView): req_paras = ["name", "shared"] for para in req_paras: if para not in body: - raise Exception('Required parameter %s is ' - 'missing in net creation.' % para) + raise Exception('Required parameter %s is ' + 'missing in net creation.' % para) network_name = body.get('name') network_id = body.get('id', None) target = network_id or network_name @@ -103,6 +103,3 @@ class DeleteNetworkView(APIView): else: return Response(data={'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) - - - diff --git a/vio/vio/swagger/views/port/views.py b/vio/vio/swagger/views/port/views.py index 6fdd0fd..b1047d2 100644 --- a/vio/vio/swagger/views/port/views.py +++ b/vio/vio/swagger/views/port/views.py @@ -37,8 +37,8 @@ class CreatePortView(APIView): req_paras = ["subnetId", "networkId", "name"] for para in req_paras: if para not in body: - raise Exception('Required parameter %s is ' - 'missing in port creation.' % para) + raise Exception('Required parameter %s is ' + 'missing in port creation.' % para) port_name = body.get('name') port_id = body.get('id', None) target = port_id or port_name @@ -104,6 +104,3 @@ class DeletePortView(APIView): else: return Response(data={'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) - - - diff --git a/vio/vio/swagger/views/proxyplugin/__init__.py b/vio/vio/swagger/views/proxyplugin/__init__.py index 9ac359f..12fa1e8 100644 --- a/vio/vio/swagger/views/proxyplugin/__init__.py +++ b/vio/vio/swagger/views/proxyplugin/__init__.py @@ -8,4 +8,4 @@ # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\ No newline at end of file +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/vio/vio/swagger/views/proxyplugin/heat/__init__.py b/vio/vio/swagger/views/proxyplugin/heat/__init__.py index 9ac359f..12fa1e8 100644 --- a/vio/vio/swagger/views/proxyplugin/heat/__init__.py +++ b/vio/vio/swagger/views/proxyplugin/heat/__init__.py @@ -8,4 +8,4 @@ # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\ No newline at end of file +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/vio/vio/swagger/views/proxyplugin/heat/views.py b/vio/vio/swagger/views/proxyplugin/heat/views.py index b60cb7b..f70bccf 100644 --- a/vio/vio/swagger/views/proxyplugin/heat/views.py +++ b/vio/vio/swagger/views/proxyplugin/heat/views.py @@ -17,38 +17,27 @@ class HeatServer(BaseClient): serverType = "heat" - def get(self,request,vimid,tenantid,other): - - return self.send(request=request,method="GET",vimid=vimid,tenantid=tenantid,other=other) - - def post(self,request,vimid,tenantid,other): - - return self.send(request=request,method="POST",vimid=vimid,tenantid=tenantid,other=other) - - - def put(self,request,vimid,tenantid,other): - - return self.send(request=request, method="PUT",vimid=vimid, tenantid=tenantid, other=other) - - - def delete(self,request,vimid,tenantid,other): - - return self.send(request=request, method="DELETE",vimid=vimid, tenantid=tenantid, other=other) - - def patch(self, request, vimid, tenantid,other): - - return self.send(request=request, method="PATCH",vimid=vimid, tenantid=tenantid, other=other) - - - - - + def get(self, request, vimid, tenantid, other): + return self.send(request=request, method="GET", + vimid=vimid, tenantid=tenantid, other=other) + def post(self, request, vimid, tenantid, other): + return self.send(request=request, method="POST", + vimid=vimid, tenantid=tenantid, other=other) + def put(self, request, vimid, tenantid, other): + return self.send(request=request, method="PUT", + vimid=vimid, tenantid=tenantid, other=other) + def delete(self, request, vimid, tenantid, other): + return self.send(request=request, method="DELETE", + vimid=vimid, tenantid=tenantid, other=other) + def patch(self, request, vimid, tenantid, other): + return self.send(request=request, method="PATCH", + vimid=vimid, tenantid=tenantid, other=other) diff --git a/vio/vio/swagger/views/proxyplugin/httpclient.py b/vio/vio/swagger/views/proxyplugin/httpclient.py index b335d4a..f1cfbb1 100644 --- a/vio/vio/swagger/views/proxyplugin/httpclient.py +++ b/vio/vio/swagger/views/proxyplugin/httpclient.py @@ -21,17 +21,20 @@ from rest_framework.views import APIView from rest_framework.response import Response -from vio.pub.utils.syscomm import catalog,jsonResponse +from vio.pub.utils.syscomm import catalog, jsonResponse import vio.pub.exceptions as exceptions logger = logging.getLogger(__name__) + class TCPKeepAliveAdapter(requests.adapters.HTTPAdapter): """The custom adapter used to set TCP Keep-Alive on all connections.""" def init_poolmanager(self, *args, **kwargs): - if 'socket_options' not in kwargs and tuple(int(v) for v in requests.__version__.split('.')) >= (2, 4, 1): + if 'socket_options' not in kwargs \ + and tuple(int(v) for v in requests.__version__.split('.')) \ + >= (2, 4, 1): socket_options = [ # Keep Nagle's algorithm off (socket.IPPROTO_TCP, socket.TCP_NODELAY, 1), @@ -58,37 +61,40 @@ class TCPKeepAliveAdapter(requests.adapters.HTTPAdapter): class BaseClient(APIView): def __init__(self): - super(BaseClient,self).__init__() + super(BaseClient, self).__init__() self.session = requests.Session() for schema in list(self.session.adapters): - self.session.mount(schema,TCPKeepAliveAdapter()) + self.session.mount(schema, TCPKeepAliveAdapter()) - def buildRequest(self,request,vimid,tenantid="",tail=None): + def buildRequest(self, request, vimid, tenantid="", tail=None): - preUrl = catalog.getEndpointBy(vimid, serverType=self.serverType,interface="public") + preUrl = catalog.getEndpointBy( + vimid, serverType=self.serverType, interface="public") token = request.META.get('HTTP_X_AUTH_TOKEN', "") tail = "/" + tail if tail else "" tenantid = "/" + tenantid if tenantid else "" endPointURL = preUrl + tenantid + tail headers = {"X-Auth-Token": token} - headers['Content-Type'] = request.META.get("CONTENT_TYPE","application/json") + headers['Content-Type'] = request.META.get( + "CONTENT_TYPE", "application/json") try: json_req = json.loads(request.body) - except Exception as e: + except Exception: json_req = "" - return (endPointURL,headers,json_req) - + return (endPointURL, headers, json_req) - def _request(self, url, method,redirect=20, - connect_retries=0, connect_retry_delay=0.5, **kwargs): + def _request(self, url, method, redirect=20, + connect_retries=0, connect_retry_delay=0.5, **kwargs): try: try: - logger.info("%(method)s Request to %(url)s ",{'url':url,'method':method}) - resp = self.session.request(method, url,verify=False,timeout=30,**kwargs) + logger.info("%(method)s Request to %(url)s ", + {'url': url, 'method': method}) + resp = self.session.request( + method, url, verify=False, timeout=30, **kwargs) except requests.exceptions.SSLError as e: msg = 'SSL exception connecting to %(url)s: %(error)s' % { 'url': url, 'error': e} @@ -106,10 +112,11 @@ class BaseClient(APIView): except exceptions.RetriableConnectionFailure as e: if connect_retries <= 0: - return Response(data={"error":str(e)},status=status.HTTP_500_INTERNAL_SERVER_ERROR) + return Response(data={"error": str(e)}, + status=status.HTTP_500_INTERNAL_SERVER_ERROR) logger.info('Failure: %(e)s. Retrying in %(delay).1fs.', - {'e': e, 'delay': connect_retry_delay}) + {'e': e, 'delay': connect_retry_delay}) time.sleep(connect_retry_delay) return self._request( @@ -118,7 +125,6 @@ class BaseClient(APIView): connect_retry_delay=connect_retry_delay * 2, **kwargs) - if resp.status_code in [301, 302, 303, 305, 307, 308]: if isinstance(redirect, bool): @@ -134,7 +140,7 @@ class BaseClient(APIView): location = resp.headers['location'] except KeyError: logger.warning("Failed to redirect request to %s as new " - "location was not provided.", resp.url) + "location was not provided.", resp.url) pass else: @@ -148,35 +154,35 @@ class BaseClient(APIView): new_resp.history.insert(0, resp) resp = new_resp - data,content_type = jsonResponse(resp.content) - return Response(data=data, status=resp.status_code,content_type=content_type) + data, content_type = jsonResponse(resp.content) + return Response(data=data, status=resp.status_code, + content_type=content_type) + def send(self, request, method, vimid, tenantid="", other="", **kwargs): - def send(self,request,method,vimid,tenantid="",other="",**kwargs): - - (url, headers, data) = self.buildRequest(request, vimid, tenantid=tenantid, tail=other) + (url, headers, data) = self.buildRequest( + request, vimid, tenantid=tenantid, tail=other) kwargs.setdefault('headers', headers) - if method in ["POST","PUT","PATCH"]: + if method in ["POST", "PUT", "PATCH"]: kwargs.setdefault('data', json.dumps(data, encoding='utf-8')) - return self._request(url,method,**kwargs) - + return self._request(url, method, **kwargs) - def get(self,request,vimid): + def get(self, request, vimid): raise NotImplementedError() - def post(self,request,vimid): + def post(self, request, vimid): raise NotImplementedError() - def put(self,request,vimid): + def put(self, request, vimid): raise NotImplementedError() - def patch(self,request,vimid): + def patch(self, request, vimid): raise NotImplementedError() - def delete(self,request,vimid): + def delete(self, request, vimid): raise NotImplementedError() - def head(self,request,vimid): + def head(self, request, vimid): raise NotImplementedError() diff --git a/vio/vio/swagger/views/proxyplugin/identity/__init__.py b/vio/vio/swagger/views/proxyplugin/identity/__init__.py index 9ac359f..12fa1e8 100644 --- a/vio/vio/swagger/views/proxyplugin/identity/__init__.py +++ b/vio/vio/swagger/views/proxyplugin/identity/__init__.py @@ -8,4 +8,4 @@ # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\ No newline at end of file +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/vio/vio/swagger/views/proxyplugin/identity/views.py b/vio/vio/swagger/views/proxyplugin/identity/views.py index 6312541..0ce6312 100644 --- a/vio/vio/swagger/views/proxyplugin/identity/views.py +++ b/vio/vio/swagger/views/proxyplugin/identity/views.py @@ -15,9 +15,9 @@ from rest_framework import status from rest_framework.response import Response from vio.pub.msapi import extsys -from vio.pub.exceptions import VimDriverVioException +from vio.pub.exceptions import VimDriverVioException from vio.pub.utils.syscomm import catalog -from vio.pub.config.config import MSB_SERVICE_PORT,MSB_SERVICE_IP +from vio.pub.config.config import MSB_SERVICE_PORT, MSB_SERVICE_IP import json import requests from collections import defaultdict @@ -27,55 +27,58 @@ from vio.swagger.views.proxyplugin.httpclient import BaseClient logger = logging.getLogger(__name__) -MSB_ADDRESS = MSB_SERVICE_IP+":"+MSB_SERVICE_PORT+"/api" +MSB_ADDRESS = MSB_SERVICE_IP + ":" + MSB_SERVICE_PORT + "/api" class IdentityServer(BaseClient): serverType = 'keystone' - def get(self,request,vimid,other=None): + def get(self, request, vimid, other=None): - (url,headers,_) = self.buildRequest(request,vimid,tail=other) + (url, headers, _) = self.buildRequest(request, vimid, tail=other) query = "" - for k,v in request.GET.items(): - query+= (k+"="+v) - query+="&" + for k, v in request.GET.items(): + query += (k + "=" + v) + query += "&" - if query!="": + if query != "": query = query[:-1] - url+="/?"+query - return self._request(url,method="GET",headers=headers) + url += "/?" + query + return self._request(url, method="GET", headers=headers) - def patch(self,request,vimid,other): + def patch(self, request, vimid, other): - return self.send(request=request,method="PATCH",vimid=vimid,other=other) + return self.send(request=request, method="PATCH", + vimid=vimid, other=other) - def post(self,request,vimid,other): + def post(self, request, vimid, other): - return self.send(request=request,method="POST",vimid=vimid,other=other) + return self.send(request=request, method="POST", + vimid=vimid, other=other) - def delete(self,request,vimid,other): + def delete(self, request, vimid, other): - return self.send(request=request,method="DELETE",vimid=vimid,other=other) + return self.send(request=request, method="DELETE", + vimid=vimid, other=other) - def head(self,request,vimid,other): - - return self.send(request=request,method="HEAD",vimid=vimid,other=other) + def head(self, request, vimid, other): + return self.send(request=request, method="HEAD", + vimid=vimid, other=other) class TokenView(BaseClient): serverType = 'identity' - - def get(self,request,vimid): + def get(self, request, vimid): url_path = request.get_full_path() - if url_path[url_path.rfind("identity"):]!="identity/v3": - return Response(data={"error":"method not allowed"},status=status.HTTP_405_METHOD_NOT_ALLOWED) + if url_path[url_path.rfind("identity"):] != "identity/v3": + return Response(data={"error": "method not allowed"}, + status=status.HTTP_405_METHOD_NOT_ALLOWED) try: vim_info = extsys.get_vim_by_id(vim_id=vimid) @@ -83,47 +86,47 @@ class TokenView(BaseClient): return Response(data={"error": str(e)}, status=e.status_code) except Exception as e: logging.exception("error %s" % e) - return Response(data={"error":str(e)},status=status.HTTP_500_INTERNAL_SERVER_ERROR) - + return Response(data={"error": str(e)}, + status=status.HTTP_500_INTERNAL_SERVER_ERROR) keystoneURL = vim_info['url'] - logger.info("vimid(%(vimid)s) get keystone url %(url)s ", {"vimid": vimid, "url": keystoneURL}) + logger.info("vimid(%(vimid)s) get keystone url %(url)s ", + {"vimid": vimid, "url": keystoneURL}) try: res = requests.get(url=keystoneURL).json() - res['version']['links'][0]['href']="http://"+MSB_ADDRESS+"/multicloud-vio/v0/"+vimid +"/identity/v3" - + res['version']['links'][0]['href'] = "http://" + \ + MSB_ADDRESS + "/multicloud-vio/v0/" + vimid + "/identity/v3" except Exception as e: logging.exception("error %s" % e) - return Response(data={"error": str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) + return Response(data={"error": str(e)}, + status=status.HTTP_500_INTERNAL_SERVER_ERROR) return Response(data=res, status=status.HTTP_200_OK) - - def delete(self,request,vimid): + def delete(self, request, vimid): (url, headers, _) = self.buildRequest(request, vimid) - subject_token = request.META.get("HTTP_X_SUBJECT_TOKEN","") + subject_token = request.META.get("HTTP_X_SUBJECT_TOKEN", "") - url+="/auth/tokens" + url += "/auth/tokens" headers["X-Subject-Token"] = subject_token - return self._request(url,method="DELETE",headers=headers) + return self._request(url, method="DELETE", headers=headers) - - def post(self,request,vimid): + def post(self, request, vimid): url_path = request.get_full_path() if url_path[url_path.rfind("identity"):] != "identity/v3/auth/tokens": - return Response(data={"error": "method not allowed"}, status=status.HTTP_405_METHOD_NOT_ALLOWED) + return Response(data={"error": "method not allowed"}, + status=status.HTTP_405_METHOD_NOT_ALLOWED) try: create_req = json.loads(request.body) except Exception as e: - return Response(data={'error': 'Fail to decode request body %s.' %e}, - status=status.HTTP_500_INTERNAL_SERVER_ERROR) - - + return Response( + data={'error': 'Fail to decode request body %s.' % e}, + status=status.HTTP_500_INTERNAL_SERVER_ERROR) try: vim_info = extsys.get_vim_by_id(vimid) @@ -131,53 +134,60 @@ class TokenView(BaseClient): return Response(data={'error': str(e)}, status=e.status_code) except Exception as e: logging.exception("error %s" % e) - return Response(data={"error": str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) + return Response(data={"error": str(e)}, + status=status.HTTP_500_INTERNAL_SERVER_ERROR) - url = vim_info['url']+"/auth/tokens" + url = vim_info['url'] + "/auth/tokens" headers = {"Content-Type": "application/json"} - logger.info("vimid(%(vimid)s) request token url %(url)s ", {"vimid": vimid, "url": url}) + logger.info("vimid(%(vimid)s) request token url %(url)s ", + {"vimid": vimid, "url": url}) try: - res = requests.post(url=url, data=json.dumps(create_req), headers=headers) + res = requests.post(url=url, data=json.dumps( + create_req), headers=headers) tokenInfo = res.json() resHeader = dict(res.headers) except Exception as e: logging.exception("error %s" % e) - return Response(data={'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) - - + return Response(data={'error': str(e)}, + status=status.HTTP_500_INTERNAL_SERVER_ERROR) try: tenantid = tokenInfo['token']['project']['id'] vimEndpoints = defaultdict(dict) - for i in tokenInfo['token']['catalog']: + for i in tokenInfo['token']['catalog']: for j in i['endpoints']: tmp = j['url'] ends = deepcopy(j['url']) ends = ends.split("/") - version = "/"+ends[3] if len(ends) > 3 else "" - ends = ends[0]+"//"+ends[2]+version - vimEndpoints[i['name']][j['interface']]=ends - res=tmp.split("/") - if i['type'] in ['image','network','cloudformation','identity']: + version = "/" + ends[3] if len(ends) > 3 else "" + ends = ends[0] + "//" + ends[2] + version + vimEndpoints[i['name']][j['interface']] = ends + res = tmp.split("/") + if i['type'] in ['image', 'network', + 'cloudformation', 'identity']: if i['type'] != 'identity': - res[2] = MSB_ADDRESS+"/multicloud-vio/v0/" + vimid + "/" + i['name'] + res[2] = MSB_ADDRESS + "/multicloud-vio/v0/" + \ + vimid + "/" + i['name'] else: # use identity instead of keystone - res[2] = MSB_ADDRESS + "/multicloud-vio/v0/" + vimid + "/" + i['type'] + res[2] = MSB_ADDRESS + "/multicloud-vio/v0/" + \ + vimid + "/" + i['type'] else: - res[2]= MSB_ADDRESS+"/multicloud-vio/v0/"+vimid+"/"+i['name']+"/"+tenantid - j['url']="http:"+"//"+res[2] + res[2] = MSB_ADDRESS + "/multicloud-vio/v0/" + \ + vimid + "/" + i['name'] + "/" + tenantid + j['url'] = "http:" + "//" + res[2] except Exception as e: logging.exception("error %s" % e) - return Response(data={'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) + return Response(data={'error': str(e)}, + status=status.HTTP_500_INTERNAL_SERVER_ERROR) - logger.info("vimid(%(vimid)s) service enpoints %(endpoint)s ",{"vimid":vimid,"endpoint":vimEndpoints}) + logger.info("vimid(%(vimid)s) service enpoints %(endpoint)s ", { + "vimid": vimid, "endpoint": vimEndpoints}) tokenInfo['token']['value'] = resHeader['X-Subject-Token'] catalog.storeEndpoint(vimid=vimid, endpoints=vimEndpoints) - Res = Response(data=tokenInfo,status=status.HTTP_200_OK) - Res['X-Subject-Token']=resHeader['X-Subject-Token'] + Res = Response(data=tokenInfo, status=status.HTTP_200_OK) + Res['X-Subject-Token'] = resHeader['X-Subject-Token'] return Res - diff --git a/vio/vio/swagger/views/proxyplugin/image/__init__.py b/vio/vio/swagger/views/proxyplugin/image/__init__.py index 9ac359f..12fa1e8 100644 --- a/vio/vio/swagger/views/proxyplugin/image/__init__.py +++ b/vio/vio/swagger/views/proxyplugin/image/__init__.py @@ -8,4 +8,4 @@ # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\ No newline at end of file +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/vio/vio/swagger/views/proxyplugin/image/views.py b/vio/vio/swagger/views/proxyplugin/image/views.py index ff14eaf..22b5b12 100644 --- a/vio/vio/swagger/views/proxyplugin/image/views.py +++ b/vio/vio/swagger/views/proxyplugin/image/views.py @@ -17,7 +17,7 @@ class ImageServer(BaseClient): serverType = "glance" - def get(self,request,vimid,other): + def get(self, request, vimid, other): (url, headers, _) = self.buildRequest(request, vimid, tail=other) @@ -31,20 +31,22 @@ class ImageServer(BaseClient): url += "?" + query return self._request(url, method="GET", headers=headers) - def post(self, request, vimid, other): - return self.send(request=request,method="POST",vimid=vimid,other=other) - + return self.send(request=request, method="POST", + vimid=vimid, other=other) def patch(self, request, vimid, other): - return self.send(request=request,method="PATCH",vimid=vimid,other=other) + return self.send(request=request, method="PATCH", + vimid=vimid, other=other) - def put(self,request,vimid,other): + def put(self, request, vimid, other): - return self.send(request=request,method="PUT",vimid=vimid,other=other) + return self.send(request=request, method="PUT", + vimid=vimid, other=other) def delete(self, request, vimid, other): - return self.send(request=request,method="DELETE",vimid=vimid,other=other)
\ No newline at end of file + return self.send(request=request, method="DELETE", + vimid=vimid, other=other) diff --git a/vio/vio/swagger/views/proxyplugin/neutron/__init__.py b/vio/vio/swagger/views/proxyplugin/neutron/__init__.py index 9ac359f..12fa1e8 100644 --- a/vio/vio/swagger/views/proxyplugin/neutron/__init__.py +++ b/vio/vio/swagger/views/proxyplugin/neutron/__init__.py @@ -8,4 +8,4 @@ # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\ No newline at end of file +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/vio/vio/swagger/views/proxyplugin/neutron/views.py b/vio/vio/swagger/views/proxyplugin/neutron/views.py index 23d01ad..3f42a14 100644 --- a/vio/vio/swagger/views/proxyplugin/neutron/views.py +++ b/vio/vio/swagger/views/proxyplugin/neutron/views.py @@ -13,27 +13,31 @@ from vio.swagger.views.proxyplugin.httpclient import BaseClient - class NetWorkServer(BaseClient): serverType = "neutron" - def get(self,request,vimid,other=None): + def get(self, request, vimid, other=None): - return self.send(request=request,method="GET",vimid=vimid,other=other) + return self.send(request=request, method="GET", + vimid=vimid, other=other) - def post(self,request,vimid,other): + def post(self, request, vimid, other): - return self.send(request=request,method="POST",vimid=vimid,other=other) + return self.send(request=request, method="POST", + vimid=vimid, other=other) def patch(self, request, vimid, other): - return self.send(request=request,method="PATCH",vimid=vimid,other=other) + return self.send(request=request, method="PATCH", + vimid=vimid, other=other) def put(self, request, vimid, other): - return self.send(request=request,method="PUT",vimid=vimid,other=other) + return self.send(request=request, method="PUT", + vimid=vimid, other=other) def delete(self, request, vimid, other): - return self.send(request=request,method="DELETE",vimid=vimid,other=other)
\ No newline at end of file + return self.send(request=request, method="DELETE", + vimid=vimid, other=other) diff --git a/vio/vio/swagger/views/proxyplugin/nova/__init__.py b/vio/vio/swagger/views/proxyplugin/nova/__init__.py index 9ac359f..12fa1e8 100644 --- a/vio/vio/swagger/views/proxyplugin/nova/__init__.py +++ b/vio/vio/swagger/views/proxyplugin/nova/__init__.py @@ -8,4 +8,4 @@ # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\ No newline at end of file +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/vio/vio/swagger/views/proxyplugin/nova/views.py b/vio/vio/swagger/views/proxyplugin/nova/views.py index 6a0a93d..83cb92c 100644 --- a/vio/vio/swagger/views/proxyplugin/nova/views.py +++ b/vio/vio/swagger/views/proxyplugin/nova/views.py @@ -17,9 +17,10 @@ class ComputeServer(BaseClient): serverType = "nova" - def get(self,request,vimid,tenantid,other): + def get(self, request, vimid, tenantid, other): - (url, headers, _) = self.buildRequest(request, vimid, tenantid=tenantid,tail=other) + (url, headers, _) = self.buildRequest( + request, vimid, tenantid=tenantid, tail=other) query = "" for k, v in request.GET.items(): query += (k + "=" + v) @@ -30,14 +31,17 @@ class ComputeServer(BaseClient): url += "?" + query return self._request(url, method="GET", headers=headers) - def post(self,request,vimid,tenantid,other): + def post(self, request, vimid, tenantid, other): - return self.send(request=request,method="POST",vimid=vimid,tenantid=tenantid,other=other) + return self.send(request=request, method="POST", vimid=vimid, + tenantid=tenantid, other=other) - def put(self,request,vimid,tenantid,other): + def put(self, request, vimid, tenantid, other): - return self.send(request=request,method="PUT",vimid=vimid,tenantid=tenantid,other=other) + return self.send(request=request, method="PUT", vimid=vimid, + tenantid=tenantid, other=other) - def delete(self,request,vimid,tenantid,other): + def delete(self, request, vimid, tenantid, other): - return self.send(request=request,method="DELETE",vimid=vimid,tenantid=tenantid,other=other) + return self.send(request=request, method="DELETE", vimid=vimid, + tenantid=tenantid, other=other) diff --git a/vio/vio/swagger/views/proxyplugin/volumn/__init__.py b/vio/vio/swagger/views/proxyplugin/volumn/__init__.py index 9ac359f..12fa1e8 100644 --- a/vio/vio/swagger/views/proxyplugin/volumn/__init__.py +++ b/vio/vio/swagger/views/proxyplugin/volumn/__init__.py @@ -8,4 +8,4 @@ # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\ No newline at end of file +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/vio/vio/swagger/views/proxyplugin/volumn/views.py b/vio/vio/swagger/views/proxyplugin/volumn/views.py index 8eccce9..569a083 100644 --- a/vio/vio/swagger/views/proxyplugin/volumn/views.py +++ b/vio/vio/swagger/views/proxyplugin/volumn/views.py @@ -17,37 +17,35 @@ class VolumeServer(BaseClient): serverType = "cinder" - def get(self,request,vimid,tenantid,other): + def get(self, request, vimid, tenantid, other): - return self.send(request=request,method="GET",vimid=vimid,tenantid=tenantid,other=other) + return self.send(request=request, method="GET", vimid=vimid, + tenantid=tenantid, other=other) - def post(self,request,vimid,tenantid,other): + def post(self, request, vimid, tenantid, other): - return self.send(request=request,method="POST",vimid=vimid,tenantid=tenantid,other=other) + return self.send(request=request, method="POST", vimid=vimid, + tenantid=tenantid, other=other) def put(self, request, vimid, tenantid, other): - return self.send(request=request,method="PUT",vimid=vimid,tenantid=tenantid,other=other) + return self.send(request=request, method="PUT", vimid=vimid, + tenantid=tenantid, other=other) def delete(self, request, vimid, tenantid, other): - return self.send(request=request,method="DELETE",vimid=vimid,tenantid=tenantid,other=other) + return self.send(request=request, method="DELETE", vimid=vimid, + tenantid=tenantid, other=other) def patch(self, request, vimid, tenantid, other): - return self.send(request=request,method="PATCH",vimid=vimid,tenantid=tenantid,other=other) + return self.send(request=request, method="PATCH", vimid=vimid, + tenantid=tenantid, other=other) class VolumeServer2(VolumeServer): serverType = "cinderv2" + class VolumeServer3(VolumeServer): serverType = "volumev3" - - - - - - - - diff --git a/vio/vio/swagger/views/service/views.py b/vio/vio/swagger/views/service/views.py index bc17d31..837d5fc 100644 --- a/vio/vio/swagger/views/service/views.py +++ b/vio/vio/swagger/views/service/views.py @@ -16,7 +16,7 @@ from rest_framework.response import Response from rest_framework.views import APIView from vio.pub.msapi import extsys -from vio.pub.vim.vimapi.nova import OperateServers +# from vio.pub.vim.vimapi.nova import OperateServers from vio.pub.vim.vimapi.nova import OperateService from vio.pub.exceptions import VimDriverVioException from vio.swagger import nova_utils diff --git a/vio/vio/swagger/views/subnet/views.py b/vio/vio/swagger/views/subnet/views.py index 8b0fc28..47330a6 100644 --- a/vio/vio/swagger/views/subnet/views.py +++ b/vio/vio/swagger/views/subnet/views.py @@ -37,12 +37,13 @@ class CreateSubnetView(APIView): req_paras = ["name", "networkId", "cidr", "ipVersion"] for para in req_paras: if para not in body: - raise Exception('Required parameter %s is ' - 'missing in subnet creation.' % para) + raise Exception('Required parameter %s is ' + 'missing in subnet creation.' % para) subnet_name = body.get('name') subnet_id = body.get('id', None) target = subnet_id or subnet_name - resp = subnet.list_subnet(vimid, tenantid, target, ignore_missing=True) + resp = subnet.list_subnet( + vimid, tenantid, target, ignore_missing=True) if resp: resp['returnCode'] = 0 return Response(data=resp, status=status.HTTP_200_OK) @@ -62,7 +63,7 @@ class CreateSubnetView(APIView): logger.info("Enter %s, method is %s, vim_id is %s", syscomm.fun_name(), request.method, vimid) query = dict(request.query_params) - subnet = OperateSubnet.OperateSubnet() + subnet = OperateSubnet.OperateSubnet() try: resp = subnet.list_subnets(vimid, tenantid, **query) return Response(data=resp, status=status.HTTP_200_OK) @@ -79,7 +80,7 @@ class DeleteSubnetView(APIView): def get(self, request, vimid, tenantid, subnetid): logger.info("Enter %s, method is %s, vim_id is %s", syscomm.fun_name(), request.method, vimid) - subnet = OperateSubnet.OperateSubnet() + subnet = OperateSubnet.OperateSubnet() try: resp = subnet.list_subnet(vimid, tenantid, subnetid) return Response(data=resp, status=status.HTTP_200_OK) @@ -93,7 +94,7 @@ class DeleteSubnetView(APIView): def delete(self, request, vimid, tenantid, subnetid): logger.info("Enter %s, method is %s, vim_id is %s", syscomm.fun_name(), request.method, vimid) - subnet = OperateSubnet.OperateSubnet() + subnet = OperateSubnet.OperateSubnet() try: resp = subnet.delete_subnet(vimid, tenantid, subnetid) return Response(data=resp, status=status.HTTP_204_NO_CONTENT) @@ -103,6 +104,3 @@ class DeleteSubnetView(APIView): else: return Response(data={'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) - - - diff --git a/vio/vio/swagger/views/swagger_json.py b/vio/vio/swagger/views/swagger_json.py index a660a21..79bc970 100644 --- a/vio/vio/swagger/views/swagger_json.py +++ b/vio/vio/swagger/views/swagger_json.py @@ -24,64 +24,75 @@ logger = logging.getLogger(__name__) class SwaggerJsonView(APIView): def get(self, request): - json_file = os.path.join(os.path.dirname(__file__), 'multivim.flavor.swagger.json') + json_file = os.path.join(os.path.dirname( + __file__), 'multivim.flavor.swagger.json') f = open(json_file) json_data = json.JSONDecoder().decode(f.read()) f.close() - json_file = os.path.join(os.path.dirname(__file__), 'multivim.image.swagger.json') + json_file = os.path.join(os.path.dirname( + __file__), 'multivim.image.swagger.json') f = open(json_file) json_data_temp = json.JSONDecoder().decode(f.read()) f.close() json_data["paths"].update(json_data_temp["paths"]) json_data["definitions"].update(json_data_temp["definitions"]) - json_file = os.path.join(os.path.dirname(__file__), 'multivim.network.swagger.json') + json_file = os.path.join(os.path.dirname( + __file__), 'multivim.network.swagger.json') f = open(json_file) json_data_temp = json.JSONDecoder().decode(f.read()) f.close() json_data["paths"].update(json_data_temp["paths"]) json_data["definitions"].update(json_data_temp["definitions"]) - json_file = os.path.join(os.path.dirname(__file__), 'multivim.subnet.swagger.json') + json_file = os.path.join(os.path.dirname( + __file__), 'multivim.subnet.swagger.json') f = open(json_file) json_data_temp = json.JSONDecoder().decode(f.read()) f.close() json_data["paths"].update(json_data_temp["paths"]) json_data["definitions"].update(json_data_temp["definitions"]) - json_file = os.path.join(os.path.dirname(__file__), 'multivim.server.swagger.json') + json_file = os.path.join(os.path.dirname( + __file__), 'multivim.server.swagger.json') f = open(json_file) json_data_temp = json.JSONDecoder().decode(f.read()) f.close() json_data["paths"].update(json_data_temp["paths"]) json_data["definitions"].update(json_data_temp["definitions"]) - json_file = os.path.join(os.path.dirname(__file__), 'multivim.volume.swagger.json') + json_file = os.path.join(os.path.dirname( + __file__), 'multivim.volume.swagger.json') f = open(json_file) json_data_temp = json.JSONDecoder().decode(f.read()) f.close() json_data["paths"].update(json_data_temp["paths"]) json_data["definitions"].update(json_data_temp["definitions"]) - json_file = os.path.join(os.path.dirname(__file__), 'multivim.vport.swagger.json') + json_file = os.path.join(os.path.dirname( + __file__), 'multivim.vport.swagger.json') f = open(json_file) json_data_temp = json.JSONDecoder().decode(f.read()) f.close() json_data["paths"].update(json_data_temp["paths"]) json_data["definitions"].update(json_data_temp["definitions"]) - json_file = os.path.join(os.path.dirname(__file__), 'multivim.tenant.swagger.json') + json_file = os.path.join(os.path.dirname( + __file__), 'multivim.tenant.swagger.json') f = open(json_file) json_data_temp = json.JSONDecoder().decode(f.read()) f.close() json_data["paths"].update(json_data_temp["paths"]) json_data["definitions"].update(json_data_temp["definitions"]) - json_file = os.path.join(os.path.dirname(__file__), 'multivim.host.swagger.json') + json_file = os.path.join(os.path.dirname( + __file__), 'multivim.host.swagger.json') f = open(json_file) json_data_temp = json.JSONDecoder().decode(f.read()) f.close() json_data["paths"].update(json_data_temp["paths"]) json_data["definitions"].update(json_data_temp["definitions"]) - json_file = os.path.join(os.path.dirname(__file__), 'multivim.limit.swagger.json') + json_file = os.path.join(os.path.dirname( + __file__), 'multivim.limit.swagger.json') f = open(json_file) json_data_temp = json.JSONDecoder().decode(f.read()) f.close() json_data["paths"].update(json_data_temp["paths"]) json_data["definitions"].update(json_data_temp["definitions"]) json_data["basePath"] = "/api/multicloud-vio/v0/" - json_data["info"]["title"] = "MultiVIM driver of OpenStack VIO Service NBI" + json_data["info"]["title"] = "MultiVIM \ + driver of OpenStack VIO Service NBI" return Response(json_data) diff --git a/vio/vio/swagger/views/volume/views.py b/vio/vio/swagger/views/volume/views.py index fa3131c..64825f5 100644 --- a/vio/vio/swagger/views/volume/views.py +++ b/vio/vio/swagger/views/volume/views.py @@ -41,7 +41,7 @@ class GetDeleteVolumeView(APIView): try: volume = volume_op.get_vim_volume(volumeid) vim_rsp = volume_utils.vim_formatter(vim_info, tenantid) - rsp = volume_utils.volume_formatter(volume) + rsp = volume_utils.volume_formatter(volume) rsp.update(vim_rsp) return Response(data=rsp, status=status.HTTP_200_OK) except Exception as e: @@ -91,7 +91,8 @@ class CreateListVolumeView(APIView): vim_rsp = volume_utils.vim_formatter(vim_info, tenantid) for volume in volumes: volume_info = volume_op.get_vim_volume(volume.id) - rsp['volumes'].append(volume_utils.volume_formatter(volume_info)) + rsp['volumes'].append( + volume_utils.volume_formatter(volume_info)) rsp.update(vim_rsp) return Response(data=rsp, status=status.HTTP_200_OK) @@ -102,7 +103,6 @@ class CreateListVolumeView(APIView): return Response(data={'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) - def post(self, request, vimid, tenantid): try: vim_info = extsys.get_vim_by_id(vimid) @@ -122,7 +122,7 @@ class CreateListVolumeView(APIView): for volume in volumes_detail: if volume.name == body.get('name'): volume_info = volume_op.get_vim_volume(volume.id) - rsp = volume_utils.volume_formatter(volume_info) + rsp = volume_utils.volume_formatter(volume_info) rsp['returnCode'] = 0 rsp.update(vim_rsp) return Response(data=rsp, status=status.HTTP_200_OK) @@ -136,7 +136,7 @@ class CreateListVolumeView(APIView): param = volume_utils.req_body_formatter(body) volume_info = volume_op.create_vim_volume(**param) - rsp = volume_utils.volume_formatter(volume_info) + rsp = volume_utils.volume_formatter(volume_info) rsp['returnCode'] = 1 rsp.update(vim_rsp) return Response(data=rsp, status=status.HTTP_202_ACCEPTED) diff --git a/vio/vio/swagger/volume_utils.py b/vio/vio/swagger/volume_utils.py index 2d20a05..0a858e7 100644 --- a/vio/vio/swagger/volume_utils.py +++ b/vio/vio/swagger/volume_utils.py @@ -16,23 +16,23 @@ def volume_formatter(volume): attachments = [] for attach in volume.attachments: vim_attach = { - 'device' : attach['device'], - 'volumeId' : attach['volume_id'], - 'hostName' : attach['host_name'], - 'Id' : attach['attachment_id'], - 'serverId' : attach['server_id'] + 'device': attach['device'], + 'volumeId': attach['volume_id'], + 'hostName': attach['host_name'], + 'Id': attach['attachment_id'], + 'serverId': attach['server_id'] } attachments.append(vim_attach) return { - 'id' : volume.id, - 'name' : volume.name, - 'createTime' : volume.created_at, - 'status' : volume.status, - 'type' : volume.volume_type, - 'size' : volume.size, - 'availabilityZone' : volume.availability_zone, - 'attachments' : attachments + 'id': volume.id, + 'name': volume.name, + 'createTime': volume.created_at, + 'status': volume.status, + 'type': volume.volume_type, + 'size': volume.size, + 'availabilityZone': volume.availability_zone, + 'attachments': attachments } diff --git a/vio/vio/urls.py b/vio/vio/urls.py index ab5e952..93b6d8e 100644 --- a/vio/vio/urls.py +++ b/vio/vio/urls.py @@ -11,7 +11,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. from django.conf.urls import include, url -from vio.pub.config.config import REG_TO_MSB_WHEN_START, REG_TO_MSB_REG_URL, REG_TO_MSB_REG_PARAM +from vio.pub.config.config import REG_TO_MSB_WHEN_START +from vio.pub.config.config import REG_TO_MSB_REG_URL +from vio.pub.config.config import REG_TO_MSB_REG_PARAM urlpatterns = [ url(r'^', include('vio.swagger.urls')), @@ -22,4 +24,5 @@ urlpatterns = [ if REG_TO_MSB_WHEN_START: import json from vio.pub.utils.restcall import req_by_msb - req_by_msb(REG_TO_MSB_REG_URL, "POST", json.JSONEncoder().encode(REG_TO_MSB_REG_PARAM)) + req_by_msb(REG_TO_MSB_REG_URL, "POST", + json.JSONEncoder().encode(REG_TO_MSB_REG_PARAM)) |