From 73c11a1fb4ccf35a9b66185a2155dfc6823348f2 Mon Sep 17 00:00:00 2001 From: EdLeafe <ed@leafe.com> Date: Tue, 21 Jan 2014 17:08:07 -0600 Subject: [PATCH] Added example code based on pystack. --- README.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.rst b/README.rst index e5acb2a13..2e8b46473 100644 --- a/README.rst +++ b/README.rst @@ -19,3 +19,19 @@ Example: container = client.object_storage.containers.create(name='stuff') container.objects.create(name='a thing', contents=io.BytesIO(b'all the bytes')) + +.. code-block:: python + + import pystack + from pystack.identity import KeystoneIdentity + ident = KeystoneIdentity(username="ed", tenant_id="1234567890abcdef", + password="******", auth_endpoint="http://123.123.123.123:5000/v2.0/") + context = ident.authenticate() + services_for_region = context.some_region + compute_client = services_for_region.compute.client + image = compute_client.list_images()[0] + server = compute_client.create("server_name", image=image) + + storage_client = services_for_region.object_storage.client + container = storage_client.create("stuff") + obj = container.create(file_or_path="/path/to/my/cool.jpg")