From: Philip Joseph Date: Wed, 18 Jan 2017 12:00:40 +0000 (+0530) Subject: Bug 154 Fix terminate VL during terminate NS X-Git-Tag: v1.1.0~18 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=e673ae8d29326d3212a38b5abbb7a5f1219805e8;p=osm%2FSO.git Bug 154 Fix terminate VL during terminate NS Signed-off-by: Philip Joseph --- diff --git a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/cloud.py b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/cloud.py index 32efff2a..007e62ca 100644 --- a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/cloud.py +++ b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/cloud.py @@ -40,6 +40,9 @@ class RwNsPlugin(rwnsmplugin.NsmPluginBase): self._log = log self._loop = loop + def set_state(self, nsr_id, state): + pass + def create_nsr(self, nsr_msg, nsd,key_pairs=None): """ Create Network service record diff --git a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/openmano_nsm.py b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/openmano_nsm.py index 6c189464..e009ba3f 100644 --- a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/openmano_nsm.py +++ b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/openmano_nsm.py @@ -244,17 +244,18 @@ class OpenmanoVnfr(object): class OpenmanoNSRecordState(Enum): """ Network Service Record State """ + # Make sure the values match with NetworkServiceRecordState INIT = 101 INSTANTIATION_PENDING = 102 - RUNNING = 103 - SCALING_OUT = 104 - SCALING_IN = 105 - TERMINATE = 106 - TERMINATE_RCVD = 107 - TERMINATED = 108 - FAILED = 109 - VL_INSTANTIATE = 110 - VL_TERMINATE = 111 + RUNNING = 106 + SCALING_OUT = 107 + SCALING_IN = 108 + TERMINATE = 109 + TERMINATE_RCVD = 110 + TERMINATED = 114 + FAILED = 115 + VL_INSTANTIATE = 116 + VL_TERMINATE = 117 class OpenmanoNsr(object): @@ -421,6 +422,13 @@ class OpenmanoNsr(object): @asyncio.coroutine def remove_vlr(self, vlr): + if vlr in self._vlrs: + self._vlrs.remove(vlr) + yield from self._publisher.unpublish_vlr(None, vlr.vlr_msg) + yield from asyncio.sleep(1, loop=self._loop) + + @asyncio.coroutine + def delete_vlr(self, vlr): if vlr in self._vlrs: self._vlrs.remove(vlr) if not vlr.vld_msg.vim_network_name: @@ -815,6 +823,15 @@ class OpenmanoNsPlugin(rwnsmplugin.NsmPluginBase): ro_account.openmano.tenant_id, ) + def set_state(self, nsr_id, state): + # Currently we update only during terminate to + # decide how to handle VL terminate + if state.value == OpenmanoNSRecordState.TERMINATE.value: + self._openmano_nsrs[nsr_id]._state = \ + [member.value for name, member in \ + OpenmanoNSRecordState.__members__.items() \ + if member.value == state.value] + def create_nsr(self, nsr_config_msg, nsd_msg, key_pairs=None): """ Create Network service record @@ -920,6 +937,7 @@ class OpenmanoNsPlugin(rwnsmplugin.NsmPluginBase): """ self._log.debug("Received terminate VL for VLR {}".format(vlr)) openmano_nsr = self._openmano_nsrs[vlr._nsr_id] - yield from openmano_nsr.remove_vlr(vlr) - - + if openmano_nsr._state == OpenmanoNSRecordState.RUNNING: + yield from openmano_nsr.delete_vlr(vlr) + else: + yield from openmano_nsr.remove_vlr(vlr) diff --git a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmplugin.py b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmplugin.py index ec162597..77fa57cc 100755 --- a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmplugin.py +++ b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmplugin.py @@ -48,6 +48,11 @@ class NsmPluginBase(object): def nsm(self): return self._nsm + @abc.abstractmethod + def set_state(self, nsr_id, state): + pass + + @abc.abstractmethod def create_nsr(self, nsr): """ Create an NSR """ pass diff --git a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmtasklet.py b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmtasklet.py index 0537cc53..3153a48c 100755 --- a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmtasklet.py +++ b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmtasklet.py @@ -1296,6 +1296,7 @@ class NetworkServiceRecord(object): self._vnf_phase_completed = True self._op_status.set_state(state) + self._nsm_plugin.set_state(self.id, state) @property def id(self):