# -*- 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.
#
# 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
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")
raise # NfvoException("Exception {}".format(e), HTTP_Bad_Request)
+@deprecated("Use new_vnfd_v3")
def new_vnf(mydb, tenant_id, vnf_descriptor):
global global_config
raise NfvoException(error_text, e.http_code)
+@deprecated("Use new_vnfd_v3")
def new_vnf_v02(mydb, tenant_id, vnf_descriptor):
global global_config
# 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:
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)
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"]
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)
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:
}
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:
# 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:
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
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:
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
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']