コード例 #1
0
ファイル: dns.py プロジェクト: elvgarrui/nmstate
def get_running():
    dns_state = {DNS.SERVER: [], DNS.SEARCH: []}
    client = nmclient.client()
    for dns_conf in client.get_dns_configuration():
        iface_name = dns_conf.get_interface()
        for ns in dns_conf.get_nameservers():
            if iplib.is_ipv6_link_local_addr(ns, IPV6_ADDRESS_LENGTH):
                if not iface_name:
                    # For IPv6 link local address, the interface name should be
                    # appended also.
                    raise NmstateInternalError(
                        "Missing interface for IPv6 link-local DNS server "
                        "entry {}".format(ns))
                ns_addr = "{}%{}".format(ns, iface_name)
            else:
                ns_addr = ns
            if ns_addr not in dns_state[DNS.SERVER]:
                dns_state[DNS.SERVER].append(ns_addr)
        dns_domains = [
            dns_domain for dns_domain in dns_conf.get_domains()
            if dns_domain not in dns_state[DNS.SEARCH]
        ]
        dns_state[DNS.SEARCH].extend(dns_domains)
    if not dns_state[DNS.SERVER] and not dns_state[DNS.SEARCH]:
        dns_state = {}
    return dns_state
コード例 #2
0
ファイル: ipv6.py プロジェクト: pavitra14/nmstate
def get_route_config():
    routes = nm_route.get_config(acs_and_ip_profiles(nmclient.client()))
    for route in routes:
        if route[Route.METRIC] == 0:
            # Kernel will convert 0 to IPV6_DEFAULT_ROUTE_METRIC.
            route[Route.METRIC] = IPV6_DEFAULT_ROUTE_METRIC

    return routes
コード例 #3
0
def _get_nm_profile_uuid(iface_name):
    nmcli = nmclient.client()
    cur_dev = None
    for dev in nmcli.get_all_devices():
        if dev.get_iface() == iface_name:
            cur_dev = dev
            break

    active_conn = cur_dev.get_active_connection()
    return active_conn.get_uuid()
コード例 #4
0
    def _refresh_checkpoint_timeout(self, data):
        cancellable, cb, cb_data = (None, None, None)
        nm_client = client()

        # Activation finished, _delete_client() invoked, which then invoke
        # _nmclient.delete_client(). Then it set self._client as None. The main
        # context got event from timeout, then invoke
        # _refresh_checkpoint_timeout(). So that time, the _nmclient is not
        # None while _nmclient.client is None.
        if nm_client:
            nm_client.checkpoint_adjust_rollback_timeout(
                self._dbuspath, self._timeout, cancellable, cb, cb_data)
            return GLib.SOURCE_CONTINUE
        else:
            return GLib.SOURCE_REMOVE
コード例 #5
0
ファイル: ipv6.py プロジェクト: pavitra14/nmstate
def get_routing_rule_config():
    return nm_route.get_routing_rule_config(
        acs_and_ip_profiles(nmclient.client()))
コード例 #6
0
ファイル: ipv6.py プロジェクト: pavitra14/nmstate
def get_route_running():
    return nm_route.get_running(_acs_and_ip_cfgs(nmclient.client()))
コード例 #7
0
ファイル: checkpoint.py プロジェクト: bellle/nmstate
def get_checkpoints():
    nm_client = client()
    checkpoints = [c.get_path() for c in nm_client.get_checkpoints()]
    return checkpoints
コード例 #8
0
def has_team_capability():
    nm_client = nmclient.client()
    return nmclient.NM.Capability.TEAM in nm_client.get_capabilities()