I have the following code implemented with result getting produced as given below:
Code:
for tenant in tenants_list:
tenant_id = tenant.id
server_list = nova.servers.list(search_opts={'all_tenants':1,'tenant_id':tenant_id})
tenant_server_combination[tenant_id] = server_list
# for tenant and instance combinations dict
for a,b in tenant_server_combination.iteritems():
for server_id in b:
server = server_id.name
tenant_id_dict[a] = server
print tenant_id_dict
Actual Result:
{u'b0116ce25cad4106becbbddfffa61a1c': u'demo_ins1', u'1578f81703ec4bbaa1d548532c922ab9': u'new_tenant_ins'}
Basically second key is having one more entry: 'new_ins_1'
Current code which I have created overwrite the value based on Key.
Now I need the way to achieve the result which is as follows:
{'b0116ce25cad4106becbbddfffa61a1c': ['demo_ins1'],'1578f81703ec4bbaa1d548532c922ab9': ['new_ins_1','new_tenant_ins']}