To use openstack.cloud in a project:
import openstack.cloud
Note
API methods that return a description of an OpenStack resource (e.g.,
server instance, image, volume, etc.) do so using a munch.Munch object
from the Munch library. Munch
objects can be accessed using either dictionary or object notation
(e.g., server.id
, image.name
and server['id']
, image['name']
)
openstack.cloud.
OpenStackCloud
¶Represent a connection to an OpenStack Cloud.
OpenStackCloud is the entry point for all cloud operations, regardless of which OpenStack service those operations may ultimately come from. The operations on an OpenStackCloud are resource oriented rather than REST API operation oriented. For instance, one will request a Floating IP and that Floating IP will be actualized either via neutron or via nova depending on how this particular cloud has decided to arrange itself.
Parameters: | strict (bool) – Only return documented attributes for each resource as per the Data Model contract. (Default False) |
---|
connect_as
(**kwargs)¶Make a new OpenStackCloud object with new auth context.
Take the existing settings from the current cloud and construct a new OpenStackCloud object with some of the auth settings overridden. This is useful for getting an object to perform tasks with as another user, or in the context of a different project.
conn = openstack.connect(cloud='example')
# Work normally
servers = conn.list_servers()
conn2 = conn.connect_as(username='different-user', password='')
# Work as different-user
servers = conn2.list_servers()
Parameters: | kwargs – keyword arguments can contain anything that would normally go in an auth dict. They will override the same settings from the parent cloud as appropriate. Entries that do not want to be overridden can be ommitted. |
---|
connect_as_project
(project)¶Make a new OpenStackCloud object with a new project.
Take the existing settings from the current cloud and construct a new OpenStackCloud object with the project settings overridden. This is useful for getting an object to perform tasks with as another user, or in the context of a different project.
cloud = openstack.connect(cloud='example')
# Work normally
servers = cloud.list_servers()
cloud2 = cloud.connect_as_project('different-project')
# Work in different-project
servers = cloud2.list_servers()
Parameters: | project – Either a project name or a project dict as returned by list_projects. |
---|
pprint
(resource)¶Wrapper aroud pprint that groks munch objects
pformat
(resource)¶Wrapper aroud pformat that groks munch objects
current_user_id
¶Get the id of the currently logged-in user from the token.
current_project_id
¶Get the current project ID.
Returns the project_id of the current token scope. None means that the token is domain scoped or unscoped.
Raises: |
|
---|
current_project
¶Return a munch.Munch
describing the current project
current_location
¶Return a munch.Munch
explaining the current cloud location.
range_search
(data, filters)¶Perform integer range searches across a list of dictionaries.
Given a list of dictionaries, search across the list using the given dictionary keys and a range of integer values for each key. Only dictionaries that match ALL search filters across the entire original data set will be returned.
It is not a requirement that each dictionary contain the key used for searching. Those without the key will be considered non-matching.
The range values must be string values and is either a set of digits representing an integer for matching, or a range operator followed by a set of digits representing an integer for matching. If a range operator is not given, exact value matching will be used. Valid operators are one of: <,>,<=,>=
Parameters: |
|
---|---|
Returns: | A list subset of the original data set. |
Raises: | OpenStackCloudException on invalid range expressions. |
search_projects
(name_or_id=None, filters=None, domain_id=None)¶Backwards compatibility method for search_projects
search_projects originally had a parameter list that was name_or_id, filters and list had domain_id first. This method exists in this form to allow code written with positional parameter to still work. But really, use keyword arguments.
get_project
(name_or_id, filters=None, domain_id=None)¶Get exactly one project.
Parameters: |
|
---|---|
Returns: | a list of |
Raises: |
|
create_project
(name, description=None, domain_id=None, enabled=True)¶Create a project.
delete_project
(name_or_id, domain_id=None)¶Delete a project.
Parameters: |
|
---|---|
Returns: | True if delete succeeded, False if the project was not found. |
Raises: |
|
search_users
(name_or_id=None, filters=None, **kwargs)¶Search users.
Parameters: |
|
---|---|
Returns: | a list of |
Raises: |
|
get_user
(name_or_id, filters=None, **kwargs)¶Get exactly one user.
Parameters: |
|
---|---|
Returns: | a single |
Raises: |
|
get_user_by_id
(user_id, normalize=True)¶Get a user by ID.
Parameters: |
|
---|---|
Returns: | a single |
create_user
(name, password=None, email=None, default_project=None, enabled=True, domain_id=None, description=None)¶Create a user.
add_user_to_group
(name_or_id, group_name_or_id)¶Add a user to a group.
Parameters: |
|
---|---|
Raises: |
|
is_user_in_group
(name_or_id, group_name_or_id)¶Check to see if a user is in a group.
Parameters: |
|
---|---|
Returns: | True if user is in the group, False otherwise |
Raises: |
|
remove_user_from_group
(name_or_id, group_name_or_id)¶Remove a user from a group.
Parameters: |
|
---|---|
Raises: |
|
create_stack
(name, tags=None, template_file=None, template_url=None, template_object=None, files=None, rollback=True, wait=False, timeout=3600, environment_files=None, **parameters)¶Create a stack.
Parameters: |
|
---|
Other arguments will be passed as stack parameters which will take precedence over any parameters specified in the environments.
Only one of template_file, template_url, template_object should be specified.
Returns: | a dict containing the stack description |
---|---|
Raises: | OpenStackCloudException if something goes wrong during
the OpenStack API call |
update_stack
(name_or_id, template_file=None, template_url=None, template_object=None, files=None, rollback=True, wait=False, timeout=3600, environment_files=None, **parameters)¶Update a stack.
Parameters: |
|
---|
Other arguments will be passed as stack parameters which will take precedence over any parameters specified in the environments.
Only one of template_file, template_url, template_object should be specified.
Returns: | a dict containing the stack description |
---|---|
Raises: | OpenStackCloudException if something goes wrong during
the OpenStack API calls |
delete_stack
(name_or_id, wait=False)¶Delete a stack
Parameters: |
|
---|---|
Returns: | True if delete succeeded, False if the stack was not found. |
Raises: |
|
get_flavor_by_ram
(ram, include=None, get_extra=True)¶Get a flavor based on amount of RAM available.
Finds the flavor with the least amount of RAM that is at least as much as the specified amount. If include is given, further filter based on matching flavor name.
Parameters: |
|
---|
search_networks
(name_or_id=None, filters=None)¶Search networks
Parameters: |
|
---|---|
Returns: | a list of |
Raises: |
|
search_routers
(name_or_id=None, filters=None)¶Search routers
Parameters: |
|
---|---|
Returns: | a list of |
Raises: |
|
search_subnets
(name_or_id=None, filters=None)¶Search subnets
Parameters: |
|
---|---|
Returns: | a list of |
Raises: |
|
search_ports
(name_or_id=None, filters=None)¶Search ports
Parameters: |
|
---|---|
Returns: | a list of |
Raises: |
|
search_qos_policies
(name_or_id=None, filters=None)¶Search QoS policies
Parameters: |
|
---|---|
Returns: | a list of |
Raises: |
|
search_server_groups
(name_or_id=None, filters=None)¶Seach server groups.
Parameters: |
|
---|---|
Returns: | a list of dicts containing the server groups |
Raises: |
|
search_stacks
(name_or_id=None, filters=None)¶Search stacks.
Parameters: |
|
---|---|
Returns: | a list of |
Raises: |
|
list_keypairs
()¶List all available keypairs.
Returns: | A list of munch.Munch containing keypair info. |
---|
list_networks
(filters=None)¶List all available networks.
Parameters: | filters – (optional) dict of filter conditions to push down |
---|---|
Returns: | A list of munch.Munch containing network info. |
list_routers
(filters=None)¶List all available routers.
Parameters: | filters – (optional) dict of filter conditions to push down |
---|---|
Returns: | A list of router munch.Munch . |
list_subnets
(filters=None)¶List all available subnets.
Parameters: | filters – (optional) dict of filter conditions to push down |
---|---|
Returns: | A list of subnet munch.Munch . |
list_ports
(filters=None)¶List all available ports.
Parameters: | filters – (optional) dict of filter conditions to push down |
---|---|
Returns: | A list of port munch.Munch . |
list_qos_rule_types
(filters=None)¶List all available QoS rule types.
Parameters: | filters – (optional) dict of filter conditions to push down |
---|---|
Returns: | A list of rule types munch.Munch . |
get_qos_rule_type_details
(rule_type, filters=None)¶Get a QoS rule type details by rule type name.
Parameters: | rule_type (string) – Name of the QoS rule type. |
---|---|
Returns: | A rule type details munch.Munch or None if
no matching rule type is found. |
list_qos_policies
(filters=None)¶List all available QoS policies.
Parameters: | filters – (optional) dict of filter conditions to push down |
---|---|
Returns: | A list of policies munch.Munch . |
list_server_security_groups
(server)¶List all security groups associated with the given server.
Returns: | A list of security group munch.Munch . |
---|
add_server_security_groups
(server, security_groups)¶Add security groups to a server.
Add existing security groups to an existing server. If the security groups are already present on the server this will continue unaffected.
Returns: | False if server or security groups are undefined, True otherwise. |
---|---|
Raises: | OpenStackCloudException , on operation error. |
remove_server_security_groups
(server, security_groups)¶Remove security groups from a server
Remove existing security groups from an existing server. If the security groups are not present on the server this will continue unaffected.
Returns: | False if server or security groups are undefined, True otherwise. |
---|---|
Raises: | OpenStackCloudException , on operation error. |
list_security_groups
(filters=None)¶List all available security groups.
Parameters: | filters – (optional) dict of filter conditions to push down |
---|---|
Returns: | A list of security group munch.Munch . |
list_servers
(detailed=False, all_projects=False, bare=False, filters=None)¶List all available servers.
Parameters: |
|
---|---|
Returns: | A list of server |
list_server_groups
()¶List all available server groups.
Returns: | A list of server group dicts. |
---|
get_compute_limits
(name_or_id=None)¶Get compute limits for a project
Parameters: | name_or_id – (optional) project name or ID to get limits for if different from the current project |
---|---|
Raises: | OpenStackCloudException if it’s not a valid project |
Returns: | Munch object with the limits |
list_floating_ip_pools
()¶List all available floating IP pools.
NOTE: This function supports the nova-net view of the world. nova-net has been deprecated, so it’s highly recommended to switch to using neutron. get_external_ipv4_floating_networks is what you should almost certainly be using.
Returns: | A list of floating IP pool munch.Munch . |
---|
list_floating_ips
(filters=None)¶List all available floating IPs.
Parameters: | filters – (optional) dict of filter conditions to push down |
---|---|
Returns: | A list of floating IP munch.Munch . |
get_nat_destination
()¶Return the network that is configured to be the NAT destination.
Returns: | A network dict if one is found |
---|
get_default_network
()¶Return the network that is configured to be the default interface.
Returns: | A network dict if one is found |
---|
get_external_networks
()¶Return the networks that are configured to route northbound.
This should be avoided in favor of the specific ipv4/ipv6 method, but is here for backwards compatibility.
Returns: | A list of network munch.Munch if one is found |
---|
get_internal_networks
()¶Return the networks that are configured to not route northbound.
This should be avoided in favor of the specific ipv4/ipv6 method, but is here for backwards compatibility.
Returns: | A list of network munch.Munch if one is found |
---|
get_external_ipv4_networks
()¶Return the networks that are configured to route northbound.
Returns: | A list of network munch.Munch if one is found |
---|
get_external_ipv4_floating_networks
()¶Return the networks that are configured to route northbound.
Returns: | A list of network munch.Munch if one is found |
---|
get_internal_ipv4_networks
()¶Return the networks that are configured to not route northbound.
Returns: | A list of network munch.Munch if one is found |
---|
get_external_ipv6_networks
()¶Return the networks that are configured to route northbound.
Returns: | A list of network munch.Munch if one is found |
---|
get_internal_ipv6_networks
()¶Return the networks that are configured to not route northbound.
Returns: | A list of network munch.Munch if one is found |
---|
get_keypair
(name_or_id, filters=None)¶Get a keypair by name or ID.
Parameters: |
|
---|---|
Returns: | A keypair |
get_network
(name_or_id, filters=None)¶Get a network by name or ID.
Parameters: |
|
---|---|
Returns: | A network |
get_network_by_id
(id)¶Get a network by ID
Parameters: | id – ID of the network. |
---|---|
Returns: | A network munch.Munch . |
get_router
(name_or_id, filters=None)¶Get a router by name or ID.
Parameters: |
|
---|---|
Returns: | A router |
get_subnet
(name_or_id, filters=None)¶Get a subnet by name or ID.
Parameters: |
|
---|---|
Returns: | A subnet |
get_subnet_by_id
(id)¶Get a subnet by ID
Parameters: | id – ID of the subnet. |
---|---|
Returns: | A subnet munch.Munch . |
get_port
(name_or_id, filters=None)¶Get a port by name or ID.
Parameters: |
|
---|---|
Returns: | A port |
get_port_by_id
(id)¶Get a port by ID
Parameters: | id – ID of the port. |
---|---|
Returns: | A port munch.Munch . |
get_qos_policy
(name_or_id, filters=None)¶Get a QoS policy by name or ID.
Parameters: |
|
---|---|
Returns: | A policy |
get_volume
(name_or_id, filters=None)¶Get a volume by name or ID.
Parameters: |
|
---|---|
Returns: | A volume |
get_volume_by_id
(id)¶Get a volume by ID
Parameters: | id – ID of the volume. |
---|---|
Returns: | A volume munch.Munch . |
get_volume_type
(name_or_id, filters=None)¶Get a volume type by name or ID.
Parameters: |
|
---|---|
Returns: | A volume |
get_flavor
(name_or_id, filters=None, get_extra=True)¶Get a flavor by name or ID.
Parameters: |
|
---|---|
Returns: | A flavor |
get_flavor_by_id
(id, get_extra=False)¶Get a flavor by ID
Parameters: |
|
---|---|
Returns: | A flavor |
get_security_group
(name_or_id, filters=None)¶Get a security group by name or ID.
Parameters: |
|
---|---|
Returns: | A security group |
get_security_group_by_id
(id)¶Get a security group by ID
Parameters: | id – ID of the security group. |
---|---|
Returns: | A security group munch.Munch . |
get_server_console
(server, length=None)¶Get the console log for a server.
Parameters: |
|
---|---|
Returns: | A string containing the text of the console log or an empty string if the cloud does not support console logs. |
Raises: | OpenStackCloudException if an invalid server argument is given or if something else unforseen happens |
get_server
(name_or_id=None, filters=None, detailed=False, bare=False, all_projects=False)¶Get a server by name or ID.
Parameters: |
|
---|---|
Returns: | A server |
get_server_group
(name_or_id=None, filters=None)¶Get a server group by name or ID.
Parameters: |
|
---|---|
Returns: | A server groups dict or None if no matching server group is found. |
get_image
(name_or_id, filters=None)¶Get an image by name or ID.
Parameters: |
|
---|---|
Returns: | An image |
get_image_by_id
(id)¶Get a image by ID
Parameters: | id – ID of the image. |
---|---|
Returns: | An image munch.Munch . |
download_image
(name_or_id, output_path=None, output_file=None, chunk_size=1024)¶Download an image by name or ID
Parameters: |
|
---|---|
Raises: | OpenStackCloudException in the event download_image is called without exactly one of either output_path or output_file |
Raises: | OpenStackCloudResourceNotFound if no images are found matching the name or ID provided |
get_floating_ip
(id, filters=None)¶Get a floating IP by ID
Parameters: |
|
---|---|
Returns: | A floating IP |
get_floating_ip_by_id
(id)¶Get a floating ip by ID
Parameters: | id – ID of the floating ip. |
---|---|
Returns: | A floating ip munch.Munch . |
get_stack
(name_or_id, filters=None, resolve_outputs=True)¶Get exactly one stack.
Parameters: |
|
---|---|
Returns: | a |
Raises: |
|
create_keypair
(name, public_key=None)¶Create a new keypair.
Parameters: |
|
---|---|
Raises: | OpenStackCloudException on operation error. |
delete_keypair
(name)¶Delete a keypair.
Parameters: | name – Name of the keypair to delete. |
---|---|
Returns: | True if delete succeeded, False otherwise. |
Raises: | OpenStackCloudException on operation error. |
create_network
(name, shared=False, admin_state_up=True, external=False, provider=None, project_id=None, availability_zone_hints=None)¶Create a network.
Parameters: |
|
---|---|
Returns: | The network object. |
Raises: | OpenStackCloudException on operation error. |
delete_network
(name_or_id)¶Delete a network.
Parameters: | name_or_id – Name or ID of the network being deleted. |
---|---|
Returns: | True if delete succeeded, False otherwise. |
Raises: | OpenStackCloudException on operation error. |
create_qos_policy
(**kwargs)¶Create a QoS policy.
Parameters: |
|
---|---|
Returns: | The QoS policy object. |
Raises: | OpenStackCloudException on operation error. |
update_qos_policy
(name_or_id, **kwargs)¶Update an existing QoS policy.
Parameters: |
|
---|---|
Returns: | The updated QoS policy object. |
Raises: | OpenStackCloudException on operation error. |
delete_qos_policy
(name_or_id)¶Delete a QoS policy.
Parameters: | name_or_id – Name or ID of the policy being deleted. |
---|---|
Returns: | True if delete succeeded, False otherwise. |
Raises: | OpenStackCloudException on operation error. |
search_qos_bandwidth_limit_rules
(policy_name_or_id, rule_id=None, filters=None)¶Search QoS bandwidth limit rules
Parameters: |
|
---|---|
Returns: | a list of |
Raises: |
|
list_qos_bandwidth_limit_rules
(policy_name_or_id, filters=None)¶List all available QoS bandwith limit rules.
Parameters: |
|
---|---|
Returns: | A list of |
Raises: |
|
get_qos_bandwidth_limit_rule
(policy_name_or_id, rule_id)¶Get a QoS bandwidth limit rule by name or ID.
Parameters: |
|
---|---|
Returns: | A bandwidth limit rule |
create_qos_bandwidth_limit_rule
(policy_name_or_id, max_kbps, **kwargs)¶Create a QoS bandwidth limit rule.
Parameters: |
|
---|---|
Returns: | The QoS bandwidth limit rule. |
Raises: | OpenStackCloudException on operation error. |
update_qos_bandwidth_limit_rule
(policy_name_or_id, rule_id, **kwargs)¶Update a QoS bandwidth limit rule.
Parameters: |
|
---|---|
Returns: | The updated QoS bandwidth limit rule. |
Raises: | OpenStackCloudException on operation error. |
delete_qos_bandwidth_limit_rule
(policy_name_or_id, rule_id)¶Delete a QoS bandwidth limit rule.
Parameters: |
|
---|---|
Raises: | OpenStackCloudException on operation error. |
search_qos_dscp_marking_rules
(policy_name_or_id, rule_id=None, filters=None)¶Search QoS DSCP marking rules
Parameters: |
|
---|---|
Returns: | a list of |
Raises: |
|
list_qos_dscp_marking_rules
(policy_name_or_id, filters=None)¶List all available QoS DSCP marking rules.
Parameters: |
|
---|---|
Returns: | A list of |
Raises: |
|
get_qos_dscp_marking_rule
(policy_name_or_id, rule_id)¶Get a QoS DSCP marking rule by name or ID.
Parameters: |
|
---|---|
Returns: | A bandwidth limit rule |
create_qos_dscp_marking_rule
(policy_name_or_id, dscp_mark)¶Create a QoS DSCP marking rule.
Parameters: |
|
---|---|
Returns: | The QoS DSCP marking rule. |
Raises: | OpenStackCloudException on operation error. |
update_qos_dscp_marking_rule
(policy_name_or_id, rule_id, **kwargs)¶Update a QoS DSCP marking rule.
Parameters: |
|
---|---|
Returns: | The updated QoS bandwidth limit rule. |
Raises: | OpenStackCloudException on operation error. |
delete_qos_dscp_marking_rule
(policy_name_or_id, rule_id)¶Delete a QoS DSCP marking rule.
Parameters: |
|
---|---|
Raises: | OpenStackCloudException on operation error. |
search_qos_minimum_bandwidth_rules
(policy_name_or_id, rule_id=None, filters=None)¶Search QoS minimum bandwidth rules
Parameters: |
|
---|---|
Returns: | a list of |
Raises: |
|
list_qos_minimum_bandwidth_rules
(policy_name_or_id, filters=None)¶List all available QoS minimum bandwith rules.
Parameters: |
|
---|---|
Returns: | A list of |
Raises: |
|
get_qos_minimum_bandwidth_rule
(policy_name_or_id, rule_id)¶Get a QoS minimum bandwidth rule by name or ID.
Parameters: |
|
---|---|
Returns: | A bandwidth limit rule |
create_qos_minimum_bandwidth_rule
(policy_name_or_id, min_kbps, **kwargs)¶Create a QoS minimum bandwidth limit rule.
Parameters: |
|
---|---|
Returns: | The QoS minimum bandwidth rule. |
Raises: | OpenStackCloudException on operation error. |
update_qos_minimum_bandwidth_rule
(policy_name_or_id, rule_id, **kwargs)¶Update a QoS minimum bandwidth rule.
Parameters: |
|
---|---|
Returns: | The updated QoS minimum bandwidth rule. |
Raises: | OpenStackCloudException on operation error. |
delete_qos_minimum_bandwidth_rule
(policy_name_or_id, rule_id)¶Delete a QoS minimum bandwidth rule.
Parameters: |
|
---|---|
Raises: | OpenStackCloudException on operation error. |
add_router_interface
(router, subnet_id=None, port_id=None)¶Attach a subnet to an internal router interface.
Either a subnet ID or port ID must be specified for the internal interface. Supplying both will result in an error.
Parameters: |
|
---|---|
Returns: | A |
Raises: | OpenStackCloudException on operation error. |
remove_router_interface
(router, subnet_id=None, port_id=None)¶Detach a subnet from an internal router interface.
At least one of subnet_id or port_id must be supplied.
If you specify both subnet and port ID, the subnet ID must correspond to the subnet ID of the first IP address on the port specified by the port ID. Otherwise an error occurs.
Parameters: |
|
---|---|
Returns: | None on success |
Raises: | OpenStackCloudException on operation error. |
list_router_interfaces
(router, interface_type=None)¶List all interfaces for a router.
Parameters: |
|
---|---|
Returns: | A list of port |
create_router
(name=None, admin_state_up=True, ext_gateway_net_id=None, enable_snat=None, ext_fixed_ips=None, project_id=None, availability_zone_hints=None)¶Create a logical router.
Parameters: |
|
---|---|
Returns: | The router object. |
Raises: | OpenStackCloudException on operation error. |
update_router
(name_or_id, name=None, admin_state_up=None, ext_gateway_net_id=None, enable_snat=None, ext_fixed_ips=None)¶Update an existing logical router.
Parameters: |
|
---|---|
Returns: | The router object. |
Raises: | OpenStackCloudException on operation error. |
delete_router
(name_or_id)¶Delete a logical router.
If a name, instead of a unique UUID, is supplied, it is possible that we could find more than one matching router since names are not required to be unique. An error will be raised in this case.
Parameters: | name_or_id – Name or ID of the router being deleted. |
---|---|
Returns: | True if delete succeeded, False otherwise. |
Raises: | OpenStackCloudException on operation error. |
create_image_snapshot
(name, server, wait=False, timeout=3600, **metadata)¶Create an image by snapshotting an existing server.
Parameters: |
|
---|---|
Returns: | A |
Raises: | OpenStackCloudException if there are problems uploading |
delete_image
(name_or_id, wait=False, timeout=3600, delete_objects=True)¶Delete an existing image.
Parameters: |
|
---|---|
Returns: | True if delete succeeded, False otherwise. |
Raises: | OpenStackCloudException if there are problems deleting. |
create_image
(name, filename=None, container='images', md5=None, sha256=None, disk_format=None, container_format=None, disable_vendor_agent=True, wait=False, timeout=3600, allow_duplicates=False, meta=None, volume=None, **kwargs)¶Upload an image.
Parameters: |
|
---|
Additional kwargs will be passed to the image creation as additional metadata for the image and will have all values converted to string except for min_disk, min_ram, size and virtual_size which will be converted to int.
If you are sure you have all of your data types correct or have an advanced need to be explicit, use meta. If you are just a normal consumer, using kwargs is likely the right choice.
If a value is in meta and kwargs, meta wins.
Returns: | A munch.Munch of the Image object |
---|---|
Raises: | OpenStackCloudException if there are problems uploading |
create_volume
(size, wait=True, timeout=None, image=None, bootable=None, **kwargs)¶Create a volume.
Parameters: |
|
---|---|
Returns: | The created volume object. |
Raises: | OpenStackCloudTimeout if wait time exceeded. |
Raises: | OpenStackCloudException on operation error. |
set_volume_bootable
(name_or_id, bootable=True)¶Set a volume’s bootable flag.
Parameters: |
|
---|---|
Raises: | OpenStackCloudTimeout if wait time exceeded. |
Raises: | OpenStackCloudException on operation error. |
delete_volume
(name_or_id=None, wait=True, timeout=None, force=False)¶Delete a volume.
Parameters: |
|
---|---|
Raises: | OpenStackCloudTimeout if wait time exceeded. |
Raises: | OpenStackCloudException on operation error. |
get_volume_limits
(name_or_id=None)¶Get volume limits for a project
Parameters: | name_or_id – (optional) project name or ID to get limits for if different from the current project |
---|---|
Raises: | OpenStackCloudException if it’s not a valid project |
Returns: | Munch object with the limits |
get_volume_attach_device
(volume, server_id)¶Return the device name a volume is attached to for a server.
This can also be used to verify if a volume is attached to a particular server.
Parameters: |
|
---|---|
Returns: | Device name if attached, None if volume is not attached. |
detach_volume
(server, volume, wait=True, timeout=None)¶Detach a volume from a server.
Parameters: |
|
---|---|
Raises: | OpenStackCloudTimeout if wait time exceeded. |
Raises: | OpenStackCloudException on operation error. |
attach_volume
(server, volume, device=None, wait=True, timeout=None)¶Attach a volume to a server.
This will attach a volume, described by the passed in volume dict (as returned by get_volume()), to the server described by the passed in server dict (as returned by get_server()) on the named device on the server.
If the volume is already attached to the server, or generally not available, then an exception is raised. To re-attach to a server, but under a different device, the user must detach it first.
Parameters: |
|
---|---|
Returns: | a volume attachment object. |
Raises: | OpenStackCloudTimeout if wait time exceeded. |
Raises: | OpenStackCloudException on operation error. |
create_volume_snapshot
(volume_id, force=False, wait=True, timeout=None, **kwargs)¶Create a volume.
Parameters: |
|
---|---|
Returns: | The created volume object. |
Raises: | OpenStackCloudTimeout if wait time exceeded. |
Raises: | OpenStackCloudException on operation error. |
get_volume_snapshot_by_id
(snapshot_id)¶Takes a snapshot_id and gets a dict of the snapshot that maches that ID.
Note: This is more efficient than get_volume_snapshot.
param: snapshot_id: ID of the volume snapshot.
get_volume_snapshot
(name_or_id, filters=None)¶Get a volume by name or ID.
Parameters: |
|
---|---|
Returns: | A volume |
create_volume_backup
(volume_id, name=None, description=None, force=False, wait=True, timeout=None)¶Create a volume backup.
Parameters: |
|
---|---|
Returns: | The created volume backup object. |
Raises: | OpenStackCloudTimeout if wait time exceeded. |
Raises: | OpenStackCloudException on operation error. |
get_volume_backup
(name_or_id, filters=None)¶Get a volume backup by name or ID.
Returns: | A backup munch.Munch or None if no matching backup is
found. |
---|
list_volume_snapshots
(detailed=True, search_opts=None)¶List all volume snapshots.
Returns: | A list of volume snapshots munch.Munch . |
---|
list_volume_backups
(detailed=True, search_opts=None)¶List all volume backups.
Parameters: |
|
---|---|
Returns: | A list of volume backups |
delete_volume_backup
(name_or_id=None, force=False, wait=False, timeout=None)¶Delete a volume backup.
Parameters: |
|
---|---|
Raises: | OpenStackCloudTimeout if wait time exceeded. |
Raises: | OpenStackCloudException on operation error. |
delete_volume_snapshot
(name_or_id=None, wait=False, timeout=None)¶Delete a volume snapshot.
Parameters: |
|
---|---|
Raises: | OpenStackCloudTimeout if wait time exceeded. |
Raises: | OpenStackCloudException on operation error. |
available_floating_ip
(network=None, server=None)¶Get a floating IP from a network or a pool.
Return the first available floating IP or allocate a new one.
Parameters: |
|
---|---|
Returns: | a (normalized) structure with a floating IP address description. |
create_floating_ip
(network=None, server=None, fixed_address=None, nat_destination=None, port=None, wait=False, timeout=60)¶Allocate a new floating IP from a network or a pool.
Parameters: |
|
---|---|
Returns: | a floating IP address |
Raises: |
|
delete_floating_ip
(floating_ip_id, retry=1)¶Deallocate a floating IP from a project.
Parameters: |
|
---|---|
Returns: | True if the IP address has been deleted, False if the IP address was not found. |
Raises: |
|
delete_unattached_floating_ips
(retry=1)¶Safely delete unattached floating ips.
If the cloud can safely purge any unattached floating ips without race conditions, do so.
Safely here means a specific thing. It means that you are not running this while another process that might do a two step create/attach is running. You can safely run this method while another process is creating servers and attaching floating IPs to them if either that process is using add_auto_ip from shade, or is creating the floating IPs by passing in a server to the create_floating_ip call.
Parameters: | retry – number of times to retry. Optional, defaults to 1, which is in addition to the initial delete call. A value of 0 will also cause no checking of results to occur. |
---|---|
Returns: | True if Floating IPs have been deleted, False if not |
Raises: | OpenStackCloudException , on operation error. |
detach_ip_from_server
(server_id, floating_ip_id)¶Detach a floating IP from a server.
Parameters: |
|
---|---|
Returns: | True if the IP has been detached, or False if the IP wasn’t attached to any server. |
Raises: |
|
add_ip_list
(server, ips, wait=False, timeout=60, fixed_address=None)¶Attach a list of IPs to a server.
Parameters: |
|
---|---|
Returns: | The updated server |
Raises: |
|
add_auto_ip
(server, wait=False, timeout=60, reuse=True)¶Add a floating IP to a server.
This method is intended for basic usage. For advanced network architecture (e.g. multiple external networks or servers with multiple interfaces), use other floating IP methods.
This method can reuse available IPs, or allocate new IPs to the current project.
Parameters: |
|
---|---|
Returns: | Floating IP address attached to server. |
create_server
(name, image=None, flavor=None, auto_ip=True, ips=None, ip_pool=None, root_volume=None, terminate_volume=False, wait=False, timeout=180, reuse_ips=True, network=None, boot_from_volume=False, volume_size='50', boot_volume=None, volumes=None, nat_destination=None, group=None, **kwargs)¶Create a virtual server instance.
Parameters: |
|
---|---|
Returns: | A |
Raises: | OpenStackCloudException on operation error. |
wait_for_server
(server, auto_ip=True, ips=None, ip_pool=None, reuse=True, timeout=180, nat_destination=None)¶Wait for a server to reach ACTIVE status.
set_server_metadata
(name_or_id, metadata)¶Set metadata in a server instance.
Parameters: |
|
---|---|
Raises: | OpenStackCloudException on operation error. |
delete_server_metadata
(name_or_id, metadata_keys)¶Delete metadata from a server instance.
Parameters: |
|
---|---|
Raises: | OpenStackCloudException on operation error. |
delete_server
(name_or_id, wait=False, timeout=180, delete_ips=False, delete_ip_retry=1)¶Delete a server instance.
Parameters: |
|
---|---|
Returns: | True if delete succeeded, False otherwise if the server does not exist. |
Raises: | OpenStackCloudException on operation error. |
update_server
(name_or_id, detailed=False, bare=False, **kwargs)¶Update a server.
Parameters: |
|
---|---|
Name: | New name for the server |
Description: | New description for the server |
Returns: | a dictionary representing the updated server. |
Raises: | OpenStackCloudException on operation error. |
create_server_group
(name, policies)¶Create a new server group.
Parameters: |
|
---|---|
Returns: | a dict representing the new server group. |
Raises: | OpenStackCloudException on operation error. |
delete_server_group
(name_or_id)¶Delete a server group.
Parameters: | name_or_id – Name or ID of the server group to delete |
---|---|
Returns: | True if delete succeeded, False otherwise |
Raises: | OpenStackCloudException on operation error. |
list_containers
(full_listing=True)¶List containers.
Parameters: | full_listing – Ignored. Present for backwards compat |
---|---|
Returns: | list of Munch of the container objects |
Raises: | OpenStackCloudException on operation error. |
get_container
(name, skip_cache=False)¶Get metadata about a container.
Parameters: |
|
---|
create_container
(name, public=False)¶Create an object-store container.
Parameters: |
|
---|
delete_container
(name)¶Delete an object-store container.
Parameters: | name (str) – Name of the container to delete. |
---|
update_container
(name, headers)¶Update the metadata in a container.
Parameters: |
|
---|
set_container_access
(name, access)¶Set the access control list on a container.
Parameters: |
|
---|
get_container_access
(name)¶Get the control list from a container.
Parameters: | name (str) – Name of the container. |
---|
get_object_segment_size
(segment_size)¶Get a segment size that will work given capabilities
is_object_stale
(container, name, filename, file_md5=None, file_sha256=None)¶Check to see if an object matches the hashes of a file.
Parameters: |
|
---|
create_directory_marker_object
(container, name, **headers)¶Create a zero-byte directory marker object
Note
This method is not needed in most cases. Modern swift does not require directory marker objects. However, some swift installs may need these.
When using swift Static Web and Web Listings to serve static content one may need to create a zero-byte object to represent each “directory”. Doing so allows Web Listings to generate an index of the objects inside of it, and allows Static Web to render index.html “files” that are “inside” the directory.
Parameters: |
|
---|
create_object
(container, name, filename=None, md5=None, sha256=None, segment_size=None, use_slo=True, metadata=None, generate_checksums=None, data=None, **headers)¶Create a file object.
Automatically uses large-object segments if needed.
Parameters: |
|
---|---|
Raises: |
|
update_object
(container, name, metadata=None, **headers)¶Update the metadata of an object
Parameters: |
|
---|---|
Raises: |
|
list_objects
(container, full_listing=True)¶List objects.
Parameters: |
|
---|---|
Returns: | list of Munch of the objects |
Raises: | OpenStackCloudException on operation error. |
delete_object
(container, name, meta=None)¶Delete an object from a container.
Parameters: |
|
---|---|
Returns: | True if delete succeeded, False if the object was not found. |
Raises: | OpenStackCloudException on operation error. |
delete_autocreated_image_objects
(container='images')¶Delete all objects autocreated for image uploads.
This method should generally not be needed, as shade should clean up the objects it uses for object-based image creation. If something goes wrong and it is found that there are leaked objects, this method can be used to delete any objects that shade has created on the user’s behalf in service of image uploads.
get_object
(container, obj, query_string=None, resp_chunk_size=1024, outfile=None)¶Get the headers and body of an object
Parameters: |
|
---|---|
Returns: | Tuple (headers, body) of the object, or None if the object is not found (404) |
Raises: | OpenStackCloudException on operation error. |
create_subnet
(network_name_or_id, cidr=None, ip_version=4, enable_dhcp=False, subnet_name=None, tenant_id=None, allocation_pools=None, gateway_ip=None, disable_gateway_ip=False, dns_nameservers=None, host_routes=None, ipv6_ra_mode=None, ipv6_address_mode=None, prefixlen=None, use_default_subnetpool=False)¶Create a subnet on a specified network.
Parameters: |
|
---|---|
Returns: | The new subnet object. |
Raises: | OpenStackCloudException on operation error. |
delete_subnet
(name_or_id)¶Delete a subnet.
If a name, instead of a unique UUID, is supplied, it is possible that we could find more than one matching subnet since names are not required to be unique. An error will be raised in this case.
Parameters: | name_or_id – Name or ID of the subnet being deleted. |
---|---|
Returns: | True if delete succeeded, False otherwise. |
Raises: | OpenStackCloudException on operation error. |
update_subnet
(name_or_id, subnet_name=None, enable_dhcp=None, gateway_ip=None, disable_gateway_ip=None, allocation_pools=None, dns_nameservers=None, host_routes=None)¶Update an existing subnet.
Parameters: |
|
---|---|
Returns: | The updated subnet object. |
Raises: | OpenStackCloudException on operation error. |
create_port
(network_id, **kwargs)¶Create a port
Parameters: |
|
---|---|
Returns: | a |
Raises: |
|
update_port
(name_or_id, **kwargs)¶Update a port
Note: to unset an attribute use None value. To leave an attribute untouched just omit it.
Parameters: |
|
---|---|
Returns: | a |
Raises: | OpenStackCloudException on operation error. |
delete_port
(name_or_id)¶Delete a port
Parameters: | name_or_id – ID or name of the port to delete. |
---|---|
Returns: | True if delete succeeded, False otherwise. |
Raises: | OpenStackCloudException on operation error. |
create_security_group
(name, description, project_id=None)¶Create a new security group
Parameters: |
|
---|---|
Returns: | A |
Raises: | OpenStackCloudException on operation error. |
Raises: | OpenStackCloudUnavailableFeature if security groups are not supported on this cloud. |
delete_security_group
(name_or_id)¶Delete a security group
Parameters: | name_or_id (string) – The name or unique ID of the security group. |
---|---|
Returns: | True if delete succeeded, False otherwise. |
Raises: | OpenStackCloudException on operation error. |
Raises: | OpenStackCloudUnavailableFeature if security groups are not supported on this cloud. |
update_security_group
(name_or_id, **kwargs)¶Update a security group
Parameters: |
|
---|---|
Returns: | A |
Raises: | OpenStackCloudException on operation error. |
create_security_group_rule
(secgroup_name_or_id, port_range_min=None, port_range_max=None, protocol=None, remote_ip_prefix=None, remote_group_id=None, direction='ingress', ethertype='IPv4', project_id=None)¶Create a new security group rule
Parameters: |
|
---|---|
Returns: | A |
Raises: | OpenStackCloudException on operation error. |
delete_security_group_rule
(rule_id)¶Delete a security group rule
Parameters: | rule_id (string) – The unique ID of the security group rule. |
---|---|
Returns: | True if delete succeeded, False otherwise. |
Raises: | OpenStackCloudException on operation error. |
Raises: | OpenStackCloudUnavailableFeature if security groups are not supported on this cloud. |
list_zones
()¶List all available zones.
Returns: | A list of zones dicts. |
---|
get_zone
(name_or_id, filters=None)¶Get a zone by name or ID.
Parameters: |
|
---|---|
Returns: | A zone dict or None if no matching zone is found. |
create_zone
(name, zone_type=None, email=None, description=None, ttl=None, masters=None)¶Create a new zone.
Parameters: |
|
---|---|
Returns: | a dict representing the created zone. |
Raises: | OpenStackCloudException on operation error. |
update_zone
(name_or_id, **kwargs)¶Update a zone.
Parameters: |
|
---|---|
Returns: | a dict representing the updated zone. |
Raises: | OpenStackCloudException on operation error. |
delete_zone
(name_or_id)¶Delete a zone.
Parameters: | name_or_id – Name or ID of the zone being deleted. |
---|---|
Returns: | True if delete succeeded, False otherwise. |
Raises: | OpenStackCloudException on operation error. |
list_recordsets
(zone)¶List all available recordsets.
Parameters: | zone – Name or ID of the zone managing the recordset |
---|---|
Returns: | A list of recordsets. |
get_recordset
(zone, name_or_id)¶Get a recordset by name or ID.
Parameters: |
|
---|---|
Returns: | A recordset dict or None if no matching recordset is found. |
create_recordset
(zone, name, recordset_type, records, description=None, ttl=None)¶Create a recordset.
Parameters: |
|
---|---|
Returns: | a dict representing the created recordset. |
Raises: | OpenStackCloudException on operation error. |
update_recordset
(zone, name_or_id, **kwargs)¶Update a recordset.
Parameters: |
|
---|---|
Returns: | a dict representing the updated recordset. |
Raises: | OpenStackCloudException on operation error. |
delete_recordset
(zone, name_or_id)¶Delete a recordset.
Parameters: |
|
---|---|
Returns: | True if delete succeeded, False otherwise. |
Raises: | OpenStackCloudException on operation error. |
search_coe_clusters
(name_or_id=None, filters=None)¶Search COE cluster.
Parameters: |
|
---|---|
Returns: | a list of dict containing the cluster |
Raises: |
|
get_coe_cluster
(name_or_id, filters=None)¶Get a COE cluster by name or ID.
Parameters: |
|
---|---|
Returns: | A cluster dict or None if no matching cluster is found. |
create_coe_cluster
(name, cluster_template_id, **kwargs)¶Create a COE cluster based on given cluster template.
Parameters: |
|
---|
Other arguments will be passed in kwargs.
Returns: | a dict containing the cluster description |
---|---|
Raises: | OpenStackCloudException if something goes wrong during
the OpenStack API call |
delete_coe_cluster
(name_or_id)¶Delete a COE cluster.
Parameters: | name_or_id – Name or unique ID of the cluster. |
---|---|
Returns: | True if the delete succeeded, False if the cluster was not found. |
Raises: | OpenStackCloudException on operation error. |
update_coe_cluster
(name_or_id, operation, **kwargs)¶Update a COE cluster.
Parameters: |
|
---|
Other arguments will be passed with kwargs.
Returns: | a dict representing the updated cluster. |
---|---|
Raises: | OpenStackCloudException on operation error. |
get_coe_cluster_certificate
(cluster_id)¶Get details about the CA certificate for a cluster by name or ID.
Parameters: | cluster_id – ID of the cluster. |
---|---|
Returns: | Details about the CA certificate for the given cluster. |
sign_coe_cluster_certificate
(cluster_id, csr)¶Sign client key and generate the CA certificate for a cluster
Parameters: |
|
---|---|
Returns: | a dict representing the signed certs. |
Raises: | OpenStackCloudException on operation error. |
search_cluster_templates
(name_or_id=None, filters=None, detail=False)¶Search cluster templates.
Parameters: |
|
---|---|
Returns: | a list of dict containing the cluster templates |
Raises: |
|
search_baymodels
(name_or_id=None, filters=None, detail=False)¶Search cluster templates.
Parameters: |
|
---|---|
Returns: | a list of dict containing the cluster templates |
Raises: |
|
search_coe_cluster_templates
(name_or_id=None, filters=None, detail=False)¶Search cluster templates.
Parameters: |
|
---|---|
Returns: | a list of dict containing the cluster templates |
Raises: |
|
get_cluster_template
(name_or_id, filters=None, detail=False)¶Get a cluster template by name or ID.
Parameters: |
|
---|---|
Returns: | A cluster template dict or None if no matching cluster template is found. |
get_baymodel
(name_or_id, filters=None, detail=False)¶Get a cluster template by name or ID.
Parameters: |
|
---|---|
Returns: | A cluster template dict or None if no matching cluster template is found. |
get_coe_cluster_template
(name_or_id, filters=None, detail=False)¶Get a cluster template by name or ID.
Parameters: |
|
---|---|
Returns: | A cluster template dict or None if no matching cluster template is found. |
create_cluster_template
(name, image_id=None, keypair_id=None, coe=None, **kwargs)¶Create a cluster template.
Parameters: |
|
---|
Other arguments will be passed in kwargs.
Returns: | a dict containing the cluster template description |
---|---|
Raises: | OpenStackCloudException if something goes wrong during
the OpenStack API call |
create_baymodel
(name, image_id=None, keypair_id=None, coe=None, **kwargs)¶Create a cluster template.
Parameters: |
|
---|
Other arguments will be passed in kwargs.
Returns: | a dict containing the cluster template description |
---|---|
Raises: | OpenStackCloudException if something goes wrong during
the OpenStack API call |
create_coe_cluster_template
(name, image_id=None, keypair_id=None, coe=None, **kwargs)¶Create a cluster template.
Parameters: |
|
---|
Other arguments will be passed in kwargs.
Returns: | a dict containing the cluster template description |
---|---|
Raises: | OpenStackCloudException if something goes wrong during
the OpenStack API call |
delete_cluster_template
(name_or_id)¶Delete a cluster template.
Parameters: | name_or_id – Name or unique ID of the cluster template. |
---|---|
Returns: | True if the delete succeeded, False if the cluster template was not found. |
Raises: | OpenStackCloudException on operation error. |
delete_baymodel
(name_or_id)¶Delete a cluster template.
Parameters: | name_or_id – Name or unique ID of the cluster template. |
---|---|
Returns: | True if the delete succeeded, False if the cluster template was not found. |
Raises: | OpenStackCloudException on operation error. |
delete_coe_cluster_template
(name_or_id)¶Delete a cluster template.
Parameters: | name_or_id – Name or unique ID of the cluster template. |
---|---|
Returns: | True if the delete succeeded, False if the cluster template was not found. |
Raises: | OpenStackCloudException on operation error. |
update_cluster_template
(name_or_id, operation, **kwargs)¶Update a cluster template.
Parameters: |
|
---|
Other arguments will be passed with kwargs.
Returns: | a dict representing the updated cluster template. |
---|---|
Raises: | OpenStackCloudException on operation error. |
update_baymodel
(name_or_id, operation, **kwargs)¶Update a cluster template.
Parameters: |
|
---|
Other arguments will be passed with kwargs.
Returns: | a dict representing the updated cluster template. |
---|---|
Raises: | OpenStackCloudException on operation error. |
update_coe_cluster_template
(name_or_id, operation, **kwargs)¶Update a cluster template.
Parameters: |
|
---|
Other arguments will be passed with kwargs.
Returns: | a dict representing the updated cluster template. |
---|---|
Raises: | OpenStackCloudException on operation error. |
list_nics_for_machine
(uuid)¶Returns a list of ports present on the machine node.
Parameters: | uuid – String representing machine UUID value in order to identify the machine. |
---|---|
Returns: | A list of ports. |
get_machine
(name_or_id)¶Get Machine by name or uuid
Search the baremetal host out by utilizing the supplied id value which can consist of a name or UUID.
Parameters: | name_or_id – A node name or UUID that will be looked up. |
---|---|
Returns: | munch.Munch representing the node found or None if no
nodes are found. |
get_machine_by_mac
(mac)¶Get machine by port MAC address
Parameters: | mac – Port MAC address to query in order to return a node. |
---|---|
Returns: | munch.Munch representing the node found or None
if the node is not found. |
inspect_machine
(name_or_id, wait=False, timeout=3600)¶Inspect a Barmetal machine
Engages the Ironic node inspection behavior in order to collect metadata about the baremetal machine.
Parameters: |
|
---|---|
Returns: |
|
register_machine
(nics, wait=False, timeout=3600, lock_timeout=600, **kwargs)¶Register Baremetal with Ironic
Allows for the registration of Baremetal nodes with Ironic and population of pertinant node information or configuration to be passed to the Ironic API for the node.
This method also creates ports for a list of MAC addresses passed in to be utilized for boot and potentially network configuration.
If a failure is detected creating the network ports, any ports created are deleted, and the node is removed from Ironic.
Parameters: |
|
---|---|
Raises: | OpenStackCloudException on operation error. |
Returns: | Returns a |
unregister_machine
(nics, uuid, wait=False, timeout=600)¶Unregister Baremetal from Ironic
Removes entries for Network Interfaces and baremetal nodes from an Ironic API
Parameters: |
|
---|---|
Raises: | OpenStackCloudException on operation failure. |
patch_machine
(name_or_id, patch)¶Patch Machine Information
This method allows for an interface to manipulate node entries within Ironic.
Parameters: |
|
---|---|
Raises: | OpenStackCloudException on operation error. |
Returns: |
|
update_machine
(name_or_id, chassis_uuid=None, driver=None, driver_info=None, name=None, instance_info=None, instance_uuid=None, properties=None)¶Update a machine with new configuration information
A user-friendly method to perform updates of a machine, in whole or part.
Parameters: |
|
---|---|
Raises: | OpenStackCloudException on operation error. |
Returns: |
|
node_set_provision_state
(name_or_id, state, configdrive=None, wait=False, timeout=3600)¶Set Node Provision State
Enables a user to provision a Machine and optionally define a config drive to be utilized.
Parameters: |
|
---|---|
Raises: | OpenStackCloudException on operation error. |
Returns: |
|
set_machine_maintenance_state
(name_or_id, state=True, reason=None)¶Set Baremetal Machine Maintenance State
Sets Baremetal maintenance state and maintenance reason.
Parameters: |
|
---|---|
Raises: | OpenStackCloudException on operation error. |
Returns: | None |
remove_machine_from_maintenance
(name_or_id)¶Remove Baremetal Machine from Maintenance State
Similarly to set_machine_maintenance_state, this method removes a machine from maintenance state. It must be noted that this method simpily calls set_machine_maintenace_state for the name_or_id requested and sets the state to False.
Parameters: | name_or_id (string) – The Name or UUID value representing the baremetal node. |
---|---|
Raises: | OpenStackCloudException on operation error. |
Returns: | None |
set_machine_power_on
(name_or_id)¶Activate baremetal machine power
This is a method that sets the node power state to “on”.
Params string name_or_id: | |
---|---|
A string representing the baremetal node to have power turned to an “on” state. | |
Raises: | OpenStackCloudException on operation error. |
Returns: | None |
set_machine_power_off
(name_or_id)¶De-activate baremetal machine power
This is a method that sets the node power state to “off”.
Params string name_or_id: | |
---|---|
A string representing the baremetal node to have power turned to an “off” state. | |
Raises: | OpenStackCloudException on operation error. |
Returns: |
set_machine_power_reboot
(name_or_id)¶De-activate baremetal machine power
This is a method that sets the node power state to “reboot”, which in essence changes the machine power state to “off”, and that back to “on”.
Params string name_or_id: | |
---|---|
A string representing the baremetal node to have power turned to an “off” state. | |
Raises: | OpenStackCloudException on operation error. |
Returns: | None |
wait_for_baremetal_node_lock
(node, timeout=30)¶Wait for a baremetal node to have no lock.
Baremetal nodes in ironic have a reservation lock that is used to represent that a conductor has locked the node while performing some sort of action, such as changing configuration as a result of a machine state change.
This lock can occur during power syncronization, and prevents updates to objects attached to the node, such as ports.
In the vast majority of cases, locks should clear in a few seconds, and as such this method will only wait for 30 seconds. The default wait is two seconds between checking if the lock has cleared.
This method is intended for use by methods that need to gracefully block without genreating errors, however this method does prevent another client or a timer from triggering a lock immediately after we see the lock as having cleared.
Parameters: |
|
---|---|
Raises: | OpenStackCloudException upon client failure. |
Returns: | None |
create_service
(name, enabled=True, **kwargs)¶Create a service.
Parameters: |
|
---|---|
Returns: | a |
Raises: |
|
list_services
()¶List all Keystone services.
Returns: | a list of munch.Munch containing the services description |
---|---|
Raises: | OpenStackCloudException if something goes wrong during the
openstack API call. |
search_services
(name_or_id=None, filters=None)¶Search Keystone services.
Parameters: |
|
---|---|
Returns: | a list of |
Raises: |
|
get_service
(name_or_id, filters=None)¶Get exactly one Keystone service.
Parameters: |
|
---|---|
Returns: | a |
Raises: |
|
delete_service
(name_or_id)¶Delete a Keystone service.
Parameters: | name_or_id – Service name or id. |
---|---|
Returns: | True if delete succeeded, False otherwise. |
Raises: | OpenStackCloudException if something goes wrong during
the openstack API call |
create_endpoint
(service_name_or_id, url=None, interface=None, region=None, enabled=True, **kwargs)¶Create a Keystone endpoint.
Parameters: |
|
---|
Returns: | a list of munch.Munch containing the endpoint description |
---|---|
Raises: | OpenStackCloudException if the service cannot be found or if something goes wrong during the openstack API call. |
list_endpoints
()¶List Keystone endpoints.
Returns: | a list of munch.Munch containing the endpoint description |
---|---|
Raises: | OpenStackCloudException : if something goes wrong during
the openstack API call. |
search_endpoints
(id=None, filters=None)¶List Keystone endpoints.
Parameters: |
|
---|---|
Returns: | a list of |
Raises: |
|
get_endpoint
(id, filters=None)¶Get exactly one Keystone endpoint.
Parameters: |
|
---|---|
Returns: | a |
delete_endpoint
(id)¶Delete a Keystone endpoint.
Parameters: | id – Id of the endpoint to delete. |
---|---|
Returns: | True if delete succeeded, False otherwise. |
Raises: | OpenStackCloudException if something goes wrong during
the openstack API call. |
create_domain
(name, description=None, enabled=True)¶Create a domain.
Parameters: |
|
---|---|
Returns: | a |
Raises: | OpenStackCloudException – if the domain cannot be created. |
delete_domain
(domain_id=None, name_or_id=None)¶Delete a domain.
Parameters: |
|
---|---|
Returns: | True if delete succeeded, False otherwise. |
Raises: |
|
list_domains
(**filters)¶List Keystone domains.
Returns: | a list of munch.Munch containing the domain description. |
---|---|
Raises: | OpenStackCloudException : if something goes wrong during
the openstack API call. |
search_domains
(filters=None, name_or_id=None)¶Search Keystone domains.
Parameters: |
|
---|---|
Returns: | a list of |
Raises: |
|
get_domain
(domain_id=None, name_or_id=None, filters=None)¶Get exactly one Keystone domain.
Parameters: |
|
---|---|
Returns: | a |
Raises: |
|
search_groups
(name_or_id=None, filters=None, **kwargs)¶Search Keystone groups.
Parameters: |
|
---|---|
Returns: | A list of |
Raises: |
|
get_group
(name_or_id, filters=None, **kwargs)¶Get exactly one Keystone group.
Parameters: |
|
---|---|
Returns: | A |
Raises: |
|
create_group
(name, description, domain=None)¶Create a group.
Parameters: |
|
---|---|
Returns: | A |
Raises: |
|
update_group
(name_or_id, name=None, description=None, **kwargs)¶Update an existing group
Parameters: |
|
---|---|
Returns: | A |
Raises: |
|
delete_group
(name_or_id, **kwargs)¶Delete a group
Parameters: |
|
---|---|
Returns: | True if delete succeeded, False otherwise. |
Raises: |
|
list_roles
(**kwargs)¶List Keystone roles.
Parameters: | domain_id – domain id for listing roles (v3) |
---|---|
Returns: | a list of munch.Munch containing the role description. |
Raises: | OpenStackCloudException : if something goes wrong during
the openstack API call. |
search_roles
(name_or_id=None, filters=None, **kwargs)¶Seach Keystone roles.
Parameters: |
|
---|---|
Returns: | a list of - id: <role id>
- name: <role name>
- description: <role description>
|
Raises: |
|
get_role
(name_or_id, filters=None, **kwargs)¶Get exactly one Keystone role.
Parameters: |
|
---|---|
Returns: | a single - id: <role id>
- name: <role name>
- description: <role description>
|
Raises: |
|
list_role_assignments
(filters=None)¶List Keystone role assignments
Parameters: | filters (dict) – Dict of filter conditions. Acceptable keys are:
’user’ and ‘group’ are mutually exclusive, as are ‘domain’ and ‘project’.
|
---|---|
Returns: | a list of munch.Munch containing the role assignment
description. Contains the following attributes:- id: <role id>
- user|group: <user or group id>
- project|domain: <project or domain id>
|
Raises: | OpenStackCloudException : if something goes wrong during
the openstack API call. |
create_flavor
(name, ram, vcpus, disk, flavorid='auto', ephemeral=0, swap=0, rxtx_factor=1.0, is_public=True)¶Create a new flavor.
Parameters: |
|
---|---|
Returns: | A |
Raises: | OpenStackCloudException on operation error. |
delete_flavor
(name_or_id)¶Delete a flavor
Parameters: | name_or_id – ID or name of the flavor to delete. |
---|---|
Returns: | True if delete succeeded, False otherwise. |
Raises: | OpenStackCloudException on operation error. |
set_flavor_specs
(flavor_id, extra_specs)¶Add extra specs to a flavor
Parameters: |
|
---|---|
Raises: | OpenStackCloudException on operation error. |
Raises: | OpenStackCloudResourceNotFound if flavor ID is not found. |
unset_flavor_specs
(flavor_id, keys)¶Delete extra specs from a flavor
Parameters: |
|
---|---|
Raises: | OpenStackCloudException on operation error. |
Raises: | OpenStackCloudResourceNotFound if flavor ID is not found. |
add_flavor_access
(flavor_id, project_id)¶Grant access to a private flavor for a project/tenant.
Parameters: |
|
---|---|
Raises: | OpenStackCloudException on operation error. |
remove_flavor_access
(flavor_id, project_id)¶Revoke access from a private flavor for a project/tenant.
Parameters: |
|
---|---|
Raises: | OpenStackCloudException on operation error. |
list_flavor_access
(flavor_id)¶List access from a private flavor for a project/tenant.
Parameters: | flavor_id (string) – ID of the private flavor. |
---|---|
Returns: | a list of munch.Munch containing the access description |
Raises: | OpenStackCloudException on operation error. |
create_role
(name, **kwargs)¶Create a Keystone role.
Parameters: |
|
---|---|
Returns: | a |
Raises: | OpenStackCloudException – if the role cannot be created |
update_role
(name_or_id, name, **kwargs)¶Update a Keystone role.
Parameters: |
|
---|---|
Returns: | a |
Raises: | OpenStackCloudException – if the role cannot be created |
delete_role
(name_or_id, **kwargs)¶Delete a Keystone role.
Parameters: |
|
---|---|
Returns: | True if delete succeeded, False otherwise. |
Raises: |
|
grant_role
(name_or_id, user=None, group=None, project=None, domain=None, wait=False, timeout=60)¶Grant a role to a user.
Parameters: |
|
---|
NOTE: project is required for keystone v2
Returns: | True if the role is assigned, otherwise False |
---|---|
Raises: | OpenStackCloudException – if the role cannot be granted |
revoke_role
(name_or_id, user=None, group=None, project=None, domain=None, wait=False, timeout=60)¶Revoke a role from a user.
Parameters: |
|
---|
NOTE: project is required for keystone v2
Returns: | True if the role is revoke, otherwise False |
---|---|
Raises: | OpenStackCloudException – if the role cannot be removed |
list_hypervisors
()¶List all hypervisors
Returns: | A list of hypervisor munch.Munch . |
---|
search_aggregates
(name_or_id=None, filters=None)¶Seach host aggregates.
Parameters: |
|
---|---|
Returns: | a list of dicts containing the aggregates |
Raises: |
|
list_aggregates
()¶List all available host aggregates.
Returns: | A list of aggregate dicts. |
---|
get_aggregate
(name_or_id, filters=None)¶Get an aggregate by name or ID.
Parameters: |
|
---|---|
Returns: | An aggregate dict or None if no matching aggregate is found. |
create_aggregate
(name, availability_zone=None)¶Create a new host aggregate.
Parameters: |
|
---|---|
Returns: | a dict representing the new host aggregate. |
Raises: | OpenStackCloudException on operation error. |
update_aggregate
(name_or_id, **kwargs)¶Update a host aggregate.
Parameters: |
|
---|---|
Returns: | a dict representing the updated host aggregate. |
Raises: | OpenStackCloudException on operation error. |
delete_aggregate
(name_or_id)¶Delete a host aggregate.
Parameters: | name_or_id – Name or ID of the host aggregate to delete. |
---|---|
Returns: | True if delete succeeded, False otherwise. |
Raises: | OpenStackCloudException on operation error. |
set_aggregate_metadata
(name_or_id, metadata)¶Set aggregate metadata, replacing the existing metadata.
Parameters: |
|
---|---|
Returns: | a dict representing the new host aggregate. |
Raises: | OpenStackCloudException on operation error. |
add_host_to_aggregate
(name_or_id, host_name)¶Add a host to an aggregate.
Parameters: |
|
---|---|
Raises: | OpenStackCloudException on operation error. |
remove_host_from_aggregate
(name_or_id, host_name)¶Remove a host from an aggregate.
Parameters: |
|
---|---|
Raises: | OpenStackCloudException on operation error. |
get_volume_type_access
(name_or_id)¶Return a list of volume_type_access.
Parameters: | name_or_id – Name or ID of the volume type. |
---|---|
Raises: | OpenStackCloudException on operation error. |
add_volume_type_access
(name_or_id, project_id)¶Grant access on a volume_type to a project.
Parameters: |
|
---|
NOTE: the call works even if the project does not exist.
Raises: | OpenStackCloudException on operation error. |
---|
remove_volume_type_access
(name_or_id, project_id)¶Revoke access on a volume_type to a project.
Parameters: |
|
---|---|
Raises: | OpenStackCloudException on operation error. |
set_compute_quotas
(name_or_id, **kwargs)¶Set a quota in a project
Parameters: |
|
---|---|
Raises: | OpenStackCloudException if the resource to set the quota does not exist. |
get_compute_quotas
(name_or_id)¶Get quota for a project
Parameters: | name_or_id – project name or id |
---|---|
Raises: | OpenStackCloudException if it’s not a valid project |
Returns: | Munch object with the quotas |
delete_compute_quotas
(name_or_id)¶Delete quota for a project
Parameters: | name_or_id – project name or id |
---|---|
Raises: | OpenStackCloudException if it’s not a valid project or the nova client call failed |
Returns: | dict with the quotas |
get_compute_usage
(name_or_id, start=None, end=None)¶Get usage for a specific project
Parameters: |
|
---|---|
Raises: | OpenStackCloudException if it’s not a valid project |
Returns: | Munch object with the usage |
set_volume_quotas
(name_or_id, **kwargs)¶Set a volume quota in a project
Parameters: |
|
---|---|
Raises: | OpenStackCloudException if the resource to set the quota does not exist. |
get_volume_quotas
(name_or_id)¶Get volume quotas for a project
Parameters: | name_or_id – project name or id |
---|---|
Raises: | OpenStackCloudException if it’s not a valid project |
Returns: | Munch object with the quotas |
delete_volume_quotas
(name_or_id)¶Delete volume quotas for a project
Parameters: | name_or_id – project name or id |
---|---|
Raises: | OpenStackCloudException if it’s not a valid project or the cinder client call failed |
Returns: | dict with the quotas |
set_network_quotas
(name_or_id, **kwargs)¶Set a network quota in a project
Parameters: |
|
---|---|
Raises: | OpenStackCloudException if the resource to set the quota does not exist. |
get_network_quotas
(name_or_id, details=False)¶Get network quotas for a project
Parameters: |
|
---|---|
Raises: | OpenStackCloudException if it’s not a valid project |
Returns: | Munch object with the quotas |
get_network_extensions
()¶Get Cloud provided network extensions
Returns: | set of Neutron extension aliases |
---|
delete_network_quotas
(name_or_id)¶Delete network quotas for a project
Parameters: | name_or_id – project name or id |
---|---|
Raises: | OpenStackCloudException if it’s not a valid project or the network client call failed |
Returns: | dict with the quotas |
list_magnum_services
()¶List all Magnum services. :returns: a list of dicts containing the service details.
Raises: | OpenStackCloudException on operation error. |
---|
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.