return filepath
+class VNFExistError(Exception):
+ pass
+
class VnfrConsoleOperdataDtsHandler(object):
""" registers 'D,/vnfr:vnfr-console/vnfr:vnfr[id]/vdur[id]' and handles CRUD from DTS"""
@property
yield from self._publisher.unpublish_vlr(None, vlr.vlr_msg)
yield from asyncio.sleep(1, loop=self._loop)
+ @asyncio.coroutine
+ def remove_vnf(self,vnf):
+ if vnf in self._vnfrs:
+ self._vnfrs.remove(vnf)
+ yield from self._publisher.unpublish_vnfr(
+ None,
+ vnfr_msg
+ )
+ yield from asyncio.sleep(1, loop=self._loop)
+
@asyncio.coroutine
def delete_vlr(self, vlr):
if vlr in self._vlrs:
self._http_api = None
self._openmano_nsrs = {}
self._vnfr_uptime_tasks = {}
+ self._openmano_nsr_by_vnfr_id = {}
+ #self._nsr_uuid = None
self._set_ro_account(ro_account)
openmano_nsr.nsd_msg,
openmano_nsr.nsr_config_msg,
openmano_nsr.key_pairs,
- #openmano_nsr.nsr_msg,
vnfr.vnfd.id
)
+ self._openmano_nsr_by_vnfr_id[nsr.id] = openmano_nsr
+ if vnfr.id in self._openmano_nsr_by_vnfr_id:
+ raise VNFExistError("VNF %s already exist", vnfr.id)
+ self._openmano_nsr_by_vnfr_id[vnfr.id] = openmano_vnf_nsr
+ self._log.debug("VNFRID %s %s %s", type(self._openmano_nsr_by_vnfr_id), type(openmano_vnf_nsr), type(self._openmano_nsr_by_vnfr_id[vnfr.id]))
+
for vlr in openmano_nsr.vlrs:
yield from openmano_vnf_nsr.add_vlr(vlr)
try:
openmano_nsr.delete()
@asyncio.coroutine
- def terminate_vnf(self, vnfr):
+ def terminate_vnf(self, nsr, vnfr, scalein=False):
"""
Terminate the network service
"""
- if vnfr.id in self._vnfr_uptime_tasks:
- self._vnfr_uptime_tasks[vnfr.id].cancel()
+ if scalein:
+ openmano_vnf_nsr = self._openmano_nsr_by_vnfr_id[vnfr.id]
+ openmano_vnf_nsr.terminate()
+ openmano_vnf_nsr.delete()
+ yield from openmano_vnf_nsr.remove_vnf(vnfr)
+ if vnfr.id in self._vnfr_uptime_tasks:
+ self._vnfr_uptime_tasks[vnfr.id].cancel()
@asyncio.coroutine
def terminate_vl(self, vlr):
# Going ahead with terminate, even if there is an error in pre-scale-in config
# as this could be result of scale out failure and we need to cleanup this group
- yield from self.terminate_vnfrs(scale_instance.vnfrs)
+ yield from self.terminate_vnfrs(scale_instance.vnfrs, scalein=True)
group.delete_instance(index)
scale_instance.operational_status = "vnf_terminate_phase"
yield from self.publish()
@asyncio.coroutine
- def terminate_vnfrs(self, vnfrs):
+ def terminate_vnfrs(self, vnfrs, scalein=False):
""" Terminate VNFRS in this network service """
self._log.debug("Terminating VNFs in network service %s", self.id)
for vnfr in vnfrs:
- yield from self.nsm_plugin.terminate_vnf(vnfr)
+ self._log.debug("Terminating VNFs in network service %s %s", vnfr.id, self.id)
+ if scalein:
+ yield from self.nsm_plugin.terminate_vnf(self, vnfr, scalein=True)
@asyncio.coroutine
def terminate(self):
event_descr = "Terminating VLs in NS Id:%s" % self.id
self.record_event("terminating-vls", event_descr)
yield from terminate_vlrs()
-
yield from self.nsm_plugin.terminate_ns(self)
-
# Move the state to TERMINATED
self.set_state(NetworkServiceRecordState.TERMINATED)
event_descr = "Terminated NS Id:%s" % self.id