+
+ def lcm_notify(self, status, opState, err=None):
+ notification_content = self.prepareNotificationData(status, opState, err)
+ logger.info('Notify data = %s' % notification_content)
+ NotificationsUtil().send_notification(notification_content)
+ logger.info('Notify end')
+
+ def prepareNotificationData(self, status, opState, err=None):
+ affected_vnfcs = []
+ if status == LCM_NOTIFICATION_STATUS.RESULT and opState == OPERATION_STATE_TYPE.COMPLETED:
+ chtype = ""
+ if self.action == HEAL_ACTION_TYPE.START:
+ chtype = CHANGE_TYPE.ADDED
+ else:
+ chtype = CHANGE_TYPE.MODIFIED
+ vnfcs = VNFCInstModel.objects.filter(instid=self.nf_inst_id, vmid=self.vm_id)
+ vm_resource = {}
+ vm = VmInstModel.objects.filter(instid=self.nf_inst_id, vmid=self.vm_id)
+ if vm:
+ vm_resource = {
+ 'vimConnectionId': vm[0].vimid,
+ 'resourceId': vm[0].resourceid,
+ 'vimLevelResourceType': 'vm'
+ }
+ affected_vnfcs.append({
+ 'id': vnfcs[0].vnfcinstanceid,
+ 'vduId': vnfcs[0].vduid,
+ 'changeType': chtype,
+ 'computeResource': vm_resource
+ })
+
+ notification_content = {
+ "id": str(uuid.uuid4()),
+ "notificationType": "VnfLcmOperationOccurrenceNotification",
+ "subscriptionId": "",
+ "timeStamp": now_time(),
+ "notificationStatus": status,
+ "operationState": opState,
+ "vnfInstanceId": self.nf_inst_id,
+ "operation": OPERATION_TYPE.HEAL,
+ "isAutomaticInvocation": "false",
+ "vnfLcmOpOccId": self.job_id,
+ "affectedVnfcs": affected_vnfcs,
+ "affectedVirtualLinks": [],
+ "affectedVirtualStorages": [],
+ "changedInfo": {},
+ "changedExtConnectivity": [],
+ "_links": {"vnfInstance": {"href": ""},
+ "subscription": {"href": ""},
+ "vnfLcmOpOcc": {"href": ""}}
+ }
+ if opState in (OPERATION_STATE_TYPE.FAILED, OPERATION_STATE_TYPE.FAILED_TEMP):
+ notification_content["error"] = {"status": 500, "detail": err}
+ notification_content["_links"]["vnfInstance"]["href"] = "/vnf_instances/%s" % self.nf_inst_id
+ notification_content["_links"]["vnfLcmOpOcc"]["href"] = "/vnf_lc_ops/%s" % self.job_id
+ return notification_content