
This sucks in the git history for both projects, then moves their files in place. It should not introduce any behavior changes to any of the existing openstacksdk code, nor to openstack.config and openstack.cloud - other than the name change. TODO(shade) comments have been left indicating places where further integration work should be done. It should not be assumed that these are the final places for either to live. This is just about getting them in-tree so we can work with them. The enforcer code for reasons surpassing understanding does not work with python setup.py build_sphinx but it does work with sphinx-build (what?) For now turn it off. We can turn it back on once the build sphinx job is migrated to the new PTI. Change-Id: I9523e4e281285360c61e9e0456a8e07b7ac1243c
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.
Create Connection From A File
Default Location
To create a connection from a file you need a YAML file to contain the configuration.
../../contributor/clouds.yaml
To use a configuration file called clouds.yaml
in one of
the default locations:
- Current Directory
- ~/.config/openstack
- /etc/openstack
call :py~openstack.connection.from_config
. The
from_config
function takes three optional arguments:
- cloud_name allows you to specify a cloud from your
clouds.yaml
file. - cloud_config allows you to pass in an existing
openstack.config.loader.OpenStackConfig
` object. - options allows you to specify a namespace object with options to be added to the cloud config.
../examples/connect.py
../examples/connect.py
../examples/connect.py
Note
To enable logging, set debug=True
in the
options
object.
User Defined Location
To use 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 the
cloud_name of the cloud configuration to use, .
Next
Now that you can create a connection, continue with the user_guides
for an OpenStack
service.