• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python util.create_dbaas_client函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中trove.tests.util.create_dbaas_client函数的典型用法代码示例。如果您正苦于以下问题:Python create_dbaas_client函数的具体用法?Python create_dbaas_client怎么用?Python create_dbaas_client使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了create_dbaas_client函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setUp

 def setUp(self):
     self.orig_conf_value = CONF.root_on_create
     CONF.root_on_create = True
     self.dbaas = util.create_dbaas_client(instance_info.user)
     self.dbaas_admin = util.create_dbaas_client(instance_info.admin_user)
     self.history = self.dbaas_admin.management.root_enabled_history
     self.enabled = self.dbaas.root.is_root_enabled
开发者ID:NeCTAR-RC,项目名称:trove,代码行数:7,代码来源:root_on_create.py


示例2: setUp

 def setUp(self):
     rd_user = test_config.users.find_user(
         Requirements(is_admin=False, services=["trove"]))
     rd_admin = test_config.users.find_user(
         Requirements(is_admin=True, services=["trove"]))
     self.rd_client = create_dbaas_client(rd_user)
     self.rd_admin = create_dbaas_client(rd_admin)
开发者ID:CMSS-BCRDB,项目名称:RDSV1.0,代码行数:7,代码来源:datastores.py


示例3: mgmt_reset_task_status_clears_backups

    def mgmt_reset_task_status_clears_backups(self):
        self.reset_task_status()
        self._reload_db_info()
        assert_equal(self.db_info.task_status, InstanceTasks.NONE)

        user = test_config.users.find_user(Requirements(is_admin=False))
        dbaas = create_dbaas_client(user)
        admin = test_config.users.find_user(Requirements(is_admin=True))
        admin_dbaas = create_dbaas_client(admin)
        result = dbaas.instances.backups(self.db_info.id)
        assert_equal(0, len(result))

        # Create some backups.
        backup_models.DBBackup.create(
            name="forever_new",
            description="forever new",
            tenant_id=self.tenant_id,
            state=state.BackupState.NEW,
            instance_id=self.db_info.id,
            deleted=False)

        backup_models.DBBackup.create(
            name="forever_build",
            description="forever build",
            tenant_id=self.tenant_id,
            state=state.BackupState.BUILDING,
            instance_id=self.db_info.id,
            deleted=False)

        backup_models.DBBackup.create(
            name="forever_completed",
            description="forever completed",
            tenant_id=self.tenant_id,
            state=state.BackupState.COMPLETED,
            instance_id=self.db_info.id,
            deleted=False)

        # List the backups for this instance.
        # There ought to be three in the admin tenant, but
        # none in a different user's tenant.
        result = dbaas.instances.backups(self.db_info.id)
        assert_equal(0, len(result))
        result = admin_dbaas.instances.backups(self.db_info.id)
        assert_equal(3, len(result))
        self.backups_to_clear = result

        # Reset the task status.
        self.reset_task_status()
        self._reload_db_info()
        result = admin_dbaas.instances.backups(self.db_info.id)
        assert_equal(3, len(result))
        for backup in result:
            if backup.name == 'forever_completed':
                assert_equal(backup.status,
                             state.BackupState.COMPLETED)
            else:
                assert_equal(backup.status, state.BackupState.FAILED)
开发者ID:CMSS-BCRDB,项目名称:RDSV1.0,代码行数:57,代码来源:instances_actions.py


示例4: setUp

 def setUp(self):
     self.user1 = CONFIG.users.find_user(Requirements(is_admin=False))
     self.user2 = CONFIG.users.find_user(Requirements(is_admin=False))
     assert_not_equal(self.user1.tenant, self.user2.tenant,
                      "Not enough users to run QuotasTest. Needs >=2.")
     self.client1 = create_dbaas_client(self.user1)
     self.client2 = create_dbaas_client(self.user2)
     self.mgmt_client = create_client(is_admin=True)
     ''' Orig quotas from config
         "trove_max_instances_per_user": 55,
         "trove_max_volumes_per_user": 100,    '''
     self.original_quotas1 = self.mgmt_client.quota.show(self.user1.tenant)
     self.original_quotas2 = self.mgmt_client.quota.show(self.user2.tenant)
开发者ID:abansal,项目名称:trove,代码行数:13,代码来源:quotas.py


示例5: setUp

    def setUp(self):
        rd_user = test_config.users.find_user(Requirements(is_admin=False, services=["trove"]))
        self.rd_client = create_dbaas_client(rd_user)

        if test_config.nova_client is not None:
            nova_user = test_config.users.find_user(Requirements(services=["nova"]))
            self.nova_client = create_nova_client(nova_user)
开发者ID:cretta,项目名称:trove,代码行数:7,代码来源:flavors.py


示例6: test_limits_exception

    def test_limits_exception(self):
        """Test_limits_exception."""

        # use a different user to avoid throttling tests run out of order
        rate_user_exceeded = self._get_user('rate_limit_exceeded')
        rd_client = create_dbaas_client(rate_user_exceeded)

        get = None
        encountered = False
        for i in xrange(DEFAULT_RATE + 50):
            try:
                limits = rd_client.limits.list()
                d = self._get_limits_as_dict(limits)
                get = d["GET"]
                abs_limits = d["ABSOLUTE"]

                assert_equal(get.verb, "GET")
                assert_equal(get.unit, "MINUTE")
                assert_equal(int(abs_limits.max_instances),
                             DEFAULT_MAX_INSTANCES)
                assert_equal(int(abs_limits.max_backups),
                             DEFAULT_MAX_BACKUPS)
                assert_equal(int(abs_limits.max_volumes),
                             DEFAULT_MAX_VOLUMES)

            except exceptions.OverLimit:
                encountered = True

        assert_true(encountered)
        assert_true(int(get.remaining) <= 50)
开发者ID:magictour,项目名称:trove,代码行数:30,代码来源:limits.py


示例7: setUp

    def setUp(self):

        users = [
            {
                "auth_user": "rate_limit",
                "auth_key": "password",
                "tenant": "4000",
                "requirements": {
                    "is_admin": False,
                    "services": ["trove"]
                }
            },
            {
                "auth_user": "rate_limit_exceeded",
                "auth_key": "password",
                "tenant": "4050",
                "requirements": {
                    "is_admin": False,
                    "services": ["trove"]
                }
            }]

        self._users = Users(users)

        rate_user = self._get_user('rate_limit')
        self.rd_client = create_dbaas_client(rate_user)
开发者ID:magictour,项目名称:trove,代码行数:26,代码来源:limits.py


示例8: test_backup_delete

    def test_backup_delete(self):
        """test delete"""

        # Test to make sure that user in other tenant is not able
        # to DELETE this backup
        reqs = Requirements(is_admin=False)
        other_user = CONFIG.users.find_user(
            reqs,
            black_list=[instance_info.user.auth_user])
        other_client = create_dbaas_client(other_user)
        assert_raises(exceptions.NotFound, other_client.backups.delete,
                      backup_info.id)

        instance_info.dbaas.backups.delete(backup_info.id)
        assert_equal(202, instance_info.dbaas.last_http_code)

        def backup_is_gone():
            result = instance_info.dbaas.instances.backups(instance_info.id)
            if len(result) == 0:
                return True
            else:
                return False
        poll_until(backup_is_gone)
        assert_raises(exceptions.NotFound, instance_info.dbaas.backups.get,
                      backup_info.id)
开发者ID:VinodKrGupta,项目名称:trove,代码行数:25,代码来源:backups.py


示例9: test_backup_get

    def test_backup_get(self):
        """Test get backup."""
        backup = instance_info.dbaas.backups.get(backup_info.id)
        assert_equal(backup_info.id, backup.id)
        assert_equal(backup_info.name, backup.name)
        assert_equal(backup_info.description, backup.description)
        assert_equal(instance_info.id, backup.instance_id)
        assert_not_equal(0.0, backup.size)
        assert_equal('COMPLETED', backup.status)
        assert_equal(instance_info.dbaas_datastore,
                     backup.datastore['type'])
        assert_equal(instance_info.dbaas_datastore_version,
                     backup.datastore['version'])

        datastore_version = instance_info.dbaas.datastore_versions.get(
            instance_info.dbaas_datastore,
            instance_info.dbaas_datastore_version)
        assert_equal(datastore_version.id, backup.datastore['version_id'])

        # Test to make sure that user in other tenant is not able
        # to GET this backup
        reqs = Requirements(is_admin=False)
        other_user = CONFIG.users.find_user(
            reqs,
            black_list=[instance_info.user.auth_user])
        other_client = create_dbaas_client(other_user)
        assert_raises(exceptions.NotFound, other_client.backups.get,
                      backup_info.id)
开发者ID:Tesora,项目名称:tesora-trove,代码行数:28,代码来源:backups.py


示例10: __init__

 def __init__(self, sleep_time=10, timeout=1200):
     self.def_sleep_time = sleep_time
     self.def_timeout = timeout
     self.instance_info = instance_info
     self.auth_client = create_dbaas_client(self.instance_info.user)
     self.unauth_client = None
     self._test_helper = None
开发者ID:magictour,项目名称:trove,代码行数:7,代码来源:test_runners.py


示例11: test_instance_resize_flavor

    def test_instance_resize_flavor(self):
        """Tests the resize instance/flavor API."""

        flavor_name = CONFIG.values.get('instance_bigger_flavor_name',
                                        'm1.medium')
        flavors = self.instance.dbaas.find_flavors_by_name(flavor_name)
        new_flavor = flavors[0]

        asserts.assert_true(new_flavor is not None,
                            "Flavor '%s' not found!" % flavor_name)

        if not getattr(self, 'instance', None):
            raise SkipTest(
                "Skipping this test since instance is not available.")

        self.rd_client = create_dbaas_client(self.instance.user)
        self.rd_client.instances.resize_instance(self.instance.id,
                                                 new_flavor.id)

        asserts.assert_equal(202, self.rd_client.last_http_code)
        test_instance = self.rd_client.instances.get(self.instance.id)
        asserts.assert_equal("RESIZE", test_instance.status)

        poll_until(lambda: self._find_status(self.rd_client,
                                             self.instance.id, "ACTIVE"),
                   sleep_time=SLEEP_TIME, time_out=TIMEOUT)

        test_instance = self.rd_client.instances.get(self.instance.id)
        asserts.assert_equal(int(test_instance.flavor['id']), new_flavor.id)
        self.report.log("Resized Flavor for Instance ID: %s to %s." % (
            self.instance.id, new_flavor.id))
开发者ID:magictour,项目名称:trove,代码行数:31,代码来源:pxc.py


示例12: test_instance_delete

    def test_instance_delete(self):
        """Tests the instance delete."""
        if not getattr(self, 'instance', None):
            raise SkipTest(
                "Skipping this test since instance is not available.")

        self.rd_client = create_dbaas_client(self.instance.user)
        self.rd_client.instances.delete(self.instance.id)

        asserts.assert_equal(202, self.rd_client.last_http_code)
        test_instance = self.rd_client.instances.get(self.instance.id)
        asserts.assert_equal("SHUTDOWN", test_instance.status)

        def _poll():
            try:
                instance = self.rd_client.instances.get(self.instance.id)
                self.report.log("Instance info %s" % instance._info)
                asserts.assert_equal("SHUTDOWN", instance.status)
                return False
            except exceptions.NotFound:
                self.report.log("Instance has gone.")
                asserts.assert_equal(404, self.rd_client.last_http_code)
                return True

        poll_until(_poll, sleep_time=SLEEP_TIME, time_out=TIMEOUT)
        self.report.log("Deleted Instance ID: %s " % self.instance.id)
开发者ID:magictour,项目名称:trove,代码行数:26,代码来源:pxc.py


示例13: __init__

 def __init__(self, instance_id):
     self.instance_id = instance_id
     req_admin = Requirements(is_admin=True)
     self.user = util.test_config.users.find_user(req_admin)
     self.dbaas_admin = util.create_dbaas_client(self.user)
     self.instance = self.dbaas_admin.management.show(self.instance_id)
     self.instance_local_id = self.instance.server["local_id"]
开发者ID:CiscoSystems,项目名称:openstack-trove,代码行数:7,代码来源:server_connection.py


示例14: setUp

 def setUp(self):
     self.instances = []
     reqs = Requirements(is_admin=True)
     self.user = CONFIG.users.find_user(
         reqs, black_list=[])
     self.client = create_dbaas_client(self.user)
     self.mgmt = self.client.management
开发者ID:jeredding,项目名称:trove,代码行数:7,代码来源:instances.py


示例15: setUp

 def setUp(self):
     admin_req = Requirements(is_admin=True)
     self.admin_user = test_config.users.find_user(admin_req)
     self.admin_client = create_dbaas_client(self.admin_user)
     user_req = Requirements(is_admin=False)
     self.users = test_config.users.find_all_users_who_satisfy(user_req)
     self.user_tenant_ids = [user.tenant_id for user in self.users]
     self._create_instances_for_users()
开发者ID:HoratiusTang,项目名称:trove,代码行数:8,代码来源:accounts.py


示例16: _create_unauthorized_client

 def _create_unauthorized_client(self):
     """Create a client from a different 'unauthorized' user
     to facilitate negative testing.
     """
     requirements = Requirements(is_admin=False)
     other_user = CONFIG.users.find_user(
         requirements, black_list=[self.instance_info.user.auth_user])
     return create_dbaas_client(other_user)
开发者ID:cdelatte,项目名称:tesora-trove,代码行数:8,代码来源:test_runners.py


示例17: test_backup_delete_other

 def test_backup_delete_other(self):
     """Test another user cannot delete backup."""
     # Test to make sure that user in other tenant is not able
     # to DELETE this backup
     reqs = Requirements(is_admin=False)
     other_user = CONFIG.users.find_user(reqs, black_list=[instance_info.user.auth_user])
     other_client = create_dbaas_client(other_user)
     assert_raises(exceptions.NotFound, other_client.backups.delete, backup_info.id)
开发者ID:rumale,项目名称:trove,代码行数:8,代码来源:backups.py


示例18: clear_test_backups

 def clear_test_backups(self):
     for backup in self.backups_to_clear:
         found_backup = backup_models.DBBackup.find_by(id=backup.id)
         found_backup.delete()
     user = test_config.users.find_user(Requirements(is_admin=False))
     dbaas = create_dbaas_client(user)
     result = dbaas.instances.backups(self.db_info.id)
     assert_equal(0, len(result))
开发者ID:rickerc,项目名称:openstack-trove,代码行数:8,代码来源:instances_actions.py


示例19: test_configurations_get

    def test_configurations_get(self):
        # test that the instance shows up on the assigned configuration
        result = instance_info.dbaas.configurations.get(configuration_info.id)
        assert_equal(configuration_info.id, result.id)
        assert_equal(configuration_info.name, result.name)
        assert_equal(configuration_info.description, result.description)

        # check the result field types
        with TypeCheck("configuration", result) as check:
            check.has_field("id", basestring)
            check.has_field("name", basestring)
            check.has_field("description", basestring)
            check.has_field("values", dict)
            check.has_field("created", basestring)
            check.has_field("updated", basestring)
            check.has_field("instance_count", int)

        print(result.values)

        # check for valid timestamps
        assert_true(_is_valid_timestamp(result.created))
        assert_true(_is_valid_timestamp(result.updated))

        # check that created and updated timestamps differ, since
        # test_appending_to_existing_configuration should have changed the
        # updated timestamp
        assert_not_equal(result.created, result.updated)

        assert_equal(result.instance_count, 1)

        with CollectionCheck("configuration_values", result.values) as check:
            # check each item has the correct type according to the rules
            for (item_key, item_val) in result.values.iteritems():
                print("item_key: %s" % item_key)
                print("item_val: %s" % item_val)
                dbaas = instance_info.dbaas
                param = dbaas.configuration_parameters.get_parameter(
                    instance_info.dbaas_datastore, instance_info.dbaas_datastore_version, item_key
                )
                if param.type == "integer":
                    check.has_element(item_key, int)
                if param.type == "string":
                    check.has_element(item_key, basestring)
                if param.type == "boolean":
                    check.has_element(item_key, bool)

        # Test to make sure that another user is not able to GET this config
        reqs = Requirements(is_admin=False)
        test_auth_user = instance_info.user.auth_user
        other_user = CONFIG.users.find_user(reqs, black_list=[test_auth_user])
        other_user_tenant_id = other_user.tenant_id
        client_tenant_id = instance_info.user.tenant_id
        if other_user_tenant_id == client_tenant_id:
            other_user = CONFIG.users.find_user(reqs, black_list=[instance_info.user.auth_user, other_user])
        print(other_user)
        print(other_user.__dict__)
        other_client = create_dbaas_client(other_user)
        assert_raises(exceptions.NotFound, other_client.configurations.get, configuration_info.id)
开发者ID:rumale,项目名称:trove,代码行数:58,代码来源:configurations.py


示例20: setUp

    def setUp(self):
        rd_user = test_config.users.find_user(Requirements(is_admin=False, services=["trove"]))
        self.rd_client = create_dbaas_client(rd_user)

        self.datastore = self.rd_client.datastores.get(test_config.dbaas_datastore)
        self.name1 = "test_instance1"
        self.name2 = "test_instance2"
        self.volume = {"size": 2}
        self.instance_id = None
开发者ID:magictour,项目名称:trove,代码行数:9,代码来源:flavors.py



注:本文中的trove.tests.util.create_dbaas_client函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.poll_until函数代码示例发布时间:2022-05-27
下一篇:
Python util.init_db函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap