Merge lp:~newell-jensen/maas/prefix-filter-virsh-bug-1393423 into lp:~maas-committers/maas/trunk
- prefix-filter-virsh-bug-1393423
- Merge into trunk
Proposed by
Newell Jensen
Status: | Merged |
---|---|
Approved by: | Newell Jensen |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3404 |
Proposed branch: | lp:~newell-jensen/maas/prefix-filter-virsh-bug-1393423 |
Merge into: | lp:~maas-committers/maas/trunk |
Diff against target: |
332 lines (+113/-18) 9 files modified
src/maasserver/api/node_groups.py (+6/-1) src/maasserver/api/tests/test_nodegroup.py (+70/-0) src/maasserver/models/nodegroup.py (+4/-2) src/maasserver/models/tests/test_nodegroup.py (+5/-2) src/provisioningserver/drivers/hardware/tests/test_virsh.py (+11/-4) src/provisioningserver/drivers/hardware/virsh.py (+9/-4) src/provisioningserver/rpc/cluster.py (+1/-0) src/provisioningserver/rpc/clusterservice.py (+2/-2) src/provisioningserver/rpc/tests/test_clusterservice.py (+5/-3) |
To merge this branch: | bzr merge lp:~newell-jensen/maas/prefix-filter-virsh-bug-1393423 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Blake Rouse (community) | Approve | ||
Review via email: mp+243569@code.launchpad.net |
Commit message
This branch gives the user the capability to add an optional `prefix_filter` parameter to the api call for probe_and_
Description of the change
To post a comment you must log in.
Revision history for this message
Newell Jensen (newell-jensen) wrote : | # |
Revision history for this message
Blake Rouse (blake-rouse) wrote : | # |
Looks good.
Thanks for adding the sm15k test in there as well.
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/maasserver/api/node_groups.py' | |||
2 | --- src/maasserver/api/node_groups.py 2014-11-27 08:05:50 +0000 | |||
3 | +++ src/maasserver/api/node_groups.py 2014-12-03 22:30:57 +0000 | |||
4 | @@ -395,6 +395,8 @@ | |||
5 | 395 | :param power_pass: The password to use, when qemu+ssh is given as a | 395 | :param power_pass: The password to use, when qemu+ssh is given as a |
6 | 396 | connection string and ssh key authentication is not being used. | 396 | connection string and ssh key authentication is not being used. |
7 | 397 | :type power_pass: unicode | 397 | :type power_pass: unicode |
8 | 398 | :param prefix_filter: Only import nodes based on supplied prefix. | ||
9 | 399 | :type prefix_filter: unicode | ||
10 | 398 | 400 | ||
11 | 399 | Returns 404 if the nodegroup (cluster) is not found. | 401 | Returns 404 if the nodegroup (cluster) is not found. |
12 | 400 | Returns 403 if the user does not have access to the nodegroup. | 402 | Returns 403 if the user does not have access to the nodegroup. |
13 | @@ -417,8 +419,11 @@ | |||
14 | 417 | poweraddr = get_mandatory_param(request.data, 'power_address') | 419 | poweraddr = get_mandatory_param(request.data, 'power_address') |
15 | 418 | password = get_optional_param( | 420 | password = get_optional_param( |
16 | 419 | request.data, 'power_pass', default=None) | 421 | request.data, 'power_pass', default=None) |
17 | 422 | prefix_filter = get_optional_param( | ||
18 | 423 | request.data, 'prefix_filter', default=None) | ||
19 | 420 | 424 | ||
21 | 421 | nodegroup.add_virsh(poweraddr, password=password) | 425 | nodegroup.add_virsh( |
22 | 426 | poweraddr, password=password, prefix_filter=prefix_filter) | ||
23 | 422 | else: | 427 | else: |
24 | 423 | return HttpResponse(status=httplib.BAD_REQUEST) | 428 | return HttpResponse(status=httplib.BAD_REQUEST) |
25 | 424 | 429 | ||
26 | 425 | 430 | ||
27 | === modified file 'src/maasserver/api/tests/test_nodegroup.py' | |||
28 | --- src/maasserver/api/tests/test_nodegroup.py 2014-10-23 18:21:41 +0000 | |||
29 | +++ src/maasserver/api/tests/test_nodegroup.py 2014-12-03 22:30:57 +0000 | |||
30 | @@ -16,6 +16,7 @@ | |||
31 | 16 | 16 | ||
32 | 17 | import httplib | 17 | import httplib |
33 | 18 | import json | 18 | import json |
34 | 19 | import random | ||
35 | 19 | from textwrap import dedent | 20 | from textwrap import dedent |
36 | 20 | from urlparse import urlparse | 21 | from urlparse import urlparse |
37 | 21 | 22 | ||
38 | @@ -56,6 +57,8 @@ | |||
39 | 56 | ) | 57 | ) |
40 | 57 | from mock import Mock | 58 | from mock import Mock |
41 | 58 | from provisioningserver.rpc.cluster import ( | 59 | from provisioningserver.rpc.cluster import ( |
42 | 60 | AddSeaMicro15k, | ||
43 | 61 | AddVirsh, | ||
44 | 59 | EnlistNodesFromMSCM, | 62 | EnlistNodesFromMSCM, |
45 | 60 | EnlistNodesFromUCSM, | 63 | EnlistNodesFromUCSM, |
46 | 61 | ImportBootImages, | 64 | ImportBootImages, |
47 | @@ -327,6 +330,73 @@ | |||
48 | 327 | httplib.BAD_REQUEST, response.status_code, | 330 | httplib.BAD_REQUEST, response.status_code, |
49 | 328 | explain_unexpected_response(httplib.BAD_REQUEST, response)) | 331 | explain_unexpected_response(httplib.BAD_REQUEST, response)) |
50 | 329 | 332 | ||
51 | 333 | def test_probe_and_enlist_hardware_adds_seamicro(self): | ||
52 | 334 | nodegroup = factory.make_NodeGroup() | ||
53 | 335 | model = 'seamicro15k' | ||
54 | 336 | mac = factory.make_mac_address() | ||
55 | 337 | username = factory.make_name('user') | ||
56 | 338 | password = factory.make_name('password') | ||
57 | 339 | power_control = random.choice( | ||
58 | 340 | ['ipmi', 'restapi', 'restapi2']) | ||
59 | 341 | self.become_admin() | ||
60 | 342 | |||
61 | 343 | getClientFor = self.patch(nodegroup_module, 'getClientFor') | ||
62 | 344 | client = getClientFor.return_value | ||
63 | 345 | nodegroup = factory.make_NodeGroup() | ||
64 | 346 | |||
65 | 347 | response = self.client.post( | ||
66 | 348 | reverse('nodegroup_handler', args=[nodegroup.uuid]), | ||
67 | 349 | { | ||
68 | 350 | 'op': 'probe_and_enlist_hardware', | ||
69 | 351 | 'model': model, | ||
70 | 352 | 'mac': mac, | ||
71 | 353 | 'username': username, | ||
72 | 354 | 'password': password, | ||
73 | 355 | 'power_control': power_control, | ||
74 | 356 | }) | ||
75 | 357 | |||
76 | 358 | self.assertEqual( | ||
77 | 359 | httplib.OK, response.status_code, | ||
78 | 360 | explain_unexpected_response(httplib.OK, response)) | ||
79 | 361 | |||
80 | 362 | self.expectThat( | ||
81 | 363 | client, | ||
82 | 364 | MockCalledOnceWith( | ||
83 | 365 | AddSeaMicro15k, mac=mac, username=username, | ||
84 | 366 | password=password, power_control=power_control)) | ||
85 | 367 | |||
86 | 368 | def test_probe_and_enlist_hardware_adds_virsh(self): | ||
87 | 369 | nodegroup = factory.make_NodeGroup() | ||
88 | 370 | model = 'virsh' | ||
89 | 371 | poweraddr = factory.make_ipv4_address() | ||
90 | 372 | password = factory.make_name('password') | ||
91 | 373 | prefix_filter = factory.make_name('filter') | ||
92 | 374 | self.become_admin() | ||
93 | 375 | |||
94 | 376 | getClientFor = self.patch(nodegroup_module, 'getClientFor') | ||
95 | 377 | client = getClientFor.return_value | ||
96 | 378 | nodegroup = factory.make_NodeGroup() | ||
97 | 379 | |||
98 | 380 | response = self.client.post( | ||
99 | 381 | reverse('nodegroup_handler', args=[nodegroup.uuid]), | ||
100 | 382 | { | ||
101 | 383 | 'op': 'probe_and_enlist_hardware', | ||
102 | 384 | 'model': model, | ||
103 | 385 | 'power_address': poweraddr, | ||
104 | 386 | 'power_pass': password, | ||
105 | 387 | 'prefix_filter': prefix_filter, | ||
106 | 388 | }) | ||
107 | 389 | |||
108 | 390 | self.assertEqual( | ||
109 | 391 | httplib.OK, response.status_code, | ||
110 | 392 | explain_unexpected_response(httplib.OK, response)) | ||
111 | 393 | |||
112 | 394 | self.expectThat( | ||
113 | 395 | client, | ||
114 | 396 | MockCalledOnceWith( | ||
115 | 397 | AddVirsh, poweraddr=poweraddr, | ||
116 | 398 | password=password, prefix_filter=prefix_filter)) | ||
117 | 399 | |||
118 | 330 | def test_probe_and_enlist_ucsm_adds_ucsm(self): | 400 | def test_probe_and_enlist_ucsm_adds_ucsm(self): |
119 | 331 | nodegroup = factory.make_NodeGroup() | 401 | nodegroup = factory.make_NodeGroup() |
120 | 332 | url = 'http://url' | 402 | url = 'http://url' |
121 | 333 | 403 | ||
122 | === modified file 'src/maasserver/models/nodegroup.py' | |||
123 | --- src/maasserver/models/nodegroup.py 2014-10-23 18:21:41 +0000 | |||
124 | +++ src/maasserver/models/nodegroup.py 2014-12-03 22:30:57 +0000 | |||
125 | @@ -337,11 +337,12 @@ | |||
126 | 337 | AddSeaMicro15k, mac=mac, username=username, | 337 | AddSeaMicro15k, mac=mac, username=username, |
127 | 338 | password=password, power_control=power_control) | 338 | password=password, power_control=power_control) |
128 | 339 | 339 | ||
130 | 340 | def add_virsh(self, poweraddr, password=None): | 340 | def add_virsh(self, poweraddr, password=None, prefix_filter=None): |
131 | 341 | """ Add all of the virtual machines inside a virsh controller. | 341 | """ Add all of the virtual machines inside a virsh controller. |
132 | 342 | 342 | ||
133 | 343 | :param poweraddr: virsh connection string | 343 | :param poweraddr: virsh connection string |
134 | 344 | :param password: ssh password | 344 | :param password: ssh password |
135 | 345 | :param prefix_filter: import based on prefix | ||
136 | 345 | 346 | ||
137 | 346 | :raises NoConnectionsAvailable: If no connections to the cluster | 347 | :raises NoConnectionsAvailable: If no connections to the cluster |
138 | 347 | are available. | 348 | are available. |
139 | @@ -355,7 +356,8 @@ | |||
140 | 355 | raise | 356 | raise |
141 | 356 | else: | 357 | else: |
142 | 357 | return client( | 358 | return client( |
144 | 358 | AddVirsh, poweraddr=poweraddr, password=password) | 359 | AddVirsh, poweraddr=poweraddr, |
145 | 360 | password=password, prefix_filter=prefix_filter) | ||
146 | 359 | 361 | ||
147 | 360 | def enlist_nodes_from_ucsm(self, url, username, password): | 362 | def enlist_nodes_from_ucsm(self, url, username, password): |
148 | 361 | """ Add the servers from a Cicso UCS Manager. | 363 | """ Add the servers from a Cicso UCS Manager. |
149 | 362 | 364 | ||
150 | === modified file 'src/maasserver/models/tests/test_nodegroup.py' | |||
151 | --- src/maasserver/models/tests/test_nodegroup.py 2014-10-23 18:21:41 +0000 | |||
152 | +++ src/maasserver/models/tests/test_nodegroup.py 2014-12-03 22:30:57 +0000 | |||
153 | @@ -506,7 +506,9 @@ | |||
154 | 506 | 506 | ||
155 | 507 | self.expectThat( | 507 | self.expectThat( |
156 | 508 | protocol.AddVirsh, | 508 | protocol.AddVirsh, |
158 | 509 | MockCalledOnceWith(ANY, poweraddr=poweraddr, password=password)) | 509 | MockCalledOnceWith( |
159 | 510 | ANY, poweraddr=poweraddr, | ||
160 | 511 | password=password, prefix_filter=None)) | ||
161 | 510 | 512 | ||
162 | 511 | def test_add_virsh_calls_client_with_resource_endpoint(self): | 513 | def test_add_virsh_calls_client_with_resource_endpoint(self): |
163 | 512 | getClientFor = self.patch(nodegroup_module, 'getClientFor') | 514 | getClientFor = self.patch(nodegroup_module, 'getClientFor') |
164 | @@ -520,7 +522,8 @@ | |||
165 | 520 | self.expectThat( | 522 | self.expectThat( |
166 | 521 | client, | 523 | client, |
167 | 522 | MockCalledOnceWith( | 524 | MockCalledOnceWith( |
169 | 523 | AddVirsh, poweraddr=poweraddr, password=password)) | 525 | AddVirsh, poweraddr=poweraddr, |
170 | 526 | password=password, prefix_filter=None)) | ||
171 | 524 | 527 | ||
172 | 525 | def test_add_virsh_raises_if_no_connection_to_cluster(self): | 528 | def test_add_virsh_raises_if_no_connection_to_cluster(self): |
173 | 526 | getClientFor = self.patch(nodegroup_module, 'getClientFor') | 529 | getClientFor = self.patch(nodegroup_module, 'getClientFor') |
174 | 527 | 530 | ||
175 | === modified file 'src/provisioningserver/drivers/hardware/tests/test_virsh.py' | |||
176 | --- src/provisioningserver/drivers/hardware/tests/test_virsh.py 2014-09-18 12:44:38 +0000 | |||
177 | +++ src/provisioningserver/drivers/hardware/tests/test_virsh.py 2014-12-03 22:30:57 +0000 | |||
178 | @@ -53,10 +53,10 @@ | |||
179 | 53 | class TestVirshSSH(MAASTestCase): | 53 | class TestVirshSSH(MAASTestCase): |
180 | 54 | """Tests for `VirshSSH`.""" | 54 | """Tests for `VirshSSH`.""" |
181 | 55 | 55 | ||
183 | 56 | def configure_virshssh_pexpect(self, inputs=None): | 56 | def configure_virshssh_pexpect(self, inputs=None, dom_prefix=None): |
184 | 57 | """Configures the VirshSSH class to use 'cat' process | 57 | """Configures the VirshSSH class to use 'cat' process |
185 | 58 | for testing instead of the actual virsh.""" | 58 | for testing instead of the actual virsh.""" |
187 | 59 | conn = virsh.VirshSSH(timeout=0.1) | 59 | conn = virsh.VirshSSH(timeout=0.1, dom_prefix=dom_prefix) |
188 | 60 | self.addCleanup(conn.close) | 60 | self.addCleanup(conn.close) |
189 | 61 | self.patch(conn, '_execute') | 61 | self.patch(conn, '_execute') |
190 | 62 | conn._spawn('cat') | 62 | conn._spawn('cat') |
191 | @@ -65,9 +65,9 @@ | |||
192 | 65 | conn.sendline(line) | 65 | conn.sendline(line) |
193 | 66 | return conn | 66 | return conn |
194 | 67 | 67 | ||
196 | 68 | def configure_virshssh(self, output): | 68 | def configure_virshssh(self, output, dom_prefix=None): |
197 | 69 | self.patch(virsh.VirshSSH, 'run').return_value = output | 69 | self.patch(virsh.VirshSSH, 'run').return_value = output |
199 | 70 | return virsh.VirshSSH() | 70 | return virsh.VirshSSH(dom_prefix=dom_prefix) |
200 | 71 | 71 | ||
201 | 72 | def test_login_prompt(self): | 72 | def test_login_prompt(self): |
202 | 73 | virsh_outputs = [ | 73 | virsh_outputs = [ |
203 | @@ -157,6 +157,13 @@ | |||
204 | 157 | expected = conn.list() | 157 | expected = conn.list() |
205 | 158 | self.assertItemsEqual(names, expected) | 158 | self.assertItemsEqual(names, expected) |
206 | 159 | 159 | ||
207 | 160 | def test_list_dom_prefix(self): | ||
208 | 161 | prefix = 'dom_prefix' | ||
209 | 162 | names = [prefix + factory.make_name('machine') for _ in range(3)] | ||
210 | 163 | conn = self.configure_virshssh('\n'.join(names), dom_prefix=prefix) | ||
211 | 164 | expected = conn.list() | ||
212 | 165 | self.assertItemsEqual(names, expected) | ||
213 | 166 | |||
214 | 160 | def test_get_state(self): | 167 | def test_get_state(self): |
215 | 161 | state = factory.make_name('state') | 168 | state = factory.make_name('state') |
216 | 162 | conn = self.configure_virshssh(state) | 169 | conn = self.configure_virshssh(state) |
217 | 163 | 170 | ||
218 | === modified file 'src/provisioningserver/drivers/hardware/virsh.py' | |||
219 | --- src/provisioningserver/drivers/hardware/virsh.py 2014-12-02 05:56:30 +0000 | |||
220 | +++ src/provisioningserver/drivers/hardware/virsh.py 2014-12-03 22:30:57 +0000 | |||
221 | @@ -79,10 +79,14 @@ | |||
222 | 79 | I_PROMPT_SSHKEY = PROMPTS.index(PROMPT_SSHKEY) | 79 | I_PROMPT_SSHKEY = PROMPTS.index(PROMPT_SSHKEY) |
223 | 80 | I_PROMPT_PASSWORD = PROMPTS.index(PROMPT_PASSWORD) | 80 | I_PROMPT_PASSWORD = PROMPTS.index(PROMPT_PASSWORD) |
224 | 81 | 81 | ||
226 | 82 | def __init__(self, timeout=30, maxread=2000): | 82 | def __init__(self, timeout=30, maxread=2000, dom_prefix=None): |
227 | 83 | super(VirshSSH, self).__init__( | 83 | super(VirshSSH, self).__init__( |
228 | 84 | None, timeout=timeout, maxread=maxread) | 84 | None, timeout=timeout, maxread=maxread) |
229 | 85 | self.name = '<virssh>' | 85 | self.name = '<virssh>' |
230 | 86 | if dom_prefix is None: | ||
231 | 87 | self.dom_prefix = '' | ||
232 | 88 | else: | ||
233 | 89 | self.dom_prefix = dom_prefix | ||
234 | 86 | 90 | ||
235 | 87 | def _execute(self, poweraddr): | 91 | def _execute(self, poweraddr): |
236 | 88 | """Spawns the pexpect command.""" | 92 | """Spawns the pexpect command.""" |
237 | @@ -136,7 +140,8 @@ | |||
238 | 136 | def list(self): | 140 | def list(self): |
239 | 137 | """Lists all virtual machines by name.""" | 141 | """Lists all virtual machines by name.""" |
240 | 138 | machines = self.run(['list', '--all', '--name']) | 142 | machines = self.run(['list', '--all', '--name']) |
242 | 139 | return machines.strip().splitlines() | 143 | machines = machines.strip().splitlines() |
243 | 144 | return [m for m in machines if m.startswith(self.dom_prefix)] | ||
244 | 140 | 145 | ||
245 | 141 | def get_state(self, machine): | 146 | def get_state(self, machine): |
246 | 142 | """Gets the virtual machine state.""" | 147 | """Gets the virtual machine state.""" |
247 | @@ -183,13 +188,13 @@ | |||
248 | 183 | return True | 188 | return True |
249 | 184 | 189 | ||
250 | 185 | 190 | ||
252 | 186 | def probe_virsh_and_enlist(poweraddr, password=None): | 191 | def probe_virsh_and_enlist(poweraddr, password=None, prefix_filter=None): |
253 | 187 | """Extracts all of the virtual machines from virsh and enlists them | 192 | """Extracts all of the virtual machines from virsh and enlists them |
254 | 188 | into MAAS. | 193 | into MAAS. |
255 | 189 | 194 | ||
256 | 190 | :param poweraddr: virsh connection string | 195 | :param poweraddr: virsh connection string |
257 | 191 | """ | 196 | """ |
259 | 192 | conn = VirshSSH() | 197 | conn = VirshSSH(dom_prefix=prefix_filter) |
260 | 193 | if not conn.login(poweraddr, password): | 198 | if not conn.login(poweraddr, password): |
261 | 194 | raise VirshError('Failed to login to virsh console.') | 199 | raise VirshError('Failed to login to virsh console.') |
262 | 195 | 200 | ||
263 | 196 | 201 | ||
264 | === modified file 'src/provisioningserver/rpc/cluster.py' | |||
265 | --- src/provisioningserver/rpc/cluster.py 2014-10-23 18:21:41 +0000 | |||
266 | +++ src/provisioningserver/rpc/cluster.py 2014-12-03 22:30:57 +0000 | |||
267 | @@ -419,6 +419,7 @@ | |||
268 | 419 | arguments = [ | 419 | arguments = [ |
269 | 420 | (b"poweraddr", amp.Unicode()), | 420 | (b"poweraddr", amp.Unicode()), |
270 | 421 | (b"password", amp.Unicode(optional=True)), | 421 | (b"password", amp.Unicode(optional=True)), |
271 | 422 | (b"prefix_filter", amp.Unicode(optional=True)), | ||
272 | 422 | ] | 423 | ] |
273 | 423 | response = [] | 424 | response = [] |
274 | 424 | errors = [] | 425 | errors = [] |
275 | 425 | 426 | ||
276 | === modified file 'src/provisioningserver/rpc/clusterservice.py' | |||
277 | --- src/provisioningserver/rpc/clusterservice.py 2014-11-10 15:11:58 +0000 | |||
278 | +++ src/provisioningserver/rpc/clusterservice.py 2014-12-03 22:30:57 +0000 | |||
279 | @@ -344,12 +344,12 @@ | |||
280 | 344 | return d.addCallback(lambda _: {}) | 344 | return d.addCallback(lambda _: {}) |
281 | 345 | 345 | ||
282 | 346 | @cluster.AddVirsh.responder | 346 | @cluster.AddVirsh.responder |
284 | 347 | def add_virsh(self, poweraddr, password): | 347 | def add_virsh(self, poweraddr, password, prefix_filter): |
285 | 348 | """add_virsh() | 348 | """add_virsh() |
286 | 349 | 349 | ||
287 | 350 | Implementation of :py:class:`~provisioningserver.rpc.cluster.AddVirsh`. | 350 | Implementation of :py:class:`~provisioningserver.rpc.cluster.AddVirsh`. |
288 | 351 | """ | 351 | """ |
290 | 352 | probe_virsh_and_enlist(poweraddr, password) | 352 | probe_virsh_and_enlist(poweraddr, password, prefix_filter) |
291 | 353 | return {} | 353 | return {} |
292 | 354 | 354 | ||
293 | 355 | @cluster.AddSeaMicro15k.responder | 355 | @cluster.AddSeaMicro15k.responder |
294 | 356 | 356 | ||
295 | === modified file 'src/provisioningserver/rpc/tests/test_clusterservice.py' | |||
296 | --- src/provisioningserver/rpc/tests/test_clusterservice.py 2014-11-10 15:11:58 +0000 | |||
297 | +++ src/provisioningserver/rpc/tests/test_clusterservice.py 2014-12-03 22:30:57 +0000 | |||
298 | @@ -1889,13 +1889,15 @@ | |||
299 | 1889 | clusterservice, 'probe_virsh_and_enlist') | 1889 | clusterservice, 'probe_virsh_and_enlist') |
300 | 1890 | poweraddr = factory.make_name('poweraddr') | 1890 | poweraddr = factory.make_name('poweraddr') |
301 | 1891 | password = factory.make_name('password') | 1891 | password = factory.make_name('password') |
302 | 1892 | prefix_filter = factory.make_name('prefix_filter') | ||
303 | 1892 | call_responder(Cluster(), cluster.AddVirsh, { | 1893 | call_responder(Cluster(), cluster.AddVirsh, { |
304 | 1893 | "poweraddr": poweraddr, | 1894 | "poweraddr": poweraddr, |
305 | 1894 | "password": password, | 1895 | "password": password, |
306 | 1896 | "prefix_filter": prefix_filter, | ||
307 | 1895 | }) | 1897 | }) |
308 | 1896 | self.assertThat( | 1898 | self.assertThat( |
309 | 1897 | probe_virsh_and_enlist, MockCalledOnceWith( | 1899 | probe_virsh_and_enlist, MockCalledOnceWith( |
311 | 1898 | poweraddr, password)) | 1900 | poweraddr, password, prefix_filter)) |
312 | 1899 | 1901 | ||
313 | 1900 | def test__password_is_optional(self): | 1902 | def test__password_is_optional(self): |
314 | 1901 | probe_virsh_and_enlist = self.patch_autospec( | 1903 | probe_virsh_and_enlist = self.patch_autospec( |
315 | @@ -1907,7 +1909,7 @@ | |||
316 | 1907 | }) | 1909 | }) |
317 | 1908 | self.assertThat( | 1910 | self.assertThat( |
318 | 1909 | probe_virsh_and_enlist, MockCalledOnceWith( | 1911 | probe_virsh_and_enlist, MockCalledOnceWith( |
320 | 1910 | poweraddr, None)) | 1912 | poweraddr, None, None)) |
321 | 1911 | 1913 | ||
322 | 1912 | def test__can_be_called_without_password_key(self): | 1914 | def test__can_be_called_without_password_key(self): |
323 | 1913 | probe_virsh_and_enlist = self.patch_autospec( | 1915 | probe_virsh_and_enlist = self.patch_autospec( |
324 | @@ -1918,7 +1920,7 @@ | |||
325 | 1918 | }) | 1920 | }) |
326 | 1919 | self.assertThat( | 1921 | self.assertThat( |
327 | 1920 | probe_virsh_and_enlist, MockCalledOnceWith( | 1922 | probe_virsh_and_enlist, MockCalledOnceWith( |
329 | 1921 | poweraddr, None)) | 1923 | poweraddr, None, None)) |
330 | 1922 | 1924 | ||
331 | 1923 | 1925 | ||
332 | 1924 | class TestClusterProtocol_AddSeaMicro15k(MAASTestCase): | 1926 | class TestClusterProtocol_AddSeaMicro15k(MAASTestCase): |
Example usage:
Let us suppose there is a MAAS profile login named `admin`. Let us also suppose that we have three virsh machines with the names node0, node1, and nokk that are on MAAS's network and can PXE boot etc. Additionally let us assume the username for the host is ubuntu and the password for this system is ubuntu as well, with an IP address of 10.0.0.2.
1. Get UUID of the cluster controller for the `admin` profile.
$ uuid=$(maas admin node-groups list | grep uuid | cut -d'"' -f4)
2. probe and enlist ALL virsh nodes.
$ maas admin node-group probe-and- enlist- hardware $uuid model=virsh power_address= qemu+ssh: //ubuntu@ 10.0.0. 2/system power_pass=ubuntu
The above command will enlist ALL the virsh nodes, which are the three noted above.
This shows that the probe and enlist still works as it should. Now let's add a prefix_filter parameter to the api command so that we only enlist the nodes that start with `node` (this prefix_filter can obviously be anything that you desire to filter on). Make sure to delete all you current nodes in MAAS so that we can do the probe and enlist again. Once that is complete-
3. probe and enlist nodes with prefix of `node`.
$ maas admin node-group probe-and- enlist- hardware $uuid model=virsh power_address= qemu+ssh: //ubuntu@ 10.0.0. 2/system power_pass=ubuntu prefix_filter=node
This will now only enlist the two nodes that begin with the prefix of `node`, node0 and node1.