Example #1
0
def test_pxeboot_range():
    """ Test import of system_config file for PXEBoot network address """

    # Create the path to the system_config file
    systemfile = os.path.join(os.getcwd(), "controllerconfig/tests/files/",
                              "system_config.pxeboot")

    # Test import and generation of answer file
    _test_system_config(systemfile)

    # Test detection of invalid PXEBoot network start address
    system_config = cr.parse_system_config(systemfile)
    system_config.set('PXEBOOT_NETWORK', 'IP_START_ADDRESS', '8.123.122.345')
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test detection of invalid PXEBoot network end address
    system_config = cr.parse_system_config(systemfile)
    system_config.set('PXEBOOT_NETWORK', 'IP_END_ADDRESS', '128.123.122.345')
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test detection of smaller PXEBoot network end address
    system_config = cr.parse_system_config(systemfile)
    system_config.set('PXEBOOT_NETWORK', 'IP_END_ADDRESS', '192.168.102.30')
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test detection of PXEBoot network range less than min required (8)
    system_config = cr.parse_system_config(systemfile)
    system_config.set('PXEBOOT_NETWORK', 'IP_END_ADDRESS', '128.123.122.34')
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)
Example #2
0
def _test_region_config(tmpdir, inputfile, resultfile, mock_get_wrsroot_sig):
    """ Test import and generation of answerfile """

    mock_get_wrsroot_sig.return_value = None

    # Create the path to the output file
    outputfile = os.path.join(str(tmpdir), 'output')

    # Parse the region_config file
    region_config = cr.parse_system_config(inputfile)

    # Dump results for debugging
    print("Parsed region_config:\n")
    _dump_config(region_config)

    # Validate the region config file
    cr.create_cgcs_config_file(outputfile, region_config,
                               keystone.ServiceList(FAKE_SERVICE_DATA),
                               keystone.EndpointList(FAKE_ENDPOINT_DATA),
                               keystone.DomainList(FAKE_DOMAIN_DATA))

    # Make a local copy of the results file
    local_resultfile = os.path.join(str(tmpdir), 'result')
    shutil.copyfile(resultfile, local_resultfile)

    # Do a diff between the output and the expected results
    print("\n\nDiff of output file vs. expected results file:\n")
    with open(outputfile) as a, open(local_resultfile) as b:
        a_lines = a.readlines()
        b_lines = b.readlines()

        differ = difflib.Differ()
        diff = differ.compare(a_lines, b_lines)
        print(''.join(diff))
    # Fail the testcase if the output doesn't match the expected results
    assert filecmp.cmp(outputfile, local_resultfile)

    # Now test that configassistant can parse this answerfile. We can't
    # compare the resulting cgcs_config file because the ordering, spacing
    # and comments are different between the answerfile generated by
    # systemconfig and ConfigAssistant.
    test_answerfile._test_answerfile(tmpdir, outputfile, compare_results=False)

    # Validate the region config file.
    # Using onboard validation since the validator's reference version number
    # is only set at build-time when validating offboard
    validate(region_config, REGION_CONFIG, None, False)
Example #3
0
def _test_system_config(filename):
    """ Test import and generation of answerfile """

    # Parse the system_config file
    system_config = cr.parse_system_config(filename)

    # Dump results for debugging
    print("Parsed system_config:\n")
    _dump_config(system_config)

    # Validate the system config file
    cr.create_cgcs_config_file(None,
                               system_config,
                               None,
                               None,
                               None,
                               0,
                               validate_only=True)

    # Validate the system config file.
    # Using onboard validation since the validator's reference version number
    # is only set at build-time when validating offboard
    validate(system_config, DEFAULT_CONFIG, None, False)
Example #4
0
def test_kubernetes():
    """ Test import of system_config file for kubernetes """

    # Create the path to the system_config file
    systemfile = os.path.join(os.getcwd(), "controllerconfig/tests/files/",
                              "system_config.kubernetes")

    # Test import and generation of answer file
    _test_system_config(systemfile)

    # Test CLUSTER_NETWORK start address specified without end address
    system_config = cr.parse_system_config(systemfile)
    system_config.set('CLUSTER_NETWORK', 'IP_START_ADDRESS', '192.168.204.2')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test CLUSTER_NETWORK end address specified without start address
    system_config = cr.parse_system_config(systemfile)
    system_config.set('CLUSTER_NETWORK', 'IP_END_ADDRESS', '192.168.204.200')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test detection of overspecification of CLUSTER network addresses
    system_config = cr.parse_system_config(systemfile)
    system_config.set('CLUSTER_NETWORK', 'IP_FLOATING_ADDRESS',
                      '192.168.206.103')
    system_config.set('CLUSTER_NETWORK', 'IP_IP_UNIT_0_ADDRESS',
                      '192.168.206.106')
    system_config.set('CLUSTER_NETWORK', 'IP_IP_UNIT_1_ADDRESS',
                      '192.168.206.109')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test absence of optional DNS configuration
    system_config = cr.parse_system_config(systemfile)
    system_config.remove_section('DNS')
    cr.create_cgcs_config_file(None,
                               system_config,
                               None,
                               None,
                               None,
                               0,
                               validate_only=True)
    validate(system_config, DEFAULT_CONFIG, None, False)

    # Test absence of optional docker proxy configuration
    system_config = cr.parse_system_config(systemfile)
    system_config.remove_section('DOCKER_PROXY')
    cr.create_cgcs_config_file(None,
                               system_config,
                               None,
                               None,
                               None,
                               0,
                               validate_only=True)
    validate(system_config, DEFAULT_CONFIG, None, False)

    # Test absence of optional docker registry configuration
    system_config = cr.parse_system_config(systemfile)
    system_config.remove_section('DOCKER_REGISTRY')
    cr.create_cgcs_config_file(None,
                               system_config,
                               None,
                               None,
                               None,
                               0,
                               validate_only=True)
    validate(system_config, DEFAULT_CONFIG, None, False)
Example #5
0
def test_system_config_validation():
    """ Test detection of various errors in system_config file """

    # Create the path to the system_config files
    simple_systemfile = os.path.join(os.getcwd(),
                                     "controllerconfig/tests/files/",
                                     "system_config.simple")
    ipv6_systemfile = os.path.join(os.getcwd(),
                                   "controllerconfig/tests/files/",
                                   "system_config.ipv6")
    lag_vlan_systemfile = os.path.join(os.getcwd(),
                                       "controllerconfig/tests/files/",
                                       "system_config.lag.vlan")
    ceph_systemfile = os.path.join(os.getcwd(),
                                   "controllerconfig/tests/files/",
                                   "system_config.ceph")
    static_addr_systemfile = os.path.join(os.getcwd(),
                                          "controllerconfig/tests/files/",
                                          "system_config.static_addr")

    # Test floating outside of OAM_NETWORK CIDR
    system_config = cr.parse_system_config(ipv6_systemfile)
    system_config.set('OAM_NETWORK', 'IP_FLOATING_ADDRESS', '5555::5')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test non-ipv6 unit address
    system_config = cr.parse_system_config(ipv6_systemfile)
    system_config.set('OAM_NETWORK', 'IP_UNIT_0_ADDRESS', '10.10.10.3')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test missing pxeboot network when using IPv6 management network
    system_config = cr.parse_system_config(ipv6_systemfile)
    system_config.remove_section('PXEBOOT_NETWORK')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test ridiculously sized management network
    system_config = cr.parse_system_config(ipv6_systemfile)
    system_config.set('MGMT_NETWORK', 'IP_START_ADDRESS', '1234::b:0:0:0')
    system_config.set('MGMT_NETWORK', 'IP_END_ADDRESS',
                      '1234::b:ffff:ffff:ffff')
    system_config.remove_option('MGMT_NETWORK', 'IP_FLOATING_ADDRESS')
    system_config.remove_option('MGMT_NETWORK', 'IP_UNIT_0_ADDRESS')
    system_config.remove_option('MGMT_NETWORK', 'IP_UNIT_1_ADDRESS')
    cr.create_cgcs_config_file(None,
                               system_config,
                               None,
                               None,
                               None,
                               0,
                               validate_only=True)
    validate(system_config, DEFAULT_CONFIG, None, False)

    # Test using start/end addresses
    system_config = cr.parse_system_config(ipv6_systemfile)
    system_config.set('OAM_NETWORK', 'IP_START_ADDRESS', 'abcd::2')
    system_config.set('OAM_NETWORK', 'IP_END_ADDRESS', 'abcd::4')
    system_config.remove_option('OAM_NETWORK', 'IP_FLOATING_ADDRESS')
    system_config.remove_option('OAM_NETWORK', 'IP_UNIT_0_ADDRESS')
    system_config.remove_option('OAM_NETWORK', 'IP_UNIT_1_ADDRESS')
    cr.create_cgcs_config_file(None,
                               system_config,
                               None,
                               None,
                               None,
                               0,
                               validate_only=True)
    validate(system_config, DEFAULT_CONFIG, None, False)

    # Test detection of an invalid PXEBOOT_CIDR
    system_config = cr.parse_system_config(lag_vlan_systemfile)
    system_config.set('PXEBOOT_NETWORK', 'PXEBOOT_CIDR', '192.168.1.4/24')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    system_config.set('PXEBOOT_NETWORK', 'PXEBOOT_CIDR', 'FD00::0000/64')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    system_config.set('PXEBOOT_NETWORK', 'PXEBOOT_CIDR', '192.168.1.0/29')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    system_config.remove_option('PXEBOOT_NETWORK', 'PXEBOOT_CIDR')
    with pytest.raises(configparser.NoOptionError):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(configparser.NoOptionError):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test overlap of MGMT_NETWORK CIDR
    system_config = cr.parse_system_config(lag_vlan_systemfile)
    system_config.set('MGMT_NETWORK', 'CIDR', '192.168.203.0/26')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test invalid MGMT_NETWORK LAG_MODE
    system_config = cr.parse_system_config(lag_vlan_systemfile)
    system_config.set('LOGICAL_INTERFACE_1', 'LAG_MODE', '2')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test MGMT_NETWORK VLAN not allowed
    system_config = cr.parse_system_config(simple_systemfile)
    system_config.set('MGMT_NETWORK', 'VLAN', '123')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test MGMT_NETWORK VLAN missing
    system_config = cr.parse_system_config(lag_vlan_systemfile)
    system_config.remove_option('MGMT_NETWORK', 'VLAN')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test MGMT_NETWORK start address specified without end address
    system_config = cr.parse_system_config(simple_systemfile)
    system_config.set('MGMT_NETWORK', 'IP_START_ADDRESS', '192.168.204.2')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test MGMT_NETWORK end address specified without start address
    system_config = cr.parse_system_config(simple_systemfile)
    system_config.set('MGMT_NETWORK', 'IP_END_ADDRESS', '192.168.204.200')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test MGMT_NETWORK start and end range does not have enough addresses
    system_config = cr.parse_system_config(static_addr_systemfile)
    system_config.set('MGMT_NETWORK', 'IP_START_ADDRESS', '192.168.204.2')
    system_config.set('MGMT_NETWORK', 'IP_END_ADDRESS', '192.168.204.8')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test MGMT_NETWORK start address not in subnet
    system_config = cr.parse_system_config(simple_systemfile)
    system_config.set('MGMT_NETWORK', 'IP_START_ADDRESS', '192.168.200.2')
    system_config.set('MGMT_NETWORK', 'IP_END_ADDRESS', '192.168.204.254')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test MGMT_NETWORK end address not in subnet
    system_config = cr.parse_system_config(simple_systemfile)
    system_config.set('MGMT_NETWORK', 'IP_START_ADDRESS', '192.168.204.2')
    system_config.set('MGMT_NETWORK', 'IP_END_ADDRESS', '192.168.214.254')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test overlap of INFRA_NETWORK CIDR
    system_config = cr.parse_system_config(lag_vlan_systemfile)
    system_config.set('INFRA_NETWORK', 'CIDR', '192.168.203.0/26')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    system_config.set('INFRA_NETWORK', 'CIDR', '192.168.204.0/26')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test invalid INFRA_NETWORK LAG_MODE
    system_config = cr.parse_system_config(lag_vlan_systemfile)
    system_config.add_section('LOGICAL_INTERFACE_2')
    system_config.set('LOGICAL_INTERFACE_2', 'LAG_INTERFACE', 'Y')
    system_config.set('LOGICAL_INTERFACE_2', 'LAG_MODE', '3')
    system_config.set('LOGICAL_INTERFACE_2', 'INTERFACE_MTU', '1500')
    system_config.set('LOGICAL_INTERFACE_2', 'INTERFACE_PORTS', 'eth3,eth4')
    system_config.set('INFRA_NETWORK', 'LOGICAL_INTERFACE',
                      'LOGICAL_INTERFACE_2')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test INFRA_NETWORK VLAN overlap
    system_config = cr.parse_system_config(lag_vlan_systemfile)
    system_config.set('INFRA_NETWORK', 'VLAN', '123')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test overlap of CLUSTER_NETWORK CIDR
    system_config = cr.parse_system_config(lag_vlan_systemfile)
    system_config.set('CLUSTER_NETWORK', 'CIDR', '192.168.203.0/26')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    system_config.set('CLUSTER_NETWORK', 'CIDR', '192.168.204.0/26')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test invalid CLUSTER_NETWORK LAG_MODE
    system_config = cr.parse_system_config(lag_vlan_systemfile)
    system_config.add_section('LOGICAL_INTERFACE_2')
    system_config.set('LOGICAL_INTERFACE_2', 'LAG_INTERFACE', 'Y')
    system_config.set('LOGICAL_INTERFACE_2', 'LAG_MODE', '3')
    system_config.set('LOGICAL_INTERFACE_2', 'INTERFACE_MTU', '1500')
    system_config.set('LOGICAL_INTERFACE_2', 'INTERFACE_PORTS', 'eth3,eth4')
    system_config.set('CLUSTER_NETWORK', 'LOGICAL_INTERFACE',
                      'LOGICAL_INTERFACE_2')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test CLUSTER_NETWORK VLAN overlap
    system_config = cr.parse_system_config(lag_vlan_systemfile)
    system_config.set('CLUSTER_NETWORK', 'VLAN', '123')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test overlap of OAM_NETWORK CIDR
    system_config = cr.parse_system_config(lag_vlan_systemfile)
    system_config.set('OAM_NETWORK', 'CIDR', '192.168.203.0/26')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    system_config.set('OAM_NETWORK', 'CIDR', '192.168.204.0/26')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    system_config.set('OAM_NETWORK', 'CIDR', '192.168.205.0/26')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test invalid OAM_NETWORK LAG_MODE
    system_config = cr.parse_system_config(lag_vlan_systemfile)
    system_config.add_section('LOGICAL_INTERFACE_2')
    system_config.set('LOGICAL_INTERFACE_2', 'LAG_INTERFACE', 'Y')
    system_config.set('LOGICAL_INTERFACE_2', 'LAG_MODE', '3')
    system_config.set('LOGICAL_INTERFACE_2', 'INTERFACE_MTU', '1500')
    system_config.set('LOGICAL_INTERFACE_2', 'INTERFACE_PORTS', 'eth3,eth4')
    system_config.set('OAM_NETWORK', 'LOGICAL_INTERFACE',
                      'LOGICAL_INTERFACE_2')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test OAM_NETWORK VLAN overlap
    system_config = cr.parse_system_config(lag_vlan_systemfile)
    system_config.set('OAM_NETWORK', 'VLAN', '123')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    system_config.set('OAM_NETWORK', 'VLAN', '124')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test OAM_NETWORK VLAN missing
    system_config = cr.parse_system_config(lag_vlan_systemfile)
    system_config.remove_option('OAM_NETWORK', 'VLAN')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test missing gateway
    system_config = cr.parse_system_config(lag_vlan_systemfile)
    system_config.remove_option('MGMT_NETWORK', 'GATEWAY')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test two gateways
    system_config = cr.parse_system_config(lag_vlan_systemfile)
    system_config.set('OAM_NETWORK', 'GATEWAY', '10.10.10.1')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test detection of unsupported NTP NTP_SERVER
    system_config = cr.parse_system_config(simple_systemfile)
    system_config.add_section('NTP')
    system_config.set('NTP', 'NTP_SERVER_1', '0.pool.ntp.org')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)

    # Test detection of overspecification of MGMT network addresses
    system_config = cr.parse_system_config(ceph_systemfile)
    system_config.set('MGMT_NETWORK', 'IP_FLOATING_ADDRESS', '192.168.204.3')
    system_config.set('MGMT_NETWORK', 'IP_IP_UNIT_0_ADDRESS', '192.168.204.6')
    system_config.set('MGMT_NETWORK', 'IP_IP_UNIT_1_ADDRESS', '192.168.204.9')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)

    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test detection of overspecification of INFRA network addresses
    system_config = cr.parse_system_config(ceph_systemfile)
    system_config.set('INFRA_NETWORK', 'IP_FLOATING_ADDRESS',
                      '192.168.205.103')
    system_config.set('INFRA_NETWORK', 'IP_IP_UNIT_0_ADDRESS',
                      '192.168.205.106')
    system_config.set('INFRA_NETWORK', 'IP_IP_UNIT_1_ADDRESS',
                      '192.168.205.109')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test detection of overspecification of OAM network addresses
    system_config = cr.parse_system_config(ceph_systemfile)
    system_config.set('MGMT_NETWORK', 'IP_FLOATING_ADDRESS', '10.10.10.2')
    system_config.set('MGMT_NETWORK', 'IP_IP_UNIT_0_ADDRESS', '10.10.10.3')
    system_config.set('MGMT_NETWORK', 'IP_IP_UNIT_1_ADDRESS', '10.10.10.4')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test detection of invalid release version
    system_config = cr.parse_system_config(ceph_systemfile)
    system_config.set('VERSION', 'RELEASE', '15.12')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)
Example #6
0
def test_system_config_simplex_mgmt():
    """ Test import of system_config file for AIO-simplex with management
    configuration"""

    # Create the path to the system_config file
    systemfile = os.path.join(os.getcwd(), "controllerconfig/tests/files/",
                              "system_config.simplex_mgmt")

    _test_system_config(systemfile)

    # Test MGMT_NETWORK parameters that are not allowed
    system_config = cr.parse_system_config(systemfile)
    system_config.set('MGMT_NETWORK', 'GATEWAY', '192.168.42.1')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)
    system_config = cr.parse_system_config(systemfile)
    system_config.set('MGMT_NETWORK', 'LOGICAL_INTERFACE',
                      'LOGICAL_INTERFACE_1')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test overlap with OAM network
    system_config = cr.parse_system_config(systemfile)
    system_config.set('MGMT_NETWORK', 'CIDR', '10.10.10.0/24')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test IPv6 management CIDR (not supported)
    system_config = cr.parse_system_config(systemfile)
    system_config.set('MGMT_NETWORK', 'CIDR', 'FD01::0000/64')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)

    # Test management CIDR that is too small
    system_config = cr.parse_system_config(systemfile)
    system_config.set('MGMT_NETWORK', 'CIDR', '192.168.42.0/29')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   system_config,
                                   None,
                                   None,
                                   None,
                                   0,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(system_config, DEFAULT_CONFIG, None, False)
Example #7
0
def test_region_config_validation():
    """ Test detection of various errors in region_config file """

    # Create the path to the region_config files
    simple_regionfile = os.path.join(os.getcwd(),
                                     "controllerconfig/tests/files/",
                                     "region_config.simple")
    lag_vlan_regionfile = os.path.join(os.getcwd(),
                                       "controllerconfig/tests/files/",
                                       "region_config.lag.vlan")

    # Test detection of non-required CINDER_* parameters
    region_config = cr.parse_system_config(simple_regionfile)
    region_config.set('STORAGE', 'CINDER_BACKEND', 'lvm')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, True)

    region_config = cr.parse_system_config(simple_regionfile)
    region_config.set('STORAGE', 'CINDER_DEVICE',
                      '/dev/disk/by-path/pci-0000:00:0d.0-ata-3.0')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, False)

    region_config = cr.parse_system_config(simple_regionfile)
    region_config.set('STORAGE', 'CINDER_STORAGE', '10')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, False)

    # Test detection of an invalid PXEBOOT_CIDR
    region_config = cr.parse_system_config(lag_vlan_regionfile)
    region_config.set('REGION2_PXEBOOT_NETWORK', 'PXEBOOT_CIDR',
                      '192.168.1.4/24')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, False)

    region_config.set('REGION2_PXEBOOT_NETWORK', 'PXEBOOT_CIDR',
                      'FD00::0000/64')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, False)

    region_config.set('REGION2_PXEBOOT_NETWORK', 'PXEBOOT_CIDR',
                      '192.168.1.0/29')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, False)

    region_config.remove_option('REGION2_PXEBOOT_NETWORK', 'PXEBOOT_CIDR')
    with pytest.raises(configparser.NoOptionError):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(configparser.NoOptionError):
        validate(region_config, REGION_CONFIG, None, False)

    # Test overlap of CLM_CIDR
    region_config = cr.parse_system_config(lag_vlan_regionfile)
    region_config.set('CLM_NETWORK', 'CLM_CIDR', '192.168.203.0/26')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, False)

    # Test invalid CLM LAG_MODE
    region_config = cr.parse_system_config(lag_vlan_regionfile)
    region_config.set('LOGICAL_INTERFACE_1', 'LAG_MODE', '2')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, False)

    # Test CLM_VLAN not allowed
    region_config = cr.parse_system_config(simple_regionfile)
    region_config.set('CLM_NETWORK', 'CLM_VLAN', '123')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, False)

    # Test CLM_VLAN missing
    region_config = cr.parse_system_config(lag_vlan_regionfile)
    region_config.remove_option('CLM_NETWORK', 'CLM_VLAN')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, False)

    # Test overlap of BLS_CIDR
    region_config = cr.parse_system_config(lag_vlan_regionfile)
    region_config.set('BLS_NETWORK', 'BLS_CIDR', '192.168.203.0/26')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, False)

    region_config.set('BLS_NETWORK', 'BLS_CIDR', '192.168.204.0/26')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, False)

    # Test invalid BLS LAG_MODE
    region_config = cr.parse_system_config(lag_vlan_regionfile)
    region_config.add_section('LOGICAL_INTERFACE_2')
    region_config.set('LOGICAL_INTERFACE_2', 'LAG_INTERFACE', 'Y')
    region_config.set('LOGICAL_INTERFACE_2', 'LAG_MODE', '3')
    region_config.set('LOGICAL_INTERFACE_2', 'INTERFACE_MTU', '1500')
    region_config.set('LOGICAL_INTERFACE_2', 'INTERFACE_PORTS', 'eth3,eth4')
    region_config.set('BLS_NETWORK', 'BLS_LOGICAL_INTERFACE',
                      'LOGICAL_INTERFACE_2')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, False)

    # Test BLS_VLAN overlap
    region_config = cr.parse_system_config(lag_vlan_regionfile)
    region_config.set('BLS_NETWORK', 'BLS_VLAN', '123')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, False)

    # Test overlap of CAN_CIDR
    region_config = cr.parse_system_config(lag_vlan_regionfile)
    region_config.set('CAN_NETWORK', 'CAN_CIDR', '192.168.203.0/26')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, False)

    region_config.set('CAN_NETWORK', 'CAN_CIDR', '192.168.204.0/26')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, False)

    region_config.set('CAN_NETWORK', 'CAN_CIDR', '192.168.205.0/26')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, False)

    # Test invalid CAN LAG_MODE
    region_config = cr.parse_system_config(lag_vlan_regionfile)
    region_config.add_section('LOGICAL_INTERFACE_2')
    region_config.set('LOGICAL_INTERFACE_2', 'LAG_INTERFACE', 'Y')
    region_config.set('LOGICAL_INTERFACE_2', 'LAG_MODE', '3')
    region_config.set('LOGICAL_INTERFACE_2', 'INTERFACE_MTU', '1500')
    region_config.set('LOGICAL_INTERFACE_2', 'INTERFACE_PORTS', 'eth3,eth4')
    region_config.set('CAN_NETWORK', 'CAN_LOGICAL_INTERFACE',
                      'LOGICAL_INTERFACE_2')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, False)

    # Test CAN_VLAN overlap
    region_config = cr.parse_system_config(lag_vlan_regionfile)
    region_config.set('CAN_NETWORK', 'CAN_VLAN', '123')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, False)

    region_config.set('CAN_NETWORK', 'CAN_VLAN', '124')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, False)

    # Test CAN_VLAN missing
    region_config = cr.parse_system_config(lag_vlan_regionfile)
    region_config.remove_option('CAN_NETWORK', 'CAN_VLAN')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, False)

    # Test missing gateway
    region_config = cr.parse_system_config(lag_vlan_regionfile)
    region_config.remove_option('CLM_NETWORK', 'CLM_GATEWAY')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, False)

    # Test two gateways
    region_config = cr.parse_system_config(lag_vlan_regionfile)
    region_config.set('CAN_NETWORK', 'CAN_GATEWAY', '10.10.10.1')
    with pytest.raises(exceptions.ConfigFail):
        cr.create_cgcs_config_file(None,
                                   region_config,
                                   None,
                                   None,
                                   None,
                                   validate_only=True)
    with pytest.raises(exceptions.ConfigFail):
        validate(region_config, REGION_CONFIG, None, False)
Example #8
0
def create_cgcs_config_file(output_file,
                            system_config,
                            services,
                            endpoints,
                            domains,
                            config_type=REGION_CONFIG,
                            validate_only=False):
    """
    Create cgcs_config file or just perform validation of the system_config if
    validate_only=True.
    :param output_file: filename of output cgcs_config file
    :param system_config: system configuration
    :param services: keystone services (not used if validate_only)
    :param endpoints: keystone endpoints (not used if validate_only)
    :param domains: keystone domains (not used if validate_only)
    :param config_type: specify region, subcloud or standard config
    :param validate_only: used to validate the input system_config
    :return:
    """
    cgcs_config = None
    if not validate_only:
        cgcs_config = configparser.RawConfigParser()
        cgcs_config.optionxform = str

    # general error checking, if not validate_only cgcs config data is returned
    validate(system_config, config_type, cgcs_config)

    # Region configuration: services, endpoints and domain
    if config_type in [REGION_CONFIG, SUBCLOUD_CONFIG] and not validate_only:
        # The services and endpoints are not available in the validation phase
        region_1_name = system_config.get('SHARED_SERVICES', 'REGION_NAME')
        keystone_service_name = system_config.get('SHARED_SERVICES',
                                                  'KEYSTONE_SERVICE_NAME')
        keystone_service_type = system_config.get('SHARED_SERVICES',
                                                  'KEYSTONE_SERVICE_TYPE')
        keystone_service_id = services.get_service_id(keystone_service_name,
                                                      keystone_service_type)
        keystone_admin_url = endpoints.get_service_url(region_1_name,
                                                       keystone_service_id,
                                                       "admin")
        keystone_internal_url = endpoints.get_service_url(
            region_1_name, keystone_service_id, "internal")
        keystone_public_url = endpoints.get_service_url(
            region_1_name, keystone_service_id, "public")

        cgcs_config.set('cREGION', 'KEYSTONE_AUTH_URI', keystone_internal_url)
        cgcs_config.set('cREGION', 'KEYSTONE_IDENTITY_URI', keystone_admin_url)
        cgcs_config.set('cREGION', 'KEYSTONE_ADMIN_URI', keystone_admin_url)
        cgcs_config.set('cREGION', 'KEYSTONE_INTERNAL_URI',
                        keystone_internal_url)
        cgcs_config.set('cREGION', 'KEYSTONE_PUBLIC_URI', keystone_public_url)

        # if ldap is a shared service
        if (system_config.has_option('SHARED_SERVICES', 'LDAP_SERVICE_URL')):
            ldap_service_url = system_config.get('SHARED_SERVICES',
                                                 'LDAP_SERVICE_URL')
            cgcs_config.set('cREGION', 'LDAP_SERVICE_URI', ldap_service_url)
            cgcs_config.set('cREGION', 'LDAP_SERVICE_NAME', 'open-ldap')
            cgcs_config.set('cREGION', 'LDAP_REGION_NAME', region_1_name)

        # If primary region is non-TiC and keystone entries already created,
        # the flag will tell puppet not to create them.
        if (system_config.has_option('REGION_2_SERVICES', 'CREATE')
                and system_config.get('REGION_2_SERVICES', 'CREATE') == 'Y'):
            cgcs_config.set('cREGION', 'REGION_SERVICES_CREATE', 'True')

    # System Timezone configuration
    if system_config.has_option('SYSTEM', 'TIMEZONE'):
        timezone = system_config.get('SYSTEM', 'TIMEZONE')
        if not os.path.isfile("/usr/share/zoneinfo/%s" % timezone):
            raise ConfigFail("Timezone file %s does not exist" % timezone)

    # Dump results for debugging
    # for section in cgcs_config.sections():
    #    print "[%s]" % section
    #    for (name, value) in cgcs_config.items(section):
    #        print "%s=%s" % (name, value)

    if not validate_only:
        # Write config file
        with open(output_file, 'w') as config_file:
            cgcs_config.write(config_file)