/usr/lib/python2.6/site-packages/openstack
Edit: /usr/lib/python2.6/site-packages/openstack/connection.pyc (10629B)
Ñò
5
Wc
@ sÅ d Z d d k Z d d k Z d d k l Z d d k Z d d k l Z d d k l
Z
d d k l Z d d k l Z
d d k l Z e i e ƒ Z d d d d „ Z d
e f d „ ƒ YZ d S( s–
The :class:`~openstack.connection.Connection` class is the primary interface
to the Python SDK it maintains a context for a connection to a cloud provider.
The connection has an attribute to access each supported service. The service
attributes are created dynamically based on user profiles and the service
catalog.
Examples
--------
At a minimum, the :class:`~openstack.connection.Connection` class needs to be
created with an authenticator or the parameters to build one.
Create a connection
~~~~~~~~~~~~~~~~~~~
The following example constructor uses the identity authenticator using
username and password. The default settings for the transport are used
by this connection.::
from openstack import connection
auth_args = {
'auth_url': 'http://172.20.1.108:5000/v3',
'project_name': 'admin',
'username': 'admin',
'password': 'admin',
}
conn = connection.Connection(**auth_args)
List
~~~~
Services are accessed through an attribute named after the service. A list
of all the projects is retrieved in this manner::
projects = conn.identity.list_projects()
Find or create
~~~~~~~~~~~~~~
If you wanted to make sure you had a network named 'jenkins', you would first
try to find it and if that fails, you would create it::
network = conn.network.find_network("jenkins")
if network is None:
network = conn.network.create_network({"name": "jenkins"})
iÿÿÿÿN( t base( t profile( t proxy( t proxy2( t session( t utilsc C sé h } t i ƒ } g } | i ƒ D] } | | i q# ~ } x | D] } d | | d