Fix wrong usage of novaclient
novaclient.client.Client is a documented way to initialize novaclient. Also, it provides a backward compatible layer. Change-Id: Ibeefe215ff1405d1e6bc478fee415b530813d86c Closes-Bug: #1493576
This commit is contained in:
parent
7bf38a33be
commit
b8603c8d1d
|
@ -43,10 +43,10 @@ class CMDClientsTest(base.TestCase):
|
||||||
ca_file=environ.get("OS_CACERT"))
|
ca_file=environ.get("OS_CACERT"))
|
||||||
|
|
||||||
@mock.patch('os.environ')
|
@mock.patch('os.environ')
|
||||||
@mock.patch('novaclient.v2.client.Client')
|
@mock.patch('novaclient.client.Client')
|
||||||
def test_get_nova_bm_client(self, client_mock, environ):
|
def test_get_nova_bm_client(self, client_mock, environ):
|
||||||
clients.get_nova_bm_client()
|
clients.get_nova_bm_client()
|
||||||
client_mock.assert_called_once_with(environ["OS_USERNAME"],
|
client_mock.assert_called_once_with("2", environ["OS_USERNAME"],
|
||||||
environ["OS_PASSWORD"],
|
environ["OS_PASSWORD"],
|
||||||
environ["OS_AUTH_URL"],
|
environ["OS_AUTH_URL"],
|
||||||
environ["OS_TENANT_NAME"],
|
environ["OS_TENANT_NAME"],
|
||||||
|
|
|
@ -22,8 +22,8 @@ from keystoneclient import session
|
||||||
from keystoneclient.v2_0 import client as ksclient
|
from keystoneclient.v2_0 import client as ksclient
|
||||||
from keystoneclient.v3 import client as ks3client
|
from keystoneclient.v3 import client as ks3client
|
||||||
from neutronclient.neutron import client as neutronclient
|
from neutronclient.neutron import client as neutronclient
|
||||||
|
from novaclient import client as nova_client
|
||||||
from novaclient.extension import Extension
|
from novaclient.extension import Extension
|
||||||
from novaclient.v2 import client as novav11client
|
|
||||||
from novaclient.v2.contrib import baremetal
|
from novaclient.v2.contrib import baremetal
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -32,12 +32,8 @@ LOG = logging.getLogger(__name__)
|
||||||
def get_nova_bm_client(username, password, tenant_name, auth_url, cacert=None):
|
def get_nova_bm_client(username, password, tenant_name, auth_url, cacert=None):
|
||||||
LOG.debug('Creating nova client.')
|
LOG.debug('Creating nova client.')
|
||||||
baremetal_extension = Extension('baremetal', baremetal)
|
baremetal_extension = Extension('baremetal', baremetal)
|
||||||
return novav11client.Client(username,
|
return nova_client.Client("2", username, password, tenant_name, auth_url,
|
||||||
password,
|
extensions=[baremetal_extension], cacert=cacert)
|
||||||
tenant_name,
|
|
||||||
auth_url,
|
|
||||||
extensions=[baremetal_extension],
|
|
||||||
cacert=cacert)
|
|
||||||
|
|
||||||
|
|
||||||
def get_ironic_client(username, password, tenant_name, auth_url, cacert=None):
|
def get_ironic_client(username, password, tenant_name, auth_url, cacert=None):
|
||||||
|
|
|
@ -32,11 +32,11 @@ class ClientsTest(base.TestCase):
|
||||||
os_tenant_name='tenant_name',
|
os_tenant_name='tenant_name',
|
||||||
ca_file=None)
|
ca_file=None)
|
||||||
|
|
||||||
@mock.patch('novaclient.v2.client.Client')
|
@mock.patch('novaclient.client.Client')
|
||||||
def test_get_nova_bm_client(self, client_mock):
|
def test_get_nova_bm_client(self, client_mock):
|
||||||
clients.get_nova_bm_client('username', 'password', 'tenant_name',
|
clients.get_nova_bm_client('username', 'password', 'tenant_name',
|
||||||
'auth_url')
|
'auth_url')
|
||||||
client_mock.assert_called_once_with('username',
|
client_mock.assert_called_once_with('2', 'username',
|
||||||
'password',
|
'password',
|
||||||
'tenant_name',
|
'tenant_name',
|
||||||
'auth_url',
|
'auth_url',
|
||||||
|
|
Loading…
Reference in New Issue