Merge branch 'v1.1'
Signed-off-by: velandy <rajesh.velandy@riftio.com>
diff --git a/models/openmano/python/rift/openmano/openmano_client.py b/models/openmano/python/rift/openmano/openmano_client.py
index 814a50c..09fb43d 100755
--- a/models/openmano/python/rift/openmano/openmano_client.py
+++ b/models/openmano/python/rift/openmano/openmano_client.py
@@ -198,6 +198,7 @@
output_lines = self._openmano_cmd(
["vnf-list"],
)
+
except OpenmanoCommandFailed as e:
self._log.warning("Vnf listing returned an error: %s", str(e))
return {}
@@ -206,8 +207,9 @@
for line in output_lines:
line = line.strip()
uuid, name = line.split(" ", 1)
- name_uuid_map[name] = uuid
+ name_uuid_map[name.strip()] = uuid.strip()
+ self._log.debug("VNF list: {}".format(name_uuid_map))
return name_uuid_map
def ns_create(self, ns_yaml_str, name=None):
@@ -249,8 +251,9 @@
for line in output_lines:
line = line.strip()
uuid, name = line.split(" ", 1)
- name_uuid_map[name] = uuid
+ name_uuid_map[name.strip()] = uuid.strip()
+ self._log.debug("Scenario list: {}".format(name_uuid_map))
return name_uuid_map
def ns_delete(self, ns_uuid):
@@ -282,8 +285,9 @@
for line in output_lines:
line = line.strip()
uuid, name = line.split(" ", 1)
- name_uuid_map[name] = uuid
+ name_uuid_map[name.strip()] = uuid.strip()
+ self._log.debug("Instance Scenario list: {}".format(name_uuid_map))
return name_uuid_map
def ns_instance_scenario_create(self, instance_yaml_str):
@@ -466,6 +470,10 @@
type=valid_uuid,
)
+ _ = subparsers.add_parser(
+ 'vnf-list',
+ help="List all the openmano VNFs in the catalog",
+ )
ns_create_parser = subparsers.add_parser(
'scenario-create',
@@ -487,6 +495,10 @@
type=valid_uuid,
)
+ _ = subparsers.add_parser(
+ 'scenario-list',
+ help="List all the openmano scenarios in the catalog",
+ )
ns_instance_create_parser = subparsers.add_parser(
'scenario-deploy',
@@ -513,7 +525,13 @@
_ = subparsers.add_parser(
+ 'instance-scenario-list',
+ help="List all the openmano scenario instances in the catalog",
+ )
+
+ _ = subparsers.add_parser(
'datacenter-list',
+ help="List all the openmano datacenters",
)
args = parser.parse_args(argv)
@@ -538,18 +556,30 @@
elif args.command == "vnf-delete":
openmano_cli.vnf_delete(args.uuid)
+ elif args.command == "vnf-list":
+ for uuid, name in openmano_cli.vnf_list().items():
+ print("{} {}".format(uuid, name))
+
elif args.command == "scenario-create":
openmano_cli.ns_create(args.file.read())
elif args.command == "scenario-delete":
openmano_cli.ns_delete(args.uuid)
+ elif args.command == "scenario-list":
+ for uuid, name in openmano_cli.ns_list().items():
+ print("{} {}".format(uuid, name))
+
elif args.command == "scenario-deploy":
openmano_cli.ns_instantiate(args.scenario_name, args.instance_name)
elif args.command == "instance-scenario-delete":
openmano_cli.ns_terminate(args.instance_name)
+ elif args.command == "instance-scenario-list":
+ for uuid, name in openmano_cli.ns_instance_list().items():
+ print("{} {}".format(uuid, name))
+
elif args.command == "datacenter-list":
for uuid, name in openmano_cli.datacenter_list():
print("{} {}".format(uuid, name))
diff --git a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/cloud.py b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/cloud.py
index 32efff2..007e62c 100644
--- a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/cloud.py
+++ b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/cloud.py
@@ -40,6 +40,9 @@
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 6c18946..e009ba3 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 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):
@@ -423,6 +424,13 @@
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:
yield from self._loop.run_in_executor(
None,
@@ -815,6 +823,15 @@
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 @@
"""
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 ec16259..77fa57c 100755
--- a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmplugin.py
+++ b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmplugin.py
@@ -48,6 +48,11 @@
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 0537cc5..3153a48 100755
--- a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmtasklet.py
+++ b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmtasklet.py
@@ -1296,6 +1296,7 @@
self._vnf_phase_completed = True
self._op_status.set_state(state)
+ self._nsm_plugin.set_state(self.id, state)
@property
def id(self):