Merge "Use public discover_extensions from novaclient"

This commit is contained in:
Jenkins 2015-07-01 09:28:04 +00:00 committed by Gerrit Code Review
commit 10d0037531
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 = {