summaryrefslogtreecommitdiff
path: root/openstackclient/object
diff options
context:
space:
mode:
authorSteve Martinelli <stevemar@ca.ibm.com>2014-09-09 21:26:47 -0400
committerSteve Martinelli <stevemar@ca.ibm.com>2014-09-15 01:58:00 +0000
commit09a546891f49b17bf4a0129b0836107b165a83d3 (patch)
tree94d7bbe83a949c72eb0f5fc09c66f66a1953546b /openstackclient/object
parent505c784bad14d806dd5911c953eb95fe964d188b (diff)
downloadpython-openstackclient-09a546891f49b17bf4a0129b0836107b165a83d3.tar.gz
Add support for 'file' format objects
Some objects can be saved as 'dirname/filename' which causes the existing support to fail. The correct behaviour should be to create the directories needed. Change-Id: I71c61bc3b0f76a3e6d2703bd45508f9d6483546e
Diffstat (limited to 'openstackclient/object')
-rw-r--r--openstackclient/object/v1/lib/object.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/openstackclient/object/v1/lib/object.py b/openstackclient/object/v1/lib/object.py
index 38b3c14e..7a23fc76 100644
--- a/openstackclient/object/v1/lib/object.py
+++ b/openstackclient/object/v1/lib/object.py
@@ -16,6 +16,8 @@
"""Object v1 API library"""
+import os
+
import six
try:
@@ -171,6 +173,8 @@ def save_object(
response = session.get("%s/%s/%s" % (url, container, obj), stream=True)
if response.status_code == 200:
+ if not os.path.exists(os.path.dirname(file)):
+ os.makedirs(os.path.dirname(file))
with open(file, 'wb') as f:
for chunk in response.iter_content():
f.write(chunk)