当前位置: 首页>>代码示例>>Python>>正文


Python CONFIG.get方法代码示例

本文整理汇总了Python中trove.tests.config.CONFIG.get方法的典型用法代码示例。如果您正苦于以下问题:Python CONFIG.get方法的具体用法?Python CONFIG.get怎么用?Python CONFIG.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trove.tests.config.CONFIG的用法示例。


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

示例1: create_client_args

# 需要导入模块: from trove.tests.config import CONFIG [as 别名]
# 或者: from trove.tests.config.CONFIG import get [as 别名]
def create_client_args(user):

    auth_strategy = None

    kwargs = {"service_type": "trove", "insecure": CONFIG.values["trove_client_insecure"]}

    def set_optional(kwargs_name, test_conf_name):
        value = CONFIG.values.get(test_conf_name, None)
        if value is not None:
            kwargs[kwargs_name] = value

    service_url = CONFIG.get("override_trove_api_url", None)
    if user.requirements.is_admin:
        service_url = CONFIG.get("override_admin_trove_api_url", service_url)
    if service_url:
        kwargs["service_url"] = service_url

    auth_strategy = None
    if user.requirements.is_admin:
        auth_strategy = CONFIG.get("admin_auth_strategy", CONFIG.auth_strategy)
    else:
        auth_strategy = CONFIG.auth_strategy
    set_optional("region_name", "trove_client_region_name")
    if CONFIG.values.get("override_trove_api_url_append_tenant", False):
        kwargs["service_url"] += "/" + user.tenant

    if auth_strategy == "fake":
        from troveclient.compat import auth

        class FakeAuth(auth.Authenticator):
            def authenticate(self):
                class FakeCatalog(object):
                    def __init__(self, auth):
                        self.auth = auth

                    def get_public_url(self):
                        return "%s/%s" % (CONFIG.dbaas_url, self.auth.tenant)

                    def get_token(self):
                        return self.auth.tenant

                return FakeCatalog(self)

        auth_strategy = FakeAuth

    if auth_strategy:
        kwargs["auth_strategy"] = auth_strategy

    if not user.requirements.is_admin:
        auth_url = CONFIG.trove_auth_url
    else:
        auth_url = CONFIG.values.get("trove_admin_auth_url", CONFIG.trove_auth_url)

    if CONFIG.values.get("trove_client_cls"):
        cls_name = CONFIG.trove_client_cls
        kwargs["client_cls"] = import_class(cls_name)

    kwargs["tenant"] = user.tenant
    kwargs["auth_url"] = auth_url
    return (user.auth_user, user.auth_key), kwargs
开发者ID:pombredanne,项目名称:RDS,代码行数:62,代码来源:snippets.py

示例2: expected_default_datastore_configs

# 需要导入模块: from trove.tests.config import CONFIG [as 别名]
# 或者: from trove.tests.config.CONFIG import get [as 别名]
 def expected_default_datastore_configs():
     """Returns the expected test configurations for the default datastore
     defined in the Test Config as dbaas_datastore.
     """
     default_datatstore = CONFIG.get('dbaas_datastore', None)
     datastore_test_configs = CONFIG.get(default_datatstore, {})
     return datastore_test_configs.get("configurations", {})
开发者ID:tangguochang,项目名称:trove,代码行数:9,代码来源:configurations.py

示例3: run_initialized_instance_create

# 需要导入模块: from trove.tests.config import CONFIG [as 别名]
# 或者: from trove.tests.config.CONFIG import get [as 别名]
    def run_initialized_instance_create(
            self, with_dbs=True, with_users=True, configuration_id=None,
            expected_states=['BUILD', 'ACTIVE'], expected_http_code=200,
            create_helper_user=True):
        name = self.instance_info.name + '_init'
        flavor = self._get_instance_flavor()
        trove_volume_size = CONFIG.get('trove_volume_size', 1)
        self.init_inst_dbs = (self.test_helper.get_valid_database_definitions()
                              if with_dbs else [])
        self.init_inst_users = (self.test_helper.get_valid_user_definitions()
                                if with_users else [])
        if configuration_id:
            self.init_config_group_id = configuration_id

        if self.is_using_existing_instance:
            raise SkipTest("Using existing instance.")

        if (self.init_inst_dbs or self.init_inst_users or
                self.init_config_group_id):
            info = self.assert_instance_create(
                name, flavor, trove_volume_size,
                self.init_inst_dbs, self.init_inst_users,
                self.init_config_group_id, None,
                CONFIG.dbaas_datastore, CONFIG.dbaas_datastore_version,
                expected_states, expected_http_code,
                create_helper_user=create_helper_user)

            self.init_inst_id = info.id
        else:
            # There is no need to run this test as it's effectively the same as
            # the empty instance test.
            raise SkipTest("No testable initial properties provided.")
开发者ID:zjtheone,项目名称:trove,代码行数:34,代码来源:instance_create_runners.py

示例4: run_initialized_instance_create

# 需要导入模块: from trove.tests.config import CONFIG [as 别名]
# 或者: from trove.tests.config.CONFIG import get [as 别名]
    def run_initialized_instance_create(
            self, with_dbs=True, with_users=True, configuration_id=None,
            expected_states=['BUILD', 'ACTIVE'], expected_http_code=200):
        # TODO(pmalik): Instance create should return 202 Accepted (cast)
        # rather than 200 OK (call).
        name = self.instance_info.name
        flavor = self._get_instance_flavor()
        trove_volume_size = CONFIG.get('trove_volume_size', 1)
        self.init_inst_dbs = (self.test_helper.get_valid_database_definitions()
                              if with_dbs else [])
        self.init_inst_users = (self.test_helper.get_valid_user_definitions()
                                if with_users else [])
        if configuration_id:
            self.init_config_group_id = configuration_id

        if (self.init_inst_dbs or self.init_inst_users or
                self.init_config_group_id):
            info = self.assert_instance_create(
                name, flavor, trove_volume_size,
                self.init_inst_dbs, self.init_inst_users,
                self.init_config_group_id, None,
                CONFIG.dbaas_datastore, CONFIG.dbaas_datastore_version,
                expected_states, expected_http_code)

            self.init_inst_id = info.id
        else:
            # There is no need to run this test as it's effectively the same as
            # the empty instance test.
            raise SkipTest("No testable initial properties provided.")
开发者ID:magictour,项目名称:trove,代码行数:31,代码来源:instance_create_runners.py

示例5: expected_instance_datastore_configs

# 需要导入模块: from trove.tests.config import CONFIG [as 别名]
# 或者: from trove.tests.config.CONFIG import get [as 别名]
 def expected_instance_datastore_configs(instance_id):
     """Given an instance retrieve the expected test configurations for
     instance's datastore.
     """
     instance = instance_info.dbaas.instances.get(instance_id)
     datastore_type = instance.datastore['type']
     datastore_test_configs = CONFIG.get(datastore_type, {})
     return datastore_test_configs.get("configurations", {})
开发者ID:tangguochang,项目名称:trove,代码行数:10,代码来源:configurations.py

示例6: load_config_file

# 需要导入模块: from trove.tests.config import CONFIG [as 别名]
# 或者: from trove.tests.config.CONFIG import get [as 别名]
def load_config_file():
    global conf
    if CONFIG.get("examples", None) is None:
        fail("Missing 'examples' config in test config.")
    conf = CONFIG.examples
    global normal_user
    normal_user = CONFIG.users.find_user_by_name(conf['normal_user_name'])
    global admin_user
    admin_user = CONFIG.users.find_user_by_name(conf['admin_user_name'])
开发者ID:Tesora,项目名称:tesora-trove,代码行数:11,代码来源:snippets.py

示例7: call_xmllint

# 需要导入模块: from trove.tests.config import CONFIG [as 别名]
# 或者: from trove.tests.config.CONFIG import get [as 别名]
def call_xmllint(name, body):
    try:
        with open(CONFIG.xml_temp_file, "w") as file:
            file.write(body)

        # if CONFIG.get('xml_xsd', None):
        args = [CONFIG.xml_temp_file]
        if CONFIG.get("xml_xsd", None):
            args += ["--schema", CONFIG.xml_xsd]
        processutils.execute(CONFIG.xmllint_bin, *args, check_exit_code=0, shell=False)
    except processutils.ProcessExecutionError as pe:
        fail("Error validating XML! %s" % pe)
开发者ID:ReVolly,项目名称:trove,代码行数:14,代码来源:client.py

示例8: create_instance

# 需要导入模块: from trove.tests.config import CONFIG [as 别名]
# 或者: from trove.tests.config.CONFIG import get [as 别名]
 def create_instance(self):
     volume = None
     if VOLUME_SUPPORT:
         volume = {'size': 1}
     nics = None
     shared_network = CONFIG.get('shared_network', None)
     if shared_network:
         nics = [{'net-id': shared_network}]
     initial = self.client.instances.create(self.name, self.flavor_id,
                                            volume, [], [],
                                            nics=nics)
     self.id = initial.id
     self._wait_for_active()
开发者ID:Tesora,项目名称:tesora-trove,代码行数:15,代码来源:instances_mysql_down.py

示例9: __init__

# 需要导入模块: from trove.tests.config import CONFIG [as 别名]
# 或者: from trove.tests.config.CONFIG import get [as 别名]
    def __init__(self, sleep_time=10, timeout=1200):
        self.def_sleep_time = sleep_time
        self.def_timeout = timeout

        self.instance_info.name = "TEST_" + datetime.datetime.strftime(
            datetime.datetime.now(), '%Y_%m_%d__%H_%M_%S')
        self.instance_info.dbaas_datastore = CONFIG.dbaas_datastore
        self.instance_info.dbaas_datastore_version = (
            CONFIG.dbaas_datastore_version)
        self.instance_info.user = CONFIG.users.find_user_by_name('alt_demo')
        if self.VOLUME_SUPPORT:
            self.instance_info.volume_size = CONFIG.get('trove_volume_size', 1)
            self.instance_info.volume = {
                'size': self.instance_info.volume_size}
        else:
            self.instance_info.volume_size = None
            self.instance_info.volume = None
        self.instance_info.nics = None
        shared_network = CONFIG.get('shared_network', None)
        if shared_network:
            self.instance_info.nics = [{'net-id': shared_network}]

        self._auth_client = None
        self._unauth_client = None
        self._admin_client = None
        self._swift_client = None
        self._nova_client = None
        self._test_helper = None
        self._servers = {}

        # Attempt to register the main instance.  If it doesn't
        # exist, this will still set the 'report' and 'client' objects
        # correctly in LogOnFail
        inst_ids = []
        if hasattr(self.instance_info, 'id') and self.instance_info.id:
            inst_ids = [self.instance_info.id]
        self.register_debug_inst_ids(inst_ids)
开发者ID:Tesora,项目名称:tesora-trove,代码行数:39,代码来源:test_runners.py

示例10: __init__

# 需要导入模块: from trove.tests.config import CONFIG [as 别名]
# 或者: from trove.tests.config.CONFIG import get [as 别名]
    def __init__(self, sleep_time=10, timeout=1200):
        self.def_sleep_time = sleep_time
        self.def_timeout = timeout

        self.instance_info = instance_info
        instance_info.dbaas_datastore = CONFIG.dbaas_datastore
        instance_info.dbaas_datastore_version = CONFIG.dbaas_datastore_version
        if self.VOLUME_SUPPORT:
            instance_info.volume = {'size': CONFIG.get('trove_volume_size', 1)}
        else:
            instance_info.volume = None

        self.auth_client = create_dbaas_client(self.instance_info.user)
        self.unauth_client = None
        self._test_helper = None
开发者ID:pombredanne,项目名称:trove,代码行数:17,代码来源:test_runners.py

示例11: setUp

# 需要导入模块: from trove.tests.config import CONFIG [as 别名]
# 或者: from trove.tests.config.CONFIG import get [as 别名]
    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
        self.nics = None
        shared_network = CONFIG.get('shared_network', None)
        if shared_network:
            self.nics = [{'net-id': shared_network}]
开发者ID:Tesora,项目名称:tesora-trove,代码行数:17,代码来源:flavors.py

示例12: run_empty_instance_create

# 需要导入模块: from trove.tests.config import CONFIG [as 别名]
# 或者: from trove.tests.config.CONFIG import get [as 别名]
    def run_empty_instance_create(
            self, expected_states=['BUILD', 'ACTIVE'], expected_http_code=200):
        name = self.instance_info.name
        flavor = self._get_instance_flavor()
        trove_volume_size = CONFIG.get('trove_volume_size', 1)

        info = self.assert_instance_create(
            name, flavor, trove_volume_size, [], [], None, None,
            CONFIG.dbaas_datastore, CONFIG.dbaas_datastore_version,
            expected_states, expected_http_code, create_helper_user=True)

        # Update the shared instance info.
        self.instance_info.databases = info.databases
        self.instance_info.users = info.users
        self.instance_info.dbaas_datastore = info.dbaas_datastore
        self.instance_info.dbaas_datastore_version = (info.
                                                      dbaas_datastore_version)
        self.instance_info.dbaas_flavor_href = info.dbaas_flavor_href
        self.instance_info.volume = info.volume
        self.instance_info.id = info.id
开发者ID:zjtheone,项目名称:trove,代码行数:22,代码来源:instance_create_runners.py

示例13: __init__

# 需要导入模块: from trove.tests.config import CONFIG [as 别名]
# 或者: from trove.tests.config.CONFIG import get [as 别名]
    def __init__(self, sleep_time=10, timeout=1200):
        self.def_sleep_time = sleep_time
        self.def_timeout = timeout

        self.instance_info.name = "TEST_" + datetime.datetime.strftime(
            datetime.datetime.now(), '%Y-%m-%d_%H:%M:%S')
        self.instance_info.dbaas_datastore = CONFIG.dbaas_datastore
        self.instance_info.dbaas_datastore_version = (
            CONFIG.dbaas_datastore_version)
        self.instance_info.user = CONFIG.users.find_user_by_name('alt_demo')
        if self.VOLUME_SUPPORT:
            self.instance_info.volume = {
                'size': CONFIG.get('trove_volume_size', 1)}
        else:
            self.instance_info.volume = None

        self._auth_client = None
        self._unauth_client = None
        self._admin_client = None
        self._swift_client = None
        self._test_helper = None
开发者ID:ISCAS-VDI,项目名称:trove-base,代码行数:23,代码来源:test_runners.py

示例14: run_empty_instance_create

# 需要导入模块: from trove.tests.config import CONFIG [as 别名]
# 或者: from trove.tests.config.CONFIG import get [as 别名]
    def run_empty_instance_create(
            self, expected_states=['BUILD', 'ACTIVE'], expected_http_code=200):
        # TODO(pmalik): Instance create should return 202 Accepted (cast)
        # rather than 200 OK (call).
        name = self.instance_info.name
        flavor = self._get_instance_flavor()
        trove_volume_size = CONFIG.get('trove_volume_size', 1)

        info = self.assert_instance_create(
            name, flavor, trove_volume_size, [], [], None, None,
            CONFIG.dbaas_datastore, CONFIG.dbaas_datastore_version,
            expected_states, expected_http_code)

        # Update the shared instance info.
        self.instance_info.databases = info.databases
        self.instance_info.users = info.users
        self.instance_info.dbaas_datastore = info.dbaas_datastore
        self.instance_info.dbaas_datastore_version = (info.
                                                      dbaas_datastore_version)
        self.instance_info.dbaas_flavor_href = info.dbaas_flavor_href
        self.instance_info.volume = info.volume
        self.instance_info.id = info.id
开发者ID:magictour,项目名称:trove,代码行数:24,代码来源:instance_create_runners.py

示例15: set_up

# 需要导入模块: from trove.tests.config import CONFIG [as 别名]
# 或者: from trove.tests.config.CONFIG import get [as 别名]
 def set_up(self):
     """Create client for mgmt instance test (2)."""
     if not CONFIG.fake_mode:
         raise SkipTest("This test only works in fake mode.")
     self.client = create_client(is_admin=True)
     self.mgmt = self.client.management
     # Fake nova will fail a server ending with 'test_SERVER_ERROR'."
     # Fake volume will fail if the size is 13.
     # TODO(tim.simpson): This would be a lot nicer looking if we used a
     #                    traditional mock framework.
     datastore = {'type': 'mysql', 'version': '5.5'}
     body = {'datastore': datastore}
     vol_support = CONFIG.get(datastore['type'], 'mysql')['volume_support']
     if vol_support:
         body.update({'size': 13})
     response = self.client.instances.create(
         'test_SERVER_ERROR',
         instance_info.dbaas_flavor_href,
         body,
         [])
     poll_until(lambda: self.client.instances.get(response.id),
                lambda instance: instance.status == 'ERROR',
                time_out=10)
     self.id = response.id
开发者ID:Hopebaytech,项目名称:trove,代码行数:26,代码来源:instances.py


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