X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=rwlaunchpad%2Fplugins%2Frwvnfm%2Frift%2Ftasklets%2Frwvnfmtasklet%2Frwvnfmtasklet.py;h=2bcbecc553c9b6bc488eb331c1e5b5d7ef69347c;hb=2be87cd0da394fe7cb480db1048ea1a153f9092d;hp=e0de7b0c62a9f9f24b4ab0c6df8cdf816d1ffedf;hpb=af804410b4063fe28658e38d23e3108b1d88a799;p=osm%2FSO.git diff --git a/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py b/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py index e0de7b0c..2bcbecc5 100755 --- a/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py +++ b/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py @@ -521,6 +521,7 @@ class VirtualDeploymentUnitRecord(object): 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 @@ class VirtualDeploymentUnitRecord(object): 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": @@ -986,13 +987,14 @@ class VlRecordState(enum.Enum): class InternalVirtualLinkRecord(object): """ Internal Virtual Link record """ - def __init__(self, dts, log, loop, ivld_msg, vnfr_name, cloud_account_name): + def __init__(self, dts, log, loop, ivld_msg, vnfr_name, cloud_account_name, ip_profile=None): self._dts = dts self._log = log self._loop = loop self._ivld_msg = ivld_msg self._vnfr_name = vnfr_name self._cloud_account_name = cloud_account_name + self._ip_profile = ip_profile self._vlr_req = self.create_vlr() self._vlr = None @@ -1006,7 +1008,10 @@ class InternalVirtualLinkRecord(object): @property def name(self): """ Name of this VL """ - return self._vnfr_name + "." + self._ivld_msg.name + if self._ivld_msg.vim_network_name: + return self._ivld_msg.vim_network_name + else: + return self._vnfr_name + "." + self._ivld_msg.name @property def network_id(self): @@ -1025,6 +1030,7 @@ class InternalVirtualLinkRecord(object): "description", "version", "type_yang", + "vim_network_name", "provider_network"] vld_copy_dict = {k: v for k, v in self._ivld_msg.as_dict().items() if k in vld_fields} @@ -1033,6 +1039,10 @@ class InternalVirtualLinkRecord(object): "name": self.name, "cloud_account": self._cloud_account_name, } + + if self._ip_profile and self._ip_profile.has_field('ip_profile_params'): + vlr_dict['ip_profile_params' ] = self._ip_profile.ip_profile_params.as_dict() + vlr_dict.update(vld_copy_dict) vlr = RwVlrYang.YangData_Vlr_VlrCatalog_Vlr.from_dict(vlr_dict) @@ -1416,6 +1426,13 @@ class VirtualNetworkFunctionRecord(object): self._log.debug("Published VNFR path = [%s], record = [%s]", self.xpath, self.msg) + def resolve_vld_ip_profile(self, vnfd_msg, vld): + self._log.debug("Receieved ip profile ref is %s",vld.ip_profile_ref) + if not vld.has_field('ip_profile_ref'): + return None + profile = [profile for profile in vnfd_msg.ip_profiles if profile.name == vld.ip_profile_ref] + return profile[0] if profile else None + @asyncio.coroutine def create_vls(self): """ Publish The VLs associated with this VNF """ @@ -1431,7 +1448,8 @@ class VirtualNetworkFunctionRecord(object): loop=self._loop, ivld_msg=ivld_msg, vnfr_name=self.name, - cloud_account_name=self.cloud_account_name + cloud_account_name=self.cloud_account_name, + ip_profile=self.resolve_vld_ip_profile(self.vnfd, ivld_msg) ) self._vlrs.append(vlr) @@ -1510,6 +1528,10 @@ class VirtualNetworkFunctionRecord(object): 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 """ @@ -1574,8 +1596,8 @@ class VirtualNetworkFunctionRecord(object): 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 @@ -1603,7 +1625,6 @@ class VirtualNetworkFunctionRecord(object): # 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) @@ -1844,6 +1865,7 @@ class VirtualNetworkFunctionRecord(object): 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: @@ -1859,6 +1881,13 @@ class VirtualNetworkFunctionRecord(object): 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)