From ecca41dca04703576d91b21e288160019d97ccfa Mon Sep 17 00:00:00 2001 From: josh7810 Date: Fri, 20 Jan 2017 16:34:36 -0600 Subject: [PATCH] Changes for default unicode usage * Added a method delete_unicode_object which will encode a string in utf-8 so that a delete call will properly delete the object. * purge_container now uses this new method. Change-Id: Ief1e4c4ed665668cb958cbb1df5637a09dfeac34 --- .../objectstorage_api/behaviors.py | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/cloudcafe/objectstorage/objectstorage_api/behaviors.py b/cloudcafe/objectstorage/objectstorage_api/behaviors.py index df108ce2..f657a130 100644 --- a/cloudcafe/objectstorage/objectstorage_api/behaviors.py +++ b/cloudcafe/objectstorage/objectstorage_api/behaviors.py @@ -710,7 +710,8 @@ class ObjectStorageAPI_Behaviors(BaseBehavior): requestslib_kwargs=requestslib_kwargs) for storage_object in list_response.entity: - self.client.delete_object(container_name, storage_object.name) + self.delete_unicode_object(container_name, + storage_object.name) list_response = self.client.list_objects(container_name) @@ -931,3 +932,23 @@ class ObjectStorageAPI_Behaviors(BaseBehavior): container_name=self.config.cleanup_failure_container_name, object_name=failure_log_name, data=container_name) + + def delete_unicode_object(self, container_name, object_name): + """ + @summary: This method will encode an object name, that has unicode, + in utf-8 and then call the client delete method. + + @param container_name: Name of container where object resides. + @type container_name: string + @param object_name: Name of object to delete + @type object_name: string + + @return: response from the delete + @rtype: Requests.response object + """ + utf_object_name = u''.join(object_name).encode('utf-8') + + delete_response = self.client.delete_object(container_name, + utf_object_name) + + return delete_response