diff options
author | Brett Holman <brett.holman@canonical.com> | 2023-03-03 14:00:16 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-03 15:00:16 -0600 |
commit | b728b4e7cda8643c83d5c390411995f759cf97fa (patch) | |
tree | c8498433b5de4dbf775dd09da0a72e44f6e385c2 /cloudinit/net | |
parent | 4896402b2b0acb59646fff9d49e57b084d22d1b0 (diff) | |
download | cloud-init-git-b728b4e7cda8643c83d5c390411995f759cf97fa.tar.gz |
Remove dead code (#2038)
Diffstat (limited to 'cloudinit/net')
-rw-r--r-- | cloudinit/net/activators.py | 38 | ||||
-rw-r--r-- | cloudinit/net/bsd.py | 3 | ||||
-rw-r--r-- | cloudinit/net/eni.py | 14 | ||||
-rw-r--r-- | cloudinit/net/ephemeral.py | 16 | ||||
-rw-r--r-- | cloudinit/net/netplan.py | 20 | ||||
-rw-r--r-- | cloudinit/net/network_state.py | 7 | ||||
-rw-r--r-- | cloudinit/net/networkd.py | 14 | ||||
-rw-r--r-- | cloudinit/net/renderer.py | 21 |
8 files changed, 2 insertions, 131 deletions
diff --git a/cloudinit/net/activators.py b/cloudinit/net/activators.py index 7d11a02c..e69da40d 100644 --- a/cloudinit/net/activators.py +++ b/cloudinit/net/activators.py @@ -72,24 +72,6 @@ class NetworkActivator(ABC): [i["name"] for i in network_state.iter_interfaces()] ) - @classmethod - def bring_down_interfaces(cls, device_names: Iterable[str]) -> bool: - """Bring down specified list of interfaces. - - Return True is successful, otherwise return False - """ - return all(cls.bring_down_interface(device) for device in device_names) - - @classmethod - def bring_down_all_interfaces(cls, network_state: NetworkState) -> bool: - """Bring down all interfaces. - - Return True is successful, otherwise return False - """ - return cls.bring_down_interfaces( - [i["name"] for i in network_state.iter_interfaces()] - ) - class IfUpDownActivator(NetworkActivator): # Note that we're not overriding bring_up_interfaces to pass something @@ -205,26 +187,6 @@ class NetplanActivator(NetworkActivator): ) return _alter_interface(NetplanActivator.NETPLAN_CMD, "all") - @staticmethod - def bring_down_interfaces(device_names: Iterable[str]) -> bool: - """Apply netplan config. - - Return True is successful, otherwise return False - """ - LOG.debug( - "Calling 'netplan apply' rather than " - "altering individual interfaces" - ) - return _alter_interface(NetplanActivator.NETPLAN_CMD, "all") - - @staticmethod - def bring_down_all_interfaces(network_state: NetworkState) -> bool: - """Apply netplan config. - - Return True is successful, otherwise return False - """ - return _alter_interface(NetplanActivator.NETPLAN_CMD, "all") - class NetworkdActivator(NetworkActivator): @staticmethod diff --git a/cloudinit/net/bsd.py b/cloudinit/net/bsd.py index b23279e5..8892b3ba 100644 --- a/cloudinit/net/bsd.py +++ b/cloudinit/net/bsd.py @@ -222,9 +222,6 @@ class BSDRenderer(renderer.Renderer): def write_config(self, target=None): raise NotImplementedError() - def set_gateway(self, gateway): - raise NotImplementedError() - def rename_interface(self, cur_name, device_name): raise NotImplementedError() diff --git a/cloudinit/net/eni.py b/cloudinit/net/eni.py index 53bd35ca..ae56f72c 100644 --- a/cloudinit/net/eni.py +++ b/cloudinit/net/eni.py @@ -308,18 +308,6 @@ def _parse_deb_config_data(ifaces, contents, src_dir, src_path): ifaces[iface]["auto"] = False -def parse_deb_config(path): - """Parses a debian network configuration file.""" - ifaces = {} - with open(path, "r") as fp: - contents = fp.read().strip() - abs_path = os.path.abspath(path) - _parse_deb_config_data( - ifaces, contents, os.path.dirname(abs_path), abs_path - ) - return ifaces - - def convert_eni_data(eni_data): # return a network config representation of what is in eni_data ifaces = {} @@ -329,7 +317,7 @@ def convert_eni_data(eni_data): def _ifaces_to_net_config_data(ifaces): """Return network config that represents the ifaces data provided. - ifaces = parse_deb_config("/etc/network/interfaces") + ifaces = _parse_deb_config_data(...) config = ifaces_to_net_config_data(ifaces) state = parse_net_config_data(config).""" devs = {} diff --git a/cloudinit/net/ephemeral.py b/cloudinit/net/ephemeral.py index fa1116c9..cade2e5f 100644 --- a/cloudinit/net/ephemeral.py +++ b/cloudinit/net/ephemeral.py @@ -107,22 +107,6 @@ class EphemeralIPv4Network: for cmd in self.cleanup_cmds: subp.subp(cmd, capture=True) - def _delete_address(self, address, prefix): - """Perform the ip command to remove the specified address.""" - subp.subp( - [ - "ip", - "-family", - "inet", - "addr", - "del", - "%s/%s" % (address, prefix), - "dev", - self.interface, - ], - capture=True, - ) - def _bringup_device(self): """Perform the ip comands to fully setup the device.""" cidr = "{0}/{1}".format(self.ip, self.prefix) diff --git a/cloudinit/net/netplan.py b/cloudinit/net/netplan.py index ad586e1e..1c28e16e 100644 --- a/cloudinit/net/netplan.py +++ b/cloudinit/net/netplan.py @@ -500,23 +500,3 @@ def available(target=None): if not subp.which(p, search=search, target=target): return False return True - - -def network_state_to_netplan(network_state, header=None): - # render the provided network state, return a string of equivalent eni - netplan_path = "etc/network/50-cloud-init.yaml" - renderer = Renderer( - { - "netplan_path": netplan_path, - "netplan_header": header, - } - ) - if not header: - header = "" - if not header.endswith("\n"): - header += "\n" - contents = renderer._render_content(network_state) - return header + contents - - -# vi: ts=4 expandtab diff --git a/cloudinit/net/network_state.py b/cloudinit/net/network_state.py index 790398bc..158a2951 100644 --- a/cloudinit/net/network_state.py +++ b/cloudinit/net/network_state.py @@ -94,13 +94,6 @@ def warn_deprecated_all_devices(dikt: dict) -> None: ) -def from_state_file(state_file): - state = util.read_conf(state_file) - nsi = NetworkStateInterpreter() - nsi.load(state) - return nsi - - def diff_keys(expected, actual): missing = set(expected) for key in actual: diff --git a/cloudinit/net/networkd.py b/cloudinit/net/networkd.py index 4fd8a9b8..6a75f38a 100644 --- a/cloudinit/net/networkd.py +++ b/cloudinit/net/networkd.py @@ -80,15 +80,6 @@ class CfgParser: return contents - def dump_data(self, target_fn): - if not target_fn: - LOG.warning("Target file not given") - return - - contents = self.get_final_conf() - LOG.debug("Final content: %s", contents) - util.write_file(target_fn, contents) - class Renderer(renderer.Renderer): """ @@ -371,8 +362,3 @@ def available(target=None): if not subp.which(p, search=search, target=target): return False return True - - -def network_state_to_networkd(ns: NetworkState): - renderer = Renderer({}) - return renderer._render_content(ns) diff --git a/cloudinit/net/renderer.py b/cloudinit/net/renderer.py index 6bf4703c..72813e32 100644 --- a/cloudinit/net/renderer.py +++ b/cloudinit/net/renderer.py @@ -9,7 +9,7 @@ import abc import io from typing import Optional -from cloudinit.net.network_state import NetworkState, parse_net_config_data +from cloudinit.net.network_state import NetworkState from cloudinit.net.udev import generate_udev_rule @@ -17,10 +17,6 @@ def filter_by_type(match_type): return lambda iface: match_type == iface["type"] -def filter_by_name(match_name): - return lambda iface: match_name == iface["name"] - - def filter_by_attr(match_name): return lambda iface: (match_name in iface and iface[match_name]) @@ -57,18 +53,3 @@ class Renderer: target=None, ) -> None: """Render network state.""" - - def render_network_config( - self, - network_config: dict, - templates: Optional[dict] = None, - target=None, - ): - return self.render_network_state( - network_state=parse_net_config_data(network_config), - templates=templates, - target=target, - ) - - -# vi: ts=4 expandtab |