Use openstacksdk instead of glanceclient
Change-Id: If7d5ff7381ed2d1c94b1820e91b2b7e352a7e160
This commit is contained in:
parent
87a053a5aa
commit
5214aee521
|
@ -15,9 +15,9 @@
|
|||
|
||||
import logging
|
||||
|
||||
import glanceclient
|
||||
from ironicclient import client as ir_client
|
||||
from neutronclient.v2_0 import client as neu_client
|
||||
from openstack import connection
|
||||
import six
|
||||
|
||||
|
||||
|
@ -38,7 +38,6 @@ class DictWithAttrs(dict):
|
|||
class API(object):
|
||||
"""Various OpenStack API's."""
|
||||
|
||||
GLANCE_VERSION = '2'
|
||||
IRONIC_VERSION = '1'
|
||||
IRONIC_MICRO_VERSION = '1.28'
|
||||
|
||||
|
@ -48,15 +47,15 @@ class API(object):
|
|||
raise TypeError('Either session or cloud_region must '
|
||||
'be provided')
|
||||
self.session = session
|
||||
self.connection = connection.Connection(session=session)
|
||||
elif session is not None:
|
||||
raise TypeError('Either session or cloud_region must be provided, '
|
||||
'but not both')
|
||||
else:
|
||||
self.session = cloud_region.get_session()
|
||||
self.connection = connection.Connection(config=cloud_region)
|
||||
|
||||
LOG.debug('Creating service clients')
|
||||
self.glance = glanceclient.Client(self.GLANCE_VERSION,
|
||||
session=self.session)
|
||||
self.neutron = neu_client.Client(session=self.session)
|
||||
self.ironic = ir_client.get_client(
|
||||
self.IRONIC_VERSION, session=self.session,
|
||||
|
@ -79,9 +78,8 @@ class API(object):
|
|||
self.ironic.node.vif_detach(_node_id(node), port_id)
|
||||
|
||||
def get_image_info(self, image_id):
|
||||
for img in self.glance.images.list():
|
||||
if img.name == image_id or img.id == image_id:
|
||||
return img
|
||||
return self.connection.image.find_image(image_id,
|
||||
ignore_missing=False)
|
||||
|
||||
def get_network(self, network_id):
|
||||
for net in self.neutron.list_networks()['networks']:
|
||||
|
|
|
@ -32,7 +32,9 @@ class TestInit(testtools.TestCase):
|
|||
api = _os_api.API(session=session)
|
||||
self.assertIs(api.session, session)
|
||||
|
||||
def test_cloud_region_only(self):
|
||||
@mock.patch.object(_os_api.connection, 'Connection', autospec=True)
|
||||
def test_cloud_region_only(self, mock_conn):
|
||||
region = mock.Mock()
|
||||
api = _os_api.API(cloud_region=region)
|
||||
self.assertIs(api.session, region.get_session.return_value)
|
||||
mock_conn.assert_called_once_with(config=region)
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
||||
openstacksdk>=0.11.0 # Apache-2.0
|
||||
oslo.utils>=3.20.0 # Apache-2.0
|
||||
python-glanceclient>=2.8.0 # Apache-2.0
|
||||
python-ironicclient>=1.14.0 # Apache-2.0
|
||||
python-neutronclient>=6.3.0 # Apache-2.0
|
||||
six>=1.10.0 # MIT
|
||||
|
|
Loading…
Reference in New Issue