launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #07239
[Merge] lp:~jtv/maas/pre-987585-save-node-acquire-release into lp:maas
Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/pre-987585-save-node-acquire-release into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~jtv/maas/pre-987585-save-node-acquire-release/+merge/103316
The API acquires and releases nodes, and immediately afterwards saves them. A branch I'm working on also needs to acquire a node and immediately save it. Might as well move the save inside the model method.
Jeroen
--
https://code.launchpad.net/~jtv/maas/pre-987585-save-node-acquire-release/+merge/103316
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/maas/pre-987585-save-node-acquire-release into lp:maas.
=== modified file 'src/maasserver/api.py'
--- src/maasserver/api.py 2012-04-20 15:16:41 +0000
+++ src/maasserver/api.py 2012-04-24 16:13:22 +0000
@@ -397,7 +397,6 @@
pass
elif node.status in [NODE_STATUS.ALLOCATED, NODE_STATUS.RESERVED]:
node.release()
- node.save()
else:
raise NodeStateViolation(
"Node cannot be released in its current state ('%s')."
@@ -578,7 +577,6 @@
key = extract_oauth_key(auth_header)
token = Token.objects.get(key=key)
node.acquire(token)
- node.save()
return node
@classmethod
=== modified file 'src/maasserver/models/__init__.py'
--- src/maasserver/models/__init__.py 2012-04-23 08:29:42 +0000
+++ src/maasserver/models/__init__.py 2012-04-24 16:13:22 +0000
@@ -590,12 +590,14 @@
self.status = NODE_STATUS.ALLOCATED
self.owner = token.user
self.token = token
+ self.save()
def release(self):
"""Mark allocated or reserved node as available again."""
self.status = NODE_STATUS.READY
self.owner = None
self.token = None
+ self.save()
mac_re = re.compile(r'^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$')