Use public discover_extensions from novaclient

_discover_extensions is moved to novaclient.client.discover_extensions,
and _discover_extensions will be removed from novaclient once this
patch get merged. Using the public discover_extensions instead of
_discover_extensions.

Change-Id: Id403a8313155f6ceabfdda626cdc79d9f0fac0d1
Closes-bug: #1440779
This commit is contained in:
kylin7-sg 2015-05-07 09:03:47 +08:00
parent 995b32bdbb
commit fc8dbf8752
2 changed files with 18 additions and 3 deletions

View File

@ -22,7 +22,6 @@ import string
from novaclient import client as nc
from novaclient import exceptions
from novaclient import shell as novashell
from oslo_config import cfg
from oslo_serialization import jsonutils
from oslo_utils import uuidutils
@ -65,8 +64,16 @@ class NovaClientPlugin(client_plugin.ClientPlugin):
management_url = self.url_for(service_type=self.service_types[0],
endpoint_type=endpoint_type)
computeshell = novashell.OpenStackComputeShell()
extensions = computeshell._discover_extensions(NOVACLIENT_VERSION)
if hasattr(nc, 'discover_extensions'):
extensions = nc.discover_extensions(NOVACLIENT_VERSION)
else:
# TODO(lyj): The else condition is for backward compatibility,
# once novaclient bump to a newer version with
# discover_extensions exists, this should be safely
# removed.
from novaclient import shell as novashell
computeshell = novashell.OpenStackComputeShell()
extensions = computeshell._discover_extensions(NOVACLIENT_VERSION)
args = {
'project_id': self.context.tenant,

View File

@ -16,6 +16,7 @@ import collections
import uuid
import mock
from novaclient import client as nc
from novaclient import exceptions as nova_exceptions
from oslo_config import cfg
import six
@ -44,6 +45,13 @@ class NovaClientPluginTests(NovaClientPluginTestCase):
:module:'heat.engine.clients.os.nova'.
"""
def test_create(self):
self.nova_plugin._get_client_option = mock.MagicMock()
self.nova_plugin.url_for = mock.MagicMock()
nc.discover_extensions = mock.MagicMock()
self.nova_plugin._create()
nc.discover_extensions.assert_called_once_with('2')
def test_get_ip(self):
my_image = mock.MagicMock()
my_image.addresses = {