Merge lp:~allenap/maas/name-constraint-by-name-bug-984633 into lp:maas/trunk

Proposed by Gavin Panella on 2012-04-18
Status: Merged
Approved by: Gavin Panella on 2012-04-18
Approved revision: 481
Merged at revision: 480
Proposed branch: lp:~allenap/maas/name-constraint-by-name-bug-984633
Merge into: lp:maas/trunk
Diff against target: 60 lines (+7/-7)
3 files modified
src/maasserver/models.py (+1/-1)
src/maasserver/tests/test_api.py (+5/-5)
src/maasserver/tests/test_models.py (+1/-1)
To merge this branch: bzr merge lp:~allenap/maas/name-constraint-by-name-bug-984633
Reviewer Review Type Date Requested Status
Raphaël Badin (community) 2012-04-18 Approve on 2012-04-18
Review via email: mp+102474@code.launchpad.net

Commit message

Name constraint now filters on node hostname. Previously it would filter on system ID.

To post a comment you must log in.
Raphaël Badin (rvb) wrote :

Approved but there is a test that needs fixing:
failure: http://paste.ubuntu.com/935216/
fix: http://paste.ubuntu.com/935217/

review: Approve
481. By Gavin Panella on 2012-04-18

Fix failing test.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/models.py'
2--- src/maasserver/models.py 2012-04-16 10:00:51 +0000
3+++ src/maasserver/models.py 2012-04-18 10:10:24 +0000
4@@ -387,7 +387,7 @@
5
6 if constraints.get('name'):
7 available_nodes = available_nodes.filter(
8- system_id=constraints['name'])
9+ hostname=constraints['name'])
10
11 available_nodes = list(available_nodes[:1])
12 if len(available_nodes) == 0:
13
14=== modified file 'src/maasserver/tests/test_api.py'
15--- src/maasserver/tests/test_api.py 2012-04-16 10:00:51 +0000
16+++ src/maasserver/tests/test_api.py 2012-04-18 10:10:24 +0000
17@@ -1043,11 +1043,11 @@
18 desired_node = random.choice(available_nodes)
19 response = self.client.post(self.get_uri('nodes/'), {
20 'op': 'acquire',
21- 'name': desired_node.system_id,
22+ 'name': desired_node.hostname,
23 })
24 self.assertEqual(httplib.OK, response.status_code)
25 parsed_result = json.loads(response.content)
26- self.assertEqual(desired_node.system_id, parsed_result['system_id'])
27+ self.assertEqual(desired_node.hostname, parsed_result['hostname'])
28
29 def test_POST_acquire_would_rather_fail_than_disobey_constraint(self):
30 # If "acquire" is passed a constraint, it won't return a node
31@@ -1077,13 +1077,13 @@
32 # If a name constraint is given, "acquire" attempts to allocate
33 # a node of that name.
34 node = factory.make_node(status=NODE_STATUS.READY, owner=None)
35- system_id = node.system_id
36 response = self.client.post(self.get_uri('nodes/'), {
37 'op': 'acquire',
38- 'name': system_id,
39+ 'name': node.hostname,
40 })
41 self.assertEqual(httplib.OK, response.status_code)
42- self.assertEqual(system_id, json.loads(response.content)['system_id'])
43+ self.assertEqual(
44+ node.hostname, json.loads(response.content)['hostname'])
45
46 def test_POST_acquire_constrains_by_name(self):
47 # Negative test for name constraint.
48
49=== modified file 'src/maasserver/tests/test_models.py'
50--- src/maasserver/tests/test_models.py 2012-04-16 10:00:51 +0000
51+++ src/maasserver/tests/test_models.py 2012-04-18 10:10:24 +0000
52@@ -555,7 +555,7 @@
53 self.assertEqual(
54 nodes[1],
55 Node.objects.get_available_node_for_acquisition(
56- user, {'name': nodes[1].system_id}))
57+ user, {'name': nodes[1].hostname}))
58
59 def test_get_available_node_returns_None_if_name_is_unknown(self):
60 user = factory.make_user()