diff --git a/doc/ext/versioned_notifications.py b/doc/ext/versioned_notifications.py index 1a8107961..3149f0c47 100644 --- a/doc/ext/versioned_notifications.py +++ b/doc/ext/versioned_notifications.py @@ -20,7 +20,7 @@ It is used via a single directive in the .rst file """ -from sphinx.util.compat import Directive +from docutils.parsers.rst import Directive from docutils import nodes from watcher.notifications import base as notification diff --git a/doc/source/conf.py b/doc/source/conf.py index d975c316c..b0a7c62a8 100755 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -42,6 +42,7 @@ extensions = [ 'ext.versioned_notifications', 'oslo_config.sphinxconfiggen', 'openstackdocstheme', + 'sphinx.ext.napoleon', ] wsme_protocols = ['restjson'] diff --git a/watcher/common/nova_helper.py b/watcher/common/nova_helper.py index f99ac09cf..a1853fca8 100644 --- a/watcher/common/nova_helper.py +++ b/watcher/common/nova_helper.py @@ -29,9 +29,12 @@ import novaclient.exceptions as nvexceptions from watcher.common import clients from watcher.common import exception from watcher.common import utils +from watcher import conf LOG = log.getLogger(__name__) +CONF = conf.CONF + class NovaHelper(object): @@ -556,21 +559,31 @@ class NovaHelper(object): "for the instance %s" % instance_id) def enable_service_nova_compute(self, hostname): - if self.nova.services.enable(host=hostname, - binary='nova-compute'). \ - status == 'enabled': - return True + if float(CONF.nova_client.api_version) < 2.53: + status = self.nova.services.enable( + host=hostname, binary='nova-compute').status == 'enabled' else: - return False + service_uuid = self.nova.services.list(host=hostname, + binary='nova-compute')[0].id + status = self.nova.services.enable( + service_uuid=service_uuid).status == 'enabled' + + return status def disable_service_nova_compute(self, hostname, reason=None): - if self.nova.services.disable_log_reason(host=hostname, - binary='nova-compute', - reason=reason). \ - status == 'disabled': - return True + if float(CONF.nova_client.api_version) < 2.53: + status = self.nova.services.disable_log_reason( + host=hostname, + binary='nova-compute', + reason=reason).status == 'disabled' else: - return False + service_uuid = self.nova.services.list(host=hostname, + binary='nova-compute')[0].id + status = self.nova.services.disable_log_reason( + service_uuid=service_uuid, + reason=reason).status == 'disabled' + + return status def set_host_offline(self, hostname): # See API on https://developer.openstack.org/api-ref/compute/