Adjust object_store to use upload/download names

object_store had been using create_object and save_object names, but
we've previously aggreed to use upload and download for those types of
calls.

Change-Id: I59a17cc29a989096820093ac7e6dba87c1f58b66
Partial-Bug: #1488631
This commit is contained in:
Brian Curtin
2015-11-06 12:13:25 -06:00
parent c9040d2f2c
commit 244fb87f4a
3 changed files with 13 additions and 13 deletions

View File

@@ -154,21 +154,21 @@ the data stored inside of it with the
Hello, world! Hello, world!
Additionally, if you want to save the object to disk, the Additionally, if you want to save the object to disk, the
:meth:`~openstack.object_store.v1._proxy.Proxy.save_object` convenience :meth:`~openstack.object_store.v1._proxy.Proxy.download_object` convenience
method takes an :class:`~openstack.object_store.v1.obj.Object` and a method takes an :class:`~openstack.object_store.v1.obj.Object` and a
``path`` to write the contents to. :: ``path`` to write the contents to. ::
>>> conn.object_store.save_object(ob, "the_message.txt") >>> conn.object_store.download_object(ob, "the_message.txt")
Creating Objects Uploading Objects
**************** *****************
Once you have data you'd like to store in the Object Store service, you use Once you have data you'd like to store in the Object Store service, you use
the :meth:`~openstack.object_store.v1._proxy.Proxy.create_object` method. the :meth:`~openstack.object_store.v1._proxy.Proxy.upload_object` method.
This method takes the ``data`` to be stored, along with at least an object This method takes the ``data`` to be stored, along with at least an object
``name`` and the ``container`` it is to be stored in. :: ``name`` and the ``container`` it is to be stored in. ::
>>> hello = conn.object_store.create_object(container="messages", >>> hello = conn.object_store.upload_object(container="messages",
name="helloworld.txt", name="helloworld.txt",
data="Hello, world!") data="Hello, world!")
>>> print hello >>> print hello

View File

@@ -162,8 +162,8 @@ class Proxy(proxy.BaseProxy):
return self._get(_obj.Object, value, return self._get(_obj.Object, value,
path_args={"container": container_name}) path_args={"container": container_name})
def save_object(self, obj, path): def download_object(self, obj, path):
"""Save the data contained inside an object to disk. """Download the data contained inside an object to disk.
:param obj: The object to save to disk. :param obj: The object to save to disk.
:type obj: :class:`~openstack.object_store.v1.obj.Object` :type obj: :class:`~openstack.object_store.v1.obj.Object`
@@ -172,8 +172,8 @@ class Proxy(proxy.BaseProxy):
with open(path, "w") as out: with open(path, "w") as out:
out.write(self.get_object(obj)) out.write(self.get_object(obj))
def create_object(self, **attrs): def upload_object(self, **attrs):
"""Create a new object from attributes """Upload a new object from attributes
:param dict attrs: Keyword arguments which will be used to create :param dict attrs: Keyword arguments which will be used to create
a :class:`~openstack.object_store.v1.obj.Object`, a :class:`~openstack.object_store.v1.obj.Object`,

View File

@@ -78,13 +78,13 @@ class TestObjectStoreProxy(test_proxy_base.TestProxyBase):
expected_kwargs.pop("container") expected_kwargs.pop("container")
self._verify2("openstack.proxy.BaseProxy._create", self._verify2("openstack.proxy.BaseProxy._create",
self.proxy.create_object, self.proxy.upload_object,
method_kwargs=method_kwargs, method_kwargs=method_kwargs,
expected_args=[obj.Object], expected_args=[obj.Object],
expected_kwargs=expected_kwargs) expected_kwargs=expected_kwargs)
def test_object_create_no_container(self): def test_object_create_no_container(self):
self.assertRaises(ValueError, self.proxy.create_object) self.assertRaises(ValueError, self.proxy.upload_object)
def test_object_get(self): def test_object_get(self):
self.verify_get(self.proxy.get_object, obj.Object, self.verify_get(self.proxy.get_object, obj.Object,
@@ -275,7 +275,7 @@ class Test_save_object(TestObjectStoreProxy):
file_path = "blarga/somefile" file_path = "blarga/somefile"
with mock.patch("openstack.object_store.v1._proxy.open", with mock.patch("openstack.object_store.v1._proxy.open",
fake_open, create=True): fake_open, create=True):
self.proxy.save_object(ob, file_path) self.proxy.download_object(ob, file_path)
fake_open.assert_called_once_with(file_path, "w") fake_open.assert_called_once_with(file_path, "w")
fake_handle = fake_open() fake_handle = fake_open()