__author__ = "Alfonso Tierno, Gerardo Garcia, Pablo Montes"
__date__ = "$26-aug-2014 11:09:29$"
-__version__ = "0.5.44-r554"
+__version__ = "0.5.45-r555"
version_date = "Nov 2017"
database_version = 27 # expected database schema version
#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"))
if to_supersede["action"] == "FIND" and to_supersede.get("vim_id"):
task["vim_id"] = to_supersede["vim_id"]
if to_supersede["action"] == "CREATE" and to_supersede["extra"].get("created", True) and \
- (to_supersede.get("vim_id") or to_supersede["extra"].get("sdn_vim_id")):
+ (to_supersede.get("vim_id") or to_supersede["extra"].get("sdn_net_id")):
need_delete_action = True
task["vim_id"] = to_supersede["vim_id"]
- if to_supersede["extra"].get("sdn_vim_id"):
- task["extra"]["sdn_vim_id"] = to_supersede["extra"]["sdn_vim_id"]
+ if to_supersede["extra"].get("sdn_net_id"):
+ task["extra"]["sdn_net_id"] = to_supersede["extra"]["sdn_net_id"]
if to_supersede["extra"].get("interfaces"):
task["extra"]["interfaces"] = to_supersede["extra"]["interfaces"]
if to_supersede["extra"].get("created_items"):
"""
vim_nets = self.vim.get_network_list(filter_param)
if not vim_nets:
- raise VimThreadExceptionNotFound("Network not found with this criteria: '{}'".format(filter))
+ raise VimThreadExceptionNotFound("Network not found with this criteria: '{}'".format(filter_param))
elif len(vim_nets) > 1:
- raise VimThreadException("More than one network found with this criteria: '{}'".format(filter))
+ raise VimThreadException("More than one network found with this criteria: '{}'".format(filter_param))
vim_net_id = vim_nets[0]["id"]
# Discover if this network is managed by a sdn controller
task["error_msg"] = None
task["vim_id"] = vim_net_id
instance_element_update = {"vim_net_id": vim_net_id, "created": False, "status": "BUILD",
- "error_msg": None}
+ "error_msg": None, "sdn_net_id": sdn_net_id}
return instance_element_update
def get_net(self, task):
supportedClassificationTypes = ['legacy_flow_classifier']
#global var to have a timeout creating and deleting volumes
-volume_timeout = 60
-server_timeout = 300
+volume_timeout = 600
+server_timeout = 600
class vimconnector(vimconn.vimconnector):
def __init__(self, uuid, name, tenant_id, tenant_name, url, url_admin=None, user=None, passwd=None,
self._reload_connection()
if self.api_version3 and "tenant_id" in filter_dict:
filter_dict['project_id'] = filter_dict.pop('tenant_id') #TODO check
- net_dict=self.neutron.list_networks(**filter_dict)
- net_list=net_dict["networks"]
+ net_dict = self.neutron.list_networks(**filter_dict)
+ net_list = net_dict["networks"]
self.__net_os2mano(net_list)
return net_list
except (neExceptions.ConnectionFailed, ksExceptions.ClientException, neExceptions.NeutronException, ConnectionError) as e:
if net.get("mac_address"):
port_dict["mac_address"]=net["mac_address"]
new_port = self.neutron.create_port({"port": port_dict })
- created_items[("port", str(new_port["port"]["id"]))] = True
+ created_items["port:" + str(new_port["port"]["id"])] = True
net["mac_adress"] = new_port["port"]["mac_address"]
net["vim_id"] = new_port["port"]["id"]
# if try to use a network without subnetwork, it will return a emtpy list
else:
volume = self.cinder.volumes.create(size=disk['size'], name=name + '_vd' +
chr(base_disk_index))
- created_items[("volume", str(volume.id))] = True
+ created_items["volume:" + str(volume.id)] = True
block_device_mapping['_vd' + chr(base_disk_index)] = volume.id
base_disk_index += 1
if not v: # skip already deleted
continue
try:
- if k[0] == "port":
- self.neutron.delete_port(k[1])
+ if k.startswith("port:"):
+ self.neutron.delete_port(k.strip("port:"))
except Exception as e:
- self.logger.error("Error deleting port: " + type(e).__name__ + ": "+ str(e))
+ self.logger.error("Error deleting port: {}: {}".format(type(e).__name__, e))
# #commented because detaching the volumes makes the servers.delete not work properly ?!?
# #dettach volumes attached
if not v: # skip already deleted
continue
try:
- if k[0] == "volume":
- if self.cinder.volumes.get(k[1]).status != 'available':
+ if k.startswith("volume:"):
+ volume_id = k.strip("volume:")
+ if self.cinder.volumes.get(volume_id).status != 'available':
keep_waiting = True
else:
- self.cinder.volumes.delete(k[1])
+ self.cinder.volumes.delete(volume_id)
except Exception as e:
- self.logger.error("Error deleting volume: " + type(e).__name__ + ": " + str(e))
+ self.logger.error("Error deleting volume: {}: {}".format(type(e).__name__, e))
if keep_waiting:
time.sleep(1)
elapsed_time += 1