Merge "Add glance images cleanup"
This commit is contained in:
commit
39d4021a37
@ -1,6 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from glanceclient import client as glance_client
|
||||||
from keystoneauth1 import exceptions as keystoneauth_exceptions
|
from keystoneauth1 import exceptions as keystoneauth_exceptions
|
||||||
from keystoneauth1.identity import v3
|
from keystoneauth1.identity import v3
|
||||||
from keystoneauth1 import session as keystone_session
|
from keystoneauth1 import session as keystone_session
|
||||||
@ -92,6 +93,14 @@ def _cleanup_network_resources(session):
|
|||||||
for network in network_list['networks']]))
|
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):
|
def _cleanup_openstack_environment(configs, auth_url=None):
|
||||||
if 'project_name' not in configs.get('openstack', {}):
|
if 'project_name' not in configs.get('openstack', {}):
|
||||||
# Ensure that keystone configs are provided. Assume that it is not an
|
# 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 '
|
'Run with --skip-os-cleanup flag if OpenStack '
|
||||||
'is not deployed', configs['auth_url'])
|
'is not deployed', configs['auth_url'])
|
||||||
raise
|
raise
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_cleanup_servers(session)
|
_cleanup_servers(session)
|
||||||
except keystoneauth_exceptions.EndpointNotFound:
|
except keystoneauth_exceptions.EndpointNotFound:
|
||||||
LOG.info('Nova is not present, skipping instances cleanup')
|
LOG.info('Nova is not present, skipping instances cleanup')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
_cleanup_images(session)
|
||||||
|
except keystoneauth_exceptions.EndpointNotFound:
|
||||||
|
LOG.info('Glance is not present, skipping images cleanup')
|
||||||
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_cleanup_network_resources(session)
|
_cleanup_network_resources(session)
|
||||||
except keystoneauth_exceptions.EndpointNotFound:
|
except keystoneauth_exceptions.EndpointNotFound:
|
||||||
LOG.info('Neutron is not present, skipping network resources '
|
LOG.info('Neutron is not present, skipping network resources '
|
||||||
'cleanup')
|
'cleanup')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
LOG.info('OpenStack cleanup has been finished successfully.')
|
LOG.info('OpenStack cleanup has been finished successfully.')
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,15 +4,16 @@
|
|||||||
|
|
||||||
pbr>=1.6 # Apache-2.0
|
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)
|
GitPython>=1.0.1 # BSD License (3 clause)
|
||||||
Jinja2>=2.8 # 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
|
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
|
keystoneauth1>=2.10.0 # Apache-2.0
|
||||||
pykube # Apache-2.0
|
pykube # Apache-2.0
|
||||||
|
python-glanceclient>=2.5.0 # Apache-2.0
|
||||||
python-neutronclient>=5.1.0 # Apache-2.0
|
python-neutronclient>=5.1.0 # Apache-2.0
|
||||||
python-novaclient!=2.33.0,>=2.29.0 # Apache-2.0
|
python-novaclient!=2.33.0,>=2.29.0 # Apache-2.0
|
||||||
|
six>=1.9.0 # MIT
|
||||||
|
Loading…
Reference in New Issue
Block a user