what = 'uuid' if utils.check_valid_uuid(datacenter_id) else 'name'
where_={}
where_[what] = datacenter_id
- select_=['uuid', 'name','vim_url', 'vim_url_admin', 'type', 'config', 'description', 'd.created_at as created_at']
+ select_=['uuid', 'name','vim_url', 'vim_url_admin', 'type', 'd.config as config', 'description', 'd.created_at as created_at']
if tenant_id != 'any':
select_.append("datacenter_tenant_id")
where_['td.nfvo_tenant_id']= tenant_id
if tenant_id != 'any':
#get vim tenant info
vim_tenants = mydb.get_rows(
- SELECT=("vim_tenant_name", "vim_tenant_id", "user"),
+ SELECT=("vim_tenant_name", "vim_tenant_id", "user", "passwd", "config"),
FROM="datacenter_tenants",
WHERE={"uuid": datacenters[0]["datacenter_tenant_id"]},
ORDER_BY=("created", ) )
del datacenter["datacenter_tenant_id"]
datacenter["vim_tenants"] = vim_tenants
-
+ for vim_tenant in vim_tenants:
+ if vim_tenant["passwd"]:
+ vim_tenant["passwd"] = "******"
+ if vim_tenant['config'] != None:
+ try:
+ config_dict = yaml.load(vim_tenant['config'])
+ vim_tenant['config'] = config_dict
+ except Exception as e:
+ logger.error("Exception '%s' while trying to load config information", str(e))
+
if datacenter['config'] != None:
try:
config_dict = yaml.load(datacenter['config'])
datacenter['config'] = config_dict
- except Exception, e:
+ 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(datacenter)
http_content['datacenter'].get('vim_tenant'),
http_content['datacenter'].get('vim_tenant_name'),
http_content['datacenter'].get('vim_username'),
- http_content['datacenter'].get('vim_password')
- )
+ http_content['datacenter'].get('vim_password'),
+ http_content['datacenter'].get('config')
+ )
return http_get_datacenter_id(tenant_id, id_)
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_associate_datacenters error {}: {}".format(e.http_code, str(e)))
def http_post_scenario_action(tenant_id, scenario_id):
'''take an action over a scenario'''
logger.debug('FROM %s %s %s', bottle.request.remote_addr, bottle.request.method, bottle.request.url)
- #check valid tenant_id
+ # parse input data
+ http_content, _ = format_in(scenario_action_schema)
+ r = utils.remove_extra_items(http_content, scenario_action_schema)
+ if r:
+ logger.debug("Remove received extra items %s", str(r))
try:
- nfvo.check_tenant(mydb, tenant_id)
- #parse input data
- http_content,_ = format_in( scenario_action_schema )
- r = utils.remove_extra_items(http_content, scenario_action_schema)
- if r:
- logger.debug("Remove received extra items %s", str(r))
+ # check valid tenant_id
+ nfvo.check_tenant(mydb, tenant_id)
if "start" in http_content:
data = nfvo.start_scenario(mydb, tenant_id, scenario_id, http_content['start']['instance_name'], \
http_content['start'].get('description',http_content['start']['instance_name']),
@bottle.route(url_base + '/<tenant_id>/scenarios/<scenario_id>', method='DELETE')
def http_delete_scenario_id(tenant_id, scenario_id):
'''delete a scenario from database, can use both uuid or name'''
+ logger.debug('FROM %s %s %s', bottle.request.remote_addr, bottle.request.method, bottle.request.url)
try:
#check valid tenant_id
if tenant_id != "any":
- nfvo.check_tenant(mydb, tenant_id)
+ nfvo.check_tenant(mydb, tenant_id)
#obtain data
data = mydb.delete_scenario(scenario_id, tenant_id)
#print json.dumps(data, indent=4)
def http_post_instances(tenant_id):
'''create an instance-scenario'''
logger.debug('FROM %s %s %s', bottle.request.remote_addr, bottle.request.method, bottle.request.url)
+ # parse input data
+ http_content, used_schema = format_in(instance_scenario_create_schema_v01)
+ r = utils.remove_extra_items(http_content, used_schema)
+ if r is not None:
+ logger.warning("http_post_instances: Warning: remove extra items %s", str(r))
try:
#check valid tenant_id
if tenant_id != "any":
nfvo.check_tenant(mydb, tenant_id)
- #parse input data
- http_content,used_schema = format_in( instance_scenario_create_schema_v01)
- r = utils.remove_extra_items(http_content, used_schema)
- if r is not None:
- logger.warning("http_post_instances: Warning: remove extra items %s", str(r))
data = nfvo.create_instance(mydb, tenant_id, http_content["instance"])
return format_out(data)
except (nfvo.NfvoException, db_base_Exception) as e:
def http_post_instance_scenario_action(tenant_id, instance_id):
'''take an action over a scenario instance'''
logger.debug('FROM %s %s %s', bottle.request.remote_addr, bottle.request.method, bottle.request.url)
+ # parse input data
+ http_content, _ = format_in(instance_scenario_action_schema)
+ r = utils.remove_extra_items(http_content, instance_scenario_action_schema)
+ if r:
+ logger.debug("Remove received extra items %s", str(r))
try:
#check valid tenant_id
if tenant_id != "any":
nfvo.check_tenant(mydb, tenant_id)
- #parse input data
- http_content,_ = format_in( instance_scenario_action_schema )
- r = utils.remove_extra_items(http_content, instance_scenario_action_schema)
- if r:
- logger.debug("Remove received extra items %s", str(r))
#print "http_post_instance_scenario_action input: ", http_content
#obtain data
instance = mydb.get_instance_scenario(instance_id, tenant_id)