- module = "vimconn_" + vim["type"]
- module_info = imp.find_module(module)
- vim_conn = imp.load_module(vim["type"], *module_info)
- vimconn_imported[vim["type"]] = vim_conn
- except (IOError, ImportError) as e:
- if module_info and module_info[0]:
- file.close(module_info[0])
- print "Cannot open VIM module '%s.py'; %s: %s" % ( module, type(e).__name__, str(e))
- return -HTTP_Bad_Request, "Unknown vim type %s" % vim["type"]
-
- try:
- #if not tenant:
- # return -HTTP_Bad_Request, "You must provide a valid tenant name or uuid for VIM %s" % ( vim["type"])
- vim_dict[ vim['datacenter_id'] ] = vimconn_imported[ vim["type"] ].vimconnector(
- uuid=vim['datacenter_id'], name=vim['datacenter_name'],
- tenant_id=vim.get('vim_tenant_id'), tenant_name=vim.get('vim_tenant_name'),
- url=vim['vim_url'], url_admin=vim['vim_url_admin'],
- user=vim.get('user'), passwd=vim.get('passwd'),
- config=extra
- )
- except Exception as e:
- return -HTTP_Internal_Server_Error, "Error at VIM %s; %s: %s" % ( vim["type"], type(e).__name__, str(e))
- return len(vim_dict), vim_dict
-
+ #if not tenant:
+ # return -HTTP_Bad_Request, "You must provide a valid tenant name or uuid for VIM %s" % ( vim["type"])
+ vim_dict[ vim['datacenter_id'] ] = vimconn_imported[ vim["type"] ].vimconnector(
+ uuid=vim['datacenter_id'], name=vim['datacenter_name'],
+ tenant_id=vim.get('vim_tenant_id'), tenant_name=vim.get('vim_tenant_name'),
+ url=vim['vim_url'], url_admin=vim['vim_url_admin'],
+ user=vim.get('user'), passwd=vim.get('passwd'),
+ config=extra
+ )
+ except Exception as e:
+ raise NfvoException("Error at VIM {}; {}: {}".format(vim["type"], type(e).__name__, str(e)), HTTP_Internal_Server_Error)
+ return vim_dict
+ except db_base_Exception as e:
+ raise NfvoException(str(e) + " at nfvo.get_vim", e.http_code)
+