Comment 3 for bug 1613445

Revision history for this message
Abinaya (abinaya-visvanathan) wrote :

 The error reason that is being displayed now is passed in the variable: evt_details
 The function create_event displays the status of the VNF alog with its ID and other parameters.
 This part is mentioned in the function create vnf post, where the vnf status- be it ACTIVE or ERROR- the same event_status message is displayed.
 1- Since a common message is displayed for all errors messages - we have to fisr identify the errors that are possible and accordingly display the error message

 evt_details = ("Infra Instance ID created: %s and "
                       "Mgmt URL set: %s") % (instance_id, mgmt_url)

        self._cos_db_plg.create_event(
            context, res_id=vnf_dict['id'],
            res_type=constants.RES_TYPE_VNF,
            res_state=vnf_dict['status'],
            evt_type=constants.RES_EVT_CREATE,
            tstamp=timeutils.utcnow(), details=evt_details)

2 - Scenario for error- this is one of the possible reasons error can occur in the code:

     try:
            self._vnf_manager.invoke(
                driver_name, 'create_wait', plugin=self, context=context,
                vnf_dict=vnf_dict, vnf_id=instance_id,
                auth_attr=auth_attr)
        except vnfm.VNFCreateWaitFailed as e:
            LOG.error(_LE("VNF Create failed for vnf_id %s"), vnf_id)
            create_failed = True
            vnf_dict['status'] = constants.ERROR
            self.set_vnf_error_status_reason(context, vnf_id,
                                             six.text_type(e))

 As we can see, in the set_vnf_error_status_reason, six.text_type(e) parmeter is passed
 this is a unicode or a string which passes the exception message or the error message,

3- def set_vnf_error_status_reason(self, context, vnf_id, new_reason):
        with context.session.begin(subtransactions=True):
            (self._model_query(context, VNF).
                filter(VNF.id == vnf_id).
                update({'error_reason': new_reason}))

 As we can see above, according to the errors- the key value error_reason is updated.

 So, in order to display the errors reasons accordingly, the error_reason(in 3) has to be linked to the event details(in 1)