Base API Library
Bases: KeystoneSession
Base API
Create a new resource
url (string) – The API-specific portion of the URL path
session (Session) – HTTP client session
method (string) – HTTP method (default POST)
Delete a resource
url (string) – The API-specific portion of the URL path
session (Session) – HTTP client session
Find a single resource by name or ID
path (string) – The API-specific portion of the URL path
value (string) – search expression
attr (string) – name of attribute for secondary search
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.
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
n = find(netclient, ‘network’, ‘networks’, ‘matrix’)
Bulk load and filter locally
path (string) – The API-specific portion of the URL path
kwargs – A dict of AVPs to match - logical AND
list of resource dicts
Find a resource by name or ID
path (string) – The API-specific portion of the URL path
resource dict
Return a list of resources
GET ${ENDPOINT}/${PATH}?${PARAMS}
path is often the object’s plural resource type
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
JSON-decoded response, could be a list or a dict-wrapped-list
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.
Compute v2 API Library
Bases: BaseAPI
Compute v2 API
Find a single resource by name or ID
path (string) – The API-specific portion of the URL path
value (string) – search expression (required, really)
attr (string) – name of attribute for secondary search
Add a floating IP to a server
server – The Server
(or its ID) to add an IP to.
address – The FloatingIP or string floating address to add.
fixed_address – The FixedIP the floatingIP should be associated with (optional)
Create a new floating ip
https://docs.openstack.org/api-ref/compute/#create-allocate-floating-ip-address
pool – Name of floating IP pool
Delete a floating IP
https://docs.openstack.org/api-ref/compute/#delete-deallocate-floating-ip-address
floating_ip_id (string) – Floating IP ID
Return a security group given name or ID
https://docs.openstack.org/api-ref/compute/#list-floating-ip-addresses
floating_ip (string) – Floating IP address
A dict of the floating IP attributes
Get floating IPs
https://docs.openstack.org/api-ref/compute/#show-floating-ip-address-details
list of floating IPs
Get floating IP pools
https://docs.openstack.org/api-ref/compute/?expanded=#list-floating-ip-pools
list of floating IP pools
Remove a floating IP from a server
server – The Server
(or its ID) to add an IP to.
address – The FloatingIP or string floating address to add.
Lists hypervisor Hosts
https://docs.openstack.org/api-ref/compute/#list-hosts Valid for Compute 2.0 - 2.42
zone (string) – Availability zone
A dict of the floating IP attributes
Modify host properties
https://docs.openstack.org/api-ref/compute/#update-host-status Valid for Compute 2.0 - 2.42
status maintenance_mode
Show host
https://docs.openstack.org/api-ref/compute/#show-host-details Valid for Compute 2.0 - 2.42
Create a new network
https://docs.openstack.org/api-ref/compute/#create-network
name (string) – Network label (required)
subnet (integer) – Subnet for IPv4 fixed addresses in CIDR notation (required)
share_subnet (integer) – Shared subnet between projects, True or False
A dict of the network attributes
Delete a network
https://docs.openstack.org/api-ref/compute/#delete-network
network (string) – Network name or ID
Return a network given name or ID
https://docs.openstack.org/api-ref/compute/#show-network-details
network (string) – Network name or ID
A dict of the network attributes
Get networks
https://docs.openstack.org/api-ref/compute/#list-networks
list of networks
Create a new security group
https://docs.openstack.org/api-ref/compute/#create-security-group
name (string) – Security group name
description (integer) – Security group description
Delete a security group
https://docs.openstack.org/api-ref/compute/#delete-security-group
security_group (string) – Security group name or ID
Return a security group given name or ID
https://docs.openstack.org/api-ref/compute/#show-security-group-details
security_group (string) – Security group name or ID
A dict of the security group attributes
Get security groups
https://docs.openstack.org/api-ref/compute/#list-security-groups
limit (integer) – query return count limit
marker (string) – query marker
search_opts – (undocumented) Search filter dict all_tenants: True|False - return all projects
list of security groups names
Create a new security group rule
https://docs.openstack.org/api-ref/compute/#create-security-group-rule
security_group_id (string) – Security group ID
ip_protocol – IP protocol, ‘tcp’, ‘udp’ or ‘icmp’
from_port – Source port
to_port – Destination port
remote_ip – Source IP address in CIDR notation
remote_group – Remote security group
Delete a security group rule
https://docs.openstack.org/api-ref/compute/#delete-security-group-rule
security_group_rule_id (string) – Security group rule ID
Update a security group
https://docs.openstack.org/api-ref/compute/#update-security-group
security_group (string) – Security group name or ID
TODO(dtroyer): Create an update method in osc-lib
Image v1 API Library
Bases: BaseAPI
Image v1 API
Get available images
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
Image v2 API Library
Bases: APIv1
Image v2 API
Get available images
can add limit/marker
detailed – For v1 compatibility only, ignored as v2 is always ‘detailed’
public – Return public images if True
private – Return private images if True
community – Return commuity images if True
shared – Return shared images if True
If public, private, community 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, community 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
Object Store v1 API Library
Bases: BaseAPI
Object Store v1 API
Set account properties
properties (dict) – properties to add or update for the account
Show account details
Unset account properties
properties (dict) – properties to remove from the account
Create a container
container (string) – name of container to create
public (bool) – Boolean value indicating if the container should be publicly readable. Defaults to False.
storage_policy (string) – Name of the a specific storage policy to use. If not specified swift will use its default storage policy.
dict of returned headers
Delete a container
container (string) – name of container to delete
Get containers in an account
full_listing (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
list of container names
Save all the content from a container
container (string) – name of container to save
Set container properties
container (string) – name of container to modify
properties (dict) – properties to add or update for the container
Get container details
container (string) – name of container to show
dict of returned headers
Unset container properties
container (string) – name of container to modify
properties (dict) – properties to remove from the container
Create an object inside a container
container (string) – name of container to store object
object (string) – local path to object
name (string) – name of object to create
dict of returned headers
Delete an object from a container
container (string) – name of container that stores object
object (string) – name of object to delete
List objects in a container
container (string) – container name to get a listing for
full_listing (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
a tuple of (response headers, a list of objects) The response headers will be a dict and all header names will be lowercase.
Save an object stored in a container
container (string) – name of container that stores object
object (string) – name of object to save
file (string) – local name of object
Set object properties
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
Get object details
container (string) – container name for object to get
object (string) – name of object to get
dict of object properties
Unset object properties
container (string) – container name for object to modify
object (string) – name of object to modify
properties (dict) – properties to remove from the object
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.