Skip to content

Commit

Permalink
Merge pull request #129 from ifreecarve/2012-07-20_lcs_retire_bugfix
Browse files Browse the repository at this point in the history
fix bug 'old_state referenced before assignment' when retiring a resource
  • Loading branch information
daf committed Jul 20, 2012
2 parents e4a0fe2 + a8f3abd commit 4f6c575
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pyon/ion/resregistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def retire(self, resource_id):
"""
This is the official "delete" for resource objects: they are set to RETIRED lcstate
"""
self.set_lifecycle_state(resource_id, "RETIRED")
self.set_lifecycle_state(resource_id, LCS.RETIRED)

def delete(self, object_id='', del_associations=False):
res_obj = self.read(object_id)
Expand All @@ -136,7 +136,7 @@ def delete(self, object_id='', del_associations=False):
if not del_associations:
self._delete_owners(object_id)

res_obj.lcstate = 'RETIRED'
res_obj.lcstate = LCS.RETIRED
self.rr_store.update(res_obj)
res = self.rr_store.delete(object_id, del_associations=del_associations)

Expand Down Expand Up @@ -183,14 +183,14 @@ def set_lifecycle_state(self, resource_id='', target_lcstate=''):
raise BadRequest("Unknown life-cycle state %s" % target_lcstate)

res_obj = self.read(resource_id)
if target_lcstate != "RETIRED":
old_state = res_obj.lcstate
if target_lcstate != LCS.RETIRED:
restype = res_obj._get_type()
restype_workflow = get_restype_lcsm(restype)
if not restype_workflow:
raise BadRequest("Resource id=%s type=%s has no lifecycle" % (resource_id, restype))

# Check that target state is allowed
old_state = res_obj.lcstate
if not target_lcstate in restype_workflow.get_successors(res_obj.lcstate).values():
raise BadRequest("Target state %s not reachable for resource in state %s" % (target_lcstate, res_obj.lcstate))

Expand Down

0 comments on commit 4f6c575

Please sign in to comment.