__author__ = "Alfonso Tierno, Gerardo Garcia, Pablo Montes"
__date__ = "$26-aug-2014 11:09:29$"
-__version__ = "0.5.31-r541"
+__version__ = "0.5.32-r542"
version_date = "Oct 2017"
database_version = 27 # expected database schema version
select_, where_, limit_ = filter_query_string(bottle.request.query, None,
('uuid', 'name', 'description', 'created_at'))
where_['uuid'] = tenant_id
- tenant = mydb.get_rows(FROM=from_, SELECT=select_,WHERE=where_)
+ tenants = mydb.get_rows(FROM=from_, SELECT=select_,WHERE=where_)
#change_keys_http2db(content, http2db_tenant, reverse=True)
- convert_datetime2str(tenant)
- data={'tenant' : tenant}
+ convert_datetime2str(tenants)
+ data = {'tenant' : tenants[0]}
return format_out(data)
except db_base_Exception as e:
logger.error("http_get_tenant_id error {}: {}".format(e.http_code, str(e)))
user=vim['user'], passwd=vim['passwd'],
config=extra, persistent_info=vim_persistent_info[thread_id]
)
+ except vimconn.vimconnException as e:
+ myvim = e
+ logger.error("Cannot launch thread for VIM {} '{}': {}".format(vim['datacenter_name'],
+ vim['datacenter_id'], e))
except Exception as e:
raise NfvoException("Error at VIM {}; {}: {}".format(vim["type"], type(e).__name__, e),
HTTP_Internal_Server_Error)
def associate_datacenter_to_tenant(mydb, nfvo_tenant, datacenter, vim_tenant_id=None, vim_tenant_name=None, vim_username=None, vim_password=None, config=None):
- #get datacenter info
- datacenter_id, myvim = get_datacenter_by_name_uuid(mydb, None, datacenter, vim_user=vim_username, vim_passwd=vim_password)
- datacenter_name = myvim["name"]
+ # get datacenter info
+ datacenter_id = get_datacenter_uuid(mydb, None, datacenter)
create_vim_tenant = True if not vim_tenant_id and not vim_tenant_name else False
else: #if vim_tenant_id==None:
#create tenant at VIM if not provided
try:
+ _, myvim = get_datacenter_by_name_uuid(mydb, None, datacenter, vim_user=vim_username,
+ vim_passwd=vim_password)
+ datacenter_name = myvim["name"]
vim_tenant_id = myvim.new_tenant(vim_tenant_name, "created by openmano for datacenter "+datacenter_name)
except vimconn.vimconnException as e:
raise NfvoException("Not possible to create vim_tenant {} at VIM: {}".format(vim_tenant_id, str(e)), HTTP_Internal_Server_Error)
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
+ datacenter_name = myvim["name"]
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, datacenter_tenant_id,
db=db, db_lock=db_lock, ovim=ovim)
REFRESH_BUILD = 5 # 5 seconds
REFRESH_ACTIVE = 60 # 1 minute
- def __init__(self, vimconn, task_lock, name=None, datacenter_name=None, datacenter_tenant_id=None,
+ def __init__(self, myvimconn, task_lock, name=None, datacenter_name=None, datacenter_tenant_id=None,
db=None, db_lock=None, ovim=None):
"""Init a thread.
Arguments:
'db', 'db_lock': database class and lock to use it in exclusion
"""
threading.Thread.__init__(self)
- self.vim = vimconn
+ if isinstance(myvimconn, vimconn.vimconnException):
+ self.vim = None
+ self.error_status = "Error accesing to VIM: {}".format(myvimconn)
+ else:
+ self.vim = myvimconn
+ self.error_status = None
self.datacenter_name = datacenter_name
self.datacenter_tenant_id = datacenter_tenant_id
self.ovim = ovim
"""Insert a task at list of refreshing elements. The refreshing list is ordered by threshold_time (task['modified_at']
It is assumed that this is called inside this thread
"""
+ if not self.vim:
+ return
if not threshold_time:
threshold_time = time.time()
task["modified_at"] = threshold_time
# not needed to do anything but update database with the new status
result = True
database_update = None
+ elif not self.vim:
+ task["status"] == "ERROR"
+ task["error_msg"] = self.error_status
+ result = False
+ database_update = {"status": "VIM_ERROR", "error_msg": task["error_msg"]}
elif task["item"] == 'instance_vms':
if task["action"] == "CREATE":
result, database_update = self.new_vm(task)