API Reference

API Reference

class openstack.config.OpenStackConfig(config_files=None, vendor_files=None, override_defaults=None, force_ipv4=None, envvar_prefix=None, secure_files=None, pw_func=None, session_constructor=None, app_name=None, app_version=None, load_yaml_config=True, load_envvars=True, statsd_host=None, statsd_port=None, statsd_prefix=None, influxdb_config=None)
get_extra_config(key, defaults=None)

Fetch an arbitrary extra chunk of config, laying in defaults.

Parameters
  • key (string) – name of the config section to fetch

  • defaults (dict) – (optional) default values to merge under the found config

register_argparse_arguments(parser, argv, service_keys=None)

Register all of the common argparse options needed.

Given an argparse parser, register the keystoneauth Session arguments, the keystoneauth Auth Plugin Options and os-cloud. Also, peek in the argv to see if all of the auth plugin options should be registered or merely the ones already configured.

Parameters
  • argparse.ArgumentParser – parser to attach argparse options to

  • argv – the arguments provided to the application

  • service_keys (string) – Service or list of services this argparse should be specialized for, if known. The first item in the list will be used as the default value for service_type (optional)

:raises exceptions.ConfigException if an invalid auth-type is requested

auth_config_hook(config)

Allow examination of config values before loading auth plugin

OpenStackClient will override this to perform additional checks on auth_type.

option_prompt(config, p_opt)

Prompt user for option that requires a value

magic_fixes(config)

Perform the set of magic argument fixups

get_one(cloud=None, validate=True, argparse=None, **kwargs)

Retrieve a single CloudRegion and merge additional options

Parameters
  • cloud (string) – The name of the configuration to load from clouds.yaml

  • validate (boolean) – Validate the config. Setting this to False causes no auth plugin to be created. It’s really only useful for testing.

  • argparse (Namespace) – An argparse Namespace object; allows direct passing in of argparse options to be added to the cloud config. Values of None and ‘’ will be removed.

  • region_name – Name of the region of the cloud.

  • kwargs – Additional configuration options

Returns

openstack.config.cloud_region.CloudRegion

Raises

keystoneauth1.exceptions.MissingRequiredOptions on missing required auth parameters

get_one_cloud(cloud=None, validate=True, argparse=None, **kwargs)

Retrieve a single CloudRegion and merge additional options

Parameters
  • cloud (string) – The name of the configuration to load from clouds.yaml

  • validate (boolean) – Validate the config. Setting this to False causes no auth plugin to be created. It’s really only useful for testing.

  • argparse (Namespace) – An argparse Namespace object; allows direct passing in of argparse options to be added to the cloud config. Values of None and ‘’ will be removed.

  • region_name – Name of the region of the cloud.

  • kwargs – Additional configuration options

Returns

openstack.config.cloud_region.CloudRegion

Raises

keystoneauth1.exceptions.MissingRequiredOptions on missing required auth parameters

get_one_cloud_osc(cloud=None, validate=True, argparse=None, **kwargs)

Retrieve a single CloudRegion and merge additional options

Parameters
  • cloud (string) – The name of the configuration to load from clouds.yaml

  • validate (boolean) – Validate the config. Setting this to False causes no auth plugin to be created. It’s really only useful for testing.

  • argparse (Namespace) – An argparse Namespace object; allows direct passing in of argparse options to be added to the cloud config. Values of None and ‘’ will be removed.

  • region_name – Name of the region of the cloud.

  • kwargs – Additional configuration options

Raises

keystoneauth1.exceptions.MissingRequiredOptions on missing required auth parameters

static set_one_cloud(config_file, cloud, set_config=None)

Set a single cloud configuration.

Parameters
  • config_file (string) – The path to the config file to edit. If this file does not exist it will be created.

  • cloud (string) – The name of the configuration to save to clouds.yaml

  • set_config (dict) – Configuration options to be set

class openstack.config.cloud_region.CloudRegion(name=None, region_name=None, config=None, force_ipv4=False, auth_plugin=None, openstack_config=None, session_constructor=None, app_name=None, app_version=None, session=None, discovery_cache=None, extra_config=None, cache_expiration_time=0, cache_expirations=None, cache_path=None, cache_class='dogpile.cache.null', cache_arguments=None, password_callback=None, statsd_host=None, statsd_port=None, statsd_prefix=None, influxdb_config=None, collector_registry=None, cache_auth=False)

The configuration for a Region of an OpenStack Cloud.

A CloudRegion encapsulates the config information needed for connections to all of the services in a Region of a Cloud.

Parameters
  • region_name (str) – The default region name for all services in this CloudRegion. If both region_name and config['region_name'] are specified, the kwarg takes precedence. May be overridden for a given ${service} via a ${service}_region_name key in the ``config dict.

  • config (dict) –

    A dict of configuration values for the CloudRegion and its services. The key for a ${config_option} for a specific ${service} should be ${service}_${config_option}. For example, to configure the endpoint_override for the block_storage service, the config dict should contain:

    'block_storage_endpoint_override': 'http://...'
    

    To provide a default to be used if no service-specific override is present, just use the unprefixed ${config_option} as the service key, e.g.:

    'interface': 'public'
    

property full_name

Return a string that can be used as an identifier.

Always returns a valid string. It will have name and region_name or just one of the two if only one is set, or else ‘unknown’.

set_session_constructor(session_constructor)

Sets the Session constructor.

get_requests_verify_args()

Return the verify and cert values for the requests library.

get_services()

Return a list of service types we know something about.

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

Return the endpoint for a given service as found in the catalog.

For values respecting endpoint overrides, see endpoint_for()

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

Return a keystoneauth plugin from the auth credentials.

insert_user_agent()

Set sdk information into the user agent of the Session.

Warning

This method is here to be used by os-client-config. It exists as a hook point so that os-client-config can provice backwards compatibility and still be in the User Agent for people using os-client-config directly.

Normal consumers of SDK should use app_name and app_version. However, if someone else writes a subclass of CloudRegion it may be desirable.

get_session()

Return a keystoneauth session based on the auth credentials.

get_service_catalog()

Helper method to grab the service catalog.

get_session_client(service_type, version=None, constructor=<class 'openstack.proxy.Proxy'>, **kwargs)

Return a prepped keystoneauth Adapter for a given service.

This is useful for making direct requests calls against a ‘mounted’ endpoint. That is, if you do:

client = get_session_client(‘compute’)

then you can do:

client.get(‘/flavors’)

and it will work like you think.

get_session_endpoint(service_type, min_version=None, max_version=None)

Return the endpoint from config or the catalog.

If a configuration lists an explicit endpoint for a service, return that. Otherwise, fetch the service catalog from the keystone session and return the appropriate endpoint.

Parameters

service_type – Official service type of service

get_cache_resource_expiration(resource, default=None)

Get expiration time for a resource

Parameters
  • resource – Name of the resource type

  • default – Default value to return if not found (optional, defaults to None)

Returns

Expiration time for the resource type as float or default

requires_floating_ip()

Return whether or not this cloud requires floating ips.

Returns

True of False if know, None if discovery is needed. If requires_floating_ip is not configured but the cloud is known to not provide floating ips, will return False.

get_external_networks()

Get list of network names for external networks.

get_external_ipv4_networks()

Get list of network names for external IPv4 networks.

get_external_ipv6_networks()

Get list of network names for external IPv6 networks.

get_internal_networks()

Get list of network names for internal networks.

get_internal_ipv4_networks()

Get list of network names for internal IPv4 networks.

get_internal_ipv6_networks()

Get list of network names for internal IPv6 networks.

get_default_network()

Get network used for default interactions.

get_nat_destination()

Get network used for NAT destination.

get_nat_source()

Get network used for NAT source.

get_client_config(name=None, defaults=None)

Get config settings for a named client.

Settings will also be looked for in a section called ‘client’. If settings are found in both, they will be merged with the settings from the named section winning over the settings from client section, and both winning over provided defaults.

Parameters
  • name (string) – Name of the config section to look for.

  • defaults (dict) – Default settings to use.

Returns

A dict containing merged settings from the named section, the client section and the defaults.

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.