if vim_tenant_name is not None: WHERE_dict['vim_tenant_name'] = vim_tenant_name
if nfvo_tenant or vim_tenant or vim_tenant_name or datacenter_tenant_id:
from_= 'tenants_datacenters as td join datacenters as d on td.datacenter_id=d.uuid join datacenter_tenants as dt on td.datacenter_tenant_id=dt.uuid'
- select_ = ('type','config','d.uuid as datacenter_id', 'vim_url', 'vim_url_admin', 'd.name as datacenter_name',
+ select_ = ('type','d.config as config','d.uuid as datacenter_id', 'vim_url', 'vim_url_admin', 'd.name as datacenter_name',
'dt.uuid as datacenter_tenant_id','dt.vim_tenant_name as vim_tenant_name','dt.vim_tenant_id as vim_tenant_id',
- 'user','passwd')
+ 'user','passwd', 'dt.config as dt_config')
else:
from_ = 'datacenters as d'
select_ = ('type','config','d.uuid as datacenter_id', 'vim_url', 'vim_url_admin', 'd.name as datacenter_name')
vim_dict={}
for vim in vims:
extra={'datacenter_tenant_id': vim.get('datacenter_tenant_id')}
- if vim["config"] != None:
+ if vim["config"]:
extra.update(yaml.load(vim["config"]))
+ if vim.get('dt_config'):
+ extra.update(yaml.load(vim["dt_config"]))
if vim["type"] not in vimconn_imported:
module_info=None
try:
i += 1
myVMDict = {}
#myVMDict['name'] = "%s-%s-%s" % (scenarioDict['name'],sce_vnf['name'], vm['name'])
- myVMDict['name'] = "%s.%s.%d" % (instance_scenario_name,sce_vnf['name'],i)
+ myVMDict['name'] = "{}.{}.{}".format(instance_scenario_name,sce_vnf['name'],chr(96+i))
#myVMDict['description'] = vm['description']
myVMDict['description'] = myVMDict['name'][0:99]
if not startvms:
for vm in sce_vnf['vms']:
i += 1
myVMDict = {}
- myVMDict['name'] = "%s.%s.%d" % (instance_name,sce_vnf['name'],i)
+ myVMDict['name'] = "{}.{}.{}".format(instance_name,sce_vnf['name'],chr(96+i))
myVMDict['description'] = myVMDict['name'][0:99]
# if not startvms:
# myVMDict['start'] = "no"
has_mgmt_iface = True
if vm_dict[vm_id]['status'] == "ACTIVE:NoMgmtIP" and not has_mgmt_iface:
vm_dict[vm_id]['status'] = "ACTIVE"
+ if vm_dict[vm_id].get('error_msg') and len(vm_dict[vm_id]['error_msg']) >= 1024:
+ vm_dict[vm_id]['error_msg'] = vm_dict[vm_id]['error_msg'][:516] + " ... " + vm_dict[vm_id]['error_msg'][-500:]
if vm['status'] != vm_dict[vm_id]['status'] or vm.get('error_msg')!=vm_dict[vm_id].get('error_msg') or vm.get('vim_info')!=vm_dict[vm_id].get('vim_info'):
vm['status'] = vm_dict[vm_id]['status']
vm['error_msg'] = vm_dict[vm_id].get('error_msg')
# TODO: update nets inside a vnf
for net in instanceDict['nets']:
net_id = net['vim_net_id']
+ if net_dict[net_id].get('error_msg') and len(net_dict[net_id]['error_msg']) >= 1024:
+ net_dict[net_id]['error_msg'] = net_dict[net_id]['error_msg'][:516] + " ... " + net_dict[vm_id]['error_msg'][-500:]
if net['status'] != net_dict[net_id]['status'] or net.get('error_msg')!=net_dict[net_id].get('error_msg') or net.get('vim_info')!=net_dict[net_id].get('vim_info'):
net['status'] = net_dict[net_id]['status']
net['error_msg'] = net_dict[net_id].get('error_msg')
mydb.delete_row_by_id("datacenters", datacenter_dict['uuid'])
return datacenter_dict['uuid'] + " " + datacenter_dict['name']
-def associate_datacenter_to_tenant(mydb, nfvo_tenant, datacenter, vim_tenant_id=None, vim_tenant_name=None, vim_username=None, vim_password=None):
+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)
datacenter_name=myvim["name"]
datacenter_tenants_dict["user"] = vim_username
datacenter_tenants_dict["passwd"] = vim_password
datacenter_tenants_dict["datacenter_id"] = datacenter_id
+ if config:
+ datacenter_tenants_dict["config"] = yaml.safe_dump(config, default_flow_style=True, width=256)
id_ = mydb.new_row('datacenter_tenants', datacenter_tenants_dict, add_uuid=True)
datacenter_tenants_dict["uuid"] = id_