X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=rwlaunchpad%2Fplugins%2Frwvnfm%2Frift%2Ftasklets%2Frwvnfmtasklet%2Frwvnfmtasklet.py;h=d359aa4fbc9974983c77e568986aeab4a3c6abfd;hb=d748ab1836d94ebe1273b1910954be3b2a2b4486;hp=8a4474e0133feb98ad44d6232d50c791ec37dad9;hpb=2d3f1023ac94d9c19115c0b63ce85ae7a8598517;p=osm%2FSO.git diff --git a/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py b/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py index 8a4474e0..d359aa4f 100755 --- a/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py +++ b/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py @@ -311,6 +311,14 @@ class VirtualDeploymentUnitRecord(object): return conn_point.ip_address return "0.0.0.0" + def cp_mac_addr(self, cp_name): + """ Find mac address by connection point name """ + if self._vm_resp is not None: + for conn_point in self._vm_resp.connection_points: + if conn_point.name == cp_name: + return conn_point.mac_addr + return "00:00:00:00:00:00" + def cp_id(self, cp_name): """ Find connection point id by connection point name """ if self._vm_resp is not None: @@ -422,7 +430,8 @@ class VirtualDeploymentUnitRecord(object): icp_list.append({"name": cp.name, "id": cp.id, "type_yang": "VPORT", - "ip_address": self.cp_ip_addr(cp.id)}) + "ip_address": self.cp_ip_addr(cp.id), + "mac_address": self.cp_mac_addr(cp.id)}) ii_list.append({"name": intf.name, "vdur_internal_connection_point_ref": cp.id, @@ -437,7 +446,10 @@ class VirtualDeploymentUnitRecord(object): ei_list.append({"name": cp, "vnfd_connection_point_ref": cp, "virtual_interface": {}}) - self._vnfr.update_cp(cp, self.cp_ip_addr(cp), self.cp_id(cp)) + self._vnfr.update_cp(cp, + self.cp_ip_addr(cp), + self.cp_mac_addr(cp), + self.cp_id(cp)) vdur_dict["external_interface"] = ei_list @@ -1706,13 +1718,14 @@ class VirtualNetworkFunctionRecord(object): # Update the VNFR with the changed status yield from self.publish(None) - def update_cp(self, cp_name, ip_address, cp_id): + def update_cp(self, cp_name, ip_address, mac_addr, cp_id): """Updated the connection point with ip address""" for cp in self._cprs: if cp.name == cp_name: self._log.debug("Setting ip address and id for cp %s, cpr %s with ip %s id %s", cp_name, cp, ip_address, cp_id) cp.ip_address = ip_address + cp.mac_address = mac_addr cp.connection_point_id = cp_id return @@ -2505,7 +2518,13 @@ class VnfManager(object): self._dts, self._log, self._loop, self._cluster_name, self, self.vcs_handler, vnfr, mgmt_network=mgmt_network ) - self._vnfds_to_vnfr[vnfr.vnfd.id] = self._vnfrs[vnfr.id] + + #Update ref count + if vnfr.vnfd.id in self._vnfds_to_vnfr: + self._vnfds_to_vnfr[vnfr.vnfd.id] += 1 + else: + self._vnfds_to_vnfr[vnfr.vnfd.id] = 1 + return self._vnfrs[vnfr.id] @asyncio.coroutine @@ -2514,6 +2533,11 @@ class VnfManager(object): if vnfr.vnfr_id in self._vnfrs: self._log.debug("Deleting VNFR id %s", vnfr.vnfr_id) yield from self._vnfr_handler.delete(xact, vnfr.xpath) + + if vnfr.vnfd.id in self._vnfds_to_vnfr: + if self._vnfds_to_vnfr[vnfr.vnfd.id]: + self._vnfds_to_vnfr[vnfr.vnfd.id] -= 1 + del self._vnfrs[vnfr.vnfr_id] @asyncio.coroutine @@ -2542,7 +2566,7 @@ class VnfManager(object): """ Is this VNFD in use """ self._log.debug("Is this VNFD in use - msg:%s", vnfd_id) if vnfd_id in self._vnfds_to_vnfr: - return self._vnfds_to_vnfr[vnfd_id].in_use() + return (self._vnfds_to_vnfr[vnfd_id] > 0) return False @asyncio.coroutine @@ -2556,18 +2580,17 @@ class VnfManager(object): def delete_vnfd(self, vnfd_id): """ Delete the Virtual Network Function descriptor with the passed id """ self._log.debug("Deleting the virtual network function descriptor - %s", vnfd_id) - if vnfd_id not in self._vnfds_to_vnfr: - self._log.debug("Delete VNFD failed - cannot find vnfd-id %s", vnfd_id) - raise VirtualNetworkFunctionDescriptorNotFound("Cannot find %s", vnfd_id) - - if self._vnfds_to_vnfr[vnfd_id].in_use(): - self._log.debug("Cannot delete VNFD id %s reference exists %s", - vnfd_id, - self._vnfds_to_vnfr[vnfd_id].vnfd_ref_count) - raise VirtualNetworkFunctionDescriptorRefCountExists( - "Cannot delete :%s, ref_count:%s", - vnfd_id, - self._vnfds_to_vnfr[vnfd_id].vnfd_ref_count) + if vnfd_id in self._vnfds_to_vnfr: + if self._vnfds_to_vnfr[vnfd_id]: + self._log.debug("Cannot delete VNFD id %s reference exists %s", + vnfd_id, + self._vnfds_to_vnfr[vnfd_id].vnfd_ref_count) + raise VirtualNetworkFunctionDescriptorRefCountExists( + "Cannot delete :%s, ref_count:%s", + vnfd_id, + self._vnfds_to_vnfr[vnfd_id].vnfd_ref_count) + + del self._vnfds_to_vnfr[vnfd_id] # Remove any files uploaded with VNFD and stored under $RIFT_ARTIFACTS/libs/ try: @@ -2580,7 +2603,6 @@ class VnfManager(object): format(self._vnfds_to_vnfr[vnfd_id].vnfd.name, e)) self._log.exception(e) - del self._vnfds_to_vnfr[vnfd_id] def vnfd_refcount_xpath(self, vnfd_id): """ xpath for ref count entry """ @@ -2592,15 +2614,15 @@ class VnfManager(object): """ Get the vnfd_list from this VNFM""" vnfd_list = [] if vnfd_id is None or vnfd_id == "": - for vnfr in self._vnfds_to_vnfr.values(): + for vnfd in self._vnfds_to_vnfr.keys(): vnfd_msg = RwVnfrYang.YangData_Vnfr_VnfrCatalog_VnfdRefCount() - vnfd_msg.vnfd_id_ref = vnfr.vnfd.id - vnfd_msg.instance_ref_count = vnfr.vnfd_ref_count - vnfd_list.append((self.vnfd_refcount_xpath(vnfr.vnfd.id), vnfd_msg)) + vnfd_msg.vnfd_id_ref = vnfd + vnfd_msg.instance_ref_count = self._vnfds_to_vnfr[vnfd] + vnfd_list.append((self.vnfd_refcount_xpath(vnfd), vnfd_msg)) elif vnfd_id in self._vnfds_to_vnfr: vnfd_msg = RwVnfrYang.YangData_Vnfr_VnfrCatalog_VnfdRefCount() - vnfd_msg.vnfd_id_ref = self._vnfds_to_vnfr[vnfd_id].vnfd.id - vnfd_msg.instance_ref_count = self._vnfds_to_vnfr[vnfd_id].vnfd_ref_count + vnfd_msg.vnfd_id_ref = vnfd_id + vnfd_msg.instance_ref_count = self._vnfds_to_vnfr[vnfd_id] vnfd_list.append((self.vnfd_refcount_xpath(vnfd_id), vnfd_msg)) return vnfd_list