Merge lp:~gmb/maas/enlist-mscm-to-RPC into lp:~maas-committers/maas/trunk
- enlist-mscm-to-RPC
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Graham Binns |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2956 |
Proposed branch: | lp:~gmb/maas/enlist-mscm-to-RPC |
Merge into: | lp:~maas-committers/maas/trunk |
Diff against target: |
284 lines (+130/-32) 8 files modified
src/maasserver/api/tests/test_nodegroup.py (+12/-5) src/maasserver/models/nodegroup.py (+16/-6) src/maasserver/models/tests/test_nodegroup.py (+50/-0) src/provisioningserver/rpc/cluster.py (+14/-0) src/provisioningserver/rpc/clusterservice.py (+11/-0) src/provisioningserver/rpc/tests/test_clusterservice.py (+27/-0) src/provisioningserver/tasks.py (+0/-9) src/provisioningserver/tests/test_tasks.py (+0/-12) |
To merge this branch: | bzr merge lp:~gmb/maas/enlist-mscm-to-RPC |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gavin Panella (community) | Approve | ||
Review via email: mp+234279@code.launchpad.net |
Commit message
Convert the enlist_
Description of the change
Gavin Panella (allenap) : | # |
Graham Binns (gmb) wrote : | # |
MAAS Lander (maas-lander) wrote : | # |
The attempt to merge lp:~gmb/maas/enlist-mscm-to-RPC into lp:maas failed. Below is the output from the failed tests.
Ign http://
Ign http://
Hit http://
Ign http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Ign http://
Ign http://
Reading package lists...
sudo DEBIAN_
--
MAAS Lander (maas-lander) wrote : | # |
The attempt to merge lp:~gmb/maas/enlist-mscm-to-RPC into lp:maas failed. Below is the output from the failed tests.
Ign http://
Get:1 http://
Ign http://
Get:2 http://
Ign http://
Hit http://
Get:3 http://
Hit http://
Get:4 http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Hit http://
Get:5 http://
Get:6 http://
Get:7 http://
Get:8 http://
Get:9 http://
Hit http://
Hit http://
Get:10 http://
Get:11 http://
Get:12 http://
Hit http://
Hit http://
Ign http://
Ign http://
Fetched 1,080 kB in 0s (1,756 kB/s)
Reading package lists...
sudo DEBIAN_
--
Preview Diff
1 | === modified file 'src/maasserver/api/tests/test_nodegroup.py' | |||
2 | --- src/maasserver/api/tests/test_nodegroup.py 2014-09-10 06:35:46 +0000 | |||
3 | +++ src/maasserver/api/tests/test_nodegroup.py 2014-09-11 11:22:16 +0000 | |||
4 | @@ -55,7 +55,10 @@ | |||
5 | 55 | ) | 55 | ) |
6 | 56 | from mock import Mock | 56 | from mock import Mock |
7 | 57 | from provisioningserver.auth import get_recorded_nodegroup_uuid | 57 | from provisioningserver.auth import get_recorded_nodegroup_uuid |
9 | 58 | from provisioningserver.rpc.cluster import ImportBootImages | 58 | from provisioningserver.rpc.cluster import ( |
10 | 59 | EnlistNodesFromMSCM, | ||
11 | 60 | ImportBootImages, | ||
12 | 61 | ) | ||
13 | 59 | from testresources import FixtureResource | 62 | from testresources import FixtureResource |
14 | 60 | from testtools.matchers import ( | 63 | from testtools.matchers import ( |
15 | 61 | AllMatch, | 64 | AllMatch, |
16 | @@ -370,7 +373,9 @@ | |||
17 | 370 | password = factory.make_name('password') | 373 | password = factory.make_name('password') |
18 | 371 | self.become_admin() | 374 | self.become_admin() |
19 | 372 | 375 | ||
21 | 373 | mock = self.patch(nodegroup_module, 'enlist_nodes_from_mscm') | 376 | getClientFor = self.patch(nodegroup_module, 'getClientFor') |
22 | 377 | client = getClientFor.return_value | ||
23 | 378 | nodegroup = factory.make_NodeGroup() | ||
24 | 374 | 379 | ||
25 | 375 | response = self.client.post( | 380 | response = self.client.post( |
26 | 376 | reverse('nodegroup_handler', args=[nodegroup.uuid]), | 381 | reverse('nodegroup_handler', args=[nodegroup.uuid]), |
27 | @@ -385,9 +390,11 @@ | |||
28 | 385 | httplib.OK, response.status_code, | 390 | httplib.OK, response.status_code, |
29 | 386 | explain_unexpected_response(httplib.OK, response)) | 391 | explain_unexpected_response(httplib.OK, response)) |
30 | 387 | 392 | ||
34 | 388 | args = (host, username, password) | 393 | self.expectThat( |
35 | 389 | matcher = MockCalledOnceWith(queue=nodegroup.uuid, args=args) | 394 | client, |
36 | 390 | self.assertThat(mock.apply_async, matcher) | 395 | MockCalledOnceWith( |
37 | 396 | EnlistNodesFromMSCM, host=host, username=username, | ||
38 | 397 | password=password)) | ||
39 | 391 | 398 | ||
40 | 392 | 399 | ||
41 | 393 | class TestNodeGroupAPIAuth(MAASServerTestCase): | 400 | class TestNodeGroupAPIAuth(MAASServerTestCase): |
42 | 394 | 401 | ||
43 | === modified file 'src/maasserver/models/nodegroup.py' | |||
44 | --- src/maasserver/models/nodegroup.py 2014-09-10 16:01:38 +0000 | |||
45 | +++ src/maasserver/models/nodegroup.py 2014-09-11 11:22:16 +0000 | |||
46 | @@ -41,13 +41,11 @@ | |||
47 | 41 | from provisioningserver.rpc.cluster import ( | 41 | from provisioningserver.rpc.cluster import ( |
48 | 42 | AddSeaMicro15k, | 42 | AddSeaMicro15k, |
49 | 43 | AddVirsh, | 43 | AddVirsh, |
50 | 44 | EnlistNodesFromMSCM, | ||
51 | 44 | ImportBootImages, | 45 | ImportBootImages, |
52 | 45 | ) | 46 | ) |
53 | 46 | from provisioningserver.rpc.exceptions import NoConnectionsAvailable | 47 | from provisioningserver.rpc.exceptions import NoConnectionsAvailable |
58 | 47 | from provisioningserver.tasks import ( | 48 | from provisioningserver.tasks import enlist_nodes_from_ucsm |
55 | 48 | enlist_nodes_from_mscm, | ||
56 | 49 | enlist_nodes_from_ucsm, | ||
57 | 50 | ) | ||
59 | 51 | 49 | ||
60 | 52 | 50 | ||
61 | 53 | class NodeGroupManager(Manager): | 51 | class NodeGroupManager(Manager): |
62 | @@ -314,6 +312,18 @@ | |||
63 | 314 | :param host: IP address for the MSCM. | 312 | :param host: IP address for the MSCM. |
64 | 315 | :param username: username for MSCM. | 313 | :param username: username for MSCM. |
65 | 316 | :param password: password for MSCM. | 314 | :param password: password for MSCM. |
66 | 315 | |||
67 | 316 | :raises NoConnectionsAvailable: If no connections to the cluster | ||
68 | 317 | are available. | ||
69 | 317 | """ | 318 | """ |
72 | 318 | args = (host, username, password) | 319 | try: |
73 | 319 | enlist_nodes_from_mscm.apply_async(queue=self.uuid, args=args) | 320 | client = getClientFor(self.uuid, timeout=1) |
74 | 321 | except NoConnectionsAvailable: | ||
75 | 322 | # No connection to the cluster so we can't do anything. We | ||
76 | 323 | # let the caller handle the error, since we don't want to | ||
77 | 324 | # just drop it. | ||
78 | 325 | raise | ||
79 | 326 | else: | ||
80 | 327 | return client( | ||
81 | 328 | EnlistNodesFromMSCM, host=host, username=username, | ||
82 | 329 | password=password) | ||
83 | 320 | 330 | ||
84 | === modified file 'src/maasserver/models/tests/test_nodegroup.py' | |||
85 | --- src/maasserver/models/tests/test_nodegroup.py 2014-09-10 16:01:38 +0000 | |||
86 | +++ src/maasserver/models/tests/test_nodegroup.py 2014-09-11 11:22:16 +0000 | |||
87 | @@ -49,6 +49,7 @@ | |||
88 | 49 | from provisioningserver.rpc.cluster import ( | 49 | from provisioningserver.rpc.cluster import ( |
89 | 50 | AddSeaMicro15k, | 50 | AddSeaMicro15k, |
90 | 51 | AddVirsh, | 51 | AddVirsh, |
91 | 52 | EnlistNodesFromMSCM, | ||
92 | 52 | ImportBootImages, | 53 | ImportBootImages, |
93 | 53 | ) | 54 | ) |
94 | 54 | from provisioningserver.rpc.exceptions import NoConnectionsAvailable | 55 | from provisioningserver.rpc.exceptions import NoConnectionsAvailable |
95 | @@ -513,3 +514,52 @@ | |||
96 | 513 | self.assertRaises( | 514 | self.assertRaises( |
97 | 514 | NoConnectionsAvailable, nodegroup.add_seamicro15k, | 515 | NoConnectionsAvailable, nodegroup.add_seamicro15k, |
98 | 515 | mac, username, password, power_control) | 516 | mac, username, password, power_control) |
99 | 517 | |||
100 | 518 | def test_enlist_nodes_from_mscm_end_to_end(self): | ||
101 | 519 | nodegroup = factory.make_NodeGroup(status=NODEGROUP_STATUS.ACCEPTED) | ||
102 | 520 | |||
103 | 521 | self.useFixture(RegionEventLoopFixture("rpc")) | ||
104 | 522 | self.useFixture(RunningEventLoopFixture()) | ||
105 | 523 | fixture = self.useFixture(MockLiveRegionToClusterRPCFixture()) | ||
106 | 524 | protocol = fixture.makeCluster(nodegroup, EnlistNodesFromMSCM) | ||
107 | 525 | protocol.EnlistNodesFromMSCM.return_value = defer.succeed({}) | ||
108 | 526 | |||
109 | 527 | host = factory.make_name('host') | ||
110 | 528 | username = factory.make_name('user') | ||
111 | 529 | password = factory.make_name('password') | ||
112 | 530 | nodegroup.enlist_nodes_from_mscm( | ||
113 | 531 | host, username, password).wait(10) | ||
114 | 532 | |||
115 | 533 | self.expectThat( | ||
116 | 534 | protocol.EnlistNodesFromMSCM, | ||
117 | 535 | MockCalledOnceWith( | ||
118 | 536 | ANY, host=host, username=username, password=password)) | ||
119 | 537 | |||
120 | 538 | def test_enlist_nodes_from_mscm_calls_client_with_resource_endpoint(self): | ||
121 | 539 | getClientFor = self.patch(nodegroup_module, 'getClientFor') | ||
122 | 540 | client = getClientFor.return_value | ||
123 | 541 | nodegroup = factory.make_NodeGroup() | ||
124 | 542 | |||
125 | 543 | host = factory.make_name('host') | ||
126 | 544 | username = factory.make_name('user') | ||
127 | 545 | password = factory.make_name('password') | ||
128 | 546 | nodegroup.enlist_nodes_from_mscm( | ||
129 | 547 | host, username, password).wait(10) | ||
130 | 548 | |||
131 | 549 | self.expectThat( | ||
132 | 550 | client, | ||
133 | 551 | MockCalledOnceWith( | ||
134 | 552 | EnlistNodesFromMSCM, host=host, username=username, | ||
135 | 553 | password=password)) | ||
136 | 554 | |||
137 | 555 | def test_enlist_nodes_from_mscm_raises_if_no_connection_to_cluster(self): | ||
138 | 556 | getClientFor = self.patch(nodegroup_module, 'getClientFor') | ||
139 | 557 | getClientFor.side_effect = NoConnectionsAvailable() | ||
140 | 558 | nodegroup = factory.make_NodeGroup() | ||
141 | 559 | |||
142 | 560 | host = factory.make_name('host') | ||
143 | 561 | username = factory.make_name('user') | ||
144 | 562 | password = factory.make_name('password') | ||
145 | 563 | self.assertRaises( | ||
146 | 564 | NoConnectionsAvailable, nodegroup.enlist_nodes_from_mscm, | ||
147 | 565 | host, username, password) | ||
148 | 516 | 566 | ||
149 | === modified file 'src/provisioningserver/rpc/cluster.py' | |||
150 | --- src/provisioningserver/rpc/cluster.py 2014-09-10 16:44:28 +0000 | |||
151 | +++ src/provisioningserver/rpc/cluster.py 2014-09-11 11:22:16 +0000 | |||
152 | @@ -377,3 +377,17 @@ | |||
153 | 377 | errors = { | 377 | errors = { |
154 | 378 | exceptions.NoIPFoundForMACAddress: b"NoIPFoundForMACAddress", | 378 | exceptions.NoIPFoundForMACAddress: b"NoIPFoundForMACAddress", |
155 | 379 | } | 379 | } |
156 | 380 | |||
157 | 381 | |||
158 | 382 | class EnlistNodesFromMSCM(amp.Command): | ||
159 | 383 | """Probe for and enlist mscm machines attached to the cluster. | ||
160 | 384 | |||
161 | 385 | :since: 1.7 | ||
162 | 386 | """ | ||
163 | 387 | arguments = [ | ||
164 | 388 | (b"host", amp.Unicode()), | ||
165 | 389 | (b"username", amp.Unicode()), | ||
166 | 390 | (b"password", amp.Unicode()), | ||
167 | 391 | ] | ||
168 | 392 | response = [] | ||
169 | 393 | errors = {} | ||
170 | 380 | 394 | ||
171 | === modified file 'src/provisioningserver/rpc/clusterservice.py' | |||
172 | --- src/provisioningserver/rpc/clusterservice.py 2014-09-10 23:00:52 +0000 | |||
173 | +++ src/provisioningserver/rpc/clusterservice.py 2014-09-11 11:22:16 +0000 | |||
174 | @@ -29,6 +29,7 @@ | |||
175 | 29 | ArchitectureRegistry, | 29 | ArchitectureRegistry, |
176 | 30 | PowerTypeRegistry, | 30 | PowerTypeRegistry, |
177 | 31 | ) | 31 | ) |
178 | 32 | from provisioningserver.drivers.hardware.mscm import probe_and_enlist_mscm | ||
179 | 32 | from provisioningserver.drivers.hardware.seamicro import ( | 33 | from provisioningserver.drivers.hardware.seamicro import ( |
180 | 33 | probe_seamicro15k_and_enlist, | 34 | probe_seamicro15k_and_enlist, |
181 | 34 | ) | 35 | ) |
182 | @@ -266,6 +267,16 @@ | |||
183 | 266 | raise exceptions.NoIPFoundForMACAddress(message) | 267 | raise exceptions.NoIPFoundForMACAddress(message) |
184 | 267 | return {} | 268 | return {} |
185 | 268 | 269 | ||
186 | 270 | @cluster.EnlistNodesFromMSCM.responder | ||
187 | 271 | def enlist_nodes_from_mscm(self, host, username, password): | ||
188 | 272 | """enlist_nodes_from_mscm() | ||
189 | 273 | |||
190 | 274 | Implemention of | ||
191 | 275 | :py:class:`~provisioningserver.rpc.cluster.EnlistNodesFromMSCM`. | ||
192 | 276 | """ | ||
193 | 277 | probe_and_enlist_mscm(host, username, password) | ||
194 | 278 | return {} | ||
195 | 279 | |||
196 | 269 | 280 | ||
197 | 270 | @implementer(IConnection) | 281 | @implementer(IConnection) |
198 | 271 | class ClusterClient(Cluster): | 282 | class ClusterClient(Cluster): |
199 | 272 | 283 | ||
200 | === modified file 'src/provisioningserver/rpc/tests/test_clusterservice.py' | |||
201 | --- src/provisioningserver/rpc/tests/test_clusterservice.py 2014-09-10 23:00:52 +0000 | |||
202 | +++ src/provisioningserver/rpc/tests/test_clusterservice.py 2014-09-11 11:22:16 +0000 | |||
203 | @@ -1256,3 +1256,30 @@ | |||
204 | 1256 | probe_seamicro15k_and_enlist, MockCalledOnceWith( | 1256 | probe_seamicro15k_and_enlist, MockCalledOnceWith( |
205 | 1257 | find_ip_via_arp.return_value, username, password, | 1257 | find_ip_via_arp.return_value, username, password, |
206 | 1258 | power_control=power_control)) | 1258 | power_control=power_control)) |
207 | 1259 | |||
208 | 1260 | |||
209 | 1261 | class TestClusterProtocol_EnlistNodesFromMSCM(MAASTestCase): | ||
210 | 1262 | |||
211 | 1263 | def test__is_registered(self): | ||
212 | 1264 | protocol = Cluster() | ||
213 | 1265 | responder = protocol.locateResponder( | ||
214 | 1266 | cluster.EnlistNodesFromMSCM.commandName) | ||
215 | 1267 | self.assertIsNot(responder, None) | ||
216 | 1268 | |||
217 | 1269 | def test__calls_probe_and_enlist_mscm(self): | ||
218 | 1270 | probe_and_enlist_mscm = self.patch_autospec( | ||
219 | 1271 | clusterservice, 'probe_and_enlist_mscm') | ||
220 | 1272 | |||
221 | 1273 | host = factory.make_name('host') | ||
222 | 1274 | username = factory.make_name('user') | ||
223 | 1275 | password = factory.make_name('password') | ||
224 | 1276 | |||
225 | 1277 | call_responder(Cluster(), cluster.EnlistNodesFromMSCM, { | ||
226 | 1278 | 'host': host, | ||
227 | 1279 | 'username': username, | ||
228 | 1280 | 'password': password, | ||
229 | 1281 | }) | ||
230 | 1282 | |||
231 | 1283 | self.assertThat( | ||
232 | 1284 | probe_and_enlist_mscm, MockCalledOnceWith( | ||
233 | 1285 | host, username, password)) | ||
234 | 1259 | 1286 | ||
235 | === modified file 'src/provisioningserver/tasks.py' | |||
236 | --- src/provisioningserver/tasks.py 2014-09-10 17:00:43 +0000 | |||
237 | +++ src/provisioningserver/tasks.py 2014-09-11 11:22:16 +0000 | |||
238 | @@ -42,7 +42,6 @@ | |||
239 | 42 | set_up_options_conf, | 42 | set_up_options_conf, |
240 | 43 | setup_rndc, | 43 | setup_rndc, |
241 | 44 | ) | 44 | ) |
242 | 45 | from provisioningserver.drivers.hardware.mscm import probe_and_enlist_mscm | ||
243 | 46 | from provisioningserver.drivers.hardware.ucsm import probe_and_enlist_ucsm | 45 | from provisioningserver.drivers.hardware.ucsm import probe_and_enlist_ucsm |
244 | 47 | from provisioningserver.logger import get_maas_logger | 46 | from provisioningserver.logger import get_maas_logger |
245 | 48 | 47 | ||
246 | @@ -309,11 +308,3 @@ | |||
247 | 309 | def enlist_nodes_from_ucsm(url, username, password): | 308 | def enlist_nodes_from_ucsm(url, username, password): |
248 | 310 | """ See `maasserver.api.NodeGroupHandler.enlist_nodes_from_ucsm`. """ | 309 | """ See `maasserver.api.NodeGroupHandler.enlist_nodes_from_ucsm`. """ |
249 | 311 | probe_and_enlist_ucsm(url, username, password) | 310 | probe_and_enlist_ucsm(url, username, password) |
250 | 312 | |||
251 | 313 | |||
252 | 314 | @task | ||
253 | 315 | @log_task_events() | ||
254 | 316 | @log_exception_text | ||
255 | 317 | def enlist_nodes_from_mscm(host, username, password): | ||
256 | 318 | """ See `maasserver.api.NodeGroupHandler.enlist_nodes_from_mscm`. """ | ||
257 | 319 | probe_and_enlist_mscm(host, username, password) | ||
258 | 320 | 311 | ||
259 | === modified file 'src/provisioningserver/tests/test_tasks.py' | |||
260 | --- src/provisioningserver/tests/test_tasks.py 2014-09-10 17:00:43 +0000 | |||
261 | +++ src/provisioningserver/tests/test_tasks.py 2014-09-11 11:22:16 +0000 | |||
262 | @@ -55,7 +55,6 @@ | |||
263 | 55 | ) | 55 | ) |
264 | 56 | from provisioningserver.tags import MissingCredentials | 56 | from provisioningserver.tags import MissingCredentials |
265 | 57 | from provisioningserver.tasks import ( | 57 | from provisioningserver.tasks import ( |
266 | 58 | enlist_nodes_from_mscm, | ||
267 | 59 | enlist_nodes_from_ucsm, | 58 | enlist_nodes_from_ucsm, |
268 | 60 | refresh_secrets, | 59 | refresh_secrets, |
269 | 61 | report_boot_images, | 60 | report_boot_images, |
270 | @@ -403,14 +402,3 @@ | |||
271 | 403 | mock = self.patch(tasks, 'probe_and_enlist_ucsm') | 402 | mock = self.patch(tasks, 'probe_and_enlist_ucsm') |
272 | 404 | enlist_nodes_from_ucsm(url, username, password) | 403 | enlist_nodes_from_ucsm(url, username, password) |
273 | 405 | self.assertThat(mock, MockCalledOnceWith(url, username, password)) | 404 | self.assertThat(mock, MockCalledOnceWith(url, username, password)) |
274 | 406 | |||
275 | 407 | |||
276 | 408 | class TestAddMSCM(PservTestCase): | ||
277 | 409 | |||
278 | 410 | def test_enlist_nodes_from_mscm(self): | ||
279 | 411 | host = 'host' | ||
280 | 412 | username = 'username' | ||
281 | 413 | password = 'password' | ||
282 | 414 | mock = self.patch(tasks, 'probe_and_enlist_mscm') | ||
283 | 415 | enlist_nodes_from_mscm(host, username, password) | ||
284 | 416 | self.assertThat(mock, MockCalledOnceWith(host, username, password)) |
On 11 September 2014 11:28, Gavin Panella <email address hidden> wrote: MSCM(amp. Command) :
>
>> +
>> +class EnlistNodesFrom
>> + """Probe for and enlist mscm machines attached to the cluster.
>> +
>> + :since 1.7:
>> + """
>> + arguments = [
>> + (b"host", amp.Unicode()),
>> + (b"username", amp.Unicode()),
>> + (b"password", amp.Unicode()),
>> + ]
>> + response = []
>> + errors = {}
>
> No errors at all?
probe_and_ enlist_ mscm() doesn't appear to raise any, so no. This is
one of those cases where we need a catch-all, because I don't know
what might happen further down the stack (this is the one and only
time I've ever been tempted to miss Java's error declarations…)