+@bottle.route(url_base + '/<tenant_id>/vim_accounts', method='GET')
+@bottle.route(url_base + '/<tenant_id>/vim_accounts/<vim_account_id>', method='GET')
+def http_get_vim_account(tenant_id, vim_account_id=None):
+ '''get vim_account list/details, '''
+ logger.debug('FROM %s %s %s', bottle.request.remote_addr, bottle.request.method, bottle.request.url)
+ try:
+ select_ = ('uuid', 'name', 'dt.datacenter_id as vim_id', 'vim_tenant_name', 'vim_tenant_id', 'user', 'config',
+ 'dt.created_at as created_at', 'passwd')
+ where_ = {'nfvo_tenant_id': tenant_id}
+ if vim_account_id:
+ where_['dt.uuid'] = vim_account_id
+ from_ = 'tenants_datacenters as td join datacenter_tenants as dt on dt.uuid=td.datacenter_tenant_id'
+ vim_accounts = mydb.get_rows(SELECT=select_, FROM=from_, WHERE=where_)
+
+ if len(vim_accounts) == 0 and vim_account_id:
+ bottle.abort(HTTP_Not_Found, "No vim_account found for tenant {} and id '{}'".format(tenant_id,
+ vim_account_id))
+ for vim_account in vim_accounts:
+ if vim_account["passwd"]:
+ vim_account["passwd"] = "******"
+ if vim_account['config'] != None:
+ try:
+ config_dict = yaml.load(vim_account['config'])
+ vim_account['config'] = config_dict
+ if vim_account['config'].get('admin_password'):
+ vim_account['config']['admin_password'] = "******"
+ if vim_account['config'].get('vcenter_password'):
+ vim_account['config']['vcenter_password'] = "******"
+ if vim_account['config'].get('nsx_password'):
+ vim_account['config']['nsx_password'] = "******"
+ except Exception as e:
+ logger.error("Exception '%s' while trying to load config information", str(e))
+ # change_keys_http2db(content, http2db_datacenter, reverse=True)
+ #convert_datetime2str(vim_account)
+ if vim_account_id:
+ return format_out({"datacenter": vim_accounts[0]})
+ else:
+ return format_out({"datacenters": vim_accounts})
+ except bottle.HTTPError:
+ raise
+ except (nfvo.NfvoException, db_base_Exception) as e:
+ logger.error("http_get_datacenter_id error {}: {}".format(e.http_code, str(e)))
+ bottle.abort(e.http_code, str(e))
+ except Exception as e:
+ logger.error("Unexpected exception: ", exc_info=True)
+ bottle.abort(HTTP_Internal_Server_Error, type(e).__name__ + ": " + str(e))
+
+