Make image name configurable in glance.
This commit is contained in:
@@ -17,6 +17,10 @@
|
||||
import logging
|
||||
import zaza.utilities.openstack as openstack_utils
|
||||
|
||||
CIRROS_IMAGE_NAME = "cirros"
|
||||
LTS_RELEASE = "bionic"
|
||||
LTS_IMAGE_NAME = "bionic"
|
||||
|
||||
|
||||
def basic_setup():
|
||||
"""Run setup for testing glance.
|
||||
@@ -26,43 +30,52 @@ def basic_setup():
|
||||
"""
|
||||
|
||||
|
||||
def add_cirros_image(glance_client=None):
|
||||
def add_cirros_image(glance_client=None, image_name=None):
|
||||
"""Add a cirros image to the current deployment.
|
||||
|
||||
:param glance: Authenticated glanceclient
|
||||
:type glance: glanceclient.Client
|
||||
:param image_name: Label for the image in glance
|
||||
:type image_name: str
|
||||
"""
|
||||
image_name = image_name or CIRROS_IMAGE_NAME
|
||||
if not glance_client:
|
||||
keystone_session = openstack_utils.get_overcloud_keystone_session()
|
||||
glance_client = openstack_utils.get_glance_session_client(
|
||||
keystone_session)
|
||||
if openstack_utils.get_images_by_name(glance_client, 'cirros'):
|
||||
if openstack_utils.get_images_by_name(glance_client, image_name):
|
||||
logging.warning('Using existing glance image')
|
||||
else:
|
||||
image_url = openstack_utils.find_cirros_image(arch='x86_64')
|
||||
openstack_utils.create_image(
|
||||
glance_client,
|
||||
image_url,
|
||||
'cirros')
|
||||
image_name)
|
||||
|
||||
|
||||
def add_lts_image(glance_client=None):
|
||||
def add_lts_image(glance_client=None, image_name=None, release=None):
|
||||
"""Add an Ubuntu LTS image to the current deployment.
|
||||
|
||||
:param glance: Authenticated glanceclient
|
||||
:type glance: glanceclient.Client
|
||||
:param image_name: Label for the image in glance
|
||||
:type image_name: str
|
||||
:param release: Name of ubuntu release.
|
||||
:type release: str
|
||||
"""
|
||||
image_name = image_name or LTS_IMAGE_NAME
|
||||
release = release or LTS_RELEASE
|
||||
if not glance_client:
|
||||
keystone_session = openstack_utils.get_overcloud_keystone_session()
|
||||
glance_client = openstack_utils.get_glance_session_client(
|
||||
keystone_session)
|
||||
if openstack_utils.get_images_by_name(glance_client, 'bionic'):
|
||||
if openstack_utils.get_images_by_name(glance_client, image_name):
|
||||
logging.warning('Using existing glance image')
|
||||
else:
|
||||
image_url = openstack_utils.find_ubuntu_image(
|
||||
release='bionic',
|
||||
release=release,
|
||||
arch='amd64')
|
||||
openstack_utils.create_image(
|
||||
glance_client,
|
||||
image_url,
|
||||
'bionic')
|
||||
image_name)
|
||||
|
||||
@@ -23,6 +23,7 @@ import unittest
|
||||
import zaza.model as model
|
||||
import zaza.utilities.openstack as openstack_utils
|
||||
import zaza.charm_tests.nova.utils as nova_utils
|
||||
import zaza.charm_tests.glance.setup as glance_setup
|
||||
|
||||
|
||||
class BaseGuestCreateTest(unittest.TestCase):
|
||||
@@ -113,7 +114,7 @@ class CirrosGuestCreateTest(BaseGuestCreateTest):
|
||||
|
||||
def test_launch_small_cirros_instance(self):
|
||||
"""Launch a cirros instance and test connectivity."""
|
||||
self.launch_instance('cirros')
|
||||
self.launch_instance(glance_setup.CIRROS_IMAGE_NAME)
|
||||
|
||||
|
||||
class LTSGuestCreateTest(BaseGuestCreateTest):
|
||||
@@ -121,4 +122,4 @@ class LTSGuestCreateTest(BaseGuestCreateTest):
|
||||
|
||||
def test_launch_small_cirros_instance(self):
|
||||
"""Launch a cirros instance and test connectivity."""
|
||||
self.launch_instance('bionic')
|
||||
self.launch_instance(glance_setup.LTS_IMAGE_NAME)
|
||||
|
||||
Reference in New Issue
Block a user