X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_ro%2Fnfvo.py;h=dd3b6aa068301942914df8d94e2874c7d94b124d;hb=1fdf999b4398253634e56f8541c47aeae3cd456a;hp=343685d0f84c9455c1e7067ce1a8adea9a0fdeed;hpb=d3750b355ef0488accb82ddeb70b9c5941feff6e;p=osm%2FRO.git diff --git a/osm_ro/nfvo.py b/osm_ro/nfvo.py index 343685d0..dd3b6aa0 100644 --- a/osm_ro/nfvo.py +++ b/osm_ro/nfvo.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- ## -# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U. +# Copyright 2015 Telefonica Investigacion y Desarrollo, S.A.U. # This file is part of openmano # All Rights Reserved. # @@ -31,6 +31,7 @@ __date__ ="$16-sep-2014 22:05:01$" # import json import yaml import utils +from utils import deprecated import vim_thread from db_base import HTTP_Unauthorized, HTTP_Bad_Request, HTTP_Internal_Server_Error, HTTP_Not_Found,\ HTTP_Conflict, HTTP_Method_Not_Allowed @@ -721,8 +722,8 @@ def create_or_use_flavor(mydb, vims, flavor_dict, rollback_list, only_create_at_ for index in range(0,len(devices_original)) : device=devices_original[index] if "image" not in device and "image name" not in device: - if 'size' in device: - disk_list.append({'size': device.get('size', default_volume_size), 'name': device.get('name')}) + # if 'size' in device: + disk_list.append({'size': device.get('size', default_volume_size), 'name': device.get('name')}) continue image_dict={} image_dict['name']=device.get('image name',flavor_dict['name']+str(dev_nb)+"-img") @@ -1086,6 +1087,9 @@ def new_vnfd_v3(mydb, tenant_id, vnf_descriptor): vnfd_id, vdu_id, iface.get("virtual-interface").get("type")), HTTP_Bad_Request) + if iface.get("mgmt-interface"): + db_interface["type"] = "mgmt" + if iface.get("external-connection-point-ref"): try: cp = vnfd.get("connection-point")[iface.get("external-connection-point-ref")] @@ -1302,6 +1306,7 @@ def new_vnfd_v3(mydb, tenant_id, vnf_descriptor): raise # NfvoException("Exception {}".format(e), HTTP_Bad_Request) +@deprecated("Use new_vnfd_v3") def new_vnf(mydb, tenant_id, vnf_descriptor): global global_config @@ -1439,6 +1444,7 @@ def new_vnf(mydb, tenant_id, vnf_descriptor): raise NfvoException(error_text, e.http_code) +@deprecated("Use new_vnfd_v3") def new_vnf_v02(mydb, tenant_id, vnf_descriptor): global global_config @@ -1739,6 +1745,7 @@ def delete_vnf(mydb,tenant_id,vnf_id,datacenter=None,vim_tenant=None): # return "delete_vnf. Undeleted: %s" %(undeletedItems) +@deprecated("Not used") def get_hosts_info(mydb, nfvo_tenant_id, datacenter_name=None): result, vims = get_vim(mydb, nfvo_tenant_id, None, datacenter_name) if result < 0: @@ -1789,6 +1796,7 @@ def get_hosts(mydb, nfvo_tenant_id): raise NfvoException("Not possible to get_host_list from VIM: {}".format(str(e)), e.http_code) +@deprecated("Use new_nsd_v3") def new_scenario(mydb, tenant_id, topo): # result, vims = get_vim(mydb, tenant_id) @@ -2070,6 +2078,7 @@ def new_scenario(mydb, tenant_id, topo): return c +@deprecated("Use new_nsd_v3") def new_scenario_v02(mydb, tenant_id, scenario_dict, version): """ This creates a new scenario for version 0.2 and 0.3""" scenario = scenario_dict["scenario"] @@ -2515,6 +2524,7 @@ def edit_scenario(mydb, tenant_id, scenario_id, data): return c +@deprecated("Use create_instance") def start_scenario(mydb, tenant_id, scenario_id, instance_scenario_name, instance_scenario_description, datacenter=None,vim_tenant=None, startvms=True): #print "Checking that nfvo_tenant_id exists and getting the VIM URI and the VIM tenant_id" datacenter_id, myvim = get_datacenter_by_name_uuid(mydb, tenant_id, datacenter, vim_tenant=vim_tenant) @@ -3692,6 +3702,8 @@ def instantiate_vnf(mydb, sce_vnf, params, params_out, rollbackList): netDict['vpci'] = iface['vpci'] if iface.get("mac"): netDict['mac_address'] = iface['mac'] + if iface.get("mac_address"): + netDict['mac_address'] = iface['mac_address'] if iface.get("ip_address"): netDict['ip_address'] = iface['ip_address'] if iface.get("port-security") is not None: @@ -4115,6 +4127,7 @@ def get_instance_id(mydb, tenant_id, instance_id): } return instance_dict +@deprecated("Instance is automatically refreshed by vim_threads") def refresh_instance(mydb, nfvo_tenant, instanceDict, datacenter=None, vim_tenant=None): '''Refreshes a scenario instance. It modifies instanceDict''' '''Returns: @@ -4665,7 +4678,7 @@ def edit_datacenter(mydb, datacenter_id_name, datacenter_descriptor): # edit data datacenter_id = datacenter['uuid'] - where={'uuid': datacenter['uuid']} + where = {'uuid': datacenter['uuid']} remove_port_mapping = False new_sdn_port_mapping = None if "config" in datacenter_descriptor: @@ -4675,10 +4688,10 @@ def edit_datacenter(mydb, datacenter_id_name, datacenter_descriptor): if "sdn-port-mapping" in new_config_dict: remove_port_mapping = True new_sdn_port_mapping = new_config_dict.pop("sdn-port-mapping") - #delete null fields - to_delete=[] + # delete null fields + to_delete = [] for k in new_config_dict: - if new_config_dict[k] == None: + if new_config_dict[k] is None: to_delete.append(k) if k == 'sdn-controller': remove_port_mapping = True @@ -4688,7 +4701,7 @@ def edit_datacenter(mydb, datacenter_id_name, datacenter_descriptor): config_text = '{}' config_dict = yaml.load(config_text) config_dict.update(new_config_dict) - #delete null fields + # delete null fields for k in to_delete: del config_dict[k] except Exception as e: @@ -4701,14 +4714,16 @@ def edit_datacenter(mydb, datacenter_id_name, datacenter_descriptor): try: datacenter_sdn_port_mapping_delete(mydb, None, datacenter_id) except ovimException as e: - logger.error("Error deleting datacenter-port-mapping " + str(e)) + raise NfvoException("Error deleting datacenter-port-mapping " + str(e), HTTP_Conflict) mydb.update_rows('datacenters', datacenter_descriptor, where) if new_sdn_port_mapping: try: datacenter_sdn_port_mapping_set(mydb, None, datacenter_id, new_sdn_port_mapping) except ovimException as e: - logger.error("Error adding datacenter-port-mapping " + str(e)) + # Rollback + mydb.update_rows('datacenters', datacenter, where) + raise NfvoException("Error adding datacenter-port-mapping " + str(e), HTTP_Conflict) return datacenter_id @@ -4719,7 +4734,7 @@ def delete_datacenter(mydb, datacenter): try: datacenter_sdn_port_mapping_delete(mydb, None, datacenter_dict['uuid']) except ovimException as e: - logger.error("Error deleting datacenter-port-mapping " + str(e)) + raise NfvoException("Error deleting datacenter-port-mapping " + str(e)) return datacenter_dict['uuid'] + " " + datacenter_dict['name']