From e8acf5e7367821625ee8e94866b117990d207c9f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 15 Jun 2017 16:54:52 -0400 Subject: move existing content into the new standard structure This patch rearranges and reformats existing content. It replaces the home-grown autodoc feature with the one built into pbr, for consistency with other OpenStack projects. It depends on the doc-migration spec and a pbr feature to allow us to specify where the autodoc content should go in the source tree during the build. Change-Id: I8d2bb11b5ef3e46fcd22c8bed8f84060d8ab6f03 Depends-On: Ia750cb049c0f53a234ea70ce1f2bbbb7a2aa9454 Depends-On: I2bd5652bb59cbd9c939931ba2e7db1b37d2b30bb Signed-off-by: Doug Hellmann --- doc/source/apiv2.rst | 89 -------------------------------------- doc/source/cli/glance.rst | 87 +++++++++++++++++++++++++++++++++++++ doc/source/cli/index.rst | 31 +++++++++++++ doc/source/conf.py | 43 ------------------ doc/source/index.rst | 64 ++++----------------------- doc/source/man/glance.rst | 87 ------------------------------------- doc/source/reference/api/index.rst | 8 ++++ doc/source/reference/apiv2.rst | 89 ++++++++++++++++++++++++++++++++++++++ doc/source/reference/index.rst | 27 ++++++++++++ 9 files changed, 251 insertions(+), 274 deletions(-) delete mode 100644 doc/source/apiv2.rst create mode 100644 doc/source/cli/glance.rst create mode 100644 doc/source/cli/index.rst delete mode 100644 doc/source/man/glance.rst create mode 100644 doc/source/reference/api/index.rst create mode 100644 doc/source/reference/apiv2.rst create mode 100644 doc/source/reference/index.rst (limited to 'doc') diff --git a/doc/source/apiv2.rst b/doc/source/apiv2.rst deleted file mode 100644 index 3f75bc6..0000000 --- a/doc/source/apiv2.rst +++ /dev/null @@ -1,89 +0,0 @@ -Python API v2 -============= - -To create a client:: - - from keystoneauth1 import loading - from keystoneauth1 import session - from glanceclient import Client - - loader = loading.get_plugin_loader('password') - auth = loader.load_from_options( - auth_url=AUTH_URL, - username=USERNAME, - password=PASSWORD, - project_id=PROJECT_ID) - session = session.Session(auth=auth) - - glance = Client('2', session=session) - - -Create ------- -Create a new image:: - - image = glance.images.create(name="myNewImage") - glance.images.upload(image.id, open('/tmp/myimage.iso', 'rb')) - -Show ----- -Describe a specific image:: - - glance.images.get(image.id) - -Update ------- -Update a specific image:: - - # update with a list of image attribute names and their new values - glance.images.update(image.id, name="myNewImageName") - -Custom Properties ------------------ -Set a custom property on an image:: - - # set an arbitrary property on an image - glance.images.update(image.id, my_custom_property='value') - -Remove a custom property from an image:: - - # remove the custom property 'my_custom_property' - glance.images.update(image.id, remove_props=['my_custom_property']) - -Delete ------- -Delete specified image(s):: - - glance.images.delete(image.id) - -List ----- -List images you can access:: - - for image in glance.images.list(): - print image - -Download --------- -Download a specific image:: - - d = glance.images.data(image.id) - -Share an Image --------------- -Share a specific image with a tenant:: - - glance.image_members.create(image_id, member_id) - -Remove a Share --------------- -Remove a shared image from a tenant:: - - glance.image_members.delete(image_id, member_id) - -List Sharings -------------- -Describe sharing permissions by image or tenant:: - - glance.image_members.list(image_id) - diff --git a/doc/source/cli/glance.rst b/doc/source/cli/glance.rst new file mode 100644 index 0000000..8d3cac0 --- /dev/null +++ b/doc/source/cli/glance.rst @@ -0,0 +1,87 @@ +============================== +:program:`glance` CLI man page +============================== + +.. program:: glance +.. highlight:: bash + +SYNOPSIS +======== + +:program:`glance` [options] [command-options] + +:program:`glance help` + +:program:`glance help` + + +DESCRIPTION +=========== + +The :program:`glance` command line utility interacts with OpenStack Images +Service (Glance). + +In order to use the CLI, you must provide your OpenStack username, password, +project (historically called tenant), and auth endpoint. You can use +configuration options ``--os-username``, ``--os-password``, ``--os-tenant-id``, +and ``--os-auth-url`` or set corresponding environment variables:: + + export OS_USERNAME=user + export OS_PASSWORD=pass + export OS_TENANT_ID=b363706f891f48019483f8bd6503c54b + export OS_AUTH_URL=http://auth.example.com:5000/v2.0 + +The command line tool will attempt to reauthenticate using provided credentials +for every request. You can override this behavior by manually supplying an auth +token using ``--os-image-url`` and ``--os-auth-token`` or by setting +corresponding environment variables:: + + export OS_IMAGE_URL=http://glance.example.org:9292/ + export OS_AUTH_TOKEN=3bcc3d3a03f44e3d8377f9247b0ad155 + +You can select an API version to use by ``--os-image-api-version`` option or by +setting corresponding environment variable:: + + export OS_IMAGE_API_VERSION=1 + +Default Images API used is v2. + +OPTIONS +======= + +To get a list of available commands and options run:: + + glance help + +To get usage and options of a command:: + + glance help + + +EXAMPLES +======== + +Get information about image-create command:: + + glance help image-create + +See available images:: + + glance image-list + +Create new image:: + + glance image-create --name foo --disk-format=qcow2 \ + --container-format=bare --visibility=public \ + --file /tmp/foo.img + +Describe a specific image:: + + glance image-show + + +BUGS +==== + +Glance client is hosted in Launchpad so you can view current bugs at +https://bugs.launchpad.net/python-glanceclient/. diff --git a/doc/source/cli/index.rst b/doc/source/cli/index.rst new file mode 100644 index 0000000..01b594c --- /dev/null +++ b/doc/source/cli/index.rst @@ -0,0 +1,31 @@ +============================= + Command-line Tool Reference +============================= + +In order to use the CLI, you must provide your OpenStack username, +password, tenant, and auth endpoint. Use the corresponding +configuration options (``--os-username``, ``--os-password``, +``--os-tenant-id``, and ``--os-auth-url``) or set them in environment +variables:: + + export OS_USERNAME=user + export OS_PASSWORD=pass + export OS_TENANT_ID=b363706f891f48019483f8bd6503c54b + export OS_AUTH_URL=http://auth.example.com:5000/v2.0 + +The command line tool will attempt to reauthenticate using your +provided credentials for every request. You can override this behavior +by manually supplying an auth token using ``--os-image-url`` and +``--os-auth-token``. You can alternatively set these environment +variables:: + + export OS_IMAGE_URL=http://glance.example.org:9292/ + export OS_AUTH_TOKEN=3bcc3d3a03f44e3d8377f9247b0ad155 + +Once you've configured your authentication parameters, you can run +``glance help`` to see a complete listing of available commands. + +.. toctree:: + + glance + diff --git a/doc/source/conf.py b/doc/source/conf.py index 4c22042..0056074 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -19,49 +19,6 @@ import sys sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))) -BASE_DIR = os.path.dirname(os.path.abspath(__file__)) -ROOT = os.path.abspath(os.path.join(BASE_DIR, "..", "..")) - - -def gen_ref(ver, title, names): - refdir = os.path.join(BASE_DIR, "ref") - pkg = "glanceclient" - if ver: - pkg = "%s.%s" % (pkg, ver) - refdir = os.path.join(refdir, ver) - if not os.path.exists(refdir): - os.makedirs(refdir) - idxpath = os.path.join(refdir, "index.rst") - with open(idxpath, "w") as idx: - idx.write(("%(title)s\n" - "%(signs)s\n" - "\n" - ".. toctree::\n" - " :maxdepth: 1\n" - "\n") % {"title": title, "signs": "=" * len(title)}) - for name in names: - idx.write(" %s\n" % name) - rstpath = os.path.join(refdir, "%s.rst" % name) - with open(rstpath, "w") as rst: - rst.write(("%(title)s\n" - "%(signs)s\n" - "\n" - ".. automodule:: %(pkg)s.%(name)s\n" - " :members:\n" - " :undoc-members:\n" - " :show-inheritance:\n" - " :noindex:\n") - % {"title": name.capitalize(), - "signs": "=" * len(name), - "pkg": pkg, "name": name}) - -gen_ref(None, "API", ["client", "exc"]) -gen_ref("v1", "OpenStack Images Version 1 Client Reference", - ["client", "images", "image_members"]) -gen_ref("v2", "OpenStack Images Version 2 Client Reference", - ["client", "images", "image_tags", - "image_members", "tasks", "metadefs"]) - # -- General configuration ---------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be diff --git a/doc/source/index.rst b/doc/source/index.rst index b75bc6a..1be7eff 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -1,61 +1,15 @@ -Python Bindings for the OpenStack Images API -============================================ +============================================== + Python Bindings for the OpenStack Images API +============================================== -This is a client for the OpenStack Images API. There's :doc:`a Python API ` (the :mod:`glanceclient` module) and a :doc:`command-line script` (installed as :program:`glance`). +This is a client for the OpenStack Images API. There's :doc:`a Python +API ` (the :mod:`glanceclient` module) and a +:doc:`command-line script ` (installed as +:program:`glance`). -Python API ----------- -In order to use the python api directly, you must first obtain an auth token and identify which endpoint you wish to speak to. Once you have done so, you can use the API like so:: - - >>> from glanceclient import Client - >>> glance = Client('1', endpoint=OS_IMAGE_ENDPOINT, token=OS_AUTH_TOKEN) - >>> image = glance.images.create(name="My Test Image") - >>> print image.status - 'queued' - >>> image.update(data=open('/tmp/myimage.iso', 'rb')) - >>> print image.status - 'active' - >>> image.update(properties=dict(my_custom_property='value')) - >>> with open('/tmp/copyimage.iso', 'wb') as f: - for chunk in image.data(): - f.write(chunk) - >>> image.delete() - -Python API Reference -~~~~~~~~~~~~~~~~~~~~ .. toctree:: :maxdepth: 2 - ref/index - ref/v1/index - ref/v2/index - -.. toctree:: - :maxdepth: 1 - - How to use the v2 API - -Command-line Tool Reference -~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. toctree:: - :maxdepth: 1 - - man/glance - -Command-line Tool ------------------ -In order to use the CLI, you must provide your OpenStack username, password, tenant, and auth endpoint. Use the corresponding configuration options (``--os-username``, ``--os-password``, ``--os-tenant-id``, and ``--os-auth-url``) or set them in environment variables:: - - export OS_USERNAME=user - export OS_PASSWORD=pass - export OS_TENANT_ID=b363706f891f48019483f8bd6503c54b - export OS_AUTH_URL=http://auth.example.com:5000/v2.0 - -The command line tool will attempt to reauthenticate using your provided credentials for every request. You can override this behavior by manually supplying an auth token using ``--os-image-url`` and ``--os-auth-token``. You can alternatively set these environment variables:: - - export OS_IMAGE_URL=http://glance.example.org:9292/ - export OS_AUTH_TOKEN=3bcc3d3a03f44e3d8377f9247b0ad155 - -Once you've configured your authentication parameters, you can run ``glance help`` to see a complete listing of available commands. + reference/index + cli/index -See also :doc:`/man/glance`. diff --git a/doc/source/man/glance.rst b/doc/source/man/glance.rst deleted file mode 100644 index 8d3cac0..0000000 --- a/doc/source/man/glance.rst +++ /dev/null @@ -1,87 +0,0 @@ -============================== -:program:`glance` CLI man page -============================== - -.. program:: glance -.. highlight:: bash - -SYNOPSIS -======== - -:program:`glance` [options] [command-options] - -:program:`glance help` - -:program:`glance help` - - -DESCRIPTION -=========== - -The :program:`glance` command line utility interacts with OpenStack Images -Service (Glance). - -In order to use the CLI, you must provide your OpenStack username, password, -project (historically called tenant), and auth endpoint. You can use -configuration options ``--os-username``, ``--os-password``, ``--os-tenant-id``, -and ``--os-auth-url`` or set corresponding environment variables:: - - export OS_USERNAME=user - export OS_PASSWORD=pass - export OS_TENANT_ID=b363706f891f48019483f8bd6503c54b - export OS_AUTH_URL=http://auth.example.com:5000/v2.0 - -The command line tool will attempt to reauthenticate using provided credentials -for every request. You can override this behavior by manually supplying an auth -token using ``--os-image-url`` and ``--os-auth-token`` or by setting -corresponding environment variables:: - - export OS_IMAGE_URL=http://glance.example.org:9292/ - export OS_AUTH_TOKEN=3bcc3d3a03f44e3d8377f9247b0ad155 - -You can select an API version to use by ``--os-image-api-version`` option or by -setting corresponding environment variable:: - - export OS_IMAGE_API_VERSION=1 - -Default Images API used is v2. - -OPTIONS -======= - -To get a list of available commands and options run:: - - glance help - -To get usage and options of a command:: - - glance help - - -EXAMPLES -======== - -Get information about image-create command:: - - glance help image-create - -See available images:: - - glance image-list - -Create new image:: - - glance image-create --name foo --disk-format=qcow2 \ - --container-format=bare --visibility=public \ - --file /tmp/foo.img - -Describe a specific image:: - - glance image-show - - -BUGS -==== - -Glance client is hosted in Launchpad so you can view current bugs at -https://bugs.launchpad.net/python-glanceclient/. diff --git a/doc/source/reference/api/index.rst b/doc/source/reference/api/index.rst new file mode 100644 index 0000000..df916b6 --- /dev/null +++ b/doc/source/reference/api/index.rst @@ -0,0 +1,8 @@ +====================== + Python API Reference +====================== + +.. toctree:: + :maxdepth: 2 + + autoindex diff --git a/doc/source/reference/apiv2.rst b/doc/source/reference/apiv2.rst new file mode 100644 index 0000000..3f75bc6 --- /dev/null +++ b/doc/source/reference/apiv2.rst @@ -0,0 +1,89 @@ +Python API v2 +============= + +To create a client:: + + from keystoneauth1 import loading + from keystoneauth1 import session + from glanceclient import Client + + loader = loading.get_plugin_loader('password') + auth = loader.load_from_options( + auth_url=AUTH_URL, + username=USERNAME, + password=PASSWORD, + project_id=PROJECT_ID) + session = session.Session(auth=auth) + + glance = Client('2', session=session) + + +Create +------ +Create a new image:: + + image = glance.images.create(name="myNewImage") + glance.images.upload(image.id, open('/tmp/myimage.iso', 'rb')) + +Show +---- +Describe a specific image:: + + glance.images.get(image.id) + +Update +------ +Update a specific image:: + + # update with a list of image attribute names and their new values + glance.images.update(image.id, name="myNewImageName") + +Custom Properties +----------------- +Set a custom property on an image:: + + # set an arbitrary property on an image + glance.images.update(image.id, my_custom_property='value') + +Remove a custom property from an image:: + + # remove the custom property 'my_custom_property' + glance.images.update(image.id, remove_props=['my_custom_property']) + +Delete +------ +Delete specified image(s):: + + glance.images.delete(image.id) + +List +---- +List images you can access:: + + for image in glance.images.list(): + print image + +Download +-------- +Download a specific image:: + + d = glance.images.data(image.id) + +Share an Image +-------------- +Share a specific image with a tenant:: + + glance.image_members.create(image_id, member_id) + +Remove a Share +-------------- +Remove a shared image from a tenant:: + + glance.image_members.delete(image_id, member_id) + +List Sharings +------------- +Describe sharing permissions by image or tenant:: + + glance.image_members.list(image_id) + diff --git a/doc/source/reference/index.rst b/doc/source/reference/index.rst new file mode 100644 index 0000000..33ce8b2 --- /dev/null +++ b/doc/source/reference/index.rst @@ -0,0 +1,27 @@ +========================== + Python Library Reference +========================== + +In order to use the python api directly, you must first obtain an auth +token and identify which endpoint you wish to speak to. Once you have +done so, you can use the API like so:: + + >>> from glanceclient import Client + >>> glance = Client('1', endpoint=OS_IMAGE_ENDPOINT, token=OS_AUTH_TOKEN) + >>> image = glance.images.create(name="My Test Image") + >>> print image.status + 'queued' + >>> image.update(data=open('/tmp/myimage.iso', 'rb')) + >>> print image.status + 'active' + >>> image.update(properties=dict(my_custom_property='value')) + >>> with open('/tmp/copyimage.iso', 'wb') as f: + for chunk in image.data(): + f.write(chunk) + >>> image.delete() + +.. toctree:: + :maxdepth: 2 + + api/index + apiv2 -- cgit v1.2.1