Revert "Url quoting of swift object names when deleting"

This reverts commit fc73a2e881.

Change-Id: I7d0d0d4f6af53dec2cf96e1bbc8de70d5f6c7ba3
This commit is contained in:
Adam Harwell 2019-10-21 15:41:05 -07:00
parent 0f517cf361
commit a7b9786f4a
2 changed files with 11 additions and 20 deletions

View File

@ -9,9 +9,6 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from six.moves import urllib_parse
from ospurge.resources import base
from ospurge.resources.base import BaseServiceResource
from ospurge.resources import glance
@ -20,9 +17,7 @@ from ospurge.resources import glance
class ListObjectsMixin(BaseServiceResource):
def list_objects(self):
for container in self.cloud.list_containers():
for obj in self.cloud.list_objects(
urllib_parse.quote(container['name'])
):
for obj in self.cloud.list_objects(container['name']):
obj['container_name'] = container['name']
yield obj
@ -39,10 +34,7 @@ class Objects(base.ServiceResource, glance.ListImagesMixin, ListObjectsMixin):
yield item
def delete(self, resource):
self.cloud.delete_object(
urllib_parse.quote(resource['container_name']),
urllib_parse.quote(resource['name'])
)
self.cloud.delete_object(resource['container_name'], resource['name'])
@staticmethod
def to_str(resource):
@ -60,14 +52,13 @@ class Containers(base.ServiceResource, ListObjectsMixin):
return self.cloud.list_containers()
def delete(self, resource):
self.cloud.delete_container(urllib_parse.quote(resource['name']))
self.cloud.delete_container(resource['name'])
def disable(self, resource):
# There is no disable for the swift container just removing the
# write/read access to the conatianer, so only admin can access
# write/read access to the container, so only admin can access
self.cloud.object_store.set_container_metadata(
urllib_parse.quote(resource['name']),
write_acl=None, read_acl=None
resource['name'], write_acl=None, read_acl=None
)
@staticmethod

View File

@ -12,7 +12,6 @@
import unittest
import openstack.connection
from six.moves import urllib_parse
from ospurge.resources import swift
from ospurge.tests import mock
@ -79,14 +78,15 @@ class TestObjects(unittest.TestCase):
def test_delete(self):
objects = [
{'name': 'toto', 'container_name': 'foo'},
{'name': 'tata%20foo', 'container_name': 'baz%20bar'},
{'name': 'tata foo', 'container_name': 'baz bar'},
{'name': 'titi#1', 'container_name': 'bar#2'},
{'name': 'hihi♫', 'container_name': 'bar♫'},
]
for obj in objects:
self.assertIsNone(swift.Objects(self.creds_manager).delete(obj))
self.cloud.delete_object.assert_called_with(
urllib_parse.quote(obj['container_name']),
urllib_parse.quote(obj['name'])
obj['container_name'],
obj['name']
)
def test_disable(self):
@ -130,7 +130,7 @@ class TestContainers(unittest.TestCase):
'name': 'Pouet éêù #'}
self.assertIsNone(swift.Containers(self.creds_manager).delete(cont))
self.cloud.delete_container.assert_called_once_with(
urllib_parse.quote(cont['name'])
cont['name']
)
def test_disable(self):
@ -140,7 +140,7 @@ class TestContainers(unittest.TestCase):
'name': 'Pouet éêù #'}
self.assertIsNone(swift.Containers(self.creds_manager).disable(cont))
self.cloud.object_store.set_container_metadata.assert_called_once_with(
urllib_parse.quote(cont['name']),
cont['name'],
read_acl=None, write_acl=None
)