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):
@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:
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
"""
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)