Ejemplo n.º 1
0
def show(include_status_data=False):
    """
    Reports configuration and status data on the system.
    Configuration data is the set of writable data which can change the system
    state.
    Status data is the additional data which is not configuration data,
    including read-only and statistics information.
    When include_status_data is set, both are reported, otherwise only the
    configuration data is reported.
    """
    client = nm.nmclient.client(refresh=True)

    report = {Constants.INTERFACES: interfaces()}
    if include_status_data:
        report['capabilities'] = capabilities()

    report[Constants.ROUTES] = {
        Route.RUNNING: (
            nm.ipv4.get_route_running() + nm.ipv6.get_route_running()
        ),
        Route.CONFIG: (
            nm.ipv4.get_route_config() + nm.ipv6.get_route_config()
        ),
    }

    report[Constants.DNS] = {
        DNS.RUNNING: nm_dns.get_running(),
        DNS.CONFIG: nm_dns.get_config(
            nm.ipv4.acs_and_ip_profiles(client),
            nm.ipv6.acs_and_ip_profiles(client),
        ),
    }

    validator.validate(report)
    return report
Ejemplo n.º 2
0
def test_get_dns_domain_duplicated(client_mock):
    dns_entry1 = mock_nm_dns_entry("eth1", "192.0.2.1", "example.org")
    dns_entry2 = mock_nm_dns_entry("eth2", "192.0.2.1", "example.org")
    client_mock.get_dns_configuration.return_value = [dns_entry1, dns_entry2]

    dns_state = nm_dns.get_running(client_mock)
    assert dns_state[DNS.SEARCH] == ["example.org"]
Ejemplo n.º 3
0
def test_get_dns_nameserver_duplicated(NM_mock):
    client_mock = NM_mock.Client.new.return_value
    dns_entry1 = mock_nm_dns_entry("eth1", "192.0.2.1", "example.org")
    dns_entry2 = mock_nm_dns_entry("eth2", "192.0.2.1", "example.org")
    client_mock.get_dns_configuration.return_value = [dns_entry1, dns_entry2]

    dns_state = nm_dns.get_running()
    assert dns_state[DNS.SERVER] == ["192.0.2.1"]