Exemplo n.º 1
0
    def test_getid(self):
        obj = "test"
        r = base.getid(obj)
        self.assertEqual(obj, r)

        test_id = "test_id"
        obj = Mock()
        obj.id = test_id
        r = base.getid(obj)
        self.assertEqual(test_id, r)
    def test_getid(self):
        obj = "test"
        r = base.getid(obj)
        self.assertEqual(obj, r)

        test_id = "test_id"
        obj = Mock()
        obj.id = test_id
        r = base.getid(obj)
        self.assertEqual(test_id, r)
Exemplo n.º 3
0
    def get(self, instance):
        """
        Get a specific instances.

        :rtype: :class:`Instance`
        """
        return self._get("/instances/%s" % base.getid(instance), "instance")
Exemplo n.º 4
0
 def change_passwords(self, instance, users):
     """Change the password for one or more users."""
     instance_id = base.getid(instance)
     user_dict = {"users": users}
     url = "/instances/%s/users" % instance_id
     resp, body = self.api.client.put(url, body=user_dict)
     check_for_exceptions(resp, body)
Exemplo n.º 5
0
 def change_passwords(self, instance, users):
     """Change the password for one or more users."""
     instance_id = base.getid(instance)
     user_dict = {"users": users}
     url = "/instances/%s/users" % instance_id
     resp, body = self.api.client.put(url, body=user_dict)
     check_for_exceptions(resp, body)
Exemplo n.º 6
0
 def get(self, instance):
     """
     Get the diagnostics of the guest on the instance.
     """
     return self._get(
         "/mgmt/instances/%s/diagnostics" % base.getid(instance),
         "diagnostics")
Exemplo n.º 7
0
    def get(self, flavor):
        """
        Get a specific flavor.

        :rtype: :class:`Flavor`
        """
        return self._get("/flavors/%s" % base.getid(flavor), "flavor")
Exemplo n.º 8
0
    def backups(self, instance):
        """
        Get the list of backups for a specific instance.

        :rtype: list of :class:`Backups`.
        """
        return self._list("/instances/%s/backups" % base.getid(instance),
                          "backups")
Exemplo n.º 9
0
    def show(self, instance):
        """
        Get details of one instance.

        :rtype: :class:`Instance`.
        """

        return self._get("/mgmt/instances/%s" % base.getid(instance), "instance")
Exemplo n.º 10
0
    def backups(self, instance):
        """
        Get the list of backups for a specific instance.

        :rtype: list of :class:`Backups`.
        """
        return self._list("/instances/%s/backups" % base.getid(instance),
                          "backups")
Exemplo n.º 11
0
    def list(self, instance, limit=None, marker=None):
        """
        Get a list of all Databases from the instance.

        :rtype: list of :class:`Database`.
        """
        return self._list("/instances/%s/databases" % base.getid(instance),
                          "databases", limit, marker)
Exemplo n.º 12
0
    def get(self, backup):
        """
        Get a specific backup.

        :rtype: :class:`Backups`
        """
        return self._get("/backups/%s" % base.getid(backup),
                         "backup")
Exemplo n.º 13
0
    def list(self, instance, limit=None, marker=None):
        """
        Get a list of all Databases from the instance.

        :rtype: list of :class:`Database`.
        """
        return self._list("/instances/%s/databases" % base.getid(instance),
                          "databases", limit, marker)
    def get(self, security_group):
        """
        Get a specific security group.

        :rtype: :class:`SecurityGroup`
        """
        return self._get("/security_groups/%s" % base.getid(security_group),
                         "security_group")
Exemplo n.º 15
0
 def grant(self, instance, username, databases, hostname=None):
     """Allow an existing user permissions to access a database."""
     instance_id = base.getid(instance)
     user = quote_user_host(username, hostname)
     url = "/instances/%(instance_id)s/users/%(user)s/databases"
     dbs = {'databases': [{'name': db} for db in databases]}
     resp, body = self.api.client.put(url % locals(), body=dbs)
     check_for_exceptions(resp, body)
Exemplo n.º 16
0
 def revoke(self, instance, username, database, hostname=None):
     """Revoke from an existing user access permissions to a database."""
     instance_id = base.getid(instance)
     user = quote_user_host(username, hostname)
     url = ("/instances/%(instance_id)s/users/%(user)s/"
            "databases/%(database)s")
     resp, body = self.api.client.delete(url % locals())
     check_for_exceptions(resp, body)
Exemplo n.º 17
0
    def list(self, instance, limit=None, marker=None):
        """
        Get a list of all Users from the instance's Database.

        :rtype: list of :class:`User`.
        """
        return self._list("/instances/%s/users" % base.getid(instance),
                          "users", limit, marker)
Exemplo n.º 18
0
    def list(self, instance, limit=None, marker=None):
        """
        Get a list of all Users from the instance's Database.

        :rtype: list of :class:`User`.
        """
        return self._list("/instances/%s/users" % base.getid(instance),
                          "users", limit, marker)
Exemplo n.º 19
0
    def get(self, flavor):
        """
        Get a specific flavor.

        :rtype: :class:`Flavor`
        """
        return self._get("/flavors/%s" % base.getid(flavor),
                        "flavor")
Exemplo n.º 20
0
 def revoke(self, instance, username, database, hostname=None):
     """Revoke from an existing user access permissions to a database."""
     instance_id = base.getid(instance)
     user = quote_user_host(username, hostname)
     url = ("/instances/%(instance_id)s/users/%(user)s/"
            "databases/%(database)s")
     resp, body = self.api.client.delete(url % locals())
     check_for_exceptions(resp, body)
Exemplo n.º 21
0
    def get(self, instance):
        """
        Get a specific instances.

        :rtype: :class:`Instance`
        """
        return self._get("/instances/%s" % base.getid(instance),
                        "instance")
Exemplo n.º 22
0
    def get(self, security_group):
        """
        Get a specific security group.

        :rtype: :class:`SecurityGroup`
        """
        return self._get("/security-groups/%s" % base.getid(security_group),
                         "security_group")
Exemplo n.º 23
0
 def grant(self, instance, username, databases, hostname=None):
     """Allow an existing user permissions to access a database."""
     instance_id = base.getid(instance)
     user = quote_user_host(username, hostname)
     url = "/instances/%(instance_id)s/users/%(user)s/databases"
     dbs = {'databases': [{'name': db} for db in databases]}
     resp, body = self.api.client.put(url % locals(), body=dbs)
     check_for_exceptions(resp, body)
Exemplo n.º 24
0
    def show(self, instance):
        """
        Get details of one instance.

        :rtype: :class:`Instance`.
        """

        return self._get("/mgmt/instances/%s" % base.getid(instance),
                         'instance')
Exemplo n.º 25
0
    def root_enabled_history(self, instance):
        """
        Get root access history of one instance.

        """
        url = "/mgmt/instances/%s/root" % base.getid(instance)
        resp, body = self.api.client.get(url)
        if not body:
            raise Exception("Call to " + url + " did not return a body.")
        return RootHistory(self, body["root_history"])
Exemplo n.º 26
0
    def delete(self, instance):
        """
        Delete the specified instance.

        :param instance_id: The instance id to delete
        """
        resp, body = self.api.client.delete("/instances/%s" %
                                            base.getid(instance))
        if resp.status in (422, 500):
            raise exceptions.from_response(resp, body)
    def delete(self, security_group_rule):
        """
        Delete the specified security group.

        :param security_group_id: The security group id to delete
        """
        resp, body = self.api.client.delete("/security_group_rules/%s" %
                                            base.getid(security_group_rule))
        if resp.status in (422, 500):
            raise exceptions.from_response(resp, body)
Exemplo n.º 28
0
    def delete(self, instance):
        """
        Delete the specified instance.

        :param instance_id: The instance id to delete
        """
        resp, body = self.api.client.delete("/instances/%s" %
                                            base.getid(instance))
        if resp.status in (422, 500):
            raise exceptions.from_response(resp, body)
Exemplo n.º 29
0
 def list_access(self, instance, username, hostname=None):
     """Show all databases the given user has access to. """
     instance_id = base.getid(instance)
     user = quote_user_host(username, hostname)
     url = "/instances/%(instance_id)s/users/%(user)s/databases"
     resp, body = self.api.client.get(url % locals())
     check_for_exceptions(resp, body)
     if not body:
         raise Exception("Call to %s did not return to a body" % url)
     return [databases.Database(self, db) for db in body['databases']]
Exemplo n.º 30
0
    def root_enabled_history(self, instance):
        """
        Get root access history of one instance.

        """
        url = "/mgmt/instances/%s/root" % base.getid(instance)
        resp, body = self.api.client.get(url)
        if not body:
            raise Exception("Call to " + url + " did not return a body.")
        return RootHistory(self, body['root_history'])
Exemplo n.º 31
0
 def list_access(self, instance, username, hostname=None):
     """Show all databases the given user has access to. """
     instance_id = base.getid(instance)
     user = quote_user_host(username, hostname)
     url = "/instances/%(instance_id)s/users/%(user)s/databases"
     resp, body = self.api.client.get(url % locals())
     check_for_exceptions(resp, body)
     if not body:
         raise Exception("Call to %s did not return to a body" % url)
     return [databases.Database(self, db) for db in body['databases']]
Exemplo n.º 32
0
    def delete(self, security_group_rule):
        """
        Delete the specified security group rule.

        :param security_group_rule: The security group rule to delete
        """
        resp, body = self.api.client.delete("/security-group-rules/%s" %
                                            base.getid(security_group_rule))
        if resp.status in (422, 500):
            raise exceptions.from_response(resp, body)
Exemplo n.º 33
0
 def get(self, instance):
     """
     Get the hardware information of the instance.
     """
     return self._get("/mgmt/instances/%s/hwinfo" % base.getid(instance))
Exemplo n.º 34
0
 def get(self, instance):
     """
     Get the diagnostics of the guest on the instance.
     """
     return self._get("/mgmt/instances/%s/diagnostics" % base.getid(instance),
                      "diagnostics")
Exemplo n.º 35
0
 def get(self, instance):
     """
     Get the hardware information of the instance.
     """
     return self._get("/mgmt/instances/%s/hwinfo" % base.getid(instance))