Connection

The Connection class is the primary interface to the Python SDK. It maintains a context for a connection to a region of a cloud provider. The Connection has an attribute to access each OpenStack service.

At a minimum, the Connection class needs to be created with a config or the parameters to build one.

While the overall system is very flexible, there are four main use cases for different ways to create a Connection.

  • Using config settings and keyword arguments as described in Configuring OpenStack SDK Applications

  • Using only keyword arguments passed to the constructor ignoring config files and environment variables.

  • Using an existing authenticated keystoneauth1.session.Session, such as might exist inside of an OpenStack service operational context.

  • Using an existing CloudRegion.

Using config settings

For users who want to create a Connection making use of named clouds in clouds.yaml files, OS_ environment variables and python keyword arguments, the openstack.connect() factory function is the recommended way to go:

import openstack

conn = openstack.connect(cloud='example', region_name='earth1')

If the application in question is a command line application that should also accept command line arguments, an argparse.Namespace can be passed to openstack.connect() that will have relevant arguments added to it and then subsequently consumed by the constructor:

import argparse
import openstack

options = argparse.ArgumentParser(description='Awesome OpenStack App')
conn = openstack.connect(options=options)

Using Only Keyword Arguments

If the application wants to avoid loading any settings from clouds.yaml or environment variables, use the Connection constructor directly. As long as the cloud argument is omitted or None, the Connection constructor will not load settings from files or the environment.

Note

This is a different default behavior than the connect() factory function. In connect() if cloud is omitted or None, a default cloud will be loaded, defaulting to the envvars cloud if it exists.

from openstack import connection

conn = connection.Connection(
    region_name='example-region',
    auth=dict(
        auth_url='https://auth.example.com',
        username='amazing-user',
        password='super-secret-password',
        project_id='33aa1afc-03fe-43b8-8201-4e0d3b4b8ab5',
        user_domain_id='054abd68-9ad9-418b-96d3-3437bb376703'),
    compute_api_version='2',
    identity_interface='internal')

Per-service settings as needed by keystoneauth1.adapter.Adapter such as api_version, service_name, and interface can be set, as seen above, by prefixing them with the official service-type name of the service. region_name is a setting for the entire CloudRegion and cannot be set per service.

From existing authenticated Session

For applications that already have an authenticated Session, simply passing it to the Connection constructor is all that is needed:

from openstack import connection

conn = connection.Connection(
    session=session,
    region_name='example-region',
    compute_api_version='2',
    identity_interface='internal')

From oslo.conf CONF object

For applications that have an oslo.config CONF object that has been populated with keystoneauth1.loading.register_adapter_conf_options in groups named by the OpenStack service’s project name, it is possible to construct a Connection with the CONF object and an authenticated Session.

Note

This is primarily intended for use by OpenStack services to talk amongst themselves.

from openstack import connection

conn = connection.Connection(
    session=session,
    oslo_conf=CONF)

From existing CloudRegion

If you already have an CloudRegion you can pass it in instead:

from openstack import connection
import openstack.config

config = openstack.config.get_cloud_region(
    cloud='example', region_name='earth')
conn = connection.Connection(config=config)

Using the Connection

Services are accessed through an attribute named after the service’s official service-type.

List

An iterator containing a list of all the projects is retrieved in this manner:

projects = conn.identity.projects()

Find or create

If you wanted to make sure you had a network named ‘zuul’, you would first try to find it and if that fails, you would create it:

network = conn.network.find_network("zuul")
if network is None:
    network = conn.network.create_network(name="zuul")

Additional information about the services can be found in the Service Proxies documentation.

from_config

openstack.connection.from_config(cloud=None, config=None, options=None, **kwargs)

Create a Connection using openstack.config

Parameters
  • cloud (str) – Use the cloud configuration details when creating the Connection.

  • config (openstack.config.cloud_region.CloudRegion) – An existing CloudRegion configuration. If no config is provided, openstack.config.OpenStackConfig will be called, and the provided name will be used in determining which cloud’s configuration details will be used in creation of the Connection instance.

  • options (argparse.Namespace) – Allows direct passing in of options to be added to the cloud config. This does not have to be an actual instance of argparse.Namespace, despite the naming of the openstack.config.loader.OpenStackConfig.get_one argument to which it is passed.

Return type

Connection

Connection Object

class openstack.connection.Connection(cloud=None, config=None, session=None, app_name=None, app_version=None, extra_services=None, strict=False, use_direct_get=False, task_manager=None, rate_limit=None, oslo_conf=None, service_types=None, global_request_id=None, strict_proxies=False, pool_executor=None, **kwargs)

Create a connection to a cloud.

A connection needs information about how to connect, how to authenticate and how to select the appropriate services to use.

The recommended way to provide this information is by referencing a named cloud config from an existing clouds.yaml file. The cloud name envvars may be used to consume a cloud configured via OS_ environment variables.

A pre-existing CloudRegion object can be passed in lieu of a cloud name, for cases where the user already has a fully formed CloudRegion and just wants to use it.

Similarly, if for some reason the user already has a Session and wants to use it, it may be passed in.

Parameters
  • cloud (str) – Name of the cloud from config to use.

  • config (CloudRegion) – CloudRegion object representing the config for the region of the cloud in question.

  • session (Session) – A session object compatible with Session.

  • app_name (str) – Name of the application to be added to User Agent.

  • app_version (str) – Version of the application to be added to User Agent.

  • extra_services – List of ServiceDescription objects describing services that openstacksdk otherwise does not know about.

  • use_direct_get (bool) – For get methods, make specific REST calls for server-side filtering instead of making list calls and filtering client-side. Default false.

  • task_manager – Ignored. Exists for backwards compat during transition. Rate limit parameters should be passed directly to the rate_limit parameter.

  • rate_limit – Client-side rate limit, expressed in calls per second. The parameter can either be a single float, or it can be a dict with keys as service-type and values as floats expressing the calls per second for that service. Defaults to None, which means no rate-limiting is performed.

  • oslo_conf (ConfigOpts An oslo.config CONF object that has been populated with keystoneauth1.loading.register_adapter_conf_options in groups named by the OpenStack service’s project name.) – An oslo.config CONF object.

  • service_types – A list/set of service types this Connection should support. All other service types will be disabled (will error if used). Currently only supported in conjunction with the ``oslo_conf`` kwarg.

  • global_request_id – A Request-id to send with all interactions.

  • strict_proxies (bool Throw an openstack.exceptions.ServiceDiscoveryException if the endpoint for a given service doesn’t work. This is useful for OpenStack services using sdk to talk to other OpenStack services where it can be expected that the deployer config is correct and errors should be reported immediately. Default false.) – If True, check proxies on creation and raise ServiceDiscoveryException if the service is unavailable.

  • pool_executor (Executor A futurist Executor object to be used for concurrent background activities. Defaults to None in which case a ThreadPoolExecutor will be created if needed.) –

  • kwargs – If a config is not provided, the rest of the parameters provided are assumed to be arguments to be passed to the CloudRegion constructor.

add_service(service)

Add a service to the Connection.

Attaches an instance of the Proxy class contained in ServiceDescription. The Proxy will be attached to the Connection by its service_type and by any aliases that may be specified.

Parameters

service (openstack.service_description.ServiceDescription) – Object describing the service to be attached. As a convenience, if service is a string it will be treated as a service_type and a basic ServiceDescription will be created.

authorize()

Authorize this Connection

Note

This method is optional. When an application makes a call to any OpenStack service, this method allows you to request a token manually before attempting to do anything else.

Returns

A string token.

Raises

HttpException if the authorization fails due to reasons like the credentials provided are unable to be authorized or the auth_type argument is missing, etc.

close()

Release any resources held open.

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
  • server – a server dictionary.

  • reuse – Whether or not to attempt to reuse IPs, defaults to True.

  • wait – (optional) Wait for the address to appear as assigned to the server. Defaults to False.

  • timeout – (optional) Seconds to wait, defaults to 60. See the wait parameter.

  • reuse – Try to reuse existing ips. Defaults to True.

Returns

Floating IP address attached to server.

add_flavor_access(flavor_id, project_id)

Grant access to a private flavor for a project/tenant.

Parameters
  • flavor_id (string) – ID of the private flavor.

  • project_id (string) – ID of the project/tenant.

Raises

OpenStackCloudException on operation error.

add_host_to_aggregate(name_or_id, host_name)

Add a host to an aggregate.

Parameters
  • name_or_id – Name or ID of the host aggregate.

  • host_name – Host to add.

Raises

OpenStackCloudException on operation error.

add_ip_list(server, ips, wait=False, timeout=60, fixed_address=None)

Attach a list of IPs to a server.

Parameters
  • server – a server object

  • ips – list of floating IP addresses or a single address

  • wait – (optional) Wait for the address to appear as assigned to the server. Defaults to False.

  • timeout – (optional) Seconds to wait, defaults to 60. See the wait parameter.

  • fixed_address – (optional) Fixed address of the server to attach the IP to

Returns

The updated server munch.Munch

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
  • router (dict) – The dict object of the router being changed

  • subnet_id (string) – The ID of the subnet to use for the interface

  • port_id (string) – The ID of the port to use for the interface

Returns

A munch.Munch with the router ID (ID), subnet ID (subnet_id), port ID (port_id) and tenant ID (tenant_id).

Raises

OpenStackCloudException on operation error.

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.

add_user_to_group(name_or_id, group_name_or_id)

Add a user to a group.

Parameters
  • name_or_id (string) – User name or ID

  • group_name_or_id (string) – Group name or ID

Raises

OpenStackCloudException if something goes wrong during the OpenStack API call

add_volume_type_access(name_or_id, project_id)

Grant access on a volume_type to a project.

Parameters
  • name_or_id – ID or name of a volume_type

  • project_id – A project id

NOTE: the call works even if the project does not exist.

Raises

OpenStackCloudException on operation error.

attach_port_to_machine(name_or_id, port_name_or_id)

Attach a virtual port to the bare metal machine.

Parameters
  • name_or_id (string) – A machine name or UUID.

  • port_name_or_id (string) – A port name or UUID. Note that this is a Network service port, not a bare metal NIC.

Returns

Nothing.

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
  • server – The server dict to attach to.

  • volume – The volume dict to attach.

  • device – The device name where the volume will attach.

  • wait – If true, waits for volume to be attached.

  • timeout – Seconds to wait for volume attachment. None is forever.

Returns

a volume attachment object.

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
  • network – Name or ID of the network.

  • server – Server the IP is for if known

Returns

a (normalized) structure with a floating IP address description.

bind_accelerator_request(uuid, properties)

Bind an accelerator to VM. :param uuid: The uuid of the accelerator_request to be binded. :param properties: The info of VM that will bind the accelerator. :returns: True if bind succeeded, False otherwise.

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.

create_accelerator_request(attrs)

Create an accelerator_request. :param attrs: The info of accelerator_request to be created. :returns: A munch.Munch of the created accelerator_request.

create_aggregate(name, availability_zone=None)

Create a new host aggregate.

Parameters
  • name – Name of the host aggregate being created

  • availability_zone – Availability zone to assign hosts

Returns

a dict representing the new host aggregate.

Raises

OpenStackCloudException on operation error.

create_baymodel(name, image_id=None, keypair_id=None, coe=None, **kwargs)

Create a cluster template.

Parameters
  • name (string) – Name of the cluster template.

  • image_id (string) – Name or ID of the image to use.

  • keypair_id (string) – Name or ID of the keypair to use.

  • coe (string) – Name of the coe for the cluster template.

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_cluster_template(name, image_id=None, keypair_id=None, coe=None, **kwargs)

Create a cluster template.

Parameters
  • name (string) – Name of the cluster template.

  • image_id (string) – Name or ID of the image to use.

  • keypair_id (string) – Name or ID of the keypair to use.

  • coe (string) – Name of the coe for the cluster template.

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(name, cluster_template_id, **kwargs)

Create a COE cluster based on given cluster template.

Parameters
  • name (string) – Name of the cluster.

  • image_id (string) – ID of the cluster template to use.

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

create_coe_cluster_template(name, image_id=None, keypair_id=None, coe=None, **kwargs)

Create a cluster template.

Parameters
  • name (string) – Name of the cluster template.

  • image_id (string) – Name or ID of the image to use.

  • keypair_id (string) – Name or ID of the keypair to use.

  • coe (string) – Name of the coe for the cluster template.

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_container(name, public=False)

Create an object-store container.

Parameters
  • name (str) – Name of the container to create.

  • public (bool) – Whether to set this container to be public. Defaults to False.

create_device_profile(attrs)

Create a device_profile. :param attrs: The info of device_profile to be created. :returns: A munch.Munch of the created device_profile.

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
  • container – The name of the container.

  • name – Name for the directory marker object within the container.

  • headers – These will be passed through to the object creation API as HTTP Headers.

create_domain(name, description=None, enabled=True)

Create a domain.

Parameters
  • name – The name of the domain.

  • description – A description of the domain.

  • enabled – Is the domain enabled or not (default True).

Returns

a munch.Munch containing the domain representation.

Raises

OpenStackCloudException – if the domain cannot be created.

create_endpoint(service_name_or_id, url=None, interface=None, region=None, enabled=True, **kwargs)

Create a Keystone endpoint.

Parameters
  • service_name_or_id – Service name or id for this endpoint.

  • url – URL of the endpoint

  • interface – Interface type of the endpoint

  • public_url – Endpoint public URL.

  • internal_url – Endpoint internal URL.

  • admin_url – Endpoint admin URL.

  • region – Endpoint region.

  • enabled – Whether the endpoint is enabled

NOTE: Both v2 (public_url, internal_url, admin_url) and v3

(url, interface) calling semantics are supported. But you can only use one of them at a time.

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.

create_firewall_group(**kwargs)

Creates firewall group. The keys egress_firewall_policy and ingress_firewall_policy are looked up and mapped as egress_firewall_policy_id and ingress_firewall_policy_id respectively. Port name or ids list is transformed to port ids list before the POST request.

Parameters
  • admin_state_up (bool) – State of firewall group. Will block all traffic if set to False. Defaults to True.

  • description – Human-readable description.

  • egress_firewall_policy – Name or id of egress firewall policy.

  • ingress_firewall_policy – Name or id of ingress firewall policy.

  • name – Human-readable name.

  • ports (list[str]) – List of associated ports (name or id)

  • project_id – Project id.

  • shared – Visibility to other projects. Defaults to False.

Raises

BadRequestException if parameters are malformed

Raises

DuplicateResource on multiple matches

Raises

ResourceNotFound if (ingress-, egress-) firewall policy or a port is not found.

Returns

created firewall group

Return type

FirewallGroup

create_firewall_policy(**kwargs)

Create firewall policy.

Parameters
  • audited (bool) – Status of audition of firewall policy. Set to False each time the firewall policy or the associated firewall rules are changed. Has to be explicitly set to True.

  • description – Human-readable description.

  • firewall_rules (list[str]) – List of associated firewall rules.

  • name – Human-readable name.

  • project_id – Project id.

  • shared (bool) – Visibility to other projects. Defaults to False.

Raises

BadRequestException if parameters are malformed

Raises

ResourceNotFound if a resource from firewall_list not found

Returns

created firewall policy

Return type

FirewallPolicy

create_firewall_rule(**kwargs)

Creates firewall rule.

Parameters
  • action – Action performed on traffic. Valid values: allow, deny Defaults to deny.

  • description – Human-readable description.

  • destination_firewall_group_id – ID of destination firewall group.

  • destination_ip_address – IPv4-, IPv6 address or CIDR.

  • destination_port – Port or port range (e.g. 80:90)

  • enabled (bool) – Status of firewall rule. You can disable rules without disassociating them from firewall policies. Defaults to True.

  • ip_version (int) – IP Version. Valid values: 4, 6 Defaults to 4.

  • name – Human-readable name.

  • project_id – Project id.

  • protocol – IP protocol. Valid values: icmp, tcp, udp, null

  • shared (bool) – Visibility to other projects. Defaults to False.

  • source_firewall_group_id – ID of source firewall group.

  • source_ip_address – IPv4-, IPv6 address or CIDR.

  • source_port – Port or port range (e.g. 80:90)

Raises

BadRequestException if parameters are malformed

Returns

created firewall rule

Return type

FirewallRule

create_flavor(name, ram, vcpus, disk, flavorid='auto', ephemeral=0, swap=0, rxtx_factor=1.0, is_public=True)

Create a new flavor.

Parameters
  • name – Descriptive name of the flavor

  • ram – Memory in MB for the flavor

  • vcpus – Number of VCPUs for the flavor

  • disk – Size of local disk in GB

  • flavorid – ID for the flavor (optional)

  • ephemeral – Ephemeral space size in GB

  • swap – Swap space in MB

  • rxtx_factor – RX/TX factor

  • is_public – Make flavor accessible to the public

Returns

A munch.Munch describing the new flavor.

Raises

OpenStackCloudException on operation error.

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
  • network – Name or ID of the network that the floating IP should come from.

  • server – (optional) Server dict for the server to create the IP for and to which it should be attached.

  • fixed_address – (optional) Fixed IP to attach the floating ip to.

  • nat_destination – (optional) Name or ID of the network that the fixed IP to attach the floating IP to should be on.

  • port – (optional) The port ID that the floating IP should be attached to. Specifying a port conflicts with specifying a server, fixed_address or nat_destination.

  • wait – (optional) Whether to wait for the IP to be active. Defaults to False. Only applies if a server is provided.

  • timeout – (optional) How long to wait for the IP to be active. Defaults to 60. Only applies if a server is provided.

Returns

a floating IP address

Raises

OpenStackCloudException, on operation error.

create_group(name, description, domain=None)

Create a group.

Parameters
  • name (string) – Group name.

  • description (string) – Group description.

  • domain (string) – Domain name or ID for the group.

Returns

A munch.Munch containing the group description.

Raises

OpenStackCloudException: if something goes wrong during the OpenStack API call.

create_image(name, filename=None, container=None, md5=None, sha256=None, disk_format=None, container_format=None, disable_vendor_agent=True, wait=False, timeout=3600, tags=None, allow_duplicates=False, meta=None, volume=None, **kwargs)

Upload an image.

Parameters
  • name (str) – Name of the image to create. If it is a pathname of an image, the name will be constructed from the extensionless basename of the path.

  • filename (str) – The path to the file to upload, if needed. (optional, defaults to None)

  • container (str) – Name of the container in swift where images should be uploaded for import if the cloud requires such a thing. (optiona, defaults to ‘images’)

  • md5 (str) – md5 sum of the image file. If not given, an md5 will be calculated.

  • sha256 (str) – sha256 sum of the image file. If not given, an md5 will be calculated.

  • disk_format (str) – The disk format the image is in. (optional, defaults to the os-client-config config value for this cloud)

  • container_format (str) – The container format the image is in. (optional, defaults to the os-client-config config value for this cloud)

  • tags (list) – List of tags for this image. Each tag is a string of at most 255 chars.

  • disable_vendor_agent (bool) – Whether or not to append metadata flags to the image to inform the cloud in question to not expect a vendor agent to be runing. (optional, defaults to True)

  • wait (bool) – If true, waits for image to be created. Defaults to true - however, be aware that one of the upload methods is always synchronous.

  • timeout – Seconds to wait for image creation. None is forever.

  • allow_duplicates – If true, skips checks that enforce unique image name. (optional, defaults to False)

  • meta – A dict of key/value pairs to use for metadata that bypasses automatic type conversion.

  • volume – Name or ID or volume object of a volume to create an image from. Mutually exclusive with (optional, defaults to None)

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_image_snapshot(name, server, wait=False, timeout=3600, **metadata)

Create an image by snapshotting an existing server.

..note::

On most clouds this is a cold snapshot - meaning that the server in question will be shutdown before taking the snapshot. It is possible that it’s a live snapshot - but there is no way to know as a user, so caveat emptor.

Parameters
  • name – Name of the image to be created

  • server – Server name or ID or dict representing the server to be snapshotted

  • wait – If true, waits for image to be created.

  • timeout – Seconds to wait for image creation. None is forever.

  • metadata – Metadata to give newly-created image entity

Returns

A munch.Munch of the Image object

Raises

OpenStackCloudException if there are problems uploading

create_keypair(name, public_key=None)

Create a new keypair.

Parameters
  • name – Name of the keypair being created.

  • public_key – Public key for the new keypair.

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, port_security_enabled=None, mtu_size=None, dns_domain=None)

Create a network.

Parameters
  • name (string) – Name of the network being created.

  • shared (bool) – Set the network as shared.

  • admin_state_up (bool) – Set the network administrative state to up.

  • external (bool) – Whether this network is externally accessible.

  • provider (dict) –

    A dict of network provider options. Example:

    { 'network_type': 'vlan', 'segmentation_id': 'vlan1' }
    

  • project_id (string) – Specify the project ID this network will be created on (admin-only).

  • availability_zone_hints (types.ListType) – A list of availability zone hints.

  • port_security_enabled (bool) – Enable / Disable port security

  • mtu_size (int) – maximum transmission unit value to address fragmentation. Minimum value is 68 for IPv4, and 1280 for IPv6.

  • dns_domain (string) – Specify the DNS domain associated with this network.

Returns

The network object.

Raises

OpenStackCloudException on operation error.

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
  • container – The name of the container to store the file in. This container will be created if it does not exist already.

  • name – Name for the object within the container.

  • filename – The path to the local file whose contents will be uploaded. Mutually exclusive with data.

  • data – The content to upload to the object. Mutually exclusive with filename.

  • md5 – A hexadecimal md5 of the file. (Optional), if it is known and can be passed here, it will save repeating the expensive md5 process. It is assumed to be accurate.

  • sha256 – A hexadecimal sha256 of the file. (Optional) See md5.

  • segment_size – Break the uploaded object into segments of this many bytes. (Optional) Shade will attempt to discover the maximum value for this from the server if it is not specified, or will use a reasonable default.

  • headers – These will be passed through to the object creation API as HTTP Headers.

  • use_slo – If the object is large enough to need to be a Large Object, use a static rather than dynamic object. Static Objects will delete segment objects when the manifest object is deleted. (optional, defaults to True)

  • generate_checksums – Whether to generate checksums on the client side that get added to headers for later prevention of double uploads of identical data. (optional, defaults to True)

  • metadata – This dict will get changed into headers that set metadata of the object

Raises

OpenStackCloudException on operation error.

create_port(network_id, **kwargs)

Create a port

Parameters
  • network_id – The ID of the network. (Required)

  • name – A symbolic name for the port. (Optional)

  • admin_state_up – The administrative status of the port, which is up (true, default) or down (false). (Optional)

  • mac_address – The MAC address. (Optional)

  • fixed_ips

    List of ip_addresses and subnet_ids. See subnet_id and ip_address. (Optional) For example:

    [
      {
        "ip_address": "10.29.29.13",
        "subnet_id": "a78484c4-c380-4b47-85aa-21c51a2d8cbd"
      }, ...
    ]
    

  • subnet_id – If you specify only a subnet ID, OpenStack Networking allocates an available IP from that subnet to the port. (Optional) If you specify both a subnet ID and an IP address, OpenStack Networking tries to allocate the specified address to the port.

  • ip_address – If you specify both a subnet ID and an IP address, OpenStack Networking tries to allocate the specified address to the port.

  • security_groups – List of security group UUIDs. (Optional)

  • allowed_address_pairs

    Allowed address pairs list (Optional) For example:

    [
      {
        "ip_address": "23.23.23.1",
        "mac_address": "fa:16:3e:c4:cd:3f"
      }, ...
    ]
    

  • extra_dhcp_opts

    Extra DHCP options. (Optional). For example:

    [
      {
        "opt_name": "opt name1",
        "opt_value": "value1"
      }, ...
    ]
    

  • device_owner – The ID of the entity that uses this port. For example, a DHCP agent. (Optional)

  • device_id – The ID of the device that uses this port. For example, a virtual server. (Optional)

  • vnic_type (binding) – The type of the created port. (Optional)

  • port_security_enabled – The security port state created on the network. (Optional)

  • qos_policy_id – The ID of the QoS policy to apply for port.

Returns

a munch.Munch describing the created port.

Raises

OpenStackCloudException on operation error.

create_project(name, description=None, domain_id=None, enabled=True)

Create a project.

create_qos_bandwidth_limit_rule(policy_name_or_id, max_kbps, **kwargs)

Create a QoS bandwidth limit rule.

Parameters
  • policy_name_or_id (string) – Name or ID of the QoS policy to which rule should be associated.

  • max_kbps (int) – Maximum bandwidth limit value (in kilobits per second).

  • max_burst_kbps (int) – Maximum burst value (in kilobits).

  • direction (string) – Ingress or egress. The direction in which the traffic will be limited.

Returns

The QoS bandwidth limit rule.

Raises

OpenStackCloudException on operation error.

create_qos_dscp_marking_rule(policy_name_or_id, dscp_mark)

Create a QoS DSCP marking rule.

Parameters
  • policy_name_or_id (string) – Name or ID of the QoS policy to which rule should be associated.

  • dscp_mark (int) – DSCP mark value

Returns

The QoS DSCP marking rule.

Raises

OpenStackCloudException on operation error.

create_qos_minimum_bandwidth_rule(policy_name_or_id, min_kbps, **kwargs)

Create a QoS minimum bandwidth limit rule.

Parameters
  • policy_name_or_id (string) – Name or ID of the QoS policy to which rule should be associated.

  • min_kbps (int) – Minimum bandwidth value (in kilobits per second).

  • direction (string) – Ingress or egress. The direction in which the traffic will be available.

Returns

The QoS minimum bandwidth rule.

Raises

OpenStackCloudException on operation error.

create_qos_policy(**kwargs)

Create a QoS policy.

Parameters
  • name (string) – Name of the QoS policy being created.

  • description (string) – Description of created QoS policy.

  • shared (bool) – Set the QoS policy as shared.

  • default (bool) – Set the QoS policy as default for project.

  • project_id (string) – Specify the project ID this QoS policy will be created on (admin-only).

Returns

The QoS policy object.

Raises

OpenStackCloudException on operation error.

create_recordset(zone, name, recordset_type, records, description=None, ttl=None)

Create a recordset.

Parameters
  • zone – Name, ID or openstack.dns.v2.zone.Zone instance of the zone managing the recordset.

  • name – Name of the recordset

  • recordset_type – Type of the recordset

  • records – List of the recordset definitions

  • description – Description of the recordset

  • ttl – TTL value of the recordset

Returns

a dict representing the created recordset.

Raises

OpenStackCloudException on operation error.

create_role(name, **kwargs)

Create a Keystone role.

Parameters
  • name (string) – The name of the role.

  • domain_id – domain id (v3)

Returns

a munch.Munch containing the role description

Raises

OpenStackCloudException – if the role cannot be created

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
  • name (string) – The router name.

  • admin_state_up (bool) – The administrative state of the router.

  • ext_gateway_net_id (string) – Network ID for the external gateway.

  • enable_snat (bool) – Enable Source NAT (SNAT) attribute.

  • ext_fixed_ips

    List of dictionaries of desired IP and/or subnet on the external network. Example:

    [
      {
        "subnet_id": "8ca37218-28ff-41cb-9b10-039601ea7e6b",
        "ip_address": "192.168.10.2"
      }
    ]
    

  • project_id (string) – Project ID for the router.

  • availability_zone_hints (types.ListType) – A list of availability zone hints.

Returns

The router object.

Raises

OpenStackCloudException on operation error.

create_security_group(name, description, project_id=None, stateful=None)

Create a new security group

Parameters
  • name (string) – A name for the security group.

  • description (string) – Describes the security group.

  • project_id (string) – Specify the project ID this security group will be created on (admin-only).

  • stateful (string) – Whether the security group is stateful or not.

Returns

A munch.Munch representing the new security group.

Raises

OpenStackCloudException on operation error.

Raises

OpenStackCloudUnavailableFeature if security groups are not supported on this cloud.

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, remote_address_group_id=None, direction='ingress', ethertype='IPv4', project_id=None)

Create a new security group rule

Parameters
  • secgroup_name_or_id (string) – The security group name or ID to associate with this security group rule. If a non-unique group name is given, an exception is raised.

  • port_range_min (int) – The minimum port number in the range that is matched by the security group rule. If the protocol is TCP or UDP, this value must be less than or equal to the port_range_max attribute value. If nova is used by the cloud provider for security groups, then a value of None will be transformed to -1.

  • port_range_max (int) – The maximum port number in the range that is matched by the security group rule. The port_range_min attribute constrains the port_range_max attribute. If nova is used by the cloud provider for security groups, then a value of None will be transformed to -1.

  • protocol (string) – The protocol that is matched by the security group rule. Valid values are None, tcp, udp, and icmp.

  • remote_ip_prefix (string) – The remote IP prefix to be associated with this security group rule. This attribute matches the specified IP prefix as the source IP address of the IP packet.

  • remote_group_id (string) – The remote group ID to be associated with this security group rule.

  • remote_address_group_id (string) – The remote address group ID to be associated with this security group rule.

  • direction (string) – Ingress or egress: The direction in which the security group rule is applied. For a compute instance, an ingress security group rule is applied to incoming (ingress) traffic for that instance. An egress rule is applied to traffic leaving the instance.

  • ethertype (string) – Must be IPv4 or IPv6, and addresses represented in CIDR must match the ingress or egress rules.

  • project_id (string) – Specify the project ID this security group will be created on (admin-only).

Returns

A munch.Munch representing the new security group rule.

Raises

OpenStackCloudException on operation error.

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
  • name – Something to name the server.

  • image – Image dict, name or ID to boot with. image is required unless boot_volume is given.

  • flavor – Flavor dict, name or ID to boot onto.

  • auto_ip – Whether to take actions to find a routable IP for the server. (defaults to True)

  • ips – List of IPs to attach to the server (defaults to None)

  • ip_pool – Name of the network or floating IP pool to get an address from. (defaults to None)

  • root_volume – Name or ID of a volume to boot from (defaults to None - deprecated, use boot_volume)

  • boot_volume – Name or ID of a volume to boot from (defaults to None)

  • terminate_volume – If booting from a volume, whether it should be deleted when the server is destroyed. (defaults to False)

  • volumes – (optional) A list of volumes to attach to the server

  • meta – (optional) A dict of arbitrary key/value metadata to store for this server. Both keys and values must be <=255 characters.

  • files – (optional, deprecated) A dict of files to overwrite on the server upon boot. Keys are file names (i.e. /etc/passwd) and values are the file contents (either as a string or as a file-like object). A maximum of five entries is allowed, and each file must be 10k or less.

  • reservation_id – a UUID for the set of servers being requested.

  • min_count – (optional extension) The minimum number of servers to launch.

  • max_count – (optional extension) The maximum number of servers to launch.

  • security_groups – A list of security group names

  • userdata – user data to pass to be exposed by the metadata server this can be a file type object as well or a string.

  • key_name – (optional extension) name of previously created keypair to inject into the instance.

  • availability_zone – Name of the availability zone for instance placement.

  • block_device_mapping – (optional) A dict of block device mappings for this server.

  • block_device_mapping_v2 – (optional) A dict of block device mappings for this server.

  • nics – (optional extension) an ordered list of nics to be added to this server, with information about connected networks, fixed IPs, port etc.

  • scheduler_hints – (optional extension) arbitrary key-value pairs specified by the client to help boot an instance

  • config_drive – (optional extension) value for config drive either boolean, or volume-id

  • disk_config – (optional extension) control how the disk is partitioned when the server is created. possible values are ‘AUTO’ or ‘MANUAL’.

  • admin_pass – (optional extension) add a user supplied admin password.

  • wait – (optional) Wait for the address to appear as assigned to the server. Defaults to False.

  • timeout – (optional) Seconds to wait, defaults to 60. See the wait parameter.

  • reuse_ips – (optional) Whether to attempt to reuse pre-existing floating ips should a floating IP be needed (defaults to True)

  • network – (optional) Network dict or name or ID to attach the server to. Mutually exclusive with the nics parameter. Can also be a list of network names or IDs or network dicts.

  • boot_from_volume – Whether to boot from volume. ‘boot_volume’ implies True, but boot_from_volume=True with no boot_volume is valid and will create a volume from the image and use that.

  • volume_size – When booting an image from volume, how big should the created volume be? Defaults to 50.

  • nat_destination – Which network should a created floating IP be attached to, if it’s not possible to infer from the cloud’s configuration. (Optional, defaults to None)

  • group – ServerGroup dict, name or id to boot the server in. If a group is provided in both scheduler_hints and in the group param, the group param will win. (Optional, defaults to None)

Returns

A munch.Munch representing the created server.

Raises

OpenStackCloudException on operation error.

create_server_group(name, policies=[], policy=None)

Create a new server group.

Parameters
  • name – Name of the server group being created

  • policies – List of policies for the server group.

Returns

a dict representing the new server group.

Raises

OpenStackCloudException on operation error.

create_service(name, enabled=True, **kwargs)

Create a service.

Parameters
  • name – Service name.

  • type – Service type. (type or service_type required.)

  • service_type – Service type. (type or service_type required.)

  • description – Service description (optional).

  • enabled – Whether the service is enabled (v3 only)

Returns

a munch.Munch containing the services description, i.e. the following attributes:: - id: <service id> - name: <service name> - type: <service type> - service_type: <service type> - description: <service description>

Raises

OpenStackCloudException if something goes wrong during the OpenStack API call.

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
  • name (string) – Name of the stack.

  • tags – List of tag(s) of the stack. (optional)

  • template_file (string) – Path to the template.

  • template_url (string) – URL of template.

  • template_object (string) – URL to retrieve template object.

  • files (dict) – dict of additional file content to include.

  • rollback (boolean) – Enable rollback on create failure.

  • wait (boolean) – Whether to wait for the delete to finish.

  • timeout (int) – Stack create timeout in seconds.

  • environment_files – Paths to environment files to apply.

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

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, **kwargs)

Create a subnet on a specified network.

Parameters
  • network_name_or_id (string) – The unique name or ID of the attached network. If a non-unique name is supplied, an exception is raised.

  • cidr (string) – The CIDR.

  • ip_version (int) – The IP version, which is 4 or 6.

  • enable_dhcp (bool) – Set to True if DHCP is enabled and False if disabled. Default is False.

  • subnet_name (string) – The name of the subnet.

  • tenant_id (string) – The ID of the tenant who owns the network. Only administrative users can specify a tenant ID other than their own.

  • allocation_pools

    A list of dictionaries of the start and end addresses for the allocation pools. For example:

    [
      {
        "start": "192.168.199.2",
        "end": "192.168.199.254"
      }
    ]
    

  • gateway_ip (string) – The gateway IP address. When you specify both allocation_pools and gateway_ip, you must ensure that the gateway IP does not overlap with the specified allocation pools.

  • disable_gateway_ip (bool) – Set to True if gateway IP address is disabled and False if enabled. It is not allowed with gateway_ip. Default is False.

  • dns_nameservers

    A list of DNS name servers for the subnet. For example:

    [ "8.8.8.7", "8.8.8.8" ]
    

  • host_routes

    A list of host route dictionaries for the subnet. For example:

    [
      {
        "destination": "0.0.0.0/0",
        "nexthop": "123.456.78.9"
      },
      {
        "destination": "192.168.0.0/24",
        "nexthop": "192.168.0.1"
      }
    ]
    

  • ipv6_ra_mode (string) – IPv6 Router Advertisement mode. Valid values are: ‘dhcpv6-stateful’, ‘dhcpv6-stateless’, or ‘slaac’.

  • ipv6_address_mode (string) – IPv6 address mode. Valid values are: ‘dhcpv6-stateful’, ‘dhcpv6-stateless’, or ‘slaac’.

  • prefixlen (string) – The prefix length to use for subnet allocation from a subnet pool.

  • use_default_subnetpool (bool) – Use the default subnetpool for ip_version to obtain a CIDR. It is required to pass None to the cidr argument when enabling this option.

  • kwargs – Key value pairs to be passed to the Neutron API.

Returns

The new subnet object.

Raises

OpenStackCloudException on operation error.

create_user(name, password=None, email=None, default_project=None, enabled=True, domain_id=None, description=None)

Create a user.

create_volume(size, wait=True, timeout=None, image=None, bootable=None, **kwargs)

Create a volume.

Parameters
  • size – Size, in GB of the volume to create.

  • name – (optional) Name for the volume.

  • description – (optional) Name for the volume.

  • wait – If true, waits for volume to be created.

  • timeout – Seconds to wait for volume creation. None is forever.

  • image – (optional) Image name, ID or object from which to create the volume

  • bootable – (optional) Make this volume bootable. If set, wait will also be set to true.

  • kwargs – Keyword arguments as expected for cinder client.

Returns

The created volume object.

Raises

OpenStackCloudTimeout if wait time exceeded.

Raises

OpenStackCloudException on operation error.

create_volume_backup(volume_id, name=None, description=None, force=False, wait=True, timeout=None, incremental=False, snapshot_id=None)

Create a volume backup.

Parameters
  • volume_id – the ID of the volume to backup.

  • name – name of the backup, one will be generated if one is not provided

  • description – description of the backup, one will be generated if one is not provided

  • force – If set to True the backup will be created even if the volume is attached to an instance, if False it will not

  • wait – If true, waits for volume backup to be created.

  • timeout – Seconds to wait for volume backup creation. None is forever.

  • incremental – If set to true, the backup will be incremental.

  • snapshot_id – The UUID of the source snapshot to back up.

Returns

The created volume backup 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
  • volume_id – the ID of the volume to snapshot.

  • force – If set to True the snapshot will be created even if the volume is attached to an instance, if False it will not

  • name – name of the snapshot, one will be generated if one is not provided

  • description – description of the snapshot, one will be generated if one is not provided

  • wait – If true, waits for volume snapshot to be created.

  • timeout – Seconds to wait for volume snapshot creation. None is forever.

Returns

The created volume object.

Raises

OpenStackCloudTimeout if wait time exceeded.

Raises

OpenStackCloudException on operation error.

create_zone(name, zone_type=None, email=None, description=None, ttl=None, masters=None)

Create a new zone.

Parameters
  • name – Name of the zone being created.

  • zone_type – Type of the zone (primary/secondary)

  • email – Email of the zone owner (only applies if zone_type is primary)

  • description – Description of the zone

  • ttl – TTL (Time to live) value in seconds

  • masters – Master nameservers (only applies if zone_type is secondary)

Returns

a dict representing the created zone.

Raises

OpenStackCloudException on operation error.

property current_location

Return a munch.Munch explaining the current cloud location.

property current_project

Return a munch.Munch describing the current project

property 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
  • keystoneauth1.exceptions.auth.AuthorizationFailure – if a new token fetch fails.

  • keystoneauth1.exceptions.auth_plugins.MissingAuthPlugin – if a plugin is not available.

property current_user_id

Get the id of the currently logged-in user from the token.

delete_accelerator_request(name_or_id, filters)

Delete a accelerator_request. :param name_or_id: The Name(or uuid) of accelerator_request. :param filters: dict of filter conditions to push down :returns: True if delete succeeded, False otherwise.

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.

delete_autocreated_image_objects(container=None, segment_prefix=None)

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.

Parameters
  • container (str) – Name of the container. Defaults to ‘images’.

  • segment_prefix (str) – Prefix for the image segment names to delete. If not given, all image upload segments present are deleted.

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_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_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.

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.

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

delete_container(name)

Delete an object-store container.

Parameters

name (str) – Name of the container to delete.

delete_device_profile(name_or_id, filters)

Delete a device_profile. :param name_or_id: The Name(or uuid) of device_profile to be deleted. :param filters: dict of filter conditions to push down :returns: True if delete succeeded, False otherwise.

delete_domain(domain_id=None, name_or_id=None)

Delete a domain.

Parameters
  • domain_id – ID of the domain to delete.

  • name_or_id – Name or ID of the domain to delete.

Returns

True if delete succeeded, False otherwise.

Raises

OpenStackCloudException if something goes wrong during the OpenStack API call.

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.

delete_firewall_group(name_or_id, filters=None)

Deletes firewall group. Prints debug message in case to-be-deleted resource was not found.

Parameters
  • name_or_id – firewall group name or id

  • filters (dict) – optional filters

Raises

DuplicateResource on multiple matches

Returns

True if resource is successfully deleted, False otherwise.

Return type

bool

delete_firewall_policy(name_or_id, filters=None)

Deletes firewall policy. Prints debug message in case to-be-deleted resource was not found.

Parameters
  • name_or_id – firewall policy name or id

  • filters (dict) – optional filters

Raises

DuplicateResource on multiple matches

Returns

True if resource is successfully deleted, False otherwise.

Return type

bool

delete_firewall_rule(name_or_id, filters=None)

Deletes firewall rule. Prints debug message in case to-be-deleted resource was not found.

Parameters
  • name_or_id – firewall rule name or id

  • filters (dict) – optional filters

Raises

DuplicateResource on multiple matches

Returns

True if resource is successfully deleted, False otherwise.

Return type

bool

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.

delete_floating_ip(floating_ip_id, retry=1)

Deallocate a floating IP from a project.

Parameters
  • floating_ip_id – a floating IP address ID.

  • 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 the IP address has been deleted, False if the IP address was not found.

Raises

OpenStackCloudException, on operation error.

delete_group(name_or_id, **kwargs)

Delete a group

Parameters
  • name_or_id – ID or name of the group to delete.

  • domain_id – domain id.

Returns

True if delete succeeded, False otherwise.

Raises

OpenStackCloudException: if something goes wrong during the OpenStack API call.

delete_image(name_or_id, wait=False, timeout=3600, delete_objects=True)

Delete an existing image.

Parameters
  • name_or_id – Name of the image to be deleted.

  • wait – If True, waits for image to be deleted.

  • timeout – Seconds to wait for image deletion. None is forever.

  • delete_objects – If True, also deletes uploaded swift objects.

Returns

True if delete succeeded, False otherwise.

Raises

OpenStackCloudException if there are problems deleting.

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.

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.

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

delete_object(container, name, meta=None)

Delete an object from a container.

Parameters
  • container (string) – Name of the container holding the object.

  • name (string) – Name of the object to delete.

  • meta (dict) – Metadata for the object in question. (optional, will be fetched if not provided)

Returns

True if delete succeeded, False if the object was not found.

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.

delete_project(name_or_id, domain_id=None)

Delete a project.

Parameters
  • name_or_id (string) – Project name or ID.

  • domain_id (string) – Domain ID containing the project(identity v3 only).

Returns

True if delete succeeded, False if the project was not found.

Raises

OpenStackCloudException if something goes wrong during the OpenStack API call

delete_qos_bandwidth_limit_rule(policy_name_or_id, rule_id)

Delete a QoS bandwidth limit rule.

Parameters
  • policy_name_or_id (string) – Name or ID of the QoS policy to which rule is associated.

  • rule_id (string) – ID of rule to update.

Raises

OpenStackCloudException on operation error.

delete_qos_dscp_marking_rule(policy_name_or_id, rule_id)

Delete a QoS DSCP marking rule.

Parameters
  • policy_name_or_id (string) – Name or ID of the QoS policy to which rule is associated.

  • rule_id (string) – ID of rule to update.

Raises

OpenStackCloudException on operation error.

delete_qos_minimum_bandwidth_rule(policy_name_or_id, rule_id)

Delete a QoS minimum bandwidth rule.

Parameters
  • policy_name_or_id (string) – Name or ID of the QoS policy to which rule is associated.

  • rule_id (string) – ID of rule to delete.

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.

delete_recordset(zone, name_or_id)

Delete a recordset.

Parameters
  • zone – Name, ID or openstack.dns.v2.zone.Zone instance of the zone managing the recordset.

  • name_or_id – Name or ID of the recordset being deleted.

Returns

True if delete succeeded, False otherwise.

Raises

OpenStackCloudException on operation error.

delete_role(name_or_id, **kwargs)

Delete a Keystone role.

Parameters
  • id (string) – Name or id of the role to delete.

  • domain_id – domain id (v3)

Returns

True if delete succeeded, False otherwise.

Raises

OpenStackCloudException if something goes wrong during the OpenStack API call.

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.

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.

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.

delete_server(name_or_id, wait=False, timeout=180, delete_ips=False, delete_ip_retry=1)

Delete a server instance.

Parameters
  • name_or_id – name or ID of the server to delete

  • wait (bool) – If true, waits for server to be deleted.

  • timeout (int) – Seconds to wait for server deletion.

  • delete_ips (bool) – If true, deletes any floating IPs associated with the instance.

  • delete_ip_retry (int) – Number of times to retry deleting any floating ips, should the first try be unsuccessful.

Returns

True if delete succeeded, False otherwise if the server does not exist.

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.

delete_server_metadata(name_or_id, metadata_keys)

Delete metadata from a server instance.

Parameters
  • name_or_id (str) – The name or ID of the server instance to update.

  • metadata_keys – A list with the keys to be deleted from the server instance.

Raises

OpenStackCloudException on operation error.

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

delete_stack(name_or_id, wait=False)

Delete a stack

Parameters
  • name_or_id (string) – Stack name or ID.

  • wait (boolean) – Whether to wait for the delete to finish

Returns

True if delete succeeded, False if the stack was not found.

Raises

OpenStackCloudException if something goes wrong during the OpenStack API call

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.

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

Number of Floating IPs deleted, False if none

Raises

OpenStackCloudException, on operation error.

delete_volume(name_or_id=None, wait=True, timeout=None, force=False)

Delete a volume.

Parameters
  • name_or_id – Name or unique ID of the volume.

  • wait – If true, waits for volume to be deleted.

  • timeout – Seconds to wait for volume deletion. None is forever.

  • force – Force delete volume even if the volume is in deleting or error_deleting state.

Raises

OpenStackCloudTimeout if wait time exceeded.

Raises

OpenStackCloudException on operation error.

delete_volume_backup(name_or_id=None, force=False, wait=False, timeout=None)

Delete a volume backup.

Parameters
  • name_or_id – Name or unique ID of the volume backup.

  • force – Allow delete in state other than error or available.

  • wait – If true, waits for volume backup to be deleted.

  • timeout – Seconds to wait for volume backup deletion. None is forever.

Raises

OpenStackCloudTimeout if wait time exceeded.

Raises

OpenStackCloudException on operation error.

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

delete_volume_snapshot(name_or_id=None, wait=False, timeout=None)

Delete a volume snapshot.

Parameters
  • name_or_id – Name or unique ID of the volume snapshot.

  • wait – If true, waits for volume snapshot to be deleted.

  • timeout – Seconds to wait for volume snapshot deletion. None is forever.

Raises

OpenStackCloudTimeout if wait time exceeded.

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.

detach_ip_from_server(server_id, floating_ip_id)

Detach a floating IP from a server.

Parameters
  • server_id – ID of a server.

  • floating_ip_id – Id of the floating IP to detach.

Returns

True if the IP has been detached, or False if the IP wasn’t attached to any server.

Raises

OpenStackCloudException, on operation error.

detach_port_from_machine(name_or_id, port_name_or_id)

Detach a virtual port from the bare metal machine.

Parameters
  • name_or_id (string) – A machine name or UUID.

  • port_name_or_id (string) – A port name or UUID. Note that this is a Network service port, not a bare metal NIC.

Returns

Nothing.

detach_volume(server, volume, wait=True, timeout=None)

Detach a volume from a server.

Parameters
  • server – The server dict to detach from.

  • volume – The volume dict to detach.

  • wait – If true, waits for volume to be detached.

  • timeout – Seconds to wait for volume detachment. None is forever.

Raises

OpenStackCloudTimeout if wait time exceeded.

Raises

OpenStackCloudException on operation error.

download_image(name_or_id, output_path=None, output_file=None, chunk_size=1024)

Download an image by name or ID

Parameters
  • name_or_id (str) – Name or ID of the image.

  • output_path – the output path to write the image to. Either this or output_file must be specified

  • output_file – a file object (or file-like object) to write the image data to. Only write() will be called on this object. Either this or output_path must be specified

  • chunk_size (int) – size in bytes to read from the wire and buffer at one time. Defaults to 1024

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

endpoint_for(service_type, interface=None, region_name=None)

Return the endpoint for a given service.

Respects config values for Connection, including *_endpoint_override. For direct values from the catalog regardless of overrides, see get_endpoint_from_catalog()

Parameters
  • service_type – Service Type of the endpoint to search for.

  • interface – Interface of the endpoint to search for. Optional, defaults to the configured value for interface for this Connection.

  • region_name – Region Name of the endpoint to search for. Optional, defaults to the configured value for region_name for this Connection.

Returns

The endpoint of the service, or None if not found.

get_aggregate(name_or_id, filters=None)

Get an aggregate by name or ID.

Parameters
  • name_or_id – Name or ID of the aggregate.

  • filters (dict) –

    A dictionary of meta data to use for further filtering. Elements of this dictionary may, themselves, be dictionaries. Example:

    {
      'availability_zone': 'nova',
      'metadata': {
          'cpu_allocation_ratio': '1.0'
      }
    }
    

Returns

An aggregate dict or None if no matching aggregate is found.

get_baymodel(name_or_id, filters=None, detail=False)

Get a cluster template by name or ID.

Parameters
  • name_or_id – Name or ID of the cluster template.

  • filters

    A dictionary of meta data to use for further filtering. Elements of this dictionary may, themselves, be dictionaries. Example:

    {
      'last_name': 'Smith',
      'other': {
          'gender': 'Female'
      }
    }
    

    OR A string containing a jmespath expression for further filtering. Example:: “[?last_name==`Smith`] | [?other.gender]==`Female`]”

Returns

A cluster template dict or None if no matching cluster template is found.

get_cluster_template(name_or_id, filters=None, detail=False)

Get a cluster template by name or ID.

Parameters
  • name_or_id – Name or ID of the cluster template.

  • filters

    A dictionary of meta data to use for further filtering. Elements of this dictionary may, themselves, be dictionaries. Example:

    {
      'last_name': 'Smith',
      'other': {
          'gender': 'Female'
      }
    }
    

    OR A string containing a jmespath expression for further filtering. Example:: “[?last_name==`Smith`] | [?other.gender]==`Female`]”

Returns

A cluster template dict or None if no matching cluster template is found.

get_coe_cluster(name_or_id, filters=None)

Get a COE cluster by name or ID.

Parameters
  • name_or_id – Name or ID of the cluster.

  • filters

    A dictionary of meta data to use for further filtering. Elements of this dictionary may, themselves, be dictionaries. Example:

    {
      'last_name': 'Smith',
      'other': {
          'gender': 'Female'
      }
    }
    

    OR A string containing a jmespath expression for further filtering. Example:: “[?last_name==`Smith`] | [?other.gender]==`Female`]”

Returns

A cluster dict or None if no matching cluster is found.

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.

get_coe_cluster_template(name_or_id, filters=None, detail=False)

Get a cluster template by name or ID.

Parameters
  • name_or_id – Name or ID of the cluster template.

  • filters

    A dictionary of meta data to use for further filtering. Elements of this dictionary may, themselves, be dictionaries. Example:

    {
      'last_name': 'Smith',
      'other': {
          'gender': 'Female'
      }
    }
    

    OR A string containing a jmespath expression for further filtering. Example:: “[?last_name==`Smith`] | [?other.gender]==`Female`]”

Returns

A cluster template dict or None if no matching cluster template is found.

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

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

get_compute_usage(name_or_id, start=None, end=None)

Get usage for a specific project

Parameters
  • name_or_id – project name or id

  • startdatetime.datetime or string. Start date in UTC Defaults to 2010-07-06T12:00:00Z (the date the OpenStack project was started)

  • enddatetime.datetime or string. End date in UTC. Defaults to now

Raises

OpenStackCloudException if it’s not a valid project

Returns

Munch object with the usage

get_container(name, skip_cache=False)

Get metadata about a container.

Parameters
  • name (str) – Name of the container to get metadata for.

  • skip_cache (bool) – Ignore the cache of container metadata for this container.o Defaults to False.

get_container_access(name)

Get the control list from a container.

Parameters

name (str) – Name of the container.

get_default_network()

Return the network that is configured to be the default interface.

Returns

A network dict if one is found

get_domain(domain_id=None, name_or_id=None, filters=None)

Get exactly one Keystone domain.

Parameters
  • domain_id – domain id.

  • name_or_id – domain name or id.

  • filters (dict) – A dict containing additional filters to use. Keys to search on are id, name, enabled and description.

Returns

a munch.Munch containing the domain description, or None if not found. Each munch.Munch contains the following attributes:: - id: <domain id> - name: <domain name> - description: <domain description>

Raises

OpenStackCloudException: if something goes wrong during the OpenStack API call.

get_endpoint(id, filters=None)

Get exactly one Keystone endpoint.

Parameters
  • id – endpoint id.

  • filters – a dict containing additional filters to use. e.g. {‘region’: ‘region-a.geo-1’}

Returns

a munch.Munch containing the endpoint description. i.e. a munch.Munch containing the following attributes:: - id: <endpoint id> - region: <endpoint region> - public_url: <endpoint public url> - internal_url: <endpoint internal url> (optional) - admin_url: <endpoint admin url> (optional)

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_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_ipv6_networks()

Return the networks that are configured to route northbound.

Returns

A list of network munch.Munch 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_firewall_group(name_or_id, filters=None)

Retrieves firewall group.

Parameters
  • name_or_id – firewall group name or id

  • filters (dict) – optional filters

Raises

DuplicateResource on multiple matches

Returns

firewall group or None if not found

Return type

FirewallGroup

get_firewall_policy(name_or_id, filters=None)

Retrieves a single firewall policy.

Parameters
  • name_or_id – firewall policy name or id

  • filters (dict) – optional filters

Raises

DuplicateResource on multiple matches

Returns

firewall policy or None if not found

Return type

FirewallPolicy

get_firewall_rule(name_or_id, filters=None)

Retrieves a single firewall rule.

Parameters
  • name_or_id – firewall rule name or id

  • filters (dict) – optional filters

Raises

DuplicateResource on multiple matches

Returns

firewall rule dict or None if not found

Return type

FirewallRule

get_flavor(name_or_id, filters=None, get_extra=True)

Get a flavor by name or ID.

Parameters
  • name_or_id – Name or ID of the flavor.

  • filters

    A dictionary of meta data to use for further filtering. Elements of this dictionary may, themselves, be dictionaries. Example:

    {
      'last_name': 'Smith',
      'other': {
          'gender': 'Female'
      }
    }
    

    OR A string containing a jmespath expression for further filtering. Example:: “[?last_name==`Smith`] | [?other.gender]==`Female`]”

  • get_extra – Whether or not the list_flavors call should get the extra flavor specs.

Returns

A flavor munch.Munch or None if no matching flavor is found.

get_flavor_by_id(id, get_extra=False)

Get a flavor by ID

Parameters
  • id – ID of the flavor.

  • get_extra – Whether or not the list_flavors call should get the extra flavor specs.

Returns

A flavor munch.Munch.

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
  • ram (int) – Minimum amount of RAM.

  • include (string) – If given, will return a flavor whose name contains this string as a substring.

get_floating_ip(id, filters=None)

Get a floating IP by ID

Parameters
  • id – ID of the floating IP.

  • filters

    A dictionary of meta data to use for further filtering. Elements of this dictionary may, themselves, be dictionaries. Example:

    {
      'last_name': 'Smith',
      'other': {
          'gender': 'Female'
      }
    }
    

    OR A string containing a jmespath expression for further filtering. Example:: “[?last_name==`Smith`] | [?other.gender]==`Female`]”

Returns

A floating IP munch.Munch or None if no matching floating IP is found.

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_group(name_or_id, filters=None, **kwargs)

Get exactly one Keystone group.

Parameters
  • id – Group name or id.

  • filters – A dict containing additional filters to use.

  • domain_id – domain id.

Returns

A munch.Munch containing the group description.

Raises

OpenStackCloudException: if something goes wrong during the OpenStack API call.

get_image(name_or_id, filters=None)

Get an image by name or ID.

Parameters
  • name_or_id – Name or ID of the image.

  • filters

    A dictionary of meta data to use for further filtering. Elements of this dictionary may, themselves, be dictionaries. Example:

    {
      'last_name': 'Smith',
      'other': {
          'gender': 'Female'
      }
    }
    

    OR A string containing a jmespath expression for further filtering. Example:: “[?last_name==`Smith`] | [?other.gender]==`Female`]”

Returns

An image munch.Munch or None if no matching image is found

get_image_by_id(id)

Get a image by ID

Parameters

id – ID of the image.

Returns

An image munch.Munch.

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_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_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_keypair(name_or_id, filters=None)

Get a keypair by name or ID.

Parameters
  • name_or_id – Name or ID of the keypair.

  • filters

    A dictionary of meta data to use for further filtering. Elements of this dictionary may, themselves, be dictionaries. Example:

    {
      'last_name': 'Smith',
      'other': {
          'gender': 'Female'
      }
    }
    

    OR A string containing a jmespath expression for further filtering. Example:: “[?last_name==`Smith`] | [?other.gender]==`Female`]”

Returns

A keypair munch.Munch or None if no matching keypair is found.

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.

get_nat_destination()

Return the network that is configured to be the NAT destination.

Returns

A network dict if one is found

get_nat_source()

Return the network that is configured to be the NAT destination.

Returns

A network dict if one is found

get_network(name_or_id, filters=None)

Get a network by name or ID.

Parameters
  • name_or_id – Name or ID of the network.

  • filters

    A dictionary of meta data to use for further filtering. Elements of this dictionary may, themselves, be dictionaries. Example:

    {
      'last_name': 'Smith',
      'other': {
          'gender': 'Female'
      }
    }
    

    OR A string containing a jmespath expression for further filtering. Example:: “[?last_name==`Smith`] | [?other.gender]==`Female`]”

Returns

A network munch.Munch or None if no matching network is found.

get_network_by_id(id)

Get a network by ID

Parameters

id – ID of the network.

Returns

A network munch.Munch.

get_network_extensions()

Get Cloud provided network extensions

Returns

set of Neutron extension aliases

get_network_quotas(name_or_id, details=False)

Get network quotas for a project

Parameters
  • name_or_id – project name or id

  • details – if set to True it will return details about usage of quotas by given project

Raises

OpenStackCloudException if it’s not a valid project

Returns

Munch object with the quotas

get_nic_by_mac(mac)

Get bare metal NIC by its hardware address (usually MAC).

get_object(container, obj, query_string=None, resp_chunk_size=1024, outfile=None, stream=False)

Get the headers and body of an object

Parameters
  • container (string) – name of the container.

  • obj (string) – name of the object.

  • query_string (string) – query args for uri. (delimiter, prefix, etc.)

  • resp_chunk_size (int) – chunk size of data to read. Only used if the results are being written to a file or stream is True. (optional, defaults to 1k)

  • outfile – Write the object to a file instead of returning the contents. If this option is given, body in the return tuple will be None. outfile can either be a file path given as a string, or a File like object.

Returns

Tuple (headers, body) of the object, or None if the object is not found (404).

Raises

OpenStackCloudException on operation error.

get_object_raw(container, obj, query_string=None, stream=False)

Get a raw response object for an object.

Parameters
  • container (string) – name of the container.

  • obj (string) – name of the object.

  • query_string (string) – query args for uri. (delimiter, prefix, etc.)

  • stream (bool) – Whether to stream the response or not.

Returns

A requests.Response

Raises

OpenStackCloudException on operation error.

get_object_segment_size(segment_size)

Get a segment size that will work given capabilities

get_port(name_or_id, filters=None)

Get a port by name or ID.

Parameters
  • name_or_id – Name or ID of the port.

  • filters

    A dictionary of meta data to use for further filtering. Elements of this dictionary may, themselves, be dictionaries. Example:

    {
      'last_name': 'Smith',
      'other': {
          'gender': 'Female'
      }
    }
    

    OR A string containing a jmespath expression for further filtering. Example:: “[?last_name==`Smith`] | [?other.gender]==`Female`]”

Returns

A port munch.Munch or None if no matching port is found.

get_port_by_id(id)

Get a port by ID

Parameters

id – ID of the port.

Returns

A port munch.Munch.

get_project(name_or_id, filters=None, domain_id=None)

Get exactly one project.

Parameters
  • name_or_id – project name or ID.

  • filters – a dict containing additional filters to use.

  • domain_id – domain ID (identity v3 only).

Returns

a list of munch.Munch containing the project description.

Raises

OpenStackCloudException: if something goes wrong during the OpenStack API call.

get_qos_bandwidth_limit_rule(policy_name_or_id, rule_id)

Get a QoS bandwidth limit rule by name or ID.

Parameters
  • policy_name_or_id (string) – Name or ID of the QoS policy to which rule should be associated.

  • rule_id – ID of the rule.

Returns

A bandwidth limit rule munch.Munch or None if no matching rule is found.

get_qos_dscp_marking_rule(policy_name_or_id, rule_id)

Get a QoS DSCP marking rule by name or ID.

Parameters
  • policy_name_or_id (string) – Name or ID of the QoS policy to which rule should be associated.

  • rule_id – ID of the rule.

Returns

A bandwidth limit rule munch.Munch or None if no matching rule is found.

get_qos_minimum_bandwidth_rule(policy_name_or_id, rule_id)

Get a QoS minimum bandwidth rule by name or ID.

Parameters
  • policy_name_or_id (string) – Name or ID of the QoS policy to which rule should be associated.

  • rule_id – ID of the rule.

Returns

A bandwidth limit rule munch.Munch or None if no matching rule is found.

get_qos_policy(name_or_id, filters=None)

Get a QoS policy by name or ID.

Parameters
  • name_or_id – Name or ID of the policy.

  • filters

    A dictionary of meta data to use for further filtering. Elements of this dictionary may, themselves, be dictionaries. Example:

    {
      'last_name': 'Smith',
      'other': {
          'gender': 'Female'
      }
    }
    

    OR A string containing a jmespath expression for further filtering. Example:: “[?last_name==`Smith`] | [?other.gender]==`Female`]”

Returns

A policy munch.Munch or None if no matching network is found.

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.

get_recordset(zone, name_or_id)

Get a recordset by name or ID.

Parameters
  • zone – Name, ID or openstack.dns.v2.zone.Zone instance of the zone managing the recordset.

  • name_or_id – Name or ID of the recordset

Returns

A recordset dict or None if no matching recordset is found.

get_role(name_or_id, filters=None, **kwargs)

Get exactly one Keystone role.

Parameters
  • id – role name or id.

  • filters – a dict containing additional filters to use.

  • domain_id – domain id (v3)

Returns

a single munch.Munch containing the role description. Each munch.Munch contains the following attributes:

- id: <role id>
- name: <role name>
- description: <role description>

Raises

OpenStackCloudException: if something goes wrong during the OpenStack API call.

get_router(name_or_id, filters=None)

Get a router by name or ID.

Parameters
  • name_or_id – Name or ID of the router.

  • filters

    A dictionary of meta data to use for further filtering. Elements of this dictionary may, themselves, be dictionaries. Example:

    {
      'last_name': 'Smith',
      'other': {
          'gender': 'Female'
      }
    }
    

    OR A string containing a jmespath expression for further filtering. Example:: “[?last_name==`Smith`] | [?other.gender]==`Female`]”

Returns

A router munch.Munch or None if no matching router is found.

get_security_group(name_or_id, filters=None)

Get a security group by name or ID.

Parameters
  • name_or_id – Name or ID of the security group.

  • filters

    A dictionary of meta data to use for further filtering. Elements of this dictionary may, themselves, be dictionaries. Example:

    {
      'last_name': 'Smith',
      'other': {
          'gender': 'Female'
      }
    }
    

    OR A string containing a jmespath expression for further filtering. Example:: “[?last_name==`Smith`] | [?other.gender]==`Female`]”

Returns

A security group munch.Munch or None if no matching security group is found.

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(name_or_id=None, filters=None, detailed=False, bare=False, all_projects=False)

Get a server by name or ID.

Parameters
  • name_or_id – Name or ID of the server.

  • filters

    A dictionary of meta data to use for further filtering. Elements of this dictionary may, themselves, be dictionaries. Example:

    {
      'last_name': 'Smith',
      'other': {
          'gender': 'Female'
      }
    }
    

    OR A string containing a jmespath expression for further filtering. Example:: “[?last_name==`Smith`] | [?other.gender]==`Female`]”

  • detailed – Whether or not to add detailed additional information. Defaults to False.

  • bare – Whether to skip adding any additional information to the server record. Defaults to False, meaning the addresses dict will be populated as needed from neutron. Setting to True implies detailed = False.

  • all_projects – Whether to get server from all projects or just the current auth scoped project.

Returns

A server munch.Munch or None if no matching server is found.

get_server_by_id(id)

Get a server by ID.

Parameters

id – ID of the server.

Returns

A server dict or None if no matching server is found.

get_server_console(server, length=None)

Get the console log for a server.

Parameters
  • server – The server to fetch the console log for. Can be either a server dict or the Name or ID of the server.

  • length (int) – The number of lines you would like to retrieve from the end of the log. (optional, defaults to all)

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_group(name_or_id=None, filters=None)

Get a server group by name or ID.

Parameters
  • name_or_id – Name or ID of the server group.

  • filters

    A dictionary of meta data to use for further filtering. Elements of this dictionary may, themselves, be dictionaries. Example:

    {
      'policy': 'affinity',
    }
    

    OR A string containing a jmespath expression for further filtering. Example:: “[?last_name==`Smith`] | [?other.gender]==`Female`]”

Returns

A server groups dict or None if no matching server group is found.

get_service(name_or_id, filters=None)

Get exactly one Keystone service.

Parameters
  • name_or_id – Name or id of the desired service.

  • filters – a dict containing additional filters to use. e.g. {‘type’: ‘network’}

Returns

a munch.Munch containing the services description, i.e. the following attributes:: - id: <service id> - name: <service name> - type: <service type> - description: <service description>

Raises

OpenStackCloudException if something goes wrong during the OpenStack API call or if multiple matches are found.

get_stack(name_or_id, filters=None, resolve_outputs=True)

Get exactly one stack.

Parameters
  • name_or_id – Name or ID of the desired stack.

  • filters – a dict containing additional filters to use. e.g. {‘stack_status’: ‘CREATE_COMPLETE’}

  • resolve_outputs – If True, then outputs for this stack will be resolved

Returns

a munch.Munch containing the stack description

Raises

OpenStackCloudException if something goes wrong during the OpenStack API call or if multiple matches are found.

get_subnet(name_or_id, filters=None)

Get a subnet by name or ID.

Parameters
  • name_or_id – Name or ID of the subnet.

  • filters

    A dictionary of meta data to use for further filtering. Elements of this dictionary may, themselves, be dictionaries. Example:

    {
      'last_name': 'Smith',
      'other': {
          'gender': 'Female'
      }
    }
    

Returns

A subnet munch.Munch or None if no matching subnet is found.

get_subnet_by_id(id)

Get a subnet by ID

Parameters

id – ID of the subnet.

Returns

A subnet munch.Munch.

get_user(name_or_id, filters=None, **kwargs)

Get exactly one user.

Parameters
  • name_or_id (string) – user name or ID.

  • domain_id – Domain ID. (v3)

  • filters – a dict containing additional filters to use. OR A string containing a jmespath expression for further filtering. Example:: “[?last_name==`Smith`] | [?other.gender]==`Female`]”

Returns

a single munch.Munch containing the user description.

Raises

OpenStackCloudException: if something goes wrong during the OpenStack API call.

get_user_by_id(user_id, normalize=True)

Get a user by ID.

Parameters
  • user_id (string) – user ID

  • normalize (bool) – Flag to control dict normalization

Returns

a single munch.Munch containing the user description

get_volume(name_or_id, filters=None)

Get a volume by name or ID.

Parameters
  • name_or_id – Name or ID of the volume.

  • filters

    A dictionary of meta data to use for further filtering. Elements of this dictionary may, themselves, be dictionaries. Example:

    {
      'last_name': 'Smith',
      'other': {
          'gender': 'Female'
      }
    }
    

    OR A string containing a jmespath expression for further filtering. Example:: “[?last_name==`Smith`] | [?other.gender]==`Female`]”

Returns

A volume munch.Munch or None if no matching volume is found.

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
  • volume – Volume dict

  • server_id – ID of server to check

Returns

Device name if attached, None if volume is not attached.

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.

get_volume_by_id(id)

Get a volume by ID

Parameters

id – ID of the volume.

Returns

A volume munch.Munch.

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_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

get_volume_snapshot(name_or_id, filters=None)

Get a volume by name or ID.

Parameters
  • name_or_id – Name or ID of the volume snapshot.

  • filters

    A dictionary of meta data to use for further filtering. Elements of this dictionary may, themselves, be dictionaries. Example:

    {
      'last_name': 'Smith',
      'other': {
          'gender': 'Female'
      }
    }
    

    OR A string containing a jmespath expression for further filtering. Example:: “[?last_name==`Smith`] | [?other.gender]==`Female`]”

Returns

A volume munch.Munch or None if no matching volume is found.

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_type(name_or_id, filters=None)

Get a volume type by name or ID.

Parameters
  • name_or_id – Name or ID of the volume.

  • filters

    A dictionary of meta data to use for further filtering. Elements of this dictionary may, themselves, be dictionaries. Example:

    {
      'last_name': 'Smith',
      'other': {
          'gender': 'Female'
      }
    }
    

    OR A string containing a jmespath expression for further filtering. Example:: “[?last_name==`Smith`] | [?other.gender]==`Female`]”

Returns

A volume munch.Munch or None if no matching volume is found.

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.

get_zone(name_or_id, filters=None)

Get a zone by name or ID.

Parameters
  • name_or_id – Name or ID of the zone

  • filters – A dictionary of meta data to use for further filtering

Returns

A zone dict or None if no matching zone is found.

global_request(global_request_id)

Make a new Connection object with a global request id set.

Take the existing settings from the current Connection and construct a new Connection object with the global_request_id overridden.

from oslo_context import context
cloud = openstack.connect(cloud='example')
# Work normally
servers = cloud.list_servers()
cloud2 = cloud.global_request(context.generate_request_id())
# cloud2 sends all requests with global_request_id set
servers = cloud2.list_servers()

Additionally, this can be used as a context manager:

from oslo_context import context
c = openstack.connect(cloud='example')
# Work normally
servers = c.list_servers()
with c.global_request(context.generate_request_id()) as c2:
    # c2 sends all requests with global_request_id set
    servers = c2.list_servers()
Parameters

global_request_id – The global_request_id to send.

grant_role(name_or_id, user=None, group=None, project=None, domain=None, wait=False, timeout=60)

Grant a role to a user.

Parameters
  • name_or_id (string) – The name or id of the role.

  • user (string) – The name or id of the user.

  • group (string) – The name or id of the group. (v3)

  • project (string) – The name or id of the project.

  • domain (string) – The id of the domain. (v3)

  • wait (bool) – Wait for role to be granted

  • timeout (int) – Timeout to wait for role to be granted

NOTE: domain is a required argument when the grant is on a project,

user or group specified by name. In that situation, they are all considered to be in that domain. If different domains are in use in the same role grant, it is required to specify those by ID.

NOTE: for wait and timeout, sometimes granting roles is not

instantaneous.

NOTE: project is required for keystone v2

Returns

True if the role is assigned, otherwise False

Raises

OpenStackCloudException – if the role cannot be granted

insert_rule_into_policy(name_or_id, rule_name_or_id, insert_after=None, insert_before=None, filters=None)

Adds firewall rule to the firewall_rules list of a firewall policy. Short-circuits and returns the firewall policy early if the firewall rule id is already present in the firewall_rules list. This method doesn’t do re-ordering. If you want to move a firewall rule or down the list, you have to remove and re-add it.

Parameters
  • name_or_id – firewall policy name or id

  • rule_name_or_id – firewall rule name or id

  • insert_after – rule name or id that should precede added rule

  • insert_before – rule name or id that should succeed added rule

  • filters (dict) – optional filters

Raises

DuplicateResource on multiple matches

Raises

ResourceNotFound if firewall policy or any of the firewall rules (inserted, after, before) is not found.

Returns

updated firewall policy

Return type

FirewallPolicy

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
  • name_or_id – String representing machine name or UUID value in order to identify the machine.

  • wait – Boolean value controlling if the method is to wait for the desired state to be reached or a failure to occur.

  • timeout – Integer value, defautling to 3600 seconds, for the$ wait state to reach completion.

Returns

munch.Munch representing the current state of the machine upon exit of the method.

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
  • container – Name of the container.

  • name – Name of the object.

  • filename – Path to the file.

  • file_md5 – Pre-calculated md5 of the file contents. Defaults to None which means calculate locally.

  • file_sha256 – Pre-calculated sha256 of the file contents. Defaults to None which means calculate locally.

is_user_in_group(name_or_id, group_name_or_id)

Check to see if a user is in a group.

Parameters
  • name_or_id (string) – User name or ID

  • group_name_or_id (string) – Group name or ID

Returns

True if user is in the group, False otherwise

Raises

OpenStackCloudException if something goes wrong during the OpenStack API call

list_accelerator_requests(filters=None)

List all accelerator_requests. :param filters: (optional) dict of filter conditions to push down :returns: A list of accelerator request info.

list_aggregates(filters={})

List all available host aggregates.

Returns

A list of aggregate dicts.

list_containers(full_listing=True, prefix=None)

List containers.

Parameters

full_listing – Ignored. Present for backwards compat

Returns

list of Munch of the container objects

Raises

OpenStackCloudException on operation error.

list_deployables(filters=None)

List all available deployables. :param filters: (optional) dict of filter conditions to push down :returns: A list of deployable info.

list_device_profiles(filters=None)

List all device_profiles. :param filters: (optional) dict of filter conditions to push down :returns: A list of device profile info.

list_devices(filters=None)

List all devices. :param filters: (optional) dict of filter conditions to push down :returns: A list of device info.

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.

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.

list_firewall_groups(filters=None)

Lists firewall groups.

Parameters

filters (dict) – optional filters

Returns

list of firewall groups

Return type

list[FirewallGroup]

list_firewall_policies(filters=None)

Lists firewall policies.

Parameters

filters (dict) – optional filters

Returns

list of firewall policies

Return type

list[FirewallPolicy]

list_firewall_rules(filters=None)

Lists firewall rules.

Parameters

filters (dict) – optional filters

Returns

list of firewall rules

Return type

list[FirewallRule]

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.

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.

list_hypervisors(filters={})

List all hypervisors

Returns

A list of hypervisor munch.Munch.

list_keypairs(filters=None)

List all available keypairs.

Returns

A list of munch.Munch containing keypair info.

list_machines()

List Machines.

Returns

list of munch.Munch representing machines.

list_magnum_services()

List all Magnum services. :returns: a list of dicts containing the service details.

Raises

OpenStackCloudException on operation error.

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_nics()

Return a list of all bare metal ports.

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.

list_objects(container, full_listing=True, prefix=None)

List objects.

Parameters
  • container – Name of the container to list objects in.

  • full_listing – Ignored. Present for backwards compat

  • prefix (string) – only objects with this prefix will be returned. (optional)

Returns

list of Munch of the objects

Raises

OpenStackCloudException on operation error.

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_ports_attached_to_machine(name_or_id)

List virtual ports attached to the bare metal machine.

Parameters

name_or_id (string) – A machine name or UUID.

Returns

List of munch.Munch representing the ports.

list_qos_bandwidth_limit_rules(policy_name_or_id, filters=None)

List all available QoS bandwidth limit rules.

Parameters
  • policy_name_or_id (string) – Name or ID of the QoS policy from from rules should be listed.

  • filters – (optional) dict of filter conditions to push down

Returns

A list of munch.Munch containing rule info.

Raises

OpenStackCloudResourceNotFound if QoS policy will not be found.

list_qos_dscp_marking_rules(policy_name_or_id, filters=None)

List all available QoS DSCP marking rules.

Parameters
  • policy_name_or_id (string) – Name or ID of the QoS policy from from rules should be listed.

  • filters – (optional) dict of filter conditions to push down

Returns

A list of munch.Munch containing rule info.

Raises

OpenStackCloudResourceNotFound if QoS policy will not be found.

list_qos_minimum_bandwidth_rules(policy_name_or_id, filters=None)

List all available QoS minimum bandwidth rules.

Parameters
  • policy_name_or_id (string) – Name or ID of the QoS policy from from rules should be listed.

  • filters – (optional) dict of filter conditions to push down

Returns

A list of munch.Munch containing rule info.

Raises

OpenStackCloudResourceNotFound if QoS policy will not be 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_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.

list_recordsets(zone)

List all available recordsets.

Parameters

zone – Name, ID or openstack.dns.v2.zone.Zone instance of the zone managing the recordset.

Returns

A list of recordsets.

list_role_assignments(filters=None)

List Keystone role assignments

Parameters

filters (dict) –

Dict of filter conditions. Acceptable keys are:

  • ’user’ (string) - User ID to be used as query filter.

  • ’group’ (string) - Group ID to be used as query filter.

  • ’project’ (string) - Project ID to be used as query filter.

  • ’domain’ (string) - Domain ID to be used as query filter.

  • ’role’ (string) - Role ID to be used as query filter.

  • ’os_inherit_extension_inherited_to’ (string) - Return inherited role assignments for either ‘projects’ or ‘domains’

  • ’effective’ (boolean) - Return effective role assignments.

  • ’include_subtree’ (boolean) - Include subtree

’user’ and ‘group’ are mutually exclusive, as are ‘domain’ and ‘project’.

NOTE: For keystone v2, only user, project, and role are used.

Project and user are both required in filters.

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.

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.

list_router_interfaces(router, interface_type=None)

List all interfaces for a router.

Parameters
  • router (dict) – A router dict object.

  • interface_type (string) – One of None, “internal”, or “external”. Controls whether all, internal interfaces or external interfaces are returned.

Returns

A list of port munch.Munch objects.

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_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_server_groups()

List all available server groups.

Returns

A list of server group dicts.

list_server_security_groups(server)

List all security groups associated with the given server.

Returns

A list of security group munch.Munch.

list_servers(detailed=False, all_projects=False, bare=False, filters=None)

List all available servers.

Parameters
  • detailed – Whether or not to add detailed additional information. Defaults to False.

  • all_projects – Whether to list servers from all projects or just the current auth scoped project.

  • bare – Whether to skip adding any additional information to the server record. Defaults to False, meaning the addresses dict will be populated as needed from neutron. Setting to True implies detailed = False.

  • filters – Additional query parameters passed to the API server.

Returns

A list of server munch.Munch.

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.

list_share_availability_zones()

List all availability zones for the Shared File Systems service.

Returns

A list of Shared File Systems Availability Zones.

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_volume_backups(detailed=True, search_opts=None)

List all volume backups.

Parameters
  • detailed (bool) – Also list details for each entry

  • search_opts (dict) –

    Search options A dictionary of meta data to use for further filtering. Example:

    {
        'name': 'my-volume-backup',
        'status': 'available',
        'volume_id': 'e126044c-7b4c-43be-a32a-c9cbbc9ddb56',
        'all_tenants': 1
    }
    

Returns

A list of volume backups munch.Munch.

list_volume_snapshots(detailed=True, search_opts=None)

List all volume snapshots.

Returns

A list of volume snapshots munch.Munch.

list_zones(filters=None)

List all available zones.

Returns

A list of zones dicts.

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
  • name_or_id (string) – The Name or UUID value representing the baremetal node.

  • state (string) – The desired provision state for the baremetal node.

  • configdrive (string) – An optional URL or file or path representing the configdrive. In the case of a directory, the client API will create a properly formatted configuration drive file and post the file contents to the API for deployment.

  • wait (boolean) – A boolean value, defaulted to false, to control if the method will wait for the desire end state to be reached before returning.

  • timeout (integer) – Integer value, defaulting to 3600 seconds, representing the amount of time to wait for the desire end state to be reached.

Raises

OpenStackCloudException on operation error.

Returns

munch.Munch representing the current state of the machine upon exit of the method.

patch_machine(name_or_id, patch)

Patch Machine Information

This method allows for an interface to manipulate node entries within Ironic.

Parameters
  • name_or_id (string) – A machine name or UUID to be updated.

  • patch

    The JSON Patch document is a list of dictonary objects that comply with RFC 6902 which can be found at https://tools.ietf.org/html/rfc6902.

    Example patch construction:

    patch=[]
    patch.append({
        'op': 'remove',
        'path': '/instance_info'
    })
    patch.append({
        'op': 'replace',
        'path': '/name',
        'value': 'newname'
    })
    patch.append({
        'op': 'add',
        'path': '/driver_info/username',
        'value': 'administrator'
    })
    

Raises

OpenStackCloudException on operation error.

Returns

munch.Munch representing the newly updated node.

pformat(resource)

Wrapper around pformat that groks munch objects

pprint(resource)

Wrapper around pprint that groks munch objects

project_cleanup(dry_run=True, wait_timeout=120, status_queue=None, filters=None, resource_evaluation_fn=None)

Cleanup the project resources.

Cleanup all resources in all services, which provide cleanup methods.

Parameters
  • dry_run (bool) – Cleanup or only list identified resources.

  • wait_timeout (int) – Maximum amount of time given to each service to comlete the cleanup.

  • status_queue (queue) – a threading queue object used to get current process status. The queue contain processed resources.

  • filters (dict) – Additional filters for the cleanup (only resources matching all filters will be deleted, if there are no other dependencies).

  • resource_evaluation_fn – A callback function, which will be invoked for each resurce and must return True/False depending on whether resource need to be deleted or not.

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
  • data – List of dictionaries to be searched.

  • filters

    Dict describing the one or more range searches to perform. If more than one search is given, the result will be the members of the original data set that match ALL searches. An example of filtering by multiple ranges:

    {"vcpus": "<=5", "ram": "<=2048", "disk": "1"}
    

Returns

A list subset of the original data set.

Raises

OpenStackCloudException on invalid range expressions.

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
  • nics

    An array of MAC addresses that represent the network interfaces for the node to be created.

    Example:

    [
        {'mac': 'aa:bb:cc:dd:ee:01'},
        {'mac': 'aa:bb:cc:dd:ee:02'}
    ]
    

  • wait – Boolean value, defaulting to false, to wait for the node to reach the available state where the node can be provisioned. It must be noted, when set to false, the method will still wait for locks to clear before sending the next required command.

  • timeout – Integer value, defautling to 3600 seconds, for the wait state to reach completion.

  • lock_timeout – Integer value, defaulting to 600 seconds, for locks to clear.

  • kwargs – Key value pairs to be passed to the Ironic API, including uuid, name, chassis_uuid, driver_info, parameters.

Raises

OpenStackCloudException on operation error.

Returns

Returns a munch.Munch representing the new baremetal node.

remove_flavor_access(flavor_id, project_id)

Revoke access from a private flavor for a project/tenant.

Parameters
  • flavor_id (string) – ID of the private flavor.

  • project_id (string) – ID of the project/tenant.

Raises

OpenStackCloudException on operation error.

remove_host_from_aggregate(name_or_id, host_name)

Remove a host from an aggregate.

Parameters
  • name_or_id – Name or ID of the host aggregate.

  • host_name – Host to remove.

Raises

OpenStackCloudException on operation error.

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

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
  • router (dict) – The dict object of the router being changed

  • subnet_id (string) – The ID of the subnet to use for the interface

  • port_id (string) – The ID of the port to use for the interface

Returns

None on success

Raises

OpenStackCloudException on operation error.

remove_rule_from_policy(name_or_id, rule_name_or_id, filters=None)

Remove firewall rule from firewall policy’s firewall_rules list. Short-circuits and returns firewall policy early if firewall rule is already absent from the firewall_rules list.

Parameters
  • name_or_id – firewall policy name or id

  • rule_name_or_id – firewall rule name or id

  • filters (dict) – optional filters

Raises

DuplicateResource on multiple matches

Raises

ResourceNotFound if firewall policy is not found

Returns

updated firewall policy

Return type

FirewallPolicy

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.

remove_user_from_group(name_or_id, group_name_or_id)

Remove a user from a group.

Parameters
  • name_or_id (string) – User name or ID

  • group_name_or_id (string) – Group name or ID

Raises

OpenStackCloudException if something goes wrong during the OpenStack API call

remove_volume_type_access(name_or_id, project_id)

Revoke access on a volume_type to a project.

Parameters
  • name_or_id – ID or name of a volume_type

  • project_id – A project id

Raises

OpenStackCloudException on operation error.

revoke_role(name_or_id, user=None, group=None, project=None, domain=None, wait=False, timeout=60)

Revoke a role from a user.

Parameters
  • name_or_id (string) – The name or id of the role.

  • user (string) – The name or id of the user.

  • group (string) – The name or id of the group. (v3)

  • project (string) – The name or id of the project.

  • domain (string) – The id of the domain. (v3)

  • wait (bool) – Wait for role to be revoked

  • timeout (int) – Timeout to wait for role to be revoked

NOTE: for wait and timeout, sometimes revoking roles is not

instantaneous.

NOTE: project is required for keystone v2

Returns

True if the role is revoke, otherwise False

Raises

OpenStackCloudException – if the role cannot be removed

search_aggregates(name_or_id=None, filters=None)

Seach host aggregates.

Parameters
  • name – aggregate name or id.

  • filters – a dict containing additional filters to use.

Returns

a list of dicts containing the aggregates

Raises

OpenStackCloudException: if something goes wrong during the OpenStack API call.

search_baymodels(name_or_id=None, filters=None, detail=False)

Search cluster templates.

Parameters
  • name_or_id – cluster template name or ID.

  • filters – a dict containing additional filters to use.

  • detail – a boolean to control if we need summarized or detailed output.

Returns

a list of dict containing the cluster templates

Raises

OpenStackCloudException: if something goes wrong during the OpenStack API call.

search_cluster_templates(name_or_id=None, filters=None, detail=False)

Search cluster templates.

Parameters
  • name_or_id – cluster template name or ID.

  • filters – a dict containing additional filters to use.

  • detail – a boolean to control if we need summarized or detailed output.

Returns

a list of dict containing the cluster templates

Raises

OpenStackCloudException: if something goes wrong during the OpenStack API call.

search_coe_cluster_templates(name_or_id=None, filters=None, detail=False)

Search cluster templates.

Parameters
  • name_or_id – cluster template name or ID.

  • filters – a dict containing additional filters to use.

  • detail – a boolean to control if we need summarized or detailed output.

Returns

a list of dict containing the cluster templates

Raises

OpenStackCloudException: if something goes wrong during the OpenStack API call.

search_coe_clusters(name_or_id=None, filters=None)

Search COE cluster.

Parameters
  • name_or_id – cluster name or ID.

  • filters – a dict containing additional filters to use.

  • detail – a boolean to control if we need summarized or detailed output.

Returns

a list of dict containing the cluster

Raises

OpenStackCloudException: if something goes wrong during the OpenStack API call.

search_containers(name=None, filters=None)

Search containers.

Parameters
  • name (string) – container name.

  • filters – a dict containing additional filters to use. OR A string containing a jmespath expression for further filtering. Example:: “[?last_name==`Smith`] | [?other.gender]==`Female`]”

Returns

a list of munch.Munch containing the containers.

Raises

OpenStackCloudException: if something goes wrong during the OpenStack API call.

search_domains(filters=None, name_or_id=None)

Search Keystone domains.

Parameters
  • name_or_id – domain name or id

  • filters (dict) – A dict containing additional filters to use. Keys to search on are id, name, enabled and description.

Returns

a list of munch.Munch containing the domain description. Each munch.Munch contains the following attributes:: - id: <domain id> - name: <domain name> - description: <domain description>

Raises

OpenStackCloudException: if something goes wrong during the OpenStack API call.

search_endpoints(id=None, filters=None)

List Keystone endpoints.

Parameters
  • id – endpoint id.

  • filters – a dict containing additional filters to use. e.g. {‘region’: ‘region-a.geo-1’}

Returns

a list of munch.Munch containing the endpoint description. Each dict contains the following attributes:: - id: <endpoint id> - region: <endpoint region> - public_url: <endpoint public url> - internal_url: <endpoint internal url> (optional) - admin_url: <endpoint admin url> (optional)

Raises

OpenStackCloudException: if something goes wrong during the OpenStack API call.

search_groups(name_or_id=None, filters=None, **kwargs)

Search Keystone groups.

Parameters
  • name – Group name or id.

  • filters – A dict containing additional filters to use.

  • domain_id – domain id.

Returns

A list of munch.Munch containing the group description.

Raises

OpenStackCloudException: if something goes wrong during the OpenStack API call.

search_networks(name_or_id=None, filters=None)

Search networks

Parameters
  • name_or_id – Name or ID of the desired network.

  • filters – a dict containing additional filters to use. e.g. {‘router:external’: True}

Returns

a list of munch.Munch containing the network description.

Raises

OpenStackCloudException if something goes wrong during the OpenStack API call.

search_objects(container, name=None, filters=None)

Search objects.

Parameters
  • name (string) – object name.

  • filters – a dict containing additional filters to use. OR A string containing a jmespath expression for further filtering. Example:: “[?last_name==`Smith`] | [?other.gender]==`Female`]”

Returns

a list of munch.Munch containing the objects.

Raises

OpenStackCloudException: if something goes wrong during the OpenStack API call.

search_ports(name_or_id=None, filters=None)

Search ports

Parameters
  • name_or_id – Name or ID of the desired port.

  • filters – a dict containing additional filters to use. e.g. {‘device_id’: ‘2711c67a-b4a7-43dd-ace7-6187b791c3f0’}

Returns

a list of munch.Munch containing the port description.

Raises

OpenStackCloudException if something goes wrong during the OpenStack API call.

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.

search_qos_bandwidth_limit_rules(policy_name_or_id, rule_id=None, filters=None)

Search QoS bandwidth limit rules

Parameters
  • policy_name_or_id (string) – Name or ID of the QoS policy to which rules should be associated.

  • rule_id (string) – ID of searched rule.

  • filters – a dict containing additional filters to use. e.g. {‘max_kbps’: 1000}

Returns

a list of munch.Munch containing the bandwidth limit rule descriptions.

Raises

OpenStackCloudException if something goes wrong during the OpenStack API call.

search_qos_dscp_marking_rules(policy_name_or_id, rule_id=None, filters=None)

Search QoS DSCP marking rules

Parameters
  • policy_name_or_id (string) – Name or ID of the QoS policy to which rules should be associated.

  • rule_id (string) – ID of searched rule.

  • filters – a dict containing additional filters to use. e.g. {‘dscp_mark’: 32}

Returns

a list of munch.Munch containing the dscp marking rule descriptions.

Raises

OpenStackCloudException if something goes wrong during the OpenStack API call.

search_qos_minimum_bandwidth_rules(policy_name_or_id, rule_id=None, filters=None)

Search QoS minimum bandwidth rules

Parameters
  • policy_name_or_id (string) – Name or ID of the QoS policy to which rules should be associated.

  • rule_id (string) – ID of searched rule.

  • filters – a dict containing additional filters to use. e.g. {‘min_kbps’: 1000}

Returns

a list of munch.Munch containing the bandwidth limit rule descriptions.

Raises

OpenStackCloudException if something goes wrong during the OpenStack API call.

search_qos_policies(name_or_id=None, filters=None)

Search QoS policies

Parameters
  • name_or_id – Name or ID of the desired policy.

  • filters – a dict containing additional filters to use. e.g. {‘shared’: True}

Returns

a list of munch.Munch containing the network 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
  • name (string) – role name or id.

  • filters (dict) – a dict containing additional filters to use.

  • domain_id – domain id (v3)

Returns

a list of munch.Munch containing the role description. Each munch.Munch contains the following attributes:

- id: <role id>
- name: <role name>
- description: <role description>

Raises

OpenStackCloudException: if something goes wrong during the OpenStack API call.

search_routers(name_or_id=None, filters=None)

Search routers

Parameters
  • name_or_id – Name or ID of the desired router.

  • filters – a dict containing additional filters to use. e.g. {‘admin_state_up’: True}

Returns

a list of munch.Munch containing the router description.

Raises

OpenStackCloudException if something goes wrong during the OpenStack API call.

search_server_groups(name_or_id=None, filters=None)

Seach server groups.

Parameters
  • name – server group name or ID.

  • filters – a dict containing additional filters to use.

Returns

a list of dicts containing the server groups

Raises

OpenStackCloudException: if something goes wrong during the OpenStack API call.

search_services(name_or_id=None, filters=None)

Search Keystone services.

Parameters
  • name_or_id – Name or id of the desired service.

  • filters – a dict containing additional filters to use. e.g. {‘type’: ‘network’}.

Returns

a list of munch.Munch containing the services description

Raises

OpenStackCloudException if something goes wrong during the OpenStack API call.

search_stacks(name_or_id=None, filters=None)

Search stacks.

Parameters
  • name_or_id – Name or ID of the desired stack.

  • filters – a dict containing additional filters to use. e.g. {‘stack_status’: ‘CREATE_COMPLETE’}

Returns

a list of munch.Munch containing the stack description.

Raises

OpenStackCloudException if something goes wrong during the OpenStack API call.

search_subnets(name_or_id=None, filters=None)

Search subnets

Parameters
  • name_or_id – Name or ID of the desired subnet.

  • filters – a dict containing additional filters to use. e.g. {‘enable_dhcp’: True}

Returns

a list of munch.Munch containing the subnet description.

Raises

OpenStackCloudException if something goes wrong during the OpenStack API call.

search_users(name_or_id=None, filters=None, **kwargs)

Search users.

Parameters
  • name_or_id (string) – user name or ID.

  • domain_id – Domain ID. (v3)

  • filters – a dict containing additional filters to use. OR A string containing a jmespath expression for further filtering. Example:: “[?last_name==`Smith`] | [?other.gender]==`Female`]”

Returns

a list of munch.Munch containing the users

Raises

OpenStackCloudException: if something goes wrong during the OpenStack API call.

set_aggregate_metadata(name_or_id, metadata)

Set aggregate metadata, replacing the existing metadata.

Parameters
  • name_or_id – Name of the host aggregate to update

  • metadata – Dict containing metadata to replace (Use {‘key’: None} to remove a key)

Returns

a dict representing the new host aggregate.

Raises

OpenStackCloudException on operation error.

set_compute_quotas(name_or_id, **kwargs)

Set a quota in a project

Parameters
  • name_or_id – project name or id

  • kwargs – key/value pairs of quota name and quota value

Raises

OpenStackCloudException if the resource to set the quota does not exist.

set_container_access(name, access)

Set the access control list on a container.

Parameters
  • name (str) – Name of the container.

  • access (str) – ACL string to set on the container. Can also be public or private which will be translated into appropriate ACL strings.

set_flavor_specs(flavor_id, extra_specs)

Add extra specs to a flavor

Parameters
  • flavor_id (string) – ID of the flavor to update.

  • extra_specs (dict) – Dictionary of key-value pairs.

Raises

OpenStackCloudException on operation error.

Raises

OpenStackCloudResourceNotFound if flavor ID is not found.

set_machine_maintenance_state(name_or_id, state=True, reason=None)

Set Baremetal Machine Maintenance State

Sets Baremetal maintenance state and maintenance reason.

Parameters
  • name_or_id (string) – The Name or UUID value representing the baremetal node.

  • state (boolean) – The desired state of the node. True being in maintenance where as False means the machine is not in maintenance mode. This value defaults to True if not explicitly set.

  • reason (string) – An optional freeform string that is supplied to the baremetal API to allow for notation as to why the node is in maintenance 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_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_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

set_network_quotas(name_or_id, **kwargs)

Set a network quota in a project

Parameters
  • name_or_id – project name or id

  • kwargs – key/value pairs of quota name and quota value

Raises

OpenStackCloudException if the resource to set the quota does not exist.

set_server_metadata(name_or_id, metadata)

Set metadata in a server instance.

Parameters
  • name_or_id (str) – The name or ID of the server instance to update.

  • metadata (dict) – A dictionary with the key=value pairs to set in the server instance. It only updates the key=value pairs provided. Existing ones will remain untouched.

Raises

OpenStackCloudException on operation error.

set_volume_bootable(name_or_id, bootable=True)

Set a volume’s bootable flag.

Parameters
  • name_or_id – Name, unique ID of the volume or a volume dict.

  • bootable (bool) – Whether the volume should be bootable. (Defaults to True)

Raises

OpenStackCloudTimeout if wait time exceeded.

Raises

OpenStackCloudException on operation error.

set_volume_quotas(name_or_id, **kwargs)

Set a volume quota in a project

Parameters
  • name_or_id – project name or id

  • kwargs – key/value pairs of quota name and quota value

Raises

OpenStackCloudException if the resource to set the quota does not exist.

sign_coe_cluster_certificate(cluster_id, csr)

Sign client key and generate the CA certificate for a cluster

Parameters
  • cluster_id – UUID of the cluster.

  • csr – Certificate Signing Request (CSR) for authenticating client key.The CSR will be used by Magnum to generate a signed certificate that client will use to communicate with the cluster.

Returns

a dict representing the signed certs.

Raises

OpenStackCloudException on operation error.

stream_object(container, obj, query_string=None, resp_chunk_size=1024)

Download the content via a streaming iterator.

Parameters
  • container (string) – name of the container.

  • obj (string) – name of the object.

  • query_string (string) – query args for uri. (delimiter, prefix, etc.)

  • resp_chunk_size (int) – chunk size of data to read. Only used if the results are

Returns

An iterator over the content or None if the object is not found.

Raises

OpenStackCloudException on operation error.

unbind_accelerator_request(uuid, properties)

Unbind an accelerator from VM. :param uuid: The uuid of the accelerator_request to be unbinded. :param properties: The info of VM that will unbind the accelerator. :returns:True if unbind succeeded, False otherwise.

unregister_machine(nics, uuid, wait=None, timeout=600)

Unregister Baremetal from Ironic

Removes entries for Network Interfaces and baremetal nodes from an Ironic API

Parameters
  • nics – An array of strings that consist of MAC addresses to be removed.

  • uuid (string) – The UUID of the node to be deleted.

  • wait – DEPRECATED, do not use.

  • timeout – Integer value, representing seconds with a default value of 600, which controls the maximum amount of time to block until a lock is released on machine.

Raises

OpenStackCloudException on operation failure.

unset_flavor_specs(flavor_id, keys)

Delete extra specs from a flavor

Parameters
  • flavor_id (string) – ID of the flavor to update.

  • keys – List of spec keys to delete.

Raises

OpenStackCloudException on operation error.

Raises

OpenStackCloudResourceNotFound if flavor ID is not found.

update_aggregate(name_or_id, **kwargs)

Update a host aggregate.

Parameters
  • name_or_id – Name or ID of the aggregate being updated.

  • name – New aggregate name

  • availability_zone – Availability zone to assign to hosts

Returns

a dict representing the updated host aggregate.

Raises

OpenStackCloudException on operation error.

update_baymodel(name_or_id, operation, **kwargs)

Update a cluster template.

Parameters
  • name_or_id – Name or ID of the cluster template being updated.

  • operation – Operation to perform - add, remove, replace.

Other arguments will be passed with kwargs.

Returns

a dict representing the updated cluster template.

Raises

OpenStackCloudException on operation error.

update_cluster_template(name_or_id, operation, **kwargs)

Update a cluster template.

Parameters
  • name_or_id – Name or ID of the cluster template being updated.

  • operation – Operation to perform - add, remove, replace.

Other arguments will be passed with kwargs.

Returns

a dict representing the updated cluster template.

Raises

OpenStackCloudException on operation error.

update_coe_cluster(name_or_id, operation, **kwargs)

Update a COE cluster.

Parameters
  • name_or_id – Name or ID of the COE cluster being updated.

  • operation – Operation to perform - add, remove, replace.

Other arguments will be passed with kwargs.

Returns

a dict representing the updated cluster.

Raises

OpenStackCloudException on operation error.

update_coe_cluster_template(name_or_id, operation, **kwargs)

Update a cluster template.

Parameters
  • name_or_id – Name or ID of the cluster template being updated.

  • operation – Operation to perform - add, remove, replace.

Other arguments will be passed with kwargs.

Returns

a dict representing the updated cluster template.

Raises

OpenStackCloudException on operation error.

update_container(name, headers)

Update the metadata in a container.

Parameters
  • name (str) – Name of the container to create.

  • headers (dict) – Key/Value headers to set on the container.

update_firewall_group(name_or_id, filters=None, **kwargs)

Updates firewall group. To unset egress- or ingress firewall policy, set egress_firewall_policy or ingress_firewall_policy to None. You can also set egress_firewall_policy_id and ingress_firewall_policy_id directly, which will skip the policy lookups.

Parameters
  • name_or_id – firewall group name or id

  • filters (dict) – optional filters

  • kwargs – firewall group update parameters See create_firewall_group docstring for valid parameters.

Raises

BadRequestException if parameters are malformed

Raises

DuplicateResource on multiple matches

Raises

ResourceNotFound if firewall group, a firewall policy (egress, ingress) or port is not found

Returns

updated firewall group

Return type

FirewallGroup

update_firewall_policy(name_or_id, filters=None, **kwargs)

Updates firewall policy.

Parameters
  • name_or_id – firewall policy name or id

  • filters (dict) – optional filters

  • kwargs – firewall policy update parameters See create_firewall_policy docstring for valid parameters.

Raises

BadRequestException if parameters are malformed

Raises

DuplicateResource on multiple matches

Raises

ResourceNotFound if resource is not found

Returns

updated firewall policy

Return type

FirewallPolicy

update_firewall_rule(name_or_id, filters=None, **kwargs)

Updates firewall rule.

Parameters
  • name_or_id – firewall rule name or id

  • filters (dict) – optional filters

  • kwargs – firewall rule update parameters. See create_firewall_rule docstring for valid parameters.

Raises

BadRequestException if parameters are malformed

Raises

NotFoundException if resource is not found

Returns

updated firewall rule

Return type

FirewallRule

update_group(name_or_id, name=None, description=None, **kwargs)

Update an existing group

Parameters
  • name (string) – New group name.

  • description (string) – New group description.

  • domain_id – domain id.

Returns

A munch.Munch containing the group description.

Raises

OpenStackCloudException: if something goes wrong during the OpenStack API call.

update_machine(name_or_id, **attrs)

Update a machine with new configuration information

A user-friendly method to perform updates of a machine, in whole or part.

Parameters
  • name_or_id (string) – A machine name or UUID to be updated.

  • attrs – Attributes to updated on the machine.

Raises

OpenStackCloudException on operation error.

Returns

munch.Munch containing a machine sub-dictonary consisting of the updated data returned from the API update operation, and a list named changes which contains all of the API paths that received updates.

update_network(name_or_id, **kwargs)

Update a network.

Parameters
  • name_or_id (string) – Name or ID of the network being updated.

  • name (string) – New name of the network.

  • shared (bool) – Set the network as shared.

  • admin_state_up (bool) – Set the network administrative state to up.

  • external (bool) – Whether this network is externally accessible.

  • provider (dict) –

    A dict of network provider options. Example:

    { 'network_type': 'vlan', 'segmentation_id': 'vlan1' }
    

  • mtu_size (int) – New maximum transmission unit value to address fragmentation. Minimum value is 68 for IPv4, and 1280 for IPv6.

  • port_security_enabled (bool) – Enable or disable port security.

  • dns_domain (string) – Specify the DNS domain associated with this network.

Returns

The updated network object.

Raises

OpenStackCloudException on operation error.

update_object(container, name, metadata=None, **headers)

Update the metadata of an object

Parameters
  • container – The name of the container the object is in

  • name – Name for the object within the container.

  • metadata – This dict will get changed into headers that set metadata of the object

  • headers – These will be passed through to the object update API as HTTP Headers.

Raises

OpenStackCloudException on operation error.

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
  • name_or_id – name or ID of the port to update. (Required)

  • name – A symbolic name for the port. (Optional)

  • admin_state_up – The administrative status of the port, which is up (true) or down (false). (Optional)

  • fixed_ips

    List of ip_addresses and subnet_ids. (Optional) If you specify only a subnet ID, OpenStack Networking allocates an available IP from that subnet to the port. If you specify both a subnet ID and an IP address, OpenStack Networking tries to allocate the specified address to the port. For example:

    [
      {
        "ip_address": "10.29.29.13",
        "subnet_id": "a78484c4-c380-4b47-85aa-21c51a2d8cbd"
      }, ...
    ]
    

  • security_groups – List of security group UUIDs. (Optional)

  • allowed_address_pairs

    Allowed address pairs list (Optional) For example:

    [
      {
        "ip_address": "23.23.23.1",
        "mac_address": "fa:16:3e:c4:cd:3f"
      }, ...
    ]
    

  • extra_dhcp_opts

    Extra DHCP options. (Optional). For example:

    [
      {
        "opt_name": "opt name1",
        "opt_value": "value1"
      }, ...
    ]
    

  • device_owner – The ID of the entity that uses this port. For example, a DHCP agent. (Optional)

  • device_id – The ID of the resource this port is attached to.

  • vnic_type (binding) – The type of the created port. (Optional)

  • port_security_enabled – The security port state created on the network. (Optional)

  • qos_policy_id – The ID of the QoS policy to apply for port.

Returns

a munch.Munch describing the updated port.

Raises

OpenStackCloudException on operation error.

update_qos_bandwidth_limit_rule(policy_name_or_id, rule_id, **kwargs)

Update a QoS bandwidth limit rule.

Parameters
  • policy_name_or_id (string) – Name or ID of the QoS policy to which rule is associated.

  • rule_id (string) – ID of rule to update.

  • max_kbps (int) – Maximum bandwidth limit value (in kilobits per second).

  • max_burst_kbps (int) – Maximum burst value (in kilobits).

  • direction (string) – Ingress or egress. The direction in which the traffic will be limited.

Returns

The updated QoS bandwidth limit 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
  • policy_name_or_id (string) – Name or ID of the QoS policy to which rule is associated.

  • rule_id (string) – ID of rule to update.

  • dscp_mark (int) – DSCP mark value

Returns

The updated QoS bandwidth limit 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
  • policy_name_or_id (string) – Name or ID of the QoS policy to which rule is associated.

  • rule_id (string) – ID of rule to update.

  • min_kbps (int) – Minimum bandwidth value (in kilobits per second).

  • direction (string) – Ingress or egress. The direction in which the traffic will be available.

Returns

The updated QoS minimum bandwidth rule.

Raises

OpenStackCloudException on operation error.

update_qos_policy(name_or_id, **kwargs)

Update an existing QoS policy.

Parameters
  • name_or_id (string) – Name or ID of the QoS policy to update.

  • policy_name (string) – The new name of the QoS policy.

  • description (string) – The new description of the QoS policy.

  • shared (bool) – If True, the QoS policy will be set as shared.

  • default (bool) – If True, the QoS policy will be set as default for project.

Returns

The updated QoS policy object.

Raises

OpenStackCloudException on operation error.

update_recordset(zone, name_or_id, **kwargs)

Update a recordset.

Parameters
  • zone – Name, ID or openstack.dns.v2.zone.Zone instance of the zone managing the recordset.

  • name_or_id – Name or ID of the recordset being updated.

  • records – List of the recordset definitions

  • description – Description of the recordset

  • ttl – TTL (Time to live) value in seconds of the recordset

Returns

a dict representing the updated recordset.

Raises

OpenStackCloudException on operation error.

update_role(name_or_id, name, **kwargs)

Update a Keystone role.

Parameters
  • name_or_id – Name or id of the role to update

  • name (string) – The new role name

  • domain_id – domain id

Returns

a munch.Munch containing the role description

Raises

OpenStackCloudException – if the role cannot be created

update_router(name_or_id, name=None, admin_state_up=None, ext_gateway_net_id=None, enable_snat=None, ext_fixed_ips=None, routes=None)

Update an existing logical router.

Parameters
  • name_or_id (string) – The name or UUID of the router to update.

  • name (string) – The new router name.

  • admin_state_up (bool) – The administrative state of the router.

  • ext_gateway_net_id (string) – The network ID for the external gateway.

  • enable_snat (bool) – Enable Source NAT (SNAT) attribute.

  • ext_fixed_ips

    List of dictionaries of desired IP and/or subnet on the external network. Example:

    [
      {
        "subnet_id": "8ca37218-28ff-41cb-9b10-039601ea7e6b",
        "ip_address": "192.168.10.2"
      }
    ]
    

  • routes (list) –

    A list of dictionaries with destination and nexthop parameters. To clear all routes pass an empty list ([]).

    Example:

    [
      {
        "destination": "179.24.1.0/24",
        "nexthop": "172.24.3.99"
      }
    ]
    

Returns

The router object.

Raises

OpenStackCloudException on operation error.

update_security_group(name_or_id, **kwargs)

Update a security group

Parameters
  • name_or_id (string) – Name or ID of the security group to update.

  • name (string) – New name for the security group.

  • description (string) – New description for the security group.

Returns

A munch.Munch describing the updated security group.

Raises

OpenStackCloudException on operation error.

update_server(name_or_id, detailed=False, bare=False, **kwargs)

Update a server.

Parameters
  • name_or_id – Name of the server to be updated.

  • detailed – Whether or not to add detailed additional information. Defaults to False.

  • bare – Whether to skip adding any additional information to the server record. Defaults to False, meaning the addresses dict will be populated as needed from neutron. Setting to True implies detailed = False.

Name

New name for the server

Description

New description for the server

Returns

a dictionary representing the updated server.

Raises

OpenStackCloudException on operation error.

update_stack(name_or_id, template_file=None, template_url=None, template_object=None, files=None, rollback=True, tags=None, wait=False, timeout=3600, environment_files=None, **parameters)

Update a stack.

Parameters
  • name_or_id (string) – Name or ID of the stack to update.

  • template_file (string) – Path to the template.

  • template_url (string) – URL of template.

  • template_object (string) – URL to retrieve template object.

  • files (dict) – dict of additional file content to include.

  • rollback (boolean) – Enable rollback on update failure.

  • wait (boolean) – Whether to wait for the delete to finish.

  • timeout (int) – Stack update timeout in seconds.

  • environment_files – Paths to environment files to apply.

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

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
  • name_or_id (string) – Name or ID of the subnet to update.

  • subnet_name (string) – The new name of the subnet.

  • enable_dhcp (bool) – Set to True if DHCP is enabled and False if disabled.

  • gateway_ip (string) – The gateway IP address. When you specify both allocation_pools and gateway_ip, you must ensure that the gateway IP does not overlap with the specified allocation pools.

  • disable_gateway_ip (bool) – Set to True if gateway IP address is disabled and False if enabled. It is not allowed with gateway_ip. Default is False.

  • allocation_pools

    A list of dictionaries of the start and end addresses for the allocation pools. For example:

    [
      {
        "start": "192.168.199.2",
        "end": "192.168.199.254"
      }
    ]
    

  • dns_nameservers

    A list of DNS name servers for the subnet. For example:

    [ "8.8.8.7", "8.8.8.8" ]
    

  • host_routes

    A list of host route dictionaries for the subnet. For example:

    [
      {
        "destination": "0.0.0.0/0",
        "nexthop": "123.456.78.9"
      },
      {
        "destination": "192.168.0.0/24",
        "nexthop": "192.168.0.1"
      }
    ]
    

Returns

The updated subnet object.

Raises

OpenStackCloudException on operation error.

update_zone(name_or_id, **kwargs)

Update a zone.

Parameters
  • name_or_id – Name or ID of the zone being updated.

  • email – Email of the zone owner (only applies if zone_type is primary)

  • description – Description of the zone

  • ttl – TTL (Time to live) value in seconds

  • masters – Master nameservers (only applies if zone_type is secondary)

Returns

a dict representing the updated zone.

Raises

OpenStackCloudException on operation error.

validate_machine(name_or_id, for_deploy=True)

Validate parameters of the machine.

Parameters
  • name_or_id (string) – The Name or UUID value representing the baremetal node.

  • for_deploy (bool) – If True, validate readiness for deployment, otherwise validate only the power management properties.

Raises

ValidationException

wait_for_baremetal_node_lock(node, timeout=30)

Wait for a baremetal node to have no lock.

DEPRECATED, use wait_for_node_reservation on the baremetal proxy.

Raises

OpenStackCloudException upon client failure.

Returns

None

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.

Transitioning from Profile

Support exists for users coming from older releases of OpenStack SDK who have been using the Profile interface.