vm = VmInstModel.objects.filter(vmid=vnfc.vmid)
if vm:
vm_resource = {
- 'vimId': vm[0].vimid,
+ 'vimConnectionId': vm[0].vimid,
'resourceId': vm[0].resourceid,
'resourceProviderId': vm[0].vmname, # TODO: is resourceName mapped to resourceProviderId?
'vimLevelResourceType': 'vm'
'changeType': changetype,
'networkResource': network_resource
})
- ext_link_ports = []
+ ext_connectivity = []
+ ext_connectivity_map = {}
ports = PortInstModel.objects.filter(instid=nfinstid)
for port in ports:
- ext_link_ports.append({
+ if port.networkid not in ext_connectivity_map:
+ ext_connectivity_map[port.networkid] = []
+ ext_connectivity_map[port.networkid].append({
'id': port.portid, # TODO: port.portid or port.nodeid?
'resourceHandle': {
'vimConnectionId': port.vimid,
'resourceId': port.resourceid,
'resourceProviderId': port.name, # TODO: is resourceName mapped to resourceProviderId?
- 'vimLevelResourceType': 'port'
+ 'vimLevelResourceType': 'port',
+ 'tenant': port.tenant,
+ 'ipAddress': port.ipaddress,
+ 'macAddress': port.macaddress,
+ 'instId': port.instid,
+ 'portid': port.portid,
+ 'networkid': port.networkid,
+ 'subnetworkid': port.subnetworkid
},
- 'cpInstanceId': port.cpinstanceid # TODO: port.cpinstanceid is not initiated when create port resource.
- }),
+ 'cpInstanceId': port.portid # TODO: port.cpinstanceid is not initiated when create port resource.
+ })
+ for network_id, ext_link_ports in list(ext_connectivity_map.items()):
+ networks = NetworkInstModel.objects.filter(networkid=network_id)
+ net_name = networks[0].name if networks else network_id
+ network_resource = {
+ 'vimConnectionId': ext_link_ports[0]['resourceHandle']['vimConnectionId'],
+ 'resourceId': network_id,
+ 'resourceProviderId': net_name, # TODO: is resourceName mapped to resourceProviderId?
+ 'vimLevelResourceType': 'network'
+ }
+ ext_connectivity.append({
+ 'id': network_id,
+ 'resourceHandle': network_resource,
+ 'changeType': changetype,
+ 'extLinkPorts': ext_link_ports
+ })
+ logger.debug("ext_connectivity=%s", ext_connectivity)
affected_vss = []
vss = StorageInstModel.objects.filter(instid=nfinstid)
for vs in vss:
'affectedVnfcs': affected_vnfcs,
'affectedVirtualLinks': affected_vls,
'affectedVirtualStorages': affected_vss,
- 'chengedExtConnectivity': [{
- 'id': None, # TODO
- 'resourceHandle': None, # TODO
- 'extLinkPorts': ext_link_ports
- }],
+ 'changedExtConnectivity': ext_connectivity,
'_links': {
'vnfInstance': {'href': '/api/vnflcm/v1/vnf_instances/%s' % nfinstid},
# set 'subscription' link after filtering for subscribers
}
}
nfInsts = NfInstModel.objects.filter(nfinstid=nfinstid)
- notification_content['vnfmInstId'] = nfInsts[0].vnfminstid
+ notification_content['vnfmInstId'] = nfInsts[0].vnfminstid if nfInsts[0].vnfminstid else '1'
logger.info('Notify request data = %s' % notification_content)
return notification_content