Added example code based on pystack.

This commit is contained in:
EdLeafe 2014-01-21 17:08:07 -06:00
parent fa65e373bc
commit 73c11a1fb4
1 changed files with 16 additions and 0 deletions

View File

@ -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")