Merge "Add glance images cleanup"

This commit is contained in:
Jenkins 2016-11-03 14:23:15 +00:00 committed by Gerrit Code Review
commit 39d4021a37
2 changed files with 24 additions and 5 deletions

View File

@ -1,6 +1,7 @@
import logging
import time
from glanceclient import client as glance_client
from keystoneauth1 import exceptions as keystoneauth_exceptions
from keystoneauth1.identity import v3
from keystoneauth1 import session as keystone_session
@ -92,6 +93,14 @@ def _cleanup_network_resources(session):
for network in network_list['networks']]))
def _cleanup_images(session):
LOG.debug("Cleaning up glance images")
glance = glance_client.Client("2", session=session)
for image in glance.images.list():
LOG.debug("Removing glance image %s", image.id)
glance.images.delete(image.id)
def _cleanup_openstack_environment(configs, auth_url=None):
if 'project_name' not in configs.get('openstack', {}):
# Ensure that keystone configs are provided. Assume that it is not an
@ -118,17 +127,26 @@ def _cleanup_openstack_environment(configs, auth_url=None):
'Run with --skip-os-cleanup flag if OpenStack '
'is not deployed', configs['auth_url'])
raise
try:
_cleanup_servers(session)
except keystoneauth_exceptions.EndpointNotFound:
LOG.info('Nova is not present, skipping instances cleanup')
pass
try:
_cleanup_images(session)
except keystoneauth_exceptions.EndpointNotFound:
LOG.info('Glance is not present, skipping images cleanup')
pass
try:
_cleanup_network_resources(session)
except keystoneauth_exceptions.EndpointNotFound:
LOG.info('Neutron is not present, skipping network resources '
'cleanup')
pass
LOG.info('OpenStack cleanup has been finished successfully.')

View File

@ -4,15 +4,16 @@
pbr>=1.6 # Apache-2.0
cliff>=2.2.0 # Apache-2.0
futures>=3.0;python_version=='2.7' or python_version=='2.6' # BSD
docker-py<1.8.0,>=1.6.0 # Apache-2.0
GitPython>=1.0.1 # BSD License (3 clause)
Jinja2>=2.8 # BSD License (3 clause)
jsonschema!=2.5.0,<3.0.0,>=2.0.0 # MIT
PyYAML>=3.10.0 # MIT
six>=1.9.0 # MIT
cliff>=2.2.0 # Apache-2.0
docker-py<1.8.0,>=1.6.0 # Apache-2.0
futures>=3.0;python_version=='2.7' or python_version=='2.6' # BSD
jsonschema!=2.5.0,<3.0.0,>=2.0.0 # MIT
keystoneauth1>=2.10.0 # Apache-2.0
pykube # Apache-2.0
python-glanceclient>=2.5.0 # Apache-2.0
python-neutronclient>=5.1.0 # Apache-2.0
python-novaclient!=2.33.0,>=2.29.0 # Apache-2.0
six>=1.9.0 # MIT