X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=inline;f=osm_ro%2Fnfvo.py;h=5edd55f1118660be16d4b8aa0a433a08023a6335;hb=79d1a1a9ed0b952750af7f8701da7e525b4715fd;hp=bd9d3689f173df9330822865e4fc88cc6e14bb31;hpb=66eba6ece53cd85d0efbe8b4ff4f414c812b347b;p=osm%2FRO.git diff --git a/osm_ro/nfvo.py b/osm_ro/nfvo.py index bd9d3689..5edd55f1 100644 --- a/osm_ro/nfvo.py +++ b/osm_ro/nfvo.py @@ -621,7 +621,7 @@ def create_or_use_image(mydb, vims, image_dict, rollback_list, only_create_at_vi def create_or_use_flavor(mydb, vims, flavor_dict, rollback_list, only_create_at_vim=False, return_on_error = None): - temp_flavor_dict= {'disk':flavor_dict.get('disk',1), + temp_flavor_dict= {'disk':flavor_dict.get('disk',0), 'ram':flavor_dict.get('ram'), 'vcpus':flavor_dict.get('vcpus'), } @@ -884,6 +884,11 @@ def new_vnfd_v3(mydb, tenant_id, vnf_descriptor): net_id2uuid[vld.get("id")] = net_uuid db_nets.append(db_net) + # connection points vaiable declaration + cp_name2iface_uuid = {} + cp_name2vm_uuid = {} + cp_name2db_interface = {} + # table vms (vdus) vdu_id2uuid = {} vdu_id2db_table_index = {} @@ -968,9 +973,6 @@ def new_vnfd_v3(mydb, tenant_id, vnf_descriptor): # table interfaces (internal/external interfaces) flavor_epa_interfaces = [] - cp_name2iface_uuid = {} - cp_name2vm_uuid = {} - cp_name2db_interface = {} vdu_id2cp_name = {} # stored only when one external connection point is presented at this VDU # for iface in chain(vdu.get("internal-interface").itervalues(), vdu.get("external-interface").itervalues()): for iface in vdu.get("interface").itervalues(): @@ -1046,7 +1048,7 @@ def new_vnfd_v3(mydb, tenant_id, vnf_descriptor): if cp.get("id-ref") == iface.get("internal-connection-point-ref"): db_interface["net_id"] = net_id2uuid[vld.get("id")] for cp_descriptor in vnfd_descriptor["connection-point"]: - if cp_descriptor["name"] == db_interface["external_name"]: + if cp_descriptor["name"] == db_interface["internal_name"]: break if str(cp_descriptor.get("port-security-enabled")).lower() == "false": db_interface["port_security"] = 0 @@ -1055,10 +1057,10 @@ def new_vnfd_v3(mydb, tenant_id, vnf_descriptor): break except KeyError: raise NfvoException("Error. Invalid VNF descriptor at 'vnfd[{vnf}]':'vdu[{vdu}]':" - "'interface[{iface}]':'vdu-internal-connection-point-ref':'{cp}' is not" + "'interface[{iface}]':'internal-connection-point-ref':'{cp}' is not" " referenced by any internal-vld".format( vnf=vnfd_id, vdu=vdu_id, iface=iface["name"], - cp=iface.get("vdu-internal-connection-point-ref")), + cp=iface.get("internal-connection-point-ref")), HTTP_Bad_Request) if iface.get("position") is not None: db_interface["created_at"] = int(iface.get("position")) - 1000 @@ -1069,9 +1071,9 @@ def new_vnfd_v3(mydb, tenant_id, vnf_descriptor): "name": get_str(vdu, "name", 250) + "-flv", "vcpus": int(vdu["vm-flavor"].get("vcpu-count", 1)), "ram": int(vdu["vm-flavor"].get("memory-mb", 1)), - "disk": int(vdu["vm-flavor"].get("storage-gb", 1)), + "disk": int(vdu["vm-flavor"].get("storage-gb", 0)), } - # EPA TODO revise + # TODO revise the case of several numa-node-policy node extended = {} numa = {} if devices: @@ -1083,7 +1085,7 @@ def new_vnfd_v3(mydb, tenant_id, vnf_descriptor): if vdu["guest-epa"].get("numa-node-policy"): # TODO or dedicated_int: numa_node_policy = vdu["guest-epa"].get("numa-node-policy") if numa_node_policy.get("node"): - numa_node = numa_node_policy["node"]['0'] + numa_node = numa_node_policy["node"].values()[0] if numa_node.get("num-cores"): numa["cores"] = numa_node["num-cores"] epa_vcpu_set = True @@ -1118,7 +1120,7 @@ def new_vnfd_v3(mydb, tenant_id, vnf_descriptor): extended_text = yaml.safe_dump(extended, default_flow_style=True, width=256) db_flavor["extended"] = extended_text # look if flavor exist - temp_flavor_dict = {'disk': db_flavor.get('disk', 1), + temp_flavor_dict = {'disk': db_flavor.get('disk', 0), 'ram': db_flavor.get('ram'), 'vcpus': db_flavor.get('vcpus'), 'extended': db_flavor.get('extended') @@ -1260,7 +1262,7 @@ def new_vnf(mydb, tenant_id, vnf_descriptor): myflavorDict["description"] = VNFCitem["description"] myflavorDict["ram"] = vnfc.get("ram", 0) myflavorDict["vcpus"] = vnfc.get("vcpus", 0) - myflavorDict["disk"] = vnfc.get("disk", 1) + myflavorDict["disk"] = vnfc.get("disk", 0) myflavorDict["extended"] = {} devices = vnfc.get("devices") @@ -1396,7 +1398,7 @@ def new_vnf_v02(mydb, tenant_id, vnf_descriptor): myflavorDict["description"] = VNFCitem["description"] myflavorDict["ram"] = vnfc.get("ram", 0) myflavorDict["vcpus"] = vnfc.get("vcpus", 0) - myflavorDict["disk"] = vnfc.get("disk", 1) + myflavorDict["disk"] = vnfc.get("disk", 0) myflavorDict["extended"] = {} devices = vnfc.get("devices") @@ -4339,29 +4341,35 @@ def vim_action_create(mydb, tenant_id, datacenter, item, descriptor): #If the datacenter has a SDN controller defined and the network is of dataplane type, then create the sdn network if get_sdn_controller_id(mydb, datacenter) != None and (net_type == 'data' or net_type == 'ptp'): + #obtain datacenter_tenant_id + datacenter_tenant_id = mydb.get_rows(SELECT=('uuid',), + FROM='datacenter_tenants', + WHERE={'datacenter_id': datacenter})[0]['uuid'] try: sdn_network = {} sdn_network['vlan'] = net_vlan sdn_network['type'] = net_type sdn_network['name'] = net_name + sdn_network['region'] = datacenter_tenant_id ovim_content = ovim.new_network(sdn_network) except ovimException as e: - self.logger.error("ovimException creating SDN network={} ".format( + logger.error("ovimException creating SDN network={} ".format( sdn_network) + str(e), exc_info=True) raise NfvoException("ovimException creating SDN network={} ".format(sdn_network) + str(e), HTTP_Internal_Server_Error) # Save entry in in dabase mano_db in table instance_nets to stablish a dictionary vim_net_id <->sdn_net_id # use instance_scenario_id=None to distinguish from real instaces of nets - correspondence = {'instance_scenario_id': None, 'sdn_net_id': ovim_content, 'vim_net_id': content} - #obtain datacenter_tenant_id - correspondence['datacenter_tenant_id'] = mydb.get_rows(SELECT=('uuid',), FROM='datacenter_tenants', WHERE={'datacenter_id': datacenter})[0]['uuid'] - + correspondence = {'instance_scenario_id': None, + 'sdn_net_id': ovim_content, + 'vim_net_id': content, + 'datacenter_tenant_id': datacenter_tenant_id + } try: mydb.new_row('instance_nets', correspondence, add_uuid=True) except db_base_Exception as e: - raise NfvoException("Error saving correspondence for VIM/SDN dataplane networks{}: ".format(correspondence) + - str(e), HTTP_Internal_Server_Error) + raise NfvoException("Error saving correspondence for VIM/SDN dataplane networks{}: {}".format( + correspondence, e), HTTP_Internal_Server_Error) elif item=="tenants": tenant = descriptor["tenant"] content = myvim.new_tenant(tenant["name"], tenant.get("description"))