Example #1
0
 def __init__(self, **kwargs):
     self.config = self._get_config(kwargs)
     self.backup_schedules = BackupScheduleManager(self)
     self.client = ComputeClient(self.config)
     self.flavors = FlavorManager(self)
     self.images = ImageManager(self)
     self.ipgroups = IPGroupManager(self)
     self.servers = ServerManager(self)
Example #2
0
 def __init__(self, **kwargs):
     self.config = self._get_config(kwargs)
     self.backup_schedules = BackupScheduleManager(self)
     self.client = ComputeClient(self.config)
     self.flavors = FlavorManager(self)
     self.images = ImageManager(self)
     self.servers = ServerManager(self)
     if 'IPGROUPS' in API_OPTIONS[self.config.cloud_api]:
         self.ipgroups = IPGroupManager(self)
Example #3
0
class Compute(object):
    """
    Top-level object to access the OpenStack Compute API.

    Create an instance with your creds::

    >>> compute = Compute(username=USERNAME, apikey=API_KEY)

    Then call methods on its managers::

        >>> compute.servers.list()
        ...
        >>> compute.flavors.list()
        ...

    &c.
    """

    def __init__(self, **kwargs):
        self.config = self._get_config(kwargs)
        self.backup_schedules = BackupScheduleManager(self)
        self.client = ComputeClient(self.config)
        self.flavors = FlavorManager(self)
        self.images = ImageManager(self)
        self.servers = ServerManager(self)
        self.load_balancers = LoadBalancerManager(self)
        if 'IPGROUPS' in API_OPTIONS[self.config.cloud_api]:
            self.ipgroups = IPGroupManager(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:`~openstack.compute.Unauthorized` if
        the credentials are wrong.
        """
        self.client.authenticate()

    def _get_config(self, kwargs):
        """
        Get a Config object for this API client.

        Broken out into a seperate method so that the test client can easily
        mock it up.
        """
        return Config(
            config_file = kwargs.pop('config_file', None),
            env = kwargs.pop('env', None),
            overrides = kwargs,
        )
Example #4
0
class Compute(object):
    """
    Top-level object to access the OpenStack Compute API.

    Create an instance with your creds::

    >>> compute = Compute(username=USERNAME, apikey=API_KEY)

    Then call methods on its managers::

        >>> compute.servers.list()
        ...
        >>> compute.flavors.list()
        ...

    &c.
    """
    def __init__(self, **kwargs):
        self.config = self._get_config(kwargs)
        self.backup_schedules = BackupScheduleManager(self)
        self.client = ComputeClient(self.config)
        self.flavors = FlavorManager(self)
        self.images = ImageManager(self)
        self.servers = ServerManager(self)
        if 'IPGROUPS' in API_OPTIONS[self.config.cloud_api]:
            self.ipgroups = IPGroupManager(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:`~openstack.compute.Unauthorized` if
        the credentials are wrong.
        """
        self.client.authenticate()

    def _get_config(self, kwargs):
        """
        Get a Config object for this API client.

        Broken out into a seperate method so that the test client can easily
        mock it up.
        """
        return Config(
            config_file=kwargs.pop('config_file', None),
            env=kwargs.pop('env', None),
            overrides=kwargs,
        )
Example #5
0
 def __init__(self, **kwargs):
     self.config = self._get_config(kwargs)
     self.backup_schedules = BackupScheduleManager(self)
     self.client = ComputeClient(self.config)
     self.flavors = FlavorManager(self)
     self.images = ImageManager(self)
     self.ipgroups = IPGroupManager(self)
     self.servers = ServerManager(self)
Example #6
0
 def __init__(self, **kwargs):
     self.config = self._get_config(kwargs)
     self.backup_schedules = BackupScheduleManager(self)
     self.client = ComputeClient(self.config)
     self.flavors = FlavorManager(self)
     self.images = ImageManager(self)
     self.servers = ServerManager(self)
     if 'IPGROUPS' in API_OPTIONS[self.config.cloud_api]:
         self.ipgroups = IPGroupManager(self)
Example #7
0
def client():
    cl = ComputeClient(FakeConfig())
    cl.management_url = "http://example.com"
    cl.auth_token = "token"
    return cl
def client():
    cl = ComputeClient(FakeConfig())
    cl.management_url = "http://example.com"
    cl.auth_token = "token"
    return cl