Merge lp:~yoshikadokawa/maas/lp1662404 into lp:~maas-committers/maas/trunk

Proposed by Yoshi Kadokawa
Status: Merged
Approved by: Andres Rodriguez
Approved revision: no longer in the source branch.
Merged at revision: 5760
Proposed branch: lp:~yoshikadokawa/maas/lp1662404
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 54 lines (+11/-7)
1 file modified
src/provisioningserver/drivers/power/nova.py (+11/-7)
To merge this branch: bzr merge lp:~yoshikadokawa/maas/lp1662404
Reviewer Review Type Date Requested Status
Andres Rodriguez (community) Approve
Review via email: mp+318437@code.launchpad.net

Commit message

Fix for OpenStack Nova power driver.
The class call in python3-novaclient has been changed, so updated OpenStack Nova power driver accordingly.
Also fixed some power status of nova instances to handle accordingly.

Description of the change

Fix for OpenStack Nova power driver.
The class call in python3-novaclient has been changed, so updated OpenStack Nova power driver accordingly.
Also fixed some power status of nova instances to handle accordingly.

To post a comment you must log in.
Revision history for this message
Andres Rodriguez (andreserl) wrote :

lgtm!

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (1.8 MiB)

The attempt to merge lp:~yoshikadokawa/maas/lp1662404 into lp:maas failed. Below is the output from the failed tests.

Hit:1 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:3 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Get:4 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Get:5 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates/universe Sources [134 kB]
Get:6 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [411 kB]
Get:7 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [155 kB]
Get:8 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [20.9 kB]
Get:9 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [79.1 kB]
Get:10 http://security.ubuntu.com/ubuntu xenial-security/universe Translation-en [43.9 kB]
Fetched 1,150 kB in 0s (2,236 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 libnss-wrapper libpq-dev make nodejs-legacy npm postgresql psmisc 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).
git is already the newest version (1:2.7.4-0ubuntu1).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jqu...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/provisioningserver/drivers/power/nova.py'
2--- src/provisioningserver/drivers/power/nova.py 2016-12-07 12:46:14 +0000
3+++ src/provisioningserver/drivers/power/nova.py 2017-02-28 06:05:22 +0000
4@@ -65,10 +65,10 @@
5 """Control power of nova instances."""
6 if not self.try_novaapi_import():
7 raise PowerToolError("Missing the python3-novaclient package.")
8- nova = self.nova_api.client.Client(2, os_username,
9- os_password,
10- os_tenantname,
11- os_authurl)
12+ nova = self.nova_api.Client(2, os_username,
13+ os_password,
14+ os_tenantname,
15+ os_authurl)
16
17 try:
18 urllib.request.urlopen(os_authurl)
19@@ -81,20 +81,24 @@
20 try:
21 pwr_stateStr = "OS-EXT-STS:power_state"
22 tsk_stateStr = "OS-EXT-STS:task_state"
23+ vm_stateStr = "OS-EXT-STS:vm_state"
24 power_state = getattr(nova.servers.get(nova_id), pwr_stateStr)
25 task_state = getattr(nova.servers.get(nova_id), tsk_stateStr)
26+ vm_state = getattr(nova.servers.get(nova_id), vm_stateStr)
27 except self.nova_api.exceptions.NotFound:
28 raise PowerError('%s: Instance id not found' % nova_id)
29
30 if power_state == NovaPowerState.NOSTATE:
31 raise PowerFatalError('%s: Failed to get power state' % nova_id)
32 if power_state == NovaPowerState.RUNNING:
33- if power_change == 'off' and task_state != 'powering-off':
34+ if (power_change == 'off' and task_state != 'powering-off' and
35+ vm_state != 'stopped'):
36 nova.servers.get(nova_id).stop()
37 elif power_change == 'query':
38 return 'on'
39 if power_state == NovaPowerState.SHUTDOWN:
40- if power_change == 'on' and task_state != 'powering-off':
41+ if (power_change == 'on' and task_state != 'powering-on' and
42+ vm_state != 'active'):
43 nova.servers.get(nova_id).start()
44 elif power_change == 'query':
45 return 'off'
46@@ -107,7 +111,7 @@
47 invalidate_caches()
48 try:
49 if self.nova_api is None:
50- self.nova_api = import_module('novaclient')
51+ self.nova_api = import_module('novaclient.client')
52 except ImportError:
53 return False
54 else: