コード例 #1
0
ファイル: __init__.py プロジェクト: usrleon/python-novaclient
 def __init__(self, username, apikey, projectid,
              auth_url='https://auth.api.rackspacecloud.com/v1.0'):
     self.backup_schedules = BackupScheduleManager(self)
     self.client = OpenStackClient(username, apikey, projectid, auth_url)
     self.flavors = FlavorManager(self)
     self.images = ImageManager(self)
     self.ipgroups = IPGroupManager(self)
     self.servers = ServerManager(self)
     self.zones = ZoneManager(self)
コード例 #2
0
ファイル: __init__.py プロジェクト: EdLeafe/python-novaclient
class OpenStack(object):
    """
    Top-level object to access the OpenStack Nova API.

    Create an instance with your creds::

        >>> os = OpenStack(USERNAME, API_KEY, PROJECT_ID, AUTH_URL)

    Then call methods on its managers::

        >>> os.servers.list()
        ...
        >>> os.flavors.list()
        ...

    &c.
    """

    def __init__(self, username, apikey, projectid,
            auth_url='https://auth.api.rackspacecloud.com/v1.0', timeout=None):
        self.backup_schedules = BackupScheduleManager(self)
        self.client = OpenStackClient(username, apikey, projectid, auth_url,
                timeout=timeout)
        self.flavors = FlavorManager(self)
        self.images = ImageManager(self)
        self.ipgroups = IPGroupManager(self)
        self.servers = ServerManager(self)
        self.zones = ZoneManager(self)
        self.accounts = AccountManager(self)

    def authenticate(self):
        """
        Authenticate against the server.

        Normally this is called automatically when you first access the API,
        but you can call this method to force authentication right now.

        Returns on success; raises :exc:`novaclient.Unauthorized` if the
        credentials are wrong.
        """
        self.client.authenticate()
コード例 #3
0
def client():
    cl = OpenStackClient("username", "apikey", "project_id", "auth_test")
    cl.management_url = "http://example.com"
    cl.auth_token = "token"
    return cl