From 0d49aaa0098127d4bae28cb0b1782c0e43665ace Mon Sep 17 00:00:00 2001 From: Liam Young Date: Mon, 30 Jul 2018 08:58:59 +0000 Subject: [PATCH] Add method for setting up cirros image. add_cirros_image is designed to be called by the configure step of charms to setup a cirros image in the deployment. --- zaza/charm_tests/glance/setup.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/zaza/charm_tests/glance/setup.py b/zaza/charm_tests/glance/setup.py index 3216dbd..1e206b8 100644 --- a/zaza/charm_tests/glance/setup.py +++ b/zaza/charm_tests/glance/setup.py @@ -1,5 +1,24 @@ """Code for configuring glance.""" +import zaza.utilities.openstack as openstack_utils + + +def add_cirros_image(glance_client=None): + """Add a cirros image to the current deployment. + + :param glance: Authenticated glanceclient + :type glance: glanceclient.Client + """ + if not glance_client: + keystone_session = openstack_utils.get_overcloud_keystone_session() + glance_client = openstack_utils.get_glance_session_client( + keystone_session) + image_url = openstack_utils.find_cirros_image(arch='x86_64') + openstack_utils.create_image( + glance_client, + image_url, + 'cirrosimage') + def basic_setup(): """Run setup for testing glance. @@ -7,4 +26,4 @@ def basic_setup(): Glance setup for testing glance is currently part of glance functional tests. Image setup for other tests to use should go here. """ - pass + add_cirros_image()