fullstack: search for default image
Change-Id: Ie7787c969e333d15d449e135bd84b36cf8edd3a8
This commit is contained in:
parent
2225fbd7df
commit
95a725a2a3
|
@ -11,6 +11,7 @@
|
|||
# under the License.
|
||||
|
||||
from cinderclient import client as cinder_client
|
||||
from glanceclient import client as glance_client
|
||||
from karborclient import client as karbor_client
|
||||
from neutronclient.v2_0 import client as neutron_client
|
||||
from novaclient import client as nova_client
|
||||
|
@ -77,6 +78,13 @@ def _get_cinder_client(api_version='3'):
|
|||
return client
|
||||
|
||||
|
||||
def _get_glance_client(api_version='2'):
|
||||
kwargs = _get_client_args('image')
|
||||
kwargs.pop('endpoint_type')
|
||||
client = glance_client.Client(api_version, **kwargs)
|
||||
return client
|
||||
|
||||
|
||||
def _get_nova_client(api_version='2.26'):
|
||||
kwargs = _get_client_args('compute')
|
||||
client = nova_client.Client(api_version, **kwargs)
|
||||
|
@ -129,6 +137,7 @@ class KarborBaseTest(base.BaseTestCase):
|
|||
def setUp(self):
|
||||
super(KarborBaseTest, self).setUp()
|
||||
self.cinder_client = _get_cinder_client()
|
||||
self.glance_client = _get_glance_client()
|
||||
self.nova_client = _get_nova_client()
|
||||
self.neutron_client = _get_neutron_client()
|
||||
self.karbor_client = _get_karbor_client()
|
||||
|
|
|
@ -23,7 +23,6 @@ SHORT_SLEEP = 2
|
|||
MEDIUM_SLEEP = 5
|
||||
LONG_SLEEP = 10
|
||||
|
||||
DEFAULT_IMAGE = "cirros-0.3.4-x86_64-uec"
|
||||
DEFAULT_FLAVOR = "cirros256"
|
||||
DEFAULT_NETWORK = "private"
|
||||
|
||||
|
@ -195,6 +194,7 @@ class Server(object):
|
|||
self.nova_client = base._get_nova_client()
|
||||
self.neutron_client = base._get_neutron_client()
|
||||
self.cinder_client = base._get_cinder_client()
|
||||
self.glance_client = base._get_glance_client()
|
||||
|
||||
def _server_status(self, status=None):
|
||||
try:
|
||||
|
@ -214,9 +214,15 @@ class Server(object):
|
|||
"name": self._name,
|
||||
}
|
||||
|
||||
def create(self, name=None, image=DEFAULT_IMAGE, flavor=DEFAULT_FLAVOR,
|
||||
def create(self, name=None, image=None, flavor=DEFAULT_FLAVOR,
|
||||
network=DEFAULT_NETWORK, timeout=MEDIUM_TIMEOUT):
|
||||
image = self.nova_client.images.find(name=image)
|
||||
if not image:
|
||||
images = self.glance_client.images.list()
|
||||
for image_iter in images:
|
||||
if image_iter['disk_format'] not in ('aki', 'ari'):
|
||||
image = image_iter['id']
|
||||
break
|
||||
assert image
|
||||
flavor = self.nova_client.flavors.find(name=flavor)
|
||||
if name is None:
|
||||
name = "KarborFullstack-Server-{id}".format(id=self._name_id)
|
||||
|
|
Loading…
Reference in New Issue