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:
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_