Merge lp:~rvb/maas/bug-1365591-transparent-allocation into lp:~maas-committers/maas/trunk

Proposed by Raphaël Badin
Status: Rejected
Rejected by: MAAS Lander
Proposed branch: lp:~rvb/maas/bug-1365591-transparent-allocation
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 65 lines (+24/-1)
3 files modified
src/maasserver/models/node.py (+10/-0)
src/maasserver/models/tests/test_node.py (+12/-0)
src/maasserver/node_action.py (+2/-1)
To merge this branch: bzr merge lp:~rvb/maas/bug-1365591-transparent-allocation
Reviewer Review Type Date Requested Status
MAAS Maintainers Pending
Review via email: mp+237778@code.launchpad.net

Commit message

Let a user start a ready node; the node will be auto allocated and deployed.

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

Transitioned to Git.

lp:maas has now moved from Bzr to Git.
Please propose your branches with Launchpad using Git.

git clone https://git.launchpad.net/maas

Unmerged revisions

3214. By Raphaël Badin

Allow ready nodes to be started.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/models/node.py'
2--- src/maasserver/models/node.py 2014-10-09 12:56:56 +0000
3+++ src/maasserver/models/node.py 2014-10-09 13:12:22 +0000
4@@ -398,7 +398,13 @@
5 from metadataserver.models import NodeUserData
6
7 # Obtain node model objects for each node specified.
8+ # Obtain nodes the user can edit directly.
9 nodes = self.get_nodes(by_user, NODE_PERMISSION.EDIT, ids=ids)
10+ # Also obtain the nodes the user can acquire and then edit.
11+ ready_nodes = Node.objects.filter_by_ids(
12+ query=Node.objects.get_available_nodes_for_acquisition(by_user),
13+ ids=ids)
14+ nodes = list(chain(nodes, ready_nodes))
15
16 # Record the same user data for all nodes we've been *requested* to
17 # start, regardless of whether or not we actually can; the user may
18@@ -410,6 +416,10 @@
19 # mapping of nodegroups to (ips, macs).
20 static_mappings = defaultdict(dict)
21 for node in nodes:
22+ # If the node is ready, allocate it transparently.
23+ if node.status == NODE_STATUS.READY:
24+ node.acquire(by_user)
25+
26 if node.status == NODE_STATUS.ALLOCATED:
27 claims = node.claim_static_ip_addresses()
28 static_mappings[node.nodegroup].update(claims)
29
30=== modified file 'src/maasserver/models/tests/test_node.py'
31--- src/maasserver/models/tests/test_node.py 2014-10-09 12:01:58 +0000
32+++ src/maasserver/models/tests/test_node.py 2014-10-09 13:12:22 +0000
33@@ -1980,6 +1980,18 @@
34 self.assertEqual(
35 NODE_STATUS.DEPLOYING, reload_object(node).status)
36
37+ def test__acquires_and_deploys_ready_node(self):
38+ user = factory.make_User()
39+ node = factory.make_node_with_mac_attached_to_nodegroupinterface(
40+ status=NODE_STATUS.READY, power_type='virsh')
41+ self.prepare_rpc_to_cluster(node.nodegroup)
42+ nodes_started = Node.objects.start_nodes([node.system_id], user)
43+ self.assertItemsEqual([node], nodes_started)
44+ node = reload_object(node)
45+ self.assertEqual(user, node.owner)
46+ self.assertEqual(
47+ NODE_STATUS.DEPLOYING, node.status)
48+
49 def test__does_not_change_state_of_deployed_node(self):
50 user = factory.make_User()
51 node = factory.make_Node(
52
53=== modified file 'src/maasserver/node_action.py'
54--- src/maasserver/node_action.py 2014-10-08 22:56:31 +0000
55+++ src/maasserver/node_action.py 2014-10-09 13:12:22 +0000
56@@ -307,7 +307,8 @@
57 display = "Start node"
58 display_bulk = "Start selected nodes"
59 actionable_statuses = (
60- NODE_STATUS.ALLOCATED, NODE_STATUS.DEPLOYED)
61+ NODE_STATUS.ALLOCATED, NODE_STATUS.DEPLOYED,
62+ NODE_STATUS.READY)
63 permission = NODE_PERMISSION.EDIT
64
65 def inhibit(self):