示例#1
0
文件: users.py 项目: congto/rally
    def _create_tenant_users(cls, args):
        """Create tenant with users and their endpoints.

        This is suitable for using with pool of threads.
        :param args: tuple arguments, for Pool.imap()
        :returns: tuple (dict tenant, list users)
        """

        admin_endpoint, users_num, project_dom, user_dom, task_id, i = args
        users = []

        client = keystone.wrap(osclients.Clients(admin_endpoint).keystone())
        tenant = client.create_project(
            cls.PATTERN_TENANT % {"task_id": task_id, "iter": i}, project_dom)

        LOG.debug("Creating %d users for tenant %s" % (users_num, tenant.id))

        for user_id in range(users_num):
            username = cls.PATTERN_USER % {"tenant_id": tenant.id,
                                           "uid": user_id}
            user = client.create_user(username, "password",
                                      "*****@*****.**" % username, tenant.id,
                                      user_dom)
            user_endpoint = endpoint.Endpoint(client.auth_url, user.name,
                                              "password", tenant.name,
                                              consts.EndpointPermission.USER,
                                              client.region_name,
                                              project_domain_name=project_dom,
                                              user_domain_name=user_dom)
            users.append({"id": user.id,
                          "endpoint": user_endpoint,
                          "tenant_id": tenant.id})

        return ({"id": tenant.id, "name": tenant.name}, users)
示例#2
0
 def setUp(self):
     super(KeystoneV3WrapperTestCase, self).setUp()
     self.client = mock.MagicMock()
     self.client.version = "v3"
     self.wrapped_client = keystone.wrap(self.client)
     self.client.domains.get.side_effect = exceptions.NotFound
     self.client.domains.list.return_value = [mock.MagicMock(id="domain_id")]
示例#3
0
 def setUp(self):
     super(KeystoneV3WrapperTestCase, self).setUp()
     self.client = mock.MagicMock()
     self.client.version = 'v3'
     self.wrapped_client = keystone.wrap(self.client)
     self.client.domains.get.side_effect = exceptions.NotFound
     self.client.domains.list.return_value = [
         mock.MagicMock(id='domain_id')]
示例#4
0
文件: users.py 项目: meteorfox/rally
 def consume(cache, args):
     domain, task_id, i = args
     if "client" not in cache:
         clients = osclients.Clients(self.endpoint)
         cache["client"] = keystone.wrap(clients.keystone())
     tenant = cache["client"].create_project(
         self.PATTERN_TENANT % {"task_id": task_id, "iter": i}, domain)
     tenant_dict = {"id": tenant.id, "name": tenant.name}
     tenants.append(tenant_dict)
示例#5
0
 def consume(cache, args):
     domain, task_id, i = args
     if "client" not in cache:
         clients = osclients.Clients(self.endpoint)
         cache["client"] = keystone.wrap(clients.keystone())
     tenant = cache["client"].create_project(
         self.PATTERN_TENANT % {"task_id": task_id, "iter": i}, domain)
     tenant_dict = {"id": tenant.id, "name": tenant.name}
     tenants.append(tenant_dict)
示例#6
0
文件: users.py 项目: congto/rally
    def _delete_users(cls, args):
        """Delete given users.

        :param args: tuple arguments, for Pool.imap()
        """
        admin_endpoint, users = args
        client = keystone.wrap(osclients.Clients(admin_endpoint).keystone())

        for user in users:
            try:
                client.delete_user(user["id"])
            except Exception as ex:
                LOG.warning("Failed to delete user: %(user_id)s. "
                            "Exception: %(ex)s" %
                            {"user_id": user["id"], "ex": ex})
示例#7
0
文件: users.py 项目: congto/rally
    def _delete_tenants(cls, args):
        """Delete given tenants.

        :param args: tuple arguments, for Pool.imap()
        """
        admin_endpoint, tenants = args
        client = keystone.wrap(osclients.Clients(admin_endpoint).keystone())

        for tenant in tenants:
            try:
                client.delete_project(tenant["id"])
            except Exception as ex:
                LOG.warning("Failed to delete tenant: %(tenant_id)s. "
                            "Exception: %(ex)s" %
                            {"tenant_id": tenant["id"], "ex": ex})
示例#8
0
 def consume(cache, args):
     username, password, project_dom, user_dom, tenant = args
     if "client" not in cache:
         clients = osclients.Clients(self.endpoint)
         cache["client"] = keystone.wrap(clients.keystone())
     client = cache["client"]
     user = client.create_user(username, password,
                               "*****@*****.**" % username,
                               tenant["id"], user_dom)
     user_endpoint = endpoint.Endpoint(
             client.auth_url, user.name, password, tenant["name"],
             consts.EndpointPermission.USER, client.region_name,
             project_domain_name=project_dom, user_domain_name=user_dom)
     users.append({"id": user.id,
                   "endpoint": user_endpoint,
                   "tenant_id": tenant["id"]})
示例#9
0
    def _delete_tenants(cls, args):
        """Delete given tenants.

        :param args: tuple arguments, for Pool.imap()
        """
        admin_endpoint, tenants = args
        client = keystone.wrap(osclients.Clients(admin_endpoint).keystone())

        for tenant in tenants:
            try:
                client.delete_project(tenant["id"])
            except Exception as ex:
                LOG.warning("Failed to delete tenant: %(tenant_id)s. "
                            "Exception: %(ex)s" % {
                                "tenant_id": tenant["id"],
                                "ex": ex
                            })
示例#10
0
    def _delete_users(cls, args):
        """Delete given users.

        :param args: tuple arguments, for Pool.imap()
        """
        admin_endpoint, users = args
        client = keystone.wrap(osclients.Clients(admin_endpoint).keystone())

        for user in users:
            try:
                client.delete_user(user["id"])
            except Exception as ex:
                LOG.warning("Failed to delete user: %(user_id)s. "
                            "Exception: %(ex)s" % {
                                "user_id": user["id"],
                                "ex": ex
                            })
示例#11
0
文件: users.py 项目: meteorfox/rally
 def consume(cache, args):
     username, password, project_dom, user_dom, tenant_id = args
     if "client" not in cache:
         clients = osclients.Clients(self.endpoint)
         cache["client"] = keystone.wrap(clients.keystone())
     client = cache["client"]
     user = client.create_user(username, password,
                               "*****@*****.**" % username,
                               tenant_id, user_dom)
     user_endpoint = objects.Endpoint(
             client.auth_url, user.name, password,
             self.context["tenants"][tenant_id]["name"],
             consts.EndpointPermission.USER, client.region_name,
             project_domain_name=project_dom, user_domain_name=user_dom,
             endpoint_type=self.endpoint.endpoint_type)
     users.append({"id": user.id,
                   "endpoint": user_endpoint,
                   "tenant_id": tenant_id})
示例#12
0
    def _create_tenant_users(cls, args):
        """Create tenant with users and their endpoints.

        This is suitable for using with pool of threads.
        :param args: tuple arguments, for Pool.imap()
        :returns: tuple (dict tenant, list users)
        """

        admin_endpoint, users_num, project_dom, user_dom, task_id, i = args
        users = []

        client = keystone.wrap(osclients.Clients(admin_endpoint).keystone())
        tenant = client.create_project(
            cls.PATTERN_TENANT % {
                "task_id": task_id,
                "iter": i
            }, project_dom)

        LOG.debug("Creating %d users for tenant %s" % (users_num, tenant.id))

        for user_id in range(users_num):
            username = cls.PATTERN_USER % {
                "tenant_id": tenant.id,
                "uid": user_id
            }
            user = client.create_user(username, "password",
                                      "*****@*****.**" % username, tenant.id,
                                      user_dom)
            user_endpoint = endpoint.Endpoint(client.auth_url,
                                              user.name,
                                              "password",
                                              tenant.name,
                                              consts.EndpointPermission.USER,
                                              client.region_name,
                                              project_domain_name=project_dom,
                                              user_domain_name=user_dom)
            users.append({
                "id": user.id,
                "endpoint": user_endpoint,
                "tenant_id": tenant.id
            })

        return ({"id": tenant.id, "name": tenant.name}, users)
示例#13
0
文件: utils.py 项目: congto/rally
def delete_keystone_resources(keystone):
    keystone = keystone_wrapper.wrap(keystone)
    for resource in ["user", "project", "service", "role"]:
        _delete_single_keystone_resource_type(keystone, resource)
示例#14
0
 def consume(cache, user_id):
     if "client" not in cache:
         clients = osclients.Clients(self.endpoint)
         cache["client"] = keystone.wrap(clients.keystone())
     cache["client"].delete_user(user_id)
示例#15
0
 def consume(cache, tenant_id):
     if "client" not in cache:
         clients = osclients.Clients(self.endpoint)
         cache["client"] = keystone.wrap(clients.keystone())
     cache["client"].delete_project(tenant_id)
示例#16
0
 def _manager(self):
     return keystone_wrapper.wrap(getattr(self.admin, self._service)())
 def _manager(self):
     return keystone_wrapper.wrap(getattr(self.admin, self._service)())
示例#18
0
 def consume(cache, user_id):
     if "client" not in cache:
         clients = osclients.Clients(self.endpoint)
         cache["client"] = keystone.wrap(clients.keystone())
     cache["client"].delete_user(user_id)
示例#19
0
 def consume(cache, tenant_id):
     if "client" not in cache:
         clients = osclients.Clients(self.endpoint)
         cache["client"] = keystone.wrap(clients.keystone())
     cache["client"].delete_project(tenant_id)
示例#20
0
 def setUp(self):
     super(KeystoneV2WrapperTestCase, self).setUp()
     self.client = mock.MagicMock()
     self.client.version = 'v2.0'
     self.wrapped_client = keystone.wrap(self.client)
示例#21
0
def delete_keystone_resources(keystone):
    keystone = keystone_wrapper.wrap(keystone)
    for resource in ["user", "project", "service", "role"]:
        _delete_single_keystone_resource_type(keystone, resource)