def deprovision_swift(self): """ Delete the Swift containers. """ self.logger.info('Deprovisioning swift started.') if self.storage_type == self.SWIFT_STORAGE and self.swift_provisioned: for container_name in self.swift_container_names: self.logger.info('Deleting swift container: %s', container_name) try: openstack_utils.delete_swift_container( container_name, user=self.swift_openstack_user, password=self.swift_openstack_password, tenant=self.swift_openstack_tenant, auth_url=self.swift_openstack_auth_url, region=self.swift_openstack_region, ) except SwiftClientException: # If deleting a Swift container fails, we still want to continue. self.logger.exception( 'Could not delete Swift container "%s".', container_name) self.swift_provisioned = False self.save() self.logger.info('Deprovisioning swift finished.')
def test_delete_swift_containerr(self, auth): """Test for delete_swift_container function.""" self.service.delete.return_value = [ None ] * 10 # Response contents are ignored openstack_utils.delete_swift_container(CONTAINER_NAME, **auth) self.service.delete.assert_called_once_with(CONTAINER_NAME) self.basic_checks(auth)
def deprovision_swift(self): """ Delete the Swift containers. """ if settings.SWIFT_ENABLE and self.swift_provisioned: for container_name in self.swift_container_names: try: openstack_utils.delete_swift_container( container_name, user=self.swift_openstack_user, password=self.swift_openstack_password, tenant=self.swift_openstack_tenant, auth_url=self.swift_openstack_auth_url, region=self.swift_openstack_region, ) except SwiftClientException: # If deleting a Swift container fails, we still want to continue. self.logger.exception( 'Could not delete Swift container "%s".', container_name) self.swift_provisioned = False self.save()