

def execute_lifecycle_transition(self, resource_id='', transition_event=''):
    if (transition_event == LCE.DELETE):
        return self.lcs_delete(resource_id)
    res_obj = self.read(resource_id)
    old_lcstate = res_obj.lcstate
    old_availability = res_obj.availability
    if (transition_event == LCE.RETIRE):
        if ((res_obj.lcstate == LCS.RETIRED) or (res_obj.lcstate == LCS.DELETED)):
            raise BadRequest(('Resource id=%s, type=%s, lcstate=%s, availability=%s has no transition for event %s' % (resource_id, res_obj.type_, old_lcstate, old_availability, transition_event)))
        res_obj.lcstate = LCS.RETIRED
    else:
        restype = res_obj.type_
        restype_workflow = get_restype_lcsm(restype)
        if (not restype_workflow):
            raise BadRequest(('Resource id=%s type=%s has no lifecycle' % (resource_id, restype)))
        new_lcstate = restype_workflow.get_lcstate_successor(old_lcstate, transition_event)
        new_availability = restype_workflow.get_availability_successor(old_availability, transition_event)
        if ((not new_lcstate) and (not new_availability)):
            raise BadRequest(('Resource id=%s, type=%s, lcstate=%s, availability=%s has no transition for event %s' % (resource_id, restype, old_lcstate, old_availability, self)))
        if new_lcstate:
            res_obj.lcstate = new_lcstate
        if new_availability:
            res_obj.availability = new_availability
    res_obj.ts_updated = get_ion_ts()
    self.rr_store.update(res_obj)
    log.debug('execute_lifecycle_transition(res_id=%s, event=%s). Change %s_%s to %s_%s', resource_id, transition_event, old_lcstate, old_availability, res_obj.lcstate, res_obj.availability)
    if self.container.has_capability(self.container.CCAP.EVENT_PUBLISHER):
        self.event_pub.publish_event(event_type='ResourceLifecycleEvent', origin=res_obj._id, origin_type=res_obj.type_, sub_type=('%s.%s' % (res_obj.lcstate, res_obj.availability)), lcstate=res_obj.lcstate, availability=res_obj.availability, lcstate_before=old_lcstate, availability_before=old_availability, transition_event=transition_event)
    return ('%s_%s' % (res_obj.lcstate, res_obj.availability))

dataset/ETHPy150Open ooici/pyon/pyon/ion/resregistry.py ResourceRegistry.execute_lifecycle_transition/VarMisuse@219/443 `transition_event`->`self`