From: tierno Date: Mon, 14 May 2018 11:09:33 +0000 (+0200) Subject: AWS vimconn: Allow config:flavor_data as str X-Git-Tag: v4.0.0~5 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=a357269d27ddc4853a32f571acac07781230ded7;p=osm%2FRO.git AWS vimconn: Allow config:flavor_data as str Change-Id: I292fd54c7f8604d42d27e26de2313d664068763a Signed-off-by: tierno --- diff --git a/openmanod b/openmanod index 27188d10..fab9d0a7 100755 --- a/openmanod +++ b/openmanod @@ -48,7 +48,7 @@ import osm_ro __author__ = "Alfonso Tierno, Gerardo Garcia, Pablo Montes" __date__ = "$26-aug-2014 11:09:29$" -__version__ = "0.5.62-r572" +__version__ = "0.5.63-r573" version_date = "May 2018" database_version = 31 # expected database schema version diff --git a/osm_ro/nfvo.py b/osm_ro/nfvo.py index 68037b95..d8cd9803 100644 --- a/osm_ro/nfvo.py +++ b/osm_ro/nfvo.py @@ -372,7 +372,10 @@ def get_vim(mydb, nfvo_tenant=None, datacenter_id=None, datacenter_name=None, da config=extra, persistent_info=persistent_info ) except Exception as e: - raise NfvoException("Error at VIM {}; {}: {}".format(vim["type"], type(e).__name__, str(e)), HTTP_Internal_Server_Error) + http_code = HTTP_Internal_Server_Error + if isinstance(e, vimconn.vimconnException): + http_code = e.http_code + raise NfvoException("Error at VIM {}; {}: {}".format(vim["type"], type(e).__name__, str(e)), http_code) return vim_dict except db_base_Exception as e: raise NfvoException(str(e) + " at nfvo.get_vim", e.http_code) @@ -4581,9 +4584,10 @@ def deassociate_datacenter_to_tenant(mydb, tenant_id, datacenter, vim_tenant_id= logger.error("Cannot delete datacenter_tenants " + str(e)) pass # the error will be caused because dependencies, vim_tenant can not be deleted thread_id = tenant_datacenter_item["datacenter_tenant_id"] - thread = vim_threads["running"][thread_id] - thread.insert_task("exit") - vim_threads["deleting"][thread_id] = thread + thread = vim_threads["running"].get(thread_id) + if thread: + thread.insert_task("exit") + vim_threads["deleting"][thread_id] = thread return "datacenter {} detached. {}".format(datacenter_id, warning) diff --git a/osm_ro/vimconn_aws.py b/osm_ro/vimconn_aws.py index 12b24118..e35318f2 100644 --- a/osm_ro/vimconn_aws.py +++ b/osm_ro/vimconn_aws.py @@ -78,7 +78,7 @@ class vimconnector(vimconn.vimconnector): if 'region_name' in config: self.region = config.get('region_name') else: - raise vimconn.vimconnNotFoundException("AWS region_name is not specified at config") + raise vimconn.vimconnException("AWS region_name is not specified at config") self.vpc_data = {} self.subnet_data = {} @@ -109,8 +109,11 @@ class vimconnector(vimconn.vimconnector): flavor_data = config.get('flavor_info') if isinstance(flavor_data, str): try: - with open(flavor_data[1:], 'r') as stream: - self.flavor_info = yaml.load(stream) + if flavor_data[0] == "@": # read from a file + with open(flavor_data[1:], 'r') as stream: + self.flavor_info = yaml.load(stream) + else: + self.flavor_info = yaml.load(flavor_data) except yaml.YAMLError as e: self.flavor_info = None raise vimconn.vimconnException("Bad format at file '{}': {}".format(flavor_data[1:], e))