0
$ ˆl–Ðz¾”ji?u4 \¸î*bÑ¿À
„biß¿ÃÂ
�
355ÄÃÂ c
404 Not Found
Not Found
The requested URL was not found on this server.
Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.
?÷ # Copyright 2022 Red Hat, Inc.
#
# Author: Lubomir Rintel
# Fixes and suggestions contributed by James Falcon, Neal Gompa,
# Zbigniew Jędrzejewski-Szmek and Emanuele Giuseppe Esposito.
#
# This file is part of cloud-init. See LICENSE file for license information.
import configparser
import io
import itertools
import logging
import os
import uuid
from typing import List, Optional
from cloudinit import subp, util
from cloudinit.net import (
is_ipv6_address,
is_ipv6_network,
renderer,
subnet_is_ipv6,
)
from cloudinit.net.network_state import NetworkState
from cloudinit.net.sysconfig import available_nm_ifcfg_rh
NM_RUN_DIR = "/etc/NetworkManager"
NM_LIB_DIR = "/usr/lib/NetworkManager"
IFCFG_CFG_FILE = "/etc/sysconfig/network-scripts"
NM_IPV6_ADDR_GEN_CONF = """# This is generated by cloud-init. Do not edit.
#
[.config]
enable=nm-version-min:1.40
[connection.30-cloud-init-ip6-addr-gen-mode]
# Select EUI64 to be used if the profile does not specify it.
ipv6.addr-gen-mode=0
"""
LOG = logging.getLogger(__name__)
class NMConnection:
"""Represents a NetworkManager connection profile."""
def __init__(self, con_id):
"""
Initializes the connection with some very basic properties,
notably the UUID so that the connection can be referred to.
"""
# Chosen by fair dice roll
CI_NM_UUID = uuid.UUID("a3924cb8-09e0-43e9-890b-77972a800108")
self.config = configparser.ConfigParser()
# Identity option name mapping, to achieve case sensitivity
self.config.optionxform = str
self.config["connection"] = {
"id": f"cloud-init {con_id}",
"uuid": str(uuid.uuid5(CI_NM_UUID, con_id)),
"autoconnect-priority": "120",
}
# This is not actually used anywhere, but may be useful in future
self.config["user"] = {
"org.freedesktop.NetworkManager.origin": "cloud-init"
}
def _set_default(self, section, option, value):
"""
Sets a property unless it's already set, ensuring the section
exists.
"""
if not self.config.has_section(section):
self.config[section] = {}
if not self.config.has_option(section, option):
self.config[section][option] = value
def _config_option_is_set(self, section, option):
"""
Checks if a config option is set. Returns True if it is,
else returns False.
"""
return self.config.has_section(section) and self.config.has_option(
section, option
)
def _get_config_option(self, section, option):
"""
Returns the value of a config option if its set,
else returns None.
"""
if self._config_option_is_set(section, option):
return self.config[section][option]
else:
return None
def _change_set_config_option(self, section, option, value):
"""
Overrides the value of a config option if its already set.
Else, if the config option is not set, it does nothing.
"""
if self._config_option_is_set(section, option):
self.config[section][option] = value
def _set_mayfail_true_if_both_false_dhcp(self):
"""
If for both ipv4 and ipv6, 'may-fail' is set to be False,
set it to True for both of them.
"""
for family in ["ipv4", "ipv6"]:
if self._get_config_option(family, "may-fail") != "false":
# if either ipv4 or ipv6 sections are not set/configured,
# or if both are configured