Use of single interface for creating image
Within scenario manager, we had two methods for creating image those are as follows: 1. _image_create() - private interface which creates image 2. glance_image_create() - public interface which uses the above method eventually to create image Hence, let's have single method for single work. Thus, we need to replace '_image_create()' with 'image_create()'. Implements: blueprint tempest-scenario-manager-stable Signed-off by: Soniya Vyas<svyas@redhat.com> Change-Id: I33e6abd416bbe5964a279f7969615ffd2974b4dd
This commit is contained in:
parent
c02aa28390
commit
be8d510958
@ -502,36 +502,7 @@ class ScenarioTest(tempest.test.BaseTestCase):
|
||||
linux_client.validate_authentication()
|
||||
return linux_client
|
||||
|
||||
def _image_create(self, name, fmt, path,
|
||||
disk_format=None, properties=None):
|
||||
if properties is None:
|
||||
properties = {}
|
||||
name = data_utils.rand_name('%s-' % name)
|
||||
params = {
|
||||
'name': name,
|
||||
'container_format': fmt,
|
||||
'disk_format': disk_format or fmt,
|
||||
}
|
||||
if CONF.image_feature_enabled.api_v1:
|
||||
params['is_public'] = 'False'
|
||||
params['properties'] = properties
|
||||
params = {'headers': common_image.image_meta_to_headers(**params)}
|
||||
else:
|
||||
params['visibility'] = 'private'
|
||||
# Additional properties are flattened out in the v2 API.
|
||||
params.update(properties)
|
||||
body = self.image_client.create_image(**params)
|
||||
image = body['image'] if 'image' in body else body
|
||||
self.addCleanup(self.image_client.delete_image, image['id'])
|
||||
self.assertEqual("queued", image['status'])
|
||||
with open(path, 'rb') as image_file:
|
||||
if CONF.image_feature_enabled.api_v1:
|
||||
self.image_client.update_image(image['id'], data=image_file)
|
||||
else:
|
||||
self.image_client.store_image_file(image['id'], image_file)
|
||||
return image['id']
|
||||
|
||||
def glance_image_create(self):
|
||||
def image_create(self, name='scenario-img'):
|
||||
img_path = CONF.scenario.img_file
|
||||
if not os.path.exists(img_path):
|
||||
# TODO(kopecmartin): replace LOG.warning for rasing
|
||||
@ -553,14 +524,35 @@ class ScenarioTest(tempest.test.BaseTestCase):
|
||||
"properties: %s",
|
||||
img_path, img_container_format, img_disk_format,
|
||||
img_properties)
|
||||
image = self._image_create('scenario-img',
|
||||
img_container_format,
|
||||
img_path,
|
||||
disk_format=img_disk_format,
|
||||
properties=img_properties)
|
||||
LOG.debug("image:%s", image)
|
||||
|
||||
return image
|
||||
if img_properties is None:
|
||||
img_properties = {}
|
||||
name = data_utils.rand_name('%s-' % name)
|
||||
params = {
|
||||
'name': name,
|
||||
'container_format': img_container_format,
|
||||
'disk_format': img_disk_format or img_container_format,
|
||||
}
|
||||
if CONF.image_feature_enabled.api_v1:
|
||||
params['is_public'] = 'False'
|
||||
if img_properties:
|
||||
params['properties'] = img_properties
|
||||
params = {'headers': common_image.image_meta_to_headers(**params)}
|
||||
else:
|
||||
params['visibility'] = 'private'
|
||||
# Additional properties are flattened out in the v2 API.
|
||||
if img_properties:
|
||||
params.update(img_properties)
|
||||
body = self.image_client.create_image(**params)
|
||||
image = body['image'] if 'image' in body else body
|
||||
self.addCleanup(self.image_client.delete_image, image['id'])
|
||||
self.assertEqual("queued", image['status'])
|
||||
with open(img_path, 'rb') as image_file:
|
||||
if CONF.image_feature_enabled.api_v1:
|
||||
self.image_client.update_image(image['id'], data=image_file)
|
||||
else:
|
||||
self.image_client.store_image_file(image['id'], image_file)
|
||||
LOG.debug("image:%s", image['id'])
|
||||
return image['id']
|
||||
|
||||
def _log_console_output(self, servers=None, client=None):
|
||||
if not CONF.compute_feature_enabled.console_output:
|
||||
|
@ -44,7 +44,7 @@ class TestEncryptedCinderVolumes(manager.EncryptionScenarioTest):
|
||||
raise cls.skipException('Encrypted volume attach is not supported')
|
||||
|
||||
def launch_instance(self):
|
||||
image = self.glance_image_create()
|
||||
image = self.image_create()
|
||||
keypair = self.create_keypair()
|
||||
|
||||
return self.create_server(image_id=image, key_name=keypair['name'])
|
||||
|
@ -106,7 +106,7 @@ class TestMinimumBasicScenario(manager.ScenarioTest):
|
||||
@decorators.idempotent_id('bdbb5441-9204-419d-a225-b4fdbfb1a1a8')
|
||||
@utils.services('compute', 'volume', 'image', 'network')
|
||||
def test_minimum_basic_scenario(self):
|
||||
image = self.glance_image_create()
|
||||
image = self.image_create()
|
||||
keypair = self.create_keypair()
|
||||
|
||||
server = self.create_server(image_id=image, key_name=keypair['name'])
|
||||
|
Loading…
Reference in New Issue
Block a user