In order to work with an OpenStack cloud you first need to create a Connection to it using your credentials. A Connection can be created in 3 ways, using the class itself, a file, or environment variables. If this is your first time using the SDK, we recommend simply using the class itself as illustrated below.

Create Connection

To create a connection you need a Profile and a Connection.

def create_connection(auth_url, region, project_name, username, password):
    prof = profile.Profile()
    prof.set_region(profile.Profile.ALL, region)

    return connection.Connection(

The Profile sets your preferences for each service. You will pass it the region of the OpenStack cloud that this connection will use.

The Connection is a context for a connection to an OpenStack cloud. You will primarily use it to set the Profile and authentication information. You can also set the user_agent to something that describes your application (e.g. my-web-app/1.3.4).

Full example at


To enable logging, see the Logging user guide.

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.