Example #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)
Example #3
0
    def get(self, instance):
        """
        Get a specific instances.

        :rtype: :class:`Instance`
        """
        return self._get("/instances/%s" % base.getid(instance), "instance")
Example #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)
Example #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)
Example #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")
Example #7
0
    def get(self, flavor):
        """
        Get a specific flavor.

        :rtype: :class:`Flavor`
        """
        return self._get("/flavors/%s" % base.getid(flavor), "flavor")
Example #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")
    def show(self, instance):
        """
        Get details of one instance.

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

        return self._get("/mgmt/instances/%s" % base.getid(instance), "instance")
    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")
    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, backup):
        """
        Get a specific backup.

        :rtype: :class:`Backups`
        """
        return self._get("/backups/%s" % base.getid(backup),
                         "backup")
Example #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")
Example #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)
Example #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)
Example #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)
Example #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)
Example #19
0
    def get(self, flavor):
        """
        Get a specific flavor.

        :rtype: :class:`Flavor`
        """
        return self._get("/flavors/%s" % base.getid(flavor),
                        "flavor")
Example #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)
Example #21
0
    def get(self, instance):
        """
        Get a specific instances.

        :rtype: :class:`Instance`
        """
        return self._get("/instances/%s" % base.getid(instance),
                        "instance")
Example #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")
Example #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)
Example #24
0
    def show(self, instance):
        """
        Get details of one instance.

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

        return self._get("/mgmt/instances/%s" % base.getid(instance),
                         'instance')
    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"])
Example #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)
Example #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)
Example #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']]
Example #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'])
Example #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']]
Example #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)
Example #33
0
 def get(self, instance):
     """
     Get the hardware information of the instance.
     """
     return self._get("/mgmt/instances/%s/hwinfo" % base.getid(instance))
 def get(self, instance):
     """
     Get the diagnostics of the guest on the instance.
     """
     return self._get("/mgmt/instances/%s/diagnostics" % base.getid(instance),
                      "diagnostics")
 def get(self, instance):
     """
     Get the hardware information of the instance.
     """
     return self._get("/mgmt/instances/%s/hwinfo" % base.getid(instance))