openstackclient.api package¶
Submodules¶
openstackclient.api.api module¶
Base API Library
-
class
openstackclient.api.api.
BaseAPI
(session=None, service_type=None, endpoint=None, **kwargs)¶ Bases:
openstackclient.api.api.KeystoneSession
Base API
-
create
(url, session=None, method=None, **params)¶ Create a new resource
Parameters: - url (string) – The API-specific portion of the URL path
- session (Session) – HTTP client session
- method (string) – HTTP method (default POST)
-
delete
(url, session=None, **params)¶ Delete a resource
Parameters: - url (string) – The API-specific portion of the URL path
- session (Session) – HTTP client session
-
find
(path, value=None, attr=None)¶ Find a single resource by name or ID
Parameters: - path (string) – The API-specific portion of the URL path
- search (string) – search expression
- attr (string) – name of attribute for secondary search
-
find_attr
(path, value=None, attr=None, resource=None)¶ Find a resource via attribute or ID
Most APIs return a list wrapped by a dict with the resource name as key. Some APIs (Identity) return a dict when a query string is present and there is one return value. Take steps to unwrap these bodies and return a single dict without any resource wrappers.
Parameters: - path (string) – The API-specific portion of the URL path
- value (string) – value to search for
- attr (string) – attribute to use for resource search
- resource (string) – plural of the object resource name; defaults to path
- For example:
- n = find(netclient, ‘network’, ‘networks’, ‘matrix’)
-
find_bulk
(path, **kwargs)¶ Bulk load and filter locally
Parameters: - path (string) – The API-specific portion of the URL path
- kwargs – A dict of AVPs to match - logical AND
Returns: list of resource dicts
-
find_one
(path, **kwargs)¶ Find a resource by name or ID
Parameters: path (string) – The API-specific portion of the URL path Returns: resource dict
-
list
(path, session=None, body=None, detailed=False, **params)¶ Return a list of resources
GET ${ENDPOINT}/${PATH}?${PARAMS}
path is often the object’s plural resource type
Parameters: - path (string) – The API-specific portion of the URL path
- session (Session) – HTTP client session
- body – data that will be encoded as JSON and passed in POST request (GET will be sent by default)
- detailed (bool) – Adds ‘/details’ to path for some APIs to return extended attributes
Returns: JSON-decoded response, could be a list or a dict-wrapped-list
-
-
class
openstackclient.api.api.
KeystoneSession
(session=None, endpoint=None, **kwargs)¶ Bases:
object
Wrapper for the Keystone Session
Restore some requests.session.Session compatibility; keystoneauth1.session.Session.request() has the method and url arguments swapped from the rest of the requests-using world.
openstackclient.api.auth module¶
Authentication Library
-
openstackclient.api.auth.
build_auth_params
(auth_plugin_name, cmd_options)¶
-
openstackclient.api.auth.
build_auth_plugins_option_parser
(parser)¶ Auth plugins options builder
Builds dynamically the list of options expected by each available authentication plugin.
-
openstackclient.api.auth.
check_valid_auth_options
(options, auth_plugin_name, required_scope=True)¶ Perform basic option checking, provide helpful error messages.
Parameters: required_scope – indicate whether a scoped token is required
-
openstackclient.api.auth.
get_options_list
()¶ Gather plugin options so the help action has them available
-
openstackclient.api.auth.
get_plugin_list
()¶ Gather plugin list and cache it
-
openstackclient.api.auth.
select_auth_plugin
(options)¶ Pick an auth plugin based on –os-auth-type or other options
openstackclient.api.auth_plugin module¶
Authentication Plugin Library
-
class
openstackclient.api.auth_plugin.
OSCGenericPassword
(*args, **kwargs)¶ Bases:
keystoneclient.auth.identity.generic.password.Password
Auth plugin hack to work around broken Keystone configurations
The default Keystone configuration uses http://localhost:xxxx in admin_endpoint and public_endpoint and are returned in the links.href attribute by the version routes. Deployments that do not set these are unusable with newer keystoneclient version discovery.
-
create_plugin
(session, version, url, raw_status=None)¶ Handle default Keystone endpoint configuration
Build the actual API endpoint from the scheme, host and port of the original auth URL and the rest from the returned version URL.
-
-
class
openstackclient.api.auth_plugin.
TokenEndpoint
(url, token, **kwargs)¶ Bases:
keystoneclient.auth.token_endpoint.Token
Auth plugin to handle traditional token/endpoint usage
Implements the methods required to handle token authentication with a user-specified token and service endpoint; no Identity calls are made for re-scoping, service catalog lookups or the like.
The purpose of this plugin is to get rid of the special-case paths in the code to handle this authentication format. Its primary use is for bootstrapping the Keystone database.
-
get_auth_ref
(session, **kwargs)¶
-
classmethod
get_options
()¶
-
openstackclient.api.image_v1 module¶
Image v1 API Library
-
class
openstackclient.api.image_v1.
APIv1
(endpoint=None, **kwargs)¶ Bases:
openstackclient.api.api.BaseAPI
Image v1 API
-
image_list
(detailed=False, public=False, private=False, **filter)¶ Get available images
Parameters: - detailed – Retrieve detailed response from server if True
- public – Return public images if True
- private – Return private images if True
If public and private are both True or both False then all images are returned. Both arguments False is equivalent to no filter and all images are returned. Both arguments True is a filter that includes both public and private images which is the same set as all images.
http://docs.openstack.org/api/openstack-image-service/1.1/content/requesting-a-list-of-public-vm-images.html http://docs.openstack.org/api/openstack-image-service/1.1/content/requesting-detailed-metadata-on-public-vm-images.html http://docs.openstack.org/api/openstack-image-service/1.1/content/filtering-images-returned-via-get-images-and-get-imagesdetail.html
-
openstackclient.api.image_v2 module¶
Image v2 API Library
-
class
openstackclient.api.image_v2.
APIv2
(endpoint=None, **kwargs)¶ Bases:
openstackclient.api.image_v1.APIv1
Image v2 API
-
image_list
(detailed=False, public=False, private=False, shared=False, **filter)¶ Get available images
can add limit/marker
Parameters: - detailed – For v1 compatibility only, ignored as v2 is always ‘detailed’
- public – Return public images if True
- private – Return private images if True
- shared – Return shared images if True
If public, private and shared are all True or all False then all images are returned. All arguments False is equivalent to no filter and all images are returned. All arguments True is a filter that includes all public, private and shared images which is the same set as all images.
http://docs.openstack.org/api/openstack-image-service/2.0/content/list-images.html
-
openstackclient.api.object_store_v1 module¶
Object Store v1 API Library
-
class
openstackclient.api.object_store_v1.
APIv1
(**kwargs)¶ Bases:
openstackclient.api.api.BaseAPI
Object Store v1 API
-
account_set
(properties)¶ Set account properties
Parameters: properties (dict) – properties to add or update for the account
-
account_show
()¶ Show account details
-
account_unset
(properties)¶ Unset account properties
Parameters: properties (dict) – properties to remove from the account
-
container_create
(container=None)¶ Create a container
Parameters: container (string) – name of container to create Returns: dict of returned headers
-
container_delete
(container=None)¶ Delete a container
Parameters: container (string) – name of container to delete
-
container_list
(all_data=False, limit=None, marker=None, end_marker=None, prefix=None, **params)¶ Get containers in an account
Parameters: - all_data (boolean) – if True, return a full listing, else returns a max of 10000 listings
- limit (integer) – query return count limit
- marker (string) – query marker
- end_marker (string) – query end_marker
- prefix (string) – query prefix
Returns: list of container names
-
container_save
(container=None)¶ Save all the content from a container
Parameters: container (string) – name of container to save
-
container_set
(container, properties)¶ Set container properties
Parameters: - container (string) – name of container to modify
- properties (dict) – properties to add or update for the container
-
container_show
(container=None)¶ Get container details
Parameters: container (string) – name of container to show Returns: dict of returned headers
-
container_unset
(container, properties)¶ Unset container properties
Parameters: - container (string) – name of container to modify
- properties (dict) – properties to remove from the container
-
object_create
(container=None, object=None)¶ Create an object inside a container
Parameters: - container (string) – name of container to store object
- object (string) – local path to object
Returns: dict of returned headers
-
object_delete
(container=None, object=None)¶ Delete an object from a container
Parameters: - container (string) – name of container that stores object
- object (string) – name of object to delete
-
object_list
(container=None, all_data=False, limit=None, marker=None, end_marker=None, delimiter=None, prefix=None, **params)¶ List objects in a container
Parameters: - container (string) – container name to get a listing for
- all_data (boolean) – if True, return a full listing, else returns a max of 10000 listings
- limit (integer) – query return count limit
- marker (string) – query marker
- end_marker (string) – query end_marker
- prefix (string) – query prefix
- delimiter (string) – string to delimit the queries on
Returns: a tuple of (response headers, a list of objects) The response headers will be a dict and all header names will be lowercase.
-
object_save
(container=None, object=None, file=None)¶ Save an object stored in a container
Parameters: - container (string) – name of container that stores object
- object (string) – name of object to save
- file (string) – local name of object
-
object_set
(container, object, properties)¶ Set object properties
Parameters: - container (string) – container name for object to modify
- object (string) – name of object to modify
- properties (dict) – properties to add or update for the container
-
object_show
(container=None, object=None)¶ Get object details
Parameters: - container (string) – container name for object to get
- object (string) – name of object to get
Returns: dict of object properties
-
object_unset
(container, object, properties)¶ Unset object properties
Parameters: - container (string) – container name for object to modify
- object (string) – name of object to modify
- properties (dict) – properties to remove from the object
-
openstackclient.api.utils module¶
API Utilities Library
-
openstackclient.api.utils.
simple_filter
(data=None, attr=None, value=None, property_field=None)¶ Filter a list of dicts
Parameters: - data (list) – The list to be filtered. The list is modified in-place and will be changed if any filtering occurs.
- attr (string) – The name of the attribute to filter. If attr does not exist no match will succeed and no rows will be returned. If attr is None no filtering will be performed and all rows will be returned.
- value (sring) – The value to filter. None is considered to be a ‘no filter’ value. ‘’ matches against a Python empty string.
- property_field (string) – The name of the data field containing a property dict to filter. If property_field is None, attr is a field name. If property_field is not None, attr is a property key name inside the named property field.
Returns: Returns the filtered list
Rtype list: This simple filter (one attribute, one exact-match value) searches a list of dicts to select items. It first searches the item dict for a matching
attr
then does an exact-match on thevalue
. Ifproperty_field
is given, it will look inside that field (if it exists and is a dict) for a matchingvalue
.