Files
deb-python-openstacksdk/doc/source/users/guides/connect_from_config.rst
Everett Toews 7e98020b83 The Compute User Guide
The beginning of the compute user guide.

This also begins the simplification of the examples, makes them
more specific, and adds testing.

Change-Id: Ic4bac2fe30601c196b03ce73b2dd04a916231f33
Partial-Bug: #1487269
Partial-Bug: #1419012
Partial-Bug: #1466180
2015-10-01 21:50:49 -05:00

2.2 KiB

Connect From Config

In order to work with an OpenStack cloud you first need to create a ~openstack.connection.Connection to it using your credentials. A ~openstack.connection.Connection can be created in 3 ways, using the class itself (see connect), a file, or environment variables as illustrated below. The SDK uses os-client-config to handle the configuration.

Note

To get your credentials Download the OpenStack RC file.

Create Connection From A File

Default Location

To create a connection from a file you need a YAML file to contain the configuration and the :py~openstack.connection.from_config function.

../../contributors/clouds.yaml

To look for a configuration file called clouds.yaml in the default locations:

  • Current Directory
  • ~/.config/openstack
  • /etc/openstack

call :py~openstack.connection.from_config with an object that has the name of the cloud configuration to use.

../examples/connect.py

Note

To enable logging, set debug=True in the Opts object.

User Defined Location

To look for a configuration file in a user defined location set the environment variable OS_CLIENT_CONFIG_FILE to the absolute path of a file.:

export OS_CLIENT_CONFIG_FILE=/path/to/my/config/my-clouds.yaml

and call :py~openstack.connection.from_config with an object that has the name of the cloud configuration to use.

../examples/connect.py

Note

To enable logging, set debug=True in the Opts object.

Next

Now that you can create a connection, continue with the user_guides for an OpenStack service.