Пример #1
0
def add_env_confopt_value(env_serviceprovider_line):
    """Add a new service_provider opt = val to the service_provider section.

    This function parses an existing conf file and adds the new values to
    the appropriate dictionary in the resulting conf object.

    """
    conf = ConfigParser(NEUTRON_LBAASCONFPATH, {})
    conf.parse()
    conf.sections['service_providers']['service_provider']\
        .append(env_serviceprovider_line)
    return conf
def add_env_confopt_value(env_serviceprovider_line):
    """Add a new service_provider opt = val to the service_provider section.

    This function parses an existing conf file and adds the new values to
    the appropriate dictionary in the resulting conf object.

    """
    conf = ConfigParser(NEUTRON_LBAASCONFPATH, {})
    conf.parse()
    conf.sections['service_providers']['service_provider']\
        .append(env_serviceprovider_line)
    return conf
def test_add_env_confopt_value(temp_files):
    from oslo_config.cfg import ConfigParser
    testconfname, testconfname_bak, _ = temp_files
    testconf = ConfigParser(testconfname, {})
    testconf.parse()
    original_values = set()
    original_service_providers = set()
    for section in testconf.sections.values():
        for option, values in section.items():
            if option == 'service_provider':
                original_service_providers.update(set(values))
            original_values.update(set(values))

    new_config = environment_library.add_env_confopt_value(FAKE_ENV)
    new_values = set()
    new_service_providers = set()
    for section in new_config.sections.values():
        for option, values in section.items():
            if option == 'service_provider':
                new_service_providers.update(set(values))
            new_values.update(set(values))
    assert new_values == original_values | set([FAKE_ENV])
    assert new_service_providers ==\
        original_service_providers | set([FAKE_ENV])
Пример #4
0
def test_add_env_confopt_value(temp_files):
    from oslo_config.cfg import ConfigParser
    testconfname, testconfname_bak, _ = temp_files
    testconf = ConfigParser(testconfname, {})
    testconf.parse()
    original_values = set()
    original_service_providers = set()
    for section in testconf.sections.values():
        for option, values in section.items():
            if option == 'service_provider':
                original_service_providers.update(set(values))
            original_values.update(set(values))

    new_config = environment_library.add_env_confopt_value(FAKE_ENV)
    new_values = set()
    new_service_providers = set()
    for section in new_config.sections.values():
        for option, values in section.items():
            if option == 'service_provider':
                new_service_providers.update(set(values))
            new_values.update(set(values))
    assert new_values == original_values | set([FAKE_ENV])
    assert new_service_providers ==\
        original_service_providers | set([FAKE_ENV])
 def __init__(self, filename):
     self._filename = filename
     ConfigParser.__init__(self, filename, {})
     self.parse()