Пример #1
0
 def __init__(self, username, apikey):
     self.backup_schedules = BackupScheduleManager(self)
     self.client = CloudServersClient(username, apikey)
     self.flavors = FlavorManager(self)
     self.images = ImageManager(self)
     self.ipgroups = IPGroupManager(self)
     self.servers = ServerManager(self)
Пример #2
0
 def __init__(self, username, apikey, **kwargs):
     self.backup_schedules = BackupScheduleManager(self)
     self.client = CloudServersClient(username, apikey, **kwargs)
     self.flavors = FlavorManager(self)
     self.images = ImageManager(self)
     self.ipgroups = IPGroupManager(self)
     self.servers = ServerManager(self)
Пример #3
0
 def __init__(self, username, apikey,
              auth_url='https://auth.api.rackspacecloud.com/v1.0'):
     self.backup_schedules = BackupScheduleManager(self)
     self.client = CloudServersClient(username, apikey, auth_url)
     self.flavors = FlavorManager(self)
     self.images = ImageManager(self)
     self.ipgroups = IPGroupManager(self)
     self.servers = ServerManager(self)
Пример #4
0
class CloudServers(object):
    """
    Top-level object to access the Rackspace Cloud Servers API.

    Create an instance with your creds::

        >>> cs = CloudServers(USERNAME, API_KEY [, AUTH_URL])

    Then call methods on its managers::

        >>> cs.servers.list()
        ...
        >>> cs.flavors.list()
        ...

    &c.
    """

    def __init__(self, username, apikey,
                 auth_url='https://auth.api.rackspacecloud.com/v1.0'):
        self.backup_schedules = BackupScheduleManager(self)
        self.client = CloudServersClient(username, apikey, auth_url)
        self.flavors = FlavorManager(self)
        self.images = ImageManager(self)
        self.ipgroups = IPGroupManager(self)
        self.servers = ServerManager(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:`cloudservers.Unauthorized` if the
        credentials are wrong.
        """
        self.client.authenticate()
    
    def limits(self):
        return self.client.get('/limits')
    
    def readable_limits(self):
        print self.limits()
Пример #5
0
class CloudServers(object):
    """
    Top-level object to access the Rackspace Cloud Servers API.
    
    Create an instance with your creds::
    
        >>> cs = CloudServers(USERNAME, API_KEY)
        
    Then call methods on its managers::
    
        >>> cs.servers.list()
        ...
        >>> cs.flavors.list()
        ...
        
    &c.
    """
    def __init__(self, username, apikey):
        self.backup_schedules = BackupScheduleManager(self)
        self.client = CloudServersClient(username, apikey)
        self.flavors = FlavorManager(self)
        self.images = ImageManager(self)
        self.ipgroups = IPGroupManager(self)
        self.servers = ServerManager(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:`cloudservers.Unauthorized` if the
        credentials are wrong.
        """
        self.client.authenticate()
Пример #6
0
def client():
    cl = CloudServersClient("username", "apikey")
    cl.management_url = "http://example.com"
    cl.auth_token = "token"
    return cl
def client():
    cl = CloudServersClient("username", "apikey", "auth_test")
    cl.management_url = "http://example.com"
    cl.auth_token = "token"
    return cl