Add possibility to prevent Tobiko from creating test image
It can be done with env variable TOBIKO_PREVENT_CREATE. Change-Id: I46b3fb4e34c482b99b53461cb404012f02d2c890
This commit is contained in:
parent
9b9dec3bdb
commit
b66d690c93
@ -250,7 +250,7 @@ can be used::
|
|||||||
export TOBIKO_PREVENT_CREATE=True
|
export TOBIKO_PREVENT_CREATE=True
|
||||||
|
|
||||||
If this is set to ``True`` or ``1`` then Tobiko will not try to create resources like VMs,
|
If this is set to ``True`` or ``1`` then Tobiko will not try to create resources like VMs,
|
||||||
networks or routers and just run validation of what is exists in the cloud already.
|
networks, routers or images and just run validation of what is exists in the cloud already.
|
||||||
|
|
||||||
What's Next
|
What's Next
|
||||||
-----------
|
-----------
|
||||||
|
@ -23,6 +23,7 @@ from oslo_log import log
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
import tobiko
|
import tobiko
|
||||||
|
from tobiko.config import get_bool_env
|
||||||
from tobiko.openstack.glance import _client
|
from tobiko.openstack.glance import _client
|
||||||
from tobiko.openstack.glance import _io
|
from tobiko.openstack.glance import _io
|
||||||
|
|
||||||
@ -185,6 +186,8 @@ class UploadGranceImageFixture(GlanceImageFixture):
|
|||||||
self.disk_format = disk_format
|
self.disk_format = disk_format
|
||||||
tobiko.check_valid_type(self.disk_format, str)
|
tobiko.check_valid_type(self.disk_format, str)
|
||||||
|
|
||||||
|
self.prevent_image_create = get_bool_env('TOBIKO_PREVENT_CREATE')
|
||||||
|
|
||||||
def setup_image(self):
|
def setup_image(self):
|
||||||
self.create_image()
|
self.create_image()
|
||||||
|
|
||||||
@ -198,6 +201,7 @@ class UploadGranceImageFixture(GlanceImageFixture):
|
|||||||
break
|
break
|
||||||
retries -= 1
|
retries -= 1
|
||||||
|
|
||||||
|
if not self.prevent_image_create:
|
||||||
if image:
|
if image:
|
||||||
LOG.debug('Delete existing image: %r (id=%r)',
|
LOG.debug('Delete existing image: %r (id=%r)',
|
||||||
self.image_name, image.id)
|
self.image_name, image.id)
|
||||||
@ -208,7 +212,8 @@ class UploadGranceImageFixture(GlanceImageFixture):
|
|||||||
self.image = image = None
|
self.image = image = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
LOG.debug('Creating Glance image %r (re-tries left %d)...',
|
LOG.debug('Creating Glance image %r '
|
||||||
|
'(re-tries left %d)...',
|
||||||
self.image_name, retries)
|
self.image_name, retries)
|
||||||
image_id = _client.create_image(
|
image_id = _client.create_image(
|
||||||
client=self.client,
|
client=self.client,
|
||||||
@ -216,11 +221,12 @@ class UploadGranceImageFixture(GlanceImageFixture):
|
|||||||
disk_format=self.disk_format,
|
disk_format=self.disk_format,
|
||||||
container_format=self.container_format)['id']
|
container_format=self.container_format)['id']
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception('Image creation failed %r.', self.image_name)
|
LOG.exception('Image creation failed %r.',
|
||||||
|
self.image_name)
|
||||||
else:
|
else:
|
||||||
cleanup_image_ids.add(image_id)
|
cleanup_image_ids.add(image_id)
|
||||||
LOG.debug('Created image %r (id=%r)...', self.image_name,
|
LOG.debug('Created image %r (id=%r)...',
|
||||||
image_id)
|
self.image_name, image_id)
|
||||||
|
|
||||||
if image:
|
if image:
|
||||||
if image.id in cleanup_image_ids:
|
if image.id in cleanup_image_ids:
|
||||||
|
Loading…
Reference in New Issue
Block a user