convert_datetime2str(tenants)
data={'tenants' : tenants}
return format_out(data)
+ except bottle.HTTPError:
+ raise
except db_base_Exception as e:
logger.error("http_get_tenants error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
from_ = 'nfvo_tenants'
select_, where_, limit_ = filter_query_string(bottle.request.query, None,
('uuid', 'name', 'description', 'created_at'))
- where_['uuid'] = tenant_id
+ what = 'uuid' if utils.check_valid_uuid(tenant_id) else 'name'
+ where_[what] = tenant_id
tenants = mydb.get_rows(FROM=from_, SELECT=select_,WHERE=where_)
#change_keys_http2db(content, http2db_tenant, reverse=True)
- convert_datetime2str(tenants)
- data = {'tenant' : tenants[0]}
+ if len(tenants) == 0:
+ bottle.abort(HTTP_Not_Found, "No tenant found with {}='{}'".format(what, tenant_id))
+ elif len(tenants) > 1:
+ bottle.abort(HTTP_Bad_Request, "More than one tenant found with {}='{}'".format(what, tenant_id))
+ convert_datetime2str(tenants[0])
+ data = {'tenant': tenants[0]}
return format_out(data)
+ except bottle.HTTPError:
+ raise
except db_base_Exception as e:
logger.error("http_get_tenant_id error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
try:
data = nfvo.new_tenant(mydb, http_content['tenant'])
return http_get_tenant_id(data)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_post_tenants error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
where={'uuid': tenant['uuid']}
mydb.update_rows('nfvo_tenants', http_content['tenant'], where)
return http_get_tenant_id(tenant_id)
+ except bottle.HTTPError:
+ raise
except db_base_Exception as e:
logger.error("http_edit_tenant_id error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
try:
data = nfvo.delete_tenant(mydb, tenant_id)
return format_out({"result":"tenant " + data + " deleted"})
+ except bottle.HTTPError:
+ raise
except db_base_Exception as e:
logger.error("http_delete_tenant_id error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
convert_datetime2str(datacenters)
data={'datacenters' : datacenters}
return format_out(data)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_get_datacenters error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
convert_datetime2str(datacenter)
data={'datacenter' : datacenter}
return format_out(data)
+ 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))
try:
data = nfvo.new_datacenter(mydb, http_content['datacenter'])
return http_get_datacenter_id('any', data)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_post_datacenters error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
try:
datacenter_id = nfvo.edit_datacenter(mydb, datacenter_id_name, http_content['datacenter'])
return http_get_datacenter_id('any', datacenter_id)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_edit_datacenter_id error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
data = nfvo.sdn_controller_create(mydb, tenant_id, http_content['sdn_controller'])
return format_out({"sdn_controller": nfvo.sdn_controller_list(mydb, tenant_id, data)})
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_post_sdn_controller error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
data = nfvo.sdn_controller_update(mydb, tenant_id, controller_id, http_content['sdn_controller'])
return format_out({"sdn_controller": nfvo.sdn_controller_list(mydb, tenant_id, controller_id)})
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_post_sdn_controller error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
data = {'sdn_controllers': nfvo.sdn_controller_list(mydb, tenant_id)}
return format_out(data)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_get_sdn_controller error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
logger.debug('FROM %s %s %s', bottle.request.remote_addr, bottle.request.method, bottle.request.url)
data = nfvo.sdn_controller_list(mydb, tenant_id, controller_id)
return format_out({"sdn_controllers": data})
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_get_sdn_controller_id error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
logger.debug('FROM %s %s %s', bottle.request.remote_addr, bottle.request.method, bottle.request.url)
data = nfvo.sdn_controller_delete(mydb, tenant_id, controller_id)
return format_out(data)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_delete_sdn_controller_id error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
try:
data = nfvo.datacenter_sdn_port_mapping_set(mydb, tenant_id, datacenter_id, http_content['sdn_port_mapping'])
return format_out({"sdn_port_mapping": data})
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_post_datacenter_sdn_port_mapping error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
data = nfvo.datacenter_sdn_port_mapping_list(mydb, tenant_id, datacenter_id)
return format_out({"sdn_port_mapping": data})
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_get_datacenter_sdn_port_mapping error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
logger.debug('FROM %s %s %s', bottle.request.remote_addr, bottle.request.method, bottle.request.url)
data = nfvo.datacenter_sdn_port_mapping_delete(mydb, tenant_id, datacenter_id)
return format_out({"result": data})
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_delete_datacenter_sdn_port_mapping error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
else:
data={'netmaps' : netmaps}
return format_out(data)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_getnetwork_datacenter_id error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
where_["name"] = netmap_id
#change_keys_http2db(content, http2db_tenant, reverse=True)
deleted = mydb.delete_row(FROM='datacenter_nets', WHERE= where_)
- if deleted == 0 and netmap_id :
+ if deleted == 0 and netmap_id:
bottle.abort(HTTP_Not_Found, "No netmap found with " + " and ".join(map(lambda x: str(x[0])+": "+str(x[1]), where_.iteritems())) )
if netmap_id:
return format_out({"result": "netmap %s deleted" % netmap_id})
else:
return format_out({"result": "%d netmap deleted" % deleted})
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_delnetmap_datacenter_id error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
utils.convert_str2boolean(netmaps, ('shared', 'multipoint') )
data={'netmaps' : netmaps}
return format_out(data)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_uploadnetmap_datacenter_id error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
utils.convert_str2boolean(netmaps, ('shared', 'multipoint') )
data={'netmaps' : netmaps}
return format_out(data)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_postnetmap_datacenter_id error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
try:
nfvo.datacenter_edit_netmap(mydb, tenant_id, datacenter_id, netmap_id, http_content)
return http_getnetmap_datacenter_id(tenant_id, datacenter_id, netmap_id)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_putnettmap_datacenter_id error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
return http_getnetmap_datacenter_id(datacenter_id)
else:
return format_out(result)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_action_datacenter_id error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
try:
data = nfvo.delete_datacenter(mydb, datacenter_id)
return format_out({"result":"datacenter '" + data + "' deleted"})
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_delete_datacenter_id error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
http_content['datacenter'].get('config')
)
return http_get_datacenter_id(tenant_id, id_)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_associate_datacenters error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
http_content['datacenter'].get('config')
)
return http_get_datacenter_id(tenant_id, id_)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_associate_datacenters_edit error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
try:
data = nfvo.deassociate_datacenter_to_tenant(mydb, tenant_id, datacenter_id)
return format_out({"result": data})
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_deassociate_datacenters error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
try:
data = nfvo.vim_net_sdn_attach(mydb, tenant_id, datacenter_id, network_id, http_content)
return format_out(data)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_post_vim_net_sdn_attach error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
try:
data = nfvo.vim_net_sdn_detach(mydb, tenant_id, datacenter_id, network_id, port_id)
return format_out(data)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_delete_vim_net_sdn_detach error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
try:
data = nfvo.vim_action_get(mydb, tenant_id, datacenter_id, item, name)
return format_out(data)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_get_vim_items error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
try:
data = nfvo.vim_action_delete(mydb, tenant_id, datacenter_id, item, name)
return format_out({"result":data})
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_del_vim_items error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
try:
data = nfvo.vim_action_create(mydb, tenant_id, datacenter_id, item, http_content)
return format_out(data)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_post_vim_items error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
convert_datetime2str(vnfs)
data={'vnfs' : vnfs}
return format_out(data)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_get_vnfs error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
utils.convert_str2boolean(vnf, ('public',))
convert_datetime2str(vnf)
return format_out(vnf)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_get_vnf_id error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
logger.warning('Unexpected schema_version: %s', http_content.get("schema_version"))
bottle.abort(HTTP_Bad_Request, "Invalid schema version")
return http_get_vnf_id(tenant_id, vnf_id)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_post_vnfs error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
convert_datetime2str(vnf)
vnfd_list.append(vnf["vnf"])
return format_out({"vnfd": vnfd_list})
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_post_vnfs error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
data = nfvo.delete_vnf(mydb,tenant_id,vnf_id)
#print json.dumps(data, indent=4)
return format_out({"result":"VNF " + data + " deleted"})
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_delete_vnf_id error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
convert_datetime2str(data)
#print json.dumps(data, indent=4)
return format_out(data)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_get_hosts error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
instance = nfvo.start_scenario(mydb, tenant_id, scenario_id, http_content['name'], http_content['name'])
#print json.dumps(data, indent=4)
return format_out(instance)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_post_deploy error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
#print json.dumps(data, indent=4)
#return format_out(data)
return http_get_scenario_id(tenant_id, scenario_id)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_post_scenarios error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
nsd_list.append(scenario)
data = {'nsd': nsd_list}
return format_out(data)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_post_nsds_v3 error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
instance_id = data['uuid']
nfvo.delete_instance(mydb, tenant_id,instance_id)
return format_out({"result":"Verify OK"})
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_post_scenario_action error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
data={'scenarios':scenarios}
#print json.dumps(scenarios, indent=4)
return format_out(data)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_get_scenarios error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
convert_datetime2str(scenario)
data={'scenario' : scenario}
return format_out(data)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_get_scenarios error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
data = mydb.delete_scenario(scenario_id, tenant_id)
#print json.dumps(data, indent=4)
return format_out({"result":"scenario " + data + " deleted"})
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_delete_scenario_id error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
#print json.dumps(data, indent=4)
#return format_out(data)
return http_get_scenario_id(tenant_id, scenario_id)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_put_scenario_id error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
nfvo.check_tenant(mydb, tenant_id)
data = nfvo.create_instance(mydb, tenant_id, http_content["instance"])
return format_out(data)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_post_instances error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
utils.convert_str2boolean(instances, ('public',) )
data={'instances':instances}
return format_out(data)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_get_instances error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
convert_datetime2str(instance)
# print json.dumps(instance, indent=4)
return format_out(instance)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_get_instance_id error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
#obtain data
message = nfvo.delete_instance(mydb, tenant_id,instance_id)
return format_out({"result":message})
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_delete_instance_id error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
data = nfvo.instance_action(mydb, tenant_id, instance_id, http_content)
return format_out(data)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_post_instance_scenario_action error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))
nfvo.check_tenant(mydb, tenant_id)
data = nfvo.instance_action_get(mydb, tenant_id, instance_id, action_id)
return format_out(data)
+ except bottle.HTTPError:
+ raise
except (nfvo.NfvoException, db_base_Exception) as e:
logger.error("http_get_instance_scenario_action error {}: {}".format(e.http_code, str(e)))
bottle.abort(e.http_code, str(e))