Merge lp:~ltrager/maas/lp1637401_2.1 into lp:maas/2.1

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: no longer in the source branch.
Merged at revision: 5559
Proposed branch: lp:~ltrager/maas/lp1637401_2.1
Merge into: lp:maas/2.1
Diff against target: 127 lines (+34/-20)
2 files modified
src/provisioningserver/drivers/hardware/tests/test_virsh.py (+23/-13)
src/provisioningserver/drivers/hardware/virsh.py (+11/-7)
To merge this branch: bzr merge lp:~ltrager/maas/lp1637401_2.1
Reviewer Review Type Date Requested Status
Lee Trager (community) Approve
Review via email: mp+312212@code.launchpad.net

Commit message

Backport r5579 from trunk: During probe and enlist of virsh only power off and commission new nodes.

Previously probe_virsh_and_enlist would power off each node before requesting a new node row was created. If the machine already exists or there was some issue creating the new node row the node was still powered off. This meant reprobing a virsh host would power off all known nodes. Power off now only happens if a new row was successfully created, existing nodes are ignored and left untouched.

To post a comment you must log in.
Revision history for this message
Lee Trager (ltrager) wrote :
review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (1.5 MiB)

The attempt to merge lp:~ltrager/maas/lp1637401_2.1 into lp:maas/2.1 failed. Below is the output from the failed tests.

Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Hit:2 http://prodstack-zone-1.clouds.archive.ubuntu.com/ubuntu xenial InRelease
Get:3 http://prodstack-zone-1.clouds.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:4 http://prodstack-zone-1.clouds.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Get:5 http://security.ubuntu.com/ubuntu xenial-security/main Sources [50.6 kB]
Get:6 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [181 kB]
Get:7 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [64.0 kB]
Get:8 http://prodstack-zone-1.clouds.archive.ubuntu.com/ubuntu xenial-updates/main Sources [207 kB]
Get:9 http://prodstack-zone-1.clouds.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [429 kB]
Get:10 http://prodstack-zone-1.clouds.archive.ubuntu.com/ubuntu xenial-updates/main Translation-en [166 kB]
Get:11 http://prodstack-zone-1.clouds.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [366 kB]
Fetched 1,770 kB in 0s (2,413 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
    --no-install-recommends install apache2 archdetect-deb authbind avahi-utils bash bind9 bind9utils build-essential bzr bzr-builddeb chromium-browser chromium-chromedriver curl daemontools debhelper dh-apport dh-systemd distro-info dnsutils firefox freeipmi-tools git gjs ipython isc-dhcp-common isc-dhcp-server libjs-angularjs libjs-jquery libjs-jquery-hotkeys libjs-yui3-full libjs-yui3-min libpq-dev make nodejs-legacy npm postgresql pxelinux python3-all python3-apt python3-attr python3-bson python3-convoy python3-crochet python3-cssselect python3-curtin python3-dev python3-distro-info python3-django python3-django-nose python3-django-piston3 python3-dnspython python3-docutils python3-formencode python3-hivex python3-httplib2 python3-jinja2 python3-jsonschema python3-lxml python3-netaddr python3-netifaces python3-novaclient python3-oauth python3-oauthlib python3-openssl python3-paramiko python3-petname python3-pexpect python3-psycopg2 python3-pyinotify python3-pyparsing python3-pyvmomi python3-requests python3-seamicroclient python3-setuptools python3-simplestreams python3-sphinx python3-tempita python3-twisted python3-txtftp python3-tz python3-yaml python3-zope.interface python-bson python-crochet python-django python-django-piston python-djorm-ext-pgarray python-formencode python-lxml python-netaddr python-netifaces python-pocket-lint python-psycopg2 python-simplejson python-tempita python-twisted python-yaml socat syslinux-common tgt ubuntu-cloudimage-keyring wget xvfb
Reading package lists...
Building dependency tree...
Reading state information...
authbind is already the newest version (2.1.1+nmu1).
avahi-utils is already the newest version (0.6.32~rc+dfsg-1ubuntu2).
build-essential is already the newest version (12.1ubuntu2).
debhelper is already the newest version (9.20160115ubuntu3).
distro-info is already the newest version (0.14build1).
freeipmi-tools is already the newest version (1.4.11-1ubu...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/provisioningserver/drivers/hardware/tests/test_virsh.py'
--- src/provisioningserver/drivers/hardware/tests/test_virsh.py 2016-05-12 19:07:37 +0000
+++ src/provisioningserver/drivers/hardware/tests/test_virsh.py 2016-11-30 23:24:27 +0000
@@ -13,9 +13,7 @@
13from lxml import etree13from lxml import etree
14from maastesting.factory import factory14from maastesting.factory import factory
15from maastesting.matchers import (15from maastesting.matchers import (
16 MockAnyCall,
17 MockCalledOnceWith,16 MockCalledOnceWith,
18 MockCalledWith,
19 MockCallsMatch,17 MockCallsMatch,
20)18)
21from maastesting.testcase import (19from maastesting.testcase import (
@@ -267,7 +265,7 @@
267 # with some fake architectures.265 # with some fake architectures.
268 user = factory.make_name('user')266 user = factory.make_name('user')
269 system_id = factory.make_name('system_id')267 system_id = factory.make_name('system_id')
270 machines = [factory.make_name('machine') for _ in range(4)]268 machines = [factory.make_name('machine') for _ in range(5)]
271 self.patch(virsh.VirshSSH, 'list').return_value = machines269 self.patch(virsh.VirshSSH, 'list').return_value = machines
272 fake_arch = factory.make_name('arch')270 fake_arch = factory.make_name('arch')
273 mock_arch = self.patch(virsh.VirshSSH, 'get_arch')271 mock_arch = self.patch(virsh.VirshSSH, 'get_arch')
@@ -281,6 +279,7 @@
281 virsh.VirshVMState.OFF,279 virsh.VirshVMState.OFF,
282 virsh.VirshVMState.OFF,280 virsh.VirshVMState.OFF,
283 virsh.VirshVMState.ON,281 virsh.VirshVMState.ON,
282 virsh.VirshVMState.ON,
284 ]283 ]
285 mock_state = self.patch(virsh.VirshSSH, 'get_state')284 mock_state = self.patch(virsh.VirshSSH, 'get_state')
286 mock_state.side_effect = fake_states285 mock_state.side_effect = fake_states
@@ -310,7 +309,7 @@
310 mock_poweroff = self.patch(virsh.VirshSSH, 'poweroff')309 mock_poweroff = self.patch(virsh.VirshSSH, 'poweroff')
311 mock_create_node = self.patch(virsh, 'create_node')310 mock_create_node = self.patch(virsh, 'create_node')
312 mock_create_node.side_effect = asynchronous(311 mock_create_node.side_effect = asynchronous(
313 lambda *args, **kwargs: system_id)312 lambda *args, **kwargs: None if machines[4] in args else system_id)
314 mock_commission_node = self.patch(virsh, 'commission_node')313 mock_commission_node = self.patch(virsh, 'commission_node')
315314
316 # Patch login and logout so that we don't really contact315 # Patch login and logout so that we don't really contact
@@ -324,6 +323,7 @@
324 SAMPLE_DUMPXML_2,323 SAMPLE_DUMPXML_2,
325 SAMPLE_DUMPXML_3,324 SAMPLE_DUMPXML_3,
326 SAMPLE_DUMPXML_4,325 SAMPLE_DUMPXML_4,
326 SAMPLE_DUMPXML,
327 ]327 ]
328328
329 mock_run = self.patch(virsh.VirshSSH, 'run')329 mock_run = self.patch(virsh.VirshSSH, 'run')
@@ -339,12 +339,6 @@
339 self.expectThat(339 self.expectThat(
340 mock_login, MockCalledOnceWith(poweraddr, fake_password))340 mock_login, MockCalledOnceWith(poweraddr, fake_password))
341341
342 # The first and last machine should have poweroff called on it, as it
343 # was initial in the on state.
344 self.expectThat(mock_poweroff, MockAnyCall(machines[0]))
345
346 self.expectThat(mock_poweroff, MockAnyCall(machines[3]))
347
348 # Check that the create command had the correct parameters for342 # Check that the create command had the correct parameters for
349 # each machine.343 # each machine.
350 self.expectThat(344 self.expectThat(
@@ -361,11 +355,27 @@
361 call(355 call(
362 fake_macs[3], fake_arch, 'virsh', called_params[3],356 fake_macs[3], fake_arch, 'virsh', called_params[3],
363 domain, machines[3]),357 domain, machines[3]),
364 ))358 call(
359 fake_macs[4], fake_arch, 'virsh', called_params[4],
360 domain, machines[4]),
361 ))
362
363 # The first and last machine should have poweroff called on it, as it
364 # was initial in the on state.
365 self.expectThat(
366 mock_poweroff, MockCallsMatch(
367 call(machines[0]),
368 call(machines[3]),
369 ))
370
365 self.assertThat(mock_logout, MockCalledOnceWith())371 self.assertThat(mock_logout, MockCalledOnceWith())
366 self.expectThat(372 self.expectThat(
367 mock_commission_node,373 mock_commission_node, MockCallsMatch(
368 MockCalledWith(system_id, user))374 call(system_id, user),
375 call(system_id, user),
376 call(system_id, user),
377 call(system_id, user),
378 ))
369379
370 @inlineCallbacks380 @inlineCallbacks
371 def test_probe_and_enlist_login_failure(self):381 def test_probe_and_enlist_login_failure(self):
372382
=== modified file 'src/provisioningserver/drivers/hardware/virsh.py'
--- src/provisioningserver/drivers/hardware/virsh.py 2016-05-12 19:07:37 +0000
+++ src/provisioningserver/drivers/hardware/virsh.py 2016-11-30 23:24:27 +0000
@@ -282,11 +282,6 @@
282 state = conn.get_state(machine)282 state = conn.get_state(machine)
283 macs = conn.get_mac_addresses(machine)283 macs = conn.get_mac_addresses(machine)
284284
285 # Force the machine off, as MAAS will control the machine
286 # and it needs to be in a known state of off.
287 if state == VirshVMState.ON:
288 conn.poweroff(machine)
289
290 params = {285 params = {
291 'power_address': poweraddr,286 'power_address': poweraddr,
292 'power_id': machine,287 'power_id': machine,
@@ -296,8 +291,17 @@
296 system_id = create_node(291 system_id = create_node(
297 macs, arch, 'virsh', params, domain, machine).wait(30)292 macs, arch, 'virsh', params, domain, machine).wait(30)
298293
299 if system_id is not None:294 # If the system_id is None an error occured when creating the machine.
300 conn.configure_pxe_boot(machine)295 # Most likely the error is the node already exists.
296 if system_id is None:
297 continue
298
299 # Force the machine off, as MAAS will control the machine
300 # and it needs to be in a known state of off.
301 if state == VirshVMState.ON:
302 conn.poweroff(machine)
303
304 conn.configure_pxe_boot(machine)
301305
302 if accept_all:306 if accept_all:
303 commission_node(system_id, user).wait(30)307 commission_node(system_id, user).wait(30)

Subscribers

People subscribed via source and target branches

to all changes: