From: tierno Date: Wed, 26 Apr 2017 11:23:09 +0000 (+0200) Subject: Fix error at creating vm_thread adding a datacenter X-Git-Tag: v2.0.0^0 X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FRO.git;a=commitdiff_plain;h=99314908f1e270c682b3402491b227db71d59545 Fix error at creating vm_thread adding a datacenter Change-Id: I92ed023d9f5d08abe79b86448ae633c85de09153 Signed-off-by: tierno --- diff --git a/openmanod b/openmanod index 190f7e3b..8ad0af7f 100755 --- a/openmanod +++ b/openmanod @@ -22,7 +22,7 @@ # contact with: nfvlabs@tid.es ## -''' +""" openmano server. Main program that implements a reference NFVO (Network Functions Virtualisation Orchestrator). It interfaces with an NFV VIM through its API and offers a northbound interface, based on REST (openmano API), @@ -30,12 +30,7 @@ where NFV services are offered including the creation and deletion of VNF templa network service templates and network service instances. It loads the configuration file and launches the http_server thread that will listen requests using openmano API. -''' -__author__="Alfonso Tierno, Gerardo Garcia, Pablo Montes" -__date__ ="$26-aug-2014 11:09:29$" -__version__="0.5.10-r520" -version_date="Apr 2017" -database_version="0.20" #expected database schema version +""" import time import sys @@ -50,6 +45,12 @@ from osm_ro.openmano_schemas import config_schema from osm_ro.db_base import db_base_Exception import osm_ro +__author__="Alfonso Tierno, Gerardo Garcia, Pablo Montes" +__date__ ="$26-aug-2014 11:09:29$" +__version__="0.5.11-r521" +version_date="Apr 2017" +database_version="0.20" #expected database schema version + global global_config global logger diff --git a/osm_ro/nfvo.py b/osm_ro/nfvo.py index 2692a150..06af5379 100644 --- a/osm_ro/nfvo.py +++ b/osm_ro/nfvo.py @@ -2861,18 +2861,22 @@ def associate_datacenter_to_tenant(mydb, nfvo_tenant, datacenter, vim_tenant_id= datacenter_tenants_dict["uuid"] = id_ #fill tenants_datacenters table - tenants_datacenter_dict["datacenter_tenant_id"]=datacenter_tenants_dict["uuid"] + datacenter_tenant_id = datacenter_tenants_dict["uuid"] + tenants_datacenter_dict["datacenter_tenant_id"] = datacenter_tenant_id mydb.new_row('tenants_datacenters', tenants_datacenter_dict) # create thread datacenter_id, myvim = get_datacenter_by_name_uuid(mydb, tenant_dict['uuid'], datacenter_id) # reload data thread_name = get_non_used_vim_name(datacenter_name, datacenter_id, tenant_dict['name'], tenant_dict['uuid']) - new_thread = vim_thread.vim_thread(myvim, task_lock, thread_name, datacenter_name, db=db, db_lock=db_lock, ovim=ovim) + new_thread = vim_thread.vim_thread(myvim, task_lock, thread_name, datacenter_name, datacenter_tenant_id, + db=db, db_lock=db_lock, ovim=ovim) new_thread.start() thread_id = datacenter_tenants_dict["uuid"] vim_threads["running"][thread_id] = new_thread return datacenter_id -def edit_datacenter_to_tenant(mydb, nfvo_tenant, datacenter_id, vim_tenant_id=None, vim_tenant_name=None, vim_username=None, vim_password=None, config=None): + +def edit_datacenter_to_tenant(mydb, nfvo_tenant, datacenter_id, vim_tenant_id=None, vim_tenant_name=None, + vim_username=None, vim_password=None, config=None): #Obtain the data of this datacenter_tenant_id vim_data = mydb.get_rows( SELECT=("datacenter_tenants.vim_tenant_name", "datacenter_tenants.vim_tenant_id", "datacenter_tenants.user", diff --git a/osm_ro/vim_thread.py b/osm_ro/vim_thread.py index a56dd641..373fe7bf 100644 --- a/osm_ro/vim_thread.py +++ b/osm_ro/vim_thread.py @@ -21,12 +21,10 @@ # contact with: nfvlabs@tid.es ## -''' +"""" This is thread that interact with the host and the libvirt to manage VM One thread will be launched per host -''' -__author__ = "Alfonso Tierno, Pablo Montes" -__date__ = "$10-feb-2017 12:07:15$" +""" import threading import time @@ -36,18 +34,21 @@ import vimconn from db_base import db_base_Exception from lib_osm_openvim.ovim import ovimException +__author__ = "Alfonso Tierno, Pablo Montes" +__date__ = "$10-feb-2017 12:07:15$" # from logging import Logger # import auxiliary_functions as af -def is_task_id(id): - return True if id[:5] == "TASK." else False +def is_task_id(task_id): + return True if task_id[:5] == "TASK." else False class vim_thread(threading.Thread): - def __init__(self, vimconn, task_lock, name=None, datacenter_name=None, datacenter_tenant_id=None, db=None, db_lock=None, ovim=None): + def __init__(self, vimconn, task_lock, name=None, datacenter_name=None, datacenter_tenant_id=None, + db=None, db_lock=None, ovim=None): """Init a thread. Arguments: 'id' number of thead @@ -147,7 +148,7 @@ class vim_thread(threading.Thread): self.logger.error("ovimException deleting external_port={} ".format( task_interface["sdn_port_id"]) + str(e), exc_info=True) # TODO Set error_msg at instance_nets - vim_net_id = interface.pop("vim_net_id") + vim_net_id = interface["vim_net_id"] sdn_net_id = None sdn_port_name = None with self.db_lock: @@ -195,10 +196,11 @@ class vim_thread(threading.Thread): exc_info=True) # TODO Set error_msg at instance_nets with self.db_lock: + vim_net_id = interface.pop("vim_net_id") self.db.update_rows('instance_interfaces', UPDATE=interface, WHERE={'uuid': db_iface["iface_id"]}) + interface["vim_net_id"] = vim_net_id # TODO insert instance_id - interface["vim_net_id"] = vim_net_id task["vim_info"] = vim_info if task["vim_info"]["status"] == "BUILD":