Commit 17f6b83e authored by Gabriel Hurley's avatar Gabriel Hurley

Initial commit.

Andrey Brindeyev <>
Andy Smith <>
Antony Messerli <>
Brian Lamar <>
Brian Waldon <>
Chris Behrens <>
Christopher MacGown <>
Ed Leafe <>
Eldar Nugaev <>
Ilya Alekseyev <>
Johannes Erdfelt <>
Josh Kearney <>
Kevin L. Mitchell <>
Kirill Shileev <>
Lvov Maxim <>
Matt Dietz <>
Sandy Walsh <>
Gabriel Hurley <>
Keystone Style Commandments
Step 1: Read
Step 2: Read again
Step 3: Read on
- thou shalt not import objects, only modules
- thou shalt not import more than one module per line
- thou shalt not make relative imports
- thou shalt organize your imports according to the following template
# vim: tabstop=4 shiftwidth=4 softtabstop=4
{{stdlib imports in human alphabetical order}}
{{third-party library imports in human alphabetical order}}
{{keystoneclient imports in human alphabetical order}}
{{begin your code}}
- thou shalt put two newlines twixt toplevel code (funcs, classes, etc)
- thou shalt put one newline twixt methods in classes and anywhere else
- thou shalt not write "except:", use "except Exception:" at the very least
- thou shalt include your name with TODOs as in "TODO(termie)"
- thou shalt not name anything the same name as a builtin or reserved word
- thou shalt not violate causality in our time cone, or else
Human Alphabetical Order Examples
import httplib
import logging
import random
import StringIO
import time
import unittest
import httplib2
from keystoneclient import exceptions
from keystoneclient import service_catalog
from keystoneclient.v2_0 import client
"""A one line docstring looks like this and ends in a period."""
"""A multiline docstring has a one-line summary, less than 80 characters.
Then a new paragraph after a newline that explains in more detail any
general information about the function, class or method. Example usages
are also great to have here if it is a complex class for function. After
you have finished your descriptions add an extra newline and close the
When writing the docstring for a class, an extra line should be placed
after the closing quotations. For more in-depth explanations for these
decisions see
If you are going to describe parameters and return values, use Sphinx, the
appropriate syntax is as follows.
:param foo: the foo parameter
:param bar: the bar parameter
:returns: description of the return value
This diff is collapsed.
include README.rst
recursive-include docs *
recursive-include tests *
\ No newline at end of file
Python bindings to the OpenStack Keystone API
This is a client for the OpenStack Keystone API. There's a Python API (the
``keystoneclient`` module), and a command-line script (``keystone``). The
Keystone 2.0 API is still a moving target, so this module will remain in
"Beta" status until the API is finalized and fully implemented.
Development takes place on GitHub__. Bug reports and patches may be filed there.
This code a fork of `Rackspace's python-novaclient`__ which is in turn a fork of
`Jacobian's python-cloudservers`__. The python-keystoneclient is licensed under
the Apache License like the rest of OpenStack.
.. contents:: Contents:
Python API
By way of a quick-start::
# use v2.0 auth with")
>>> from keystoneclient.v2_0 import client
>>> keystone = client.Client(USERNAME, API_KEY, PROJECT_ID)
>>> keystone.tenants.list()
>>> tenant = keystone.tenants.create(name="test", descrption="My new tenant!", enabled=True)
>>> tenant.delete()
Command-line API
.. attention:: COMING SOON
The API is not yet implemented, but will follow the pattern laid
out below.
Installing this package gets you a shell command, ``keystone``, that you
can use to interact with Keystone's API.
You'll need to provide your OpenStack username and API key. You can do this
with the ``--username``, ``--apikey`` and ``--projectid`` params, but it's
easier to just set them as environment variables::
export KEYSTONE_USERNAME=openstack
export KEYSTONE_API_KEY=yadayada
export KEYSTONE_PROJECTID=yadayada
You will also need to define the authentication url with ``--url`` and the
version of the API with ``--version``. Or set them as an environment
variables as well::
Since Keystone can return multiple regions in the Service Catalog, you
can specify the one you want with ``--region_name`` (or
``export KEYSTONE_REGION_NAME``). It defaults to the first in the list returned.
You'll find complete documentation on the shell by running
``keystone help``::
usage: keystone [--username USERNAME] [--apikey APIKEY] [--projectid PROJECTID]
[--url URL] [--version VERSION] [--region_name NAME]
<subcommand> ...
Command-line interface to the OpenStack Keystone API.
Positional arguments:
add-fixed-ip Add a new fixed IP address to a servers network.
Optional arguments:
--username USERNAME Defaults to env[KEYSTONE_USERNAME].
--apikey APIKEY Defaults to env[KEYSTONE_API_KEY].
--apikey PROJECTID Defaults to env[KEYSTONE_PROJECT_ID].
--url AUTH_URL Defaults to env[KEYSTONE_URL] or
--url ADMIN_URL Defaults to env[KEYSTONE_ADMIN_URL]
--version VERSION Defaults to env[KEYSTONE_VERSION] or 2.0.
--region_name NAME The region name in the Keystone Service Catalog
to use after authentication. Defaults to
env[KEYSTONE_REGION_NAME] or the first item
in the list returned.
See "keystone help COMMAND" for help on a specific command.
\ No newline at end of file
# Makefile for Sphinx documentation
# You can set these variables from the command line.
SPHINXBUILD = sphinx-build
BUILDDIR = _build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
-rm -rf $(BUILDDIR)/*
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
@echo "Build finished; now you can process the pickle files."
@echo "Build finished; now you can process the JSON files."
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/python-keystoneclient.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/python-keystoneclient.qhc"
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
"run these through (pdf)latex."
@echo "The overview file is in $(BUILDDIR)/changes."
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
The :mod:`keystoneclient` Python API
.. module:: keystoneclient
:synopsis: A client for the OpenStack Keystone API.
.. currentmodule:: keystoneclient.v2_0.client
.. autoclass:: Client
.. automethod:: authenticate
For more information, see the reference documentation:
.. toctree::
:maxdepth: 2
# -*- coding: utf-8 -*-
# python-keystoneclient documentation build configuration file, created by
# sphinx-quickstart on Sun Dec 6 14:19:25 2009.
# This file is execfile()d with the current directory set to its containing dir.
# Note that not all possible configuration values are present in this
# autogenerated file.
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# -- General configuration -----------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'python-keystoneclient'
copyright = u'Rackspace, based on work by Jacob Kaplan-Moss'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
# The short X.Y version.
version = '2.7'
# The full version, including alpha/beta/rc tags.
release = '2.7.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of documents that shouldn't be included in the build.
#unused_docs = []
# List of directories, relative to source directory, that shouldn't be searched
# for source files.
exclude_trees = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
html_theme = 'nature'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_use_modindex = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = ''
# Output file base name for HTML help builder.
htmlhelp_basename = 'python-keystoneclientdoc'
# -- Options for LaTeX output --------------------------------------------------
# The paper size ('letter' or 'a4').
#latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'python-keystoneclient.tex', u'python-keystoneclient Documentation',
u'Nebula Inc, based on work by Rackspace and Jacob Kaplan-Moss', 'manual'),
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# Additional stuff for the LaTeX preamble.
#latex_preamble = ''
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_use_modindex = True
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'': None}
Python bindings to the OpenStack Keystone API
This is a client for OpenStack Keystone API. There's :doc:`a Python API
<api>` (the :mod:`keystoneclient` module), and a :doc:`command-line script
<shell>` (installed as :program:`keystone`).
You'll need an `OpenStack Keystone` account, which you can get by
using `keystone-manage`.
.. toctree::
:maxdepth: 2
Development takes place `on GitHub`__; please file bugs/pull requests there.
Run tests with ``python test``.
Indices and tables
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
.. currentmodule:: keystoneclient.exceptions
.. automodule:: keystoneclient.exceptions
API Reference
The following API reference documents are available:
.. toctree::
:maxdepth: 1
Release notes
2.7.0 (October 21, 2011)
* Forked from
* Rebranded to python-keystoneclient
* Refactored to support Keystone API (auth, tokens, services, roles, tenants,
users, etc.)
2.5.8 (July 11, 2011)
* returns all public/private ips, not just first one
* better 'nova list' search options
2.5.7 - 2.5.6 = minor tweaks
2.5.5 (June 21, 2011)
* zone-boot min/max instance count added thanks to comstud
* create for user added thanks to cerberus
* fixed tests
2.5.3 (June 15, 2011)
* ProjectID can be None for backwards compatability.
* README/docs updated for projectId thanks to usrleon
2.5.1 (June 10, 2011)
* ProjectID now part of authentication
2.5.0 (June 3, 2011)
* better logging thanks to GridDynamics
2.4.4 (June 1, 2011)
* added support for GET /servers with reservation_id (and /servers/detail)
2.4.3 (May 27, 2011)
* added support for POST /zones/select (client only, not cmdline)
2.4 (March 7, 2011)
* added Jacob Kaplan-Moss copyright notices to older/untouched files.
2.3 (March 2, 2011)
* package renamed to python-novaclient. Module to novaclient
2.2 (March 1, 2011)
* removed some license/copywrite notices from source that wasn't
significantly changed.
2.1 (Feb 28, 2011)
* shell renamed to nova from novatools
* license changed from BSD to Apache
2.0 (Feb 7, 2011)
* Forked from
* Rebranded to python-novatools
* Auth URL support
* New OpenStack specific commands added (pause, suspend, etc)
1.2 (August 15, 2010)
* Support for Python 2.4 - 2.7.
* Improved output of :program:`cloudservers ipgroup-list`.
* Made ``cloudservers boot --ipgroup <name>`` work (as well as ``--ipgroup
1.1 (May 6, 2010)
* Added a ``--files`` option to :program:`cloudservers boot` supporting
the upload of (up to five) files at boot time.
* Added a ``--key`` option to :program:`cloudservers boot` to key the server
with an SSH public key at boot time. This is just a shortcut for ``--files``,
but it's a useful shortcut.
* Changed the default server image to Ubuntu 10.04 LTS.
The :program:`keystone` shell utility
.. program:: keystone
.. highlight:: bash
.. warning:: COMING SOON
The command line interface is not yet completed. This document serves
as a reference for the implementation.
The :program:`keystone` shell utility interacts with OpenStack Keystone API
from the command line. It supports the entirety of the OpenStack Keystone API.
First, you'll need an OpenStack Keystone account and an API key. You get this
by using the `keystone-manage` command in OpenStack Keystone.
You'll need to provide :program:`keystone` with your OpenStack username and
API key. You can do this with the :option:`--username`, :option:`--apikey`
and :option:`--projectid` options, but it's easier to just set them as
environment variables by setting two environment variables:
Your Keystone username.
.. envvar:: KEYSTONE_API_KEY
Your API key.
Project for work.
.. envvar:: KEYSTONE_URL
The OpenStack API server URL.
The OpenStack API version.
For example, in Bash you'd use::
export KEYSTONE_USERNAME=yourname
export KEYSTONE_API_KEY=yadayadayada
export KEYSTONE_PROJECT_ID=myproject
export KEYSTONE_URL=http://...
From there, all shell commands take the form::
keystone <command> [arguments...]
Run :program:`keystone help` to get a full list of all possible commands,
and run :program:`keystone help <command>` to get detailed help for that
# Copyright 2010 Jacob Kaplan-Moss
# Copyright 2011 OpenStack LLC.
# All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
Base utilities to build API operation managers and objects on top of.
from keystoneclient import exceptions