Bug 149
* Fix - NS instantiation going to stuck state when incorrect cloud-init file specified
Signed-off-by: Hashir Mohammed <hashir.mohammed@riftio.com>
diff --git a/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py b/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py
index 15e6f46..2bcbecc 100755
--- a/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py
+++ b/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py
@@ -521,6 +521,7 @@
try:
return cloud_init_extractor.read_script(stored_package, filename)
except rift.package.cloud_init.CloudInitExtractionError as e:
+ self.instantiation_failed(str(e))
raise VirtualDeploymentUnitRecordError(e)
else:
self._log.debug("VDU Instantiation: cloud-init script not provided")
@@ -942,8 +943,8 @@
vm_resp = yield from self.create_resource(xact, vnfr, config)
self._vm_resp = vm_resp
-
self._state = VDURecordState.RESOURCE_ALLOC_PENDING
+
self._log.debug("Requested VM from resource manager response %s",
vm_resp)
if vm_resp.resource_state == "active":
@@ -1528,6 +1529,10 @@
return placement_groups
@asyncio.coroutine
+ def vdu_cloud_init_instantiation(self):
+ [vdu.vdud_cloud_init for vdu in self._vdus]
+
+ @asyncio.coroutine
def create_vdus(self, vnfr, restart_mode=False):
""" Create the VDUs associated with this VNF """
@@ -1591,8 +1596,8 @@
vdu_id_pattern = re.compile(r"\{\{ vdu\[([^]]+)\]\S* \}\}")
for vdu in self._vdus:
- if vdu.vdud_cloud_init is not None:
- for vdu_id in vdu_id_pattern.findall(vdu.vdud_cloud_init):
+ if vdu._vdud_cloud_init is not None:
+ for vdu_id in vdu_id_pattern.findall(vdu._vdud_cloud_init):
if vdu_id != vdu.vdu_id:
# This means that vdu.vdu_id depends upon vdu_id,
# i.e. vdu_id must be instantiated before
@@ -1620,7 +1625,6 @@
# wait for the VDUR to enter a terminal state
while vdu._state not in terminal:
yield from asyncio.sleep(1, loop=self._loop)
-
# update the datastore
datastore.update(vdu)
@@ -1861,6 +1865,7 @@
self._log.debug("VNFR-ID %s: Publish VNFR", self._vnfr_id)
yield from self.publish(xact)
+
# instantiate VLs
self._log.debug("VNFR-ID %s: Instantiate VLs", self._vnfr_id)
try:
@@ -1876,6 +1881,13 @@
self._log.debug("VNFR-ID %s: Create VDUs", self._vnfr_id)
yield from self.create_vdus(self, restart_mode)
+ try:
+ yield from self.vdu_cloud_init_instantiation()
+ except Exception as e:
+ self.set_state(VirtualNetworkFunctionRecordState.FAILED)
+ self._state_failed_reason = str(e)
+ yield from self.publish(xact)
+
# publish the VNFR
self._log.debug("VNFR-ID %s: Publish VNFR", self._vnfr_id)
yield from self.publish(xact)