We need to be able to look up Instance by Node (live migration).

This commit is contained in:
Todd Willey
2010-06-29 01:20:43 -04:00
parent 3972cf90c2
commit c7f7e1bc41
+4 -1
View File
@@ -349,12 +349,15 @@ class Instance(BasicModel):
def save(self):
"""Call into superclass to save object, then save associations"""
# NOTE(todd): doesn't track migration between projects,
# NOTE(todd): doesn't track migration between projects/nodes,
# it just adds the first one
should_update_project = self.is_new_record()
should_update_node = self.is_new_record()
success = super(Instance, self).save()
if success and should_update_project:
self.associate_with("project", self.project)
if success and should_update_node:
self.associate_with("node", self['node_name'])
return True
def destroy(self):