Add object storage cleanup
Cleanup object storage when radosgw is deployed Change-Id: I4590903048992ad53c3b731e37106e1325502e3a
This commit is contained in:
parent
ca7b999bbf
commit
dd317dad56
|
@ -8,6 +8,7 @@ from keystoneauth1 import session as keystone_session
|
||||||
from neutronclient.neutron import client as neutron_client
|
from neutronclient.neutron import client as neutron_client
|
||||||
from novaclient import client as nova_client
|
from novaclient import client as nova_client
|
||||||
import pykube
|
import pykube
|
||||||
|
from swiftclient import client as swift_client
|
||||||
|
|
||||||
from fuel_ccp.common import utils
|
from fuel_ccp.common import utils
|
||||||
from fuel_ccp import config
|
from fuel_ccp import config
|
||||||
|
@ -111,6 +112,16 @@ def _cleanup_images(session):
|
||||||
glance.images.delete(image.id)
|
glance.images.delete(image.id)
|
||||||
|
|
||||||
|
|
||||||
|
def _cleanup_object_storage(session):
|
||||||
|
LOG.info("Cleaning up object storage")
|
||||||
|
swift = swift_client.Connection(session=session)
|
||||||
|
for cont in swift.get_account()[1]:
|
||||||
|
LOG.debug("Delete bucket %s", cont["name"])
|
||||||
|
for obj in swift.get_container(cont["name"])[1]:
|
||||||
|
swift.delete_object(cont["name"], obj["name"])
|
||||||
|
swift.delete_container(cont["name"])
|
||||||
|
|
||||||
|
|
||||||
def _cleanup_openstack_environment(configs, auth_url=None, verify=True):
|
def _cleanup_openstack_environment(configs, auth_url=None, verify=True):
|
||||||
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
|
||||||
|
@ -158,6 +169,12 @@ def _cleanup_openstack_environment(configs, auth_url=None, verify=True):
|
||||||
'cleanup')
|
'cleanup')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
_cleanup_object_storage(session)
|
||||||
|
except keystoneauth_exceptions.EndpointNotFound:
|
||||||
|
LOG.info("Object storage is not present, skipping buckets cleanup")
|
||||||
|
pass
|
||||||
|
|
||||||
LOG.info('OpenStack cleanup has been finished successfully.')
|
LOG.info('OpenStack cleanup has been finished successfully.')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,4 +16,5 @@ pykube # Apache-2.0
|
||||||
python-glanceclient>=2.5.0 # 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
|
||||||
|
python-swiftclient>=2.2.0 # Apache-2.0
|
||||||
six>=1.9.0 # MIT
|
six>=1.9.0 # MIT
|
||||||
|
|
Loading…
Reference in New Issue