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 | |
parent | 4896402b2b0acb59646fff9d49e57b084d22d1b0 (diff) | |
download | cloud-init-git-b728b4e7cda8643c83d5c390411995f759cf97fa.tar.gz |
Remove dead code (#2038)
33 files changed, 7 insertions, 412 deletions
diff --git a/cloudinit/analyze/show.py b/cloudinit/analyze/show.py index 8ce649de..8d5866e3 100644 --- a/cloudinit/analyze/show.py +++ b/cloudinit/analyze/show.py @@ -4,7 +4,6 @@ # # This file is part of cloud-init. See LICENSE file for license information. -import base64 import datetime import json import os @@ -66,20 +65,6 @@ def format_record(msg, event): return msg.format(**event) -def dump_event_files(event): - content = dict((k, v) for k, v in event.items() if k not in ["content"]) - files = content["files"] - saved = [] - for f in files: - fname = f["path"] - fn_local = os.path.basename(fname) - fcontent = base64.b64decode(f["content"]).decode("ascii") - util.write_file(fn_local, fcontent) - saved.append(fn_local) - - return saved - - def event_name(event): if event: return event.get("name") diff --git a/cloudinit/config/cc_apt_configure.py b/cloudinit/config/cc_apt_configure.py index 17c2fb58..e8de000a 100644 --- a/cloudinit/config/cc_apt_configure.py +++ b/cloudinit/config/cc_apt_configure.py @@ -383,15 +383,6 @@ def rename_apt_lists(new_mirrors, target, arch): LOG.warning("Failed to rename apt list:", exc_info=True) -def mirror_to_placeholder(tmpl, mirror, placeholder): - """mirror_to_placeholder - replace the specified mirror in a template with a placeholder string - Checks for existance of the expected mirror and warns if not found""" - if mirror not in tmpl: - LOG.warning("Expected mirror '%s' not found in: %s", mirror, tmpl) - return tmpl.replace(mirror, placeholder) - - def map_known_suites(suite): """there are a few default names which will be auto-extended. This comes at the inability to use those names literally as suites, diff --git a/cloudinit/config/cc_refresh_rmc_and_interface.py b/cloudinit/config/cc_refresh_rmc_and_interface.py index 18c22476..87923f0b 100644 --- a/cloudinit/config/cc_refresh_rmc_and_interface.py +++ b/cloudinit/config/cc_refresh_rmc_and_interface.py @@ -150,20 +150,3 @@ def search(contents): or contents.startswith("IPV6INIT") or contents.startswith("NM_CONTROLLED") ) - - -def refresh_rmc(): - # To make a healthy connection between RMC daemon and hypervisor we - # refresh RMC. With refreshing RMC we are ensuring that making IPv6 - # down and up shouldn't impact communication between RMC daemon and - # hypervisor. - # -z : stop Resource Monitoring & Control subsystem and all resource - # managers, but the command does not return control to the user - # until the subsystem and all resource managers are stopped. - # -s : start Resource Monitoring & Control subsystem. - try: - subp.subp([RMCCTRL, "-z"]) - subp.subp([RMCCTRL, "-s"]) - except Exception: - util.logexc(LOG, "Failed to refresh the RMC subsystem.") - raise diff --git a/cloudinit/config/schema.py b/cloudinit/config/schema.py index 9bccdcec..0669defc 100644 --- a/cloudinit/config/schema.py +++ b/cloudinit/config/schema.py @@ -1139,19 +1139,6 @@ def get_schema() -> dict: return full_schema -def get_meta() -> dict: - """Return metadata coalesced from all cc_* cloud-config module.""" - full_meta = dict() - for (_, mod_name) in get_modules().items(): - mod_locs, _ = importer.find_module( - mod_name, ["cloudinit.config"], ["meta"] - ) - if mod_locs: - mod = importer.import_module(mod_locs[0]) - full_meta[mod.meta["id"]] = mod.meta - return full_meta - - def get_parser(parser=None): """Return a parser for supported cmdline arguments.""" if not parser: diff --git a/cloudinit/distros/netbsd.py b/cloudinit/distros/netbsd.py index b3232feb..b9811e6a 100644 --- a/cloudinit/distros/netbsd.py +++ b/cloudinit/distros/netbsd.py @@ -100,13 +100,6 @@ class NetBSD(cloudinit.distros.bsd.BSD): raise self.unlock_passwd(user) - def force_passwd_change(self, user): - try: - subp.subp(["usermod", "-F", user]) - except Exception: - util.logexc(LOG, "Failed to set pw expiration for %s", user) - raise - def lock_passwd(self, name): try: subp.subp(["usermod", "-C", "yes", name]) diff --git a/cloudinit/distros/parsers/ifconfig.py b/cloudinit/distros/parsers/ifconfig.py index 3e57e41a..0897beba 100644 --- a/cloudinit/distros/parsers/ifconfig.py +++ b/cloudinit/distros/parsers/ifconfig.py @@ -71,10 +71,6 @@ class Ifstate: def is_vlan(self) -> bool: return ("vlan" in self.groups) or (self.vlan != {}) - @property - def is_wlan(self) -> bool: - return "wlan" in self.groups - class Ifconfig: """ @@ -201,9 +197,6 @@ class Ifconfig: self._ifs_by_mac = dict(ifs_by_mac) return {**self._ifs_by_name, **self._ifs_by_mac} - def ifs_by_name(self): - return self._ifs_by_name - def ifs_by_mac(self): return self._ifs_by_mac diff --git a/cloudinit/distros/rhel.py b/cloudinit/distros/rhel.py index df7dc3d6..7fb7e56d 100644 --- a/cloudinit/distros/rhel.py +++ b/cloudinit/distros/rhel.py @@ -18,13 +18,6 @@ from cloudinit.settings import PER_INSTANCE LOG = logging.getLogger(__name__) -def _make_sysconfig_bool(val): - if val: - return "yes" - else: - return "no" - - class Distro(distros.Distro): # See: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Networking_Guide/sec-Network_Configuration_Using_sysconfig_Files.html # noqa clock_conf_fn = "/etc/sysconfig/clock" diff --git a/cloudinit/helpers.py b/cloudinit/helpers.py index 3e90f07d..78ddb794 100644 --- a/cloudinit/helpers.py +++ b/cloudinit/helpers.py @@ -43,9 +43,6 @@ class DummySemaphores: def clear(self, _name, _freq): return True - def clear_all(self): - pass - class FileLock: def __init__(self, fn): @@ -83,14 +80,6 @@ class FileSemaphores: return False return True - def clear_all(self): - try: - util.del_dir(self.sem_path) - except (IOError, OSError): - util.logexc( - LOG, "Failed deleting semaphore directory %s", self.sem_path - ) - def _acquire(self, name, freq): # Check again if its been already gotten if self.has_run(name, freq): 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 diff --git a/cloudinit/sources/DataSourceOpenNebula.py b/cloudinit/sources/DataSourceOpenNebula.py index a9744fa1..bcb0927a 100644 --- a/cloudinit/sources/DataSourceOpenNebula.py +++ b/cloudinit/sources/DataSourceOpenNebula.py @@ -161,9 +161,6 @@ class OpenNebulaNetwork: def mac2ip(self, mac): return ".".join([str(int(c, 16)) for c in mac.split(":")[2:]]) - def mac2network(self, mac): - return self.mac2ip(mac).rpartition(".")[0] + ".0" - def get_nameservers(self, dev): nameservers = {} dns = self.get_field(dev, "dns", "").split() @@ -208,9 +205,6 @@ class OpenNebulaNetwork: def get_mask(self, dev): return self.get_field(dev, "mask", "255.255.255.0") - def get_network(self, dev, mac): - return self.get_field(dev, "network", self.mac2network(mac)) - def get_field(self, dev, name, default=None): """return the field name in context for device dev. diff --git a/cloudinit/sources/DataSourceSmartOS.py b/cloudinit/sources/DataSourceSmartOS.py index 266daf68..41f6ec27 100644 --- a/cloudinit/sources/DataSourceSmartOS.py +++ b/cloudinit/sources/DataSourceSmartOS.py @@ -526,9 +526,6 @@ class JoyentMetadataClient: ).decode() return self.request(rtype="PUT", param=param) - def delete(self, key): - return self.request(rtype="DELETE", param=key) - def close_transport(self): if self.fp: self.fp.close() diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py index 565e1754..8446178f 100644 --- a/cloudinit/sources/__init__.py +++ b/cloudinit/sources/__init__.py @@ -895,10 +895,6 @@ class DataSource(CloudInitPickleMixin, metaclass=abc.ABCMeta): def network_config(self): return None - @property - def first_instance_boot(self): - return - def setup(self, is_new_instance): """setup(is_new_instance) diff --git a/cloudinit/sources/helpers/cloudsigma.py b/cloudinit/sources/helpers/cloudsigma.py index 5d39946f..1d6a1b45 100644 --- a/cloudinit/sources/helpers/cloudsigma.py +++ b/cloudinit/sources/helpers/cloudsigma.py @@ -53,10 +53,6 @@ class Cepko: request_pattern = self.request_pattern.format("/meta/{}") return self.get(key, request_pattern) - def global_context(self, key=""): - request_pattern = self.request_pattern.format("/global_context/{}") - return self.get(key, request_pattern) - class CepkoResult: """ diff --git a/cloudinit/sources/helpers/vmware/imc/config.py b/cloudinit/sources/helpers/vmware/imc/config.py index df9e5c4b..a129d9a8 100644 --- a/cloudinit/sources/helpers/vmware/imc/config.py +++ b/cloudinit/sources/helpers/vmware/imc/config.py @@ -50,11 +50,6 @@ class Config: return self._configFile.get(Config.TIMEZONE, None) @property - def utc(self): - """Retrieves whether to set time to UTC or Local.""" - return self._configFile.get(Config.UTC, None) - - @property def admin_password(self): """Return the root password to be set.""" return self._configFile.get(Config.PASS, None) diff --git a/cloudinit/sources/helpers/vmware/imc/config_file.py b/cloudinit/sources/helpers/vmware/imc/config_file.py index 37185cba..9f868389 100644 --- a/cloudinit/sources/helpers/vmware/imc/config_file.py +++ b/cloudinit/sources/helpers/vmware/imc/config_file.py @@ -69,39 +69,6 @@ class ConfigFile(ConfigSource, dict): for (key, value) in config.items(category): self._insertKey(category + "|" + key, value) - def should_keep_current_value(self, key): - """ - Determines whether a value for a property must be kept. - - If the propery is missing, it is treated as it should be not - changed by the engine. - - Keyword arguments: - key -- The key to search for. - """ - # helps to distinguish from "empty" value which is used to indicate - # "removal" - return key not in self - - def should_remove_current_value(self, key): - """ - Determines whether a value for the property must be removed. - - If the specified key is empty, it is treated as it should be - removed by the engine. - - Return true if the value can be removed, false otherwise. - - Keyword arguments: - key -- The key to search for. - """ - # helps to distinguish from "missing" value which is used to indicate - # "keeping unchanged" - if key in self: - return not bool(self[key]) - else: - return False - def get_count_with_prefix(self, prefix): """ Return the total count of keys that start with the specified prefix. @@ -110,6 +77,3 @@ class ConfigFile(ConfigSource, dict): prefix -- prefix of the key """ return len([key for key in self if key.startswith(prefix)]) - - -# vi: ts=4 expandtab diff --git a/cloudinit/sources/helpers/vmware/imc/config_namespace.py b/cloudinit/sources/helpers/vmware/imc/config_namespace.py deleted file mode 100644 index d44f4c01..00000000 --- a/cloudinit/sources/helpers/vmware/imc/config_namespace.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (C) 2015 Canonical Ltd. -# Copyright (C) 2015 VMware Inc. -# -# Author: Sankar Tanguturi <stanguturi@vmware.com> -# -# This file is part of cloud-init. See LICENSE file for license information. - -from cloudinit.sources.helpers.vmware.imc.config_source import ConfigSource - - -class ConfigNamespace(ConfigSource): - """Specifies the Config Namespace.""" - - -# vi: ts=4 expandtab diff --git a/cloudinit/sources/helpers/vmware/imc/config_nic.py b/cloudinit/sources/helpers/vmware/imc/config_nic.py index 7b9e0974..5ac8cbf1 100644 --- a/cloudinit/sources/helpers/vmware/imc/config_nic.py +++ b/cloudinit/sources/helpers/vmware/imc/config_nic.py @@ -230,16 +230,6 @@ class NicConfigurator: return (subnet_list, route_list) - def _genIpv6Route(self, name, nic, addrs): - route_list = [] - - for addr in addrs: - route_list.append( - {"type": "route", "gateway": addr.gateway, "metric": 10000} - ) - - return route_list - def generate(self, configure=False, osfamily=None): """Return the config elements that are needed to configure the nics""" if configure: diff --git a/cloudinit/sources/helpers/vmware/imc/ipv4_mode.py b/cloudinit/sources/helpers/vmware/imc/ipv4_mode.py deleted file mode 100644 index f290a36f..00000000 --- a/cloudinit/sources/helpers/vmware/imc/ipv4_mode.py +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (C) 2015 Canonical Ltd. -# Copyright (C) 2015 VMware Inc. -# -# Author: Sankar Tanguturi <stanguturi@vmware.com> -# -# This file is part of cloud-init. See LICENSE file for license information. - - -class Ipv4ModeEnum: - """ - The IPv4 configuration mode which directly represents the user's goal. - - This mode effectively acts as a contract of the in-guest customization - engine. It must be set based on what the user has requested and should - not be changed by those layers. It's up to the in-guest engine to - interpret and materialize the user's request. - """ - - # The legacy mode which only allows dhcp/static based on whether IPv4 - # addresses list is empty or not - IPV4_MODE_BACKWARDS_COMPATIBLE = "BACKWARDS_COMPATIBLE" - - # IPv4 must use static address. Reserved for future use - IPV4_MODE_STATIC = "STATIC" - - # IPv4 must use DHCPv4. Reserved for future use - IPV4_MODE_DHCP = "DHCP" - - # IPv4 must be disabled - IPV4_MODE_DISABLED = "DISABLED" - - # IPv4 settings should be left untouched. Reserved for future use - IPV4_MODE_AS_IS = "AS_IS" - - -# vi: ts=4 expandtab diff --git a/cloudinit/stages.py b/cloudinit/stages.py index a063e778..65f952e7 100644 --- a/cloudinit/stages.py +++ b/cloudinit/stages.py @@ -535,9 +535,6 @@ class Init: ] return def_handlers - def _default_userdata_handlers(self): - return self._default_handlers() - def _default_vendordata_handlers(self): return self._default_handlers( opts={ diff --git a/cloudinit/templater.py b/cloudinit/templater.py index 4d712829..8f98bb5d 100644 --- a/cloudinit/templater.py +++ b/cloudinit/templater.py @@ -149,12 +149,6 @@ def render_to_file(fn, outfn, params, mode=0o644): util.write_file(outfn, contents, mode=mode) -def render_string_to_file(content, outfn, params, mode=0o644): - """Render string""" - contents = render_string(content, params) - util.write_file(outfn, contents, mode=mode) - - def render_string(content, params): """Render string""" if not params: diff --git a/cloudinit/util.py b/cloudinit/util.py index aed332ec..2beff1cf 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -1517,12 +1517,6 @@ def blkid(devs=None, disable_cache=False): return ret -def peek_file(fname, max_bytes): - LOG.debug("Peeking at %s (max_bytes=%s)", fname, max_bytes) - with open(fname, "rb") as ifh: - return ifh.read(max_bytes) - - def uniq_list(in_list): out_list = [] for i in in_list: diff --git a/tests/unittests/config/test_cc_refresh_rmc_and_interface.py b/tests/unittests/config/test_cc_refresh_rmc_and_interface.py index e038f814..ee5ee8a8 100644 --- a/tests/unittests/config/test_cc_refresh_rmc_and_interface.py +++ b/tests/unittests/config/test_cc_refresh_rmc_and_interface.py @@ -110,7 +110,6 @@ class TestRsctNodeFile(t_help.CiTestCase): util.load_file(fname), ) - @mock.patch(MPATH + ".refresh_rmc") @mock.patch(MPATH + ".restart_network_manager") @mock.patch(MPATH + ".disable_ipv6") @mock.patch(MPATH + ".refresh_ipv6") @@ -123,11 +122,13 @@ class TestRsctNodeFile(t_help.CiTestCase): m_refresh_ipv6, m_disable_ipv6, m_restart_nm, - m_which, ): - """Basic test of handle.""" + """Basic test of handle. + + TODO: This test has suspicious mock names, is it actually testing the + correct things? + """ m_netdev_info.return_value = NET_INFO - m_which.return_value = "/opt/rsct/bin/rmcctrl" ccrmci.handle("refresh_rmc_and_interface", None, None, None, None) self.assertEqual(1, m_netdev_info.call_count) m_refresh_ipv6.assert_called_with("env5") diff --git a/tests/unittests/sources/test_cloudsigma.py b/tests/unittests/sources/test_cloudsigma.py index b92c3723..e1e11b84 100644 --- a/tests/unittests/sources/test_cloudsigma.py +++ b/tests/unittests/sources/test_cloudsigma.py @@ -10,7 +10,6 @@ from tests.unittests import helpers as test_helpers SERVER_CONTEXT = { "cpu": 1000, "cpus_instead_of_cores": False, - "global_context": {"some_global_key": "some_global_val"}, "mem": 1073741824, "meta": { "ssh_public_key": "ssh-rsa AAAAB3NzaC1yc2E.../hQ5D5 john@doe", diff --git a/tests/unittests/sources/test_opennebula.py b/tests/unittests/sources/test_opennebula.py index 0fc332a9..43a5dd5f 100644 --- a/tests/unittests/sources/test_opennebula.py +++ b/tests/unittests/sources/test_opennebula.py @@ -562,26 +562,6 @@ class TestOpenNebulaNetwork(unittest.TestCase): val = net.get_mask("eth0") self.assertEqual("255.255.255.0", val) - def test_get_network(self): - """ - Verify get_network('device') correctly returns IPv4 network address. - """ - context = {"ETH0_NETWORK": "1.2.3.0"} - net = ds.OpenNebulaNetwork(context, mock.Mock()) - val = net.get_network("eth0", MACADDR) - self.assertEqual("1.2.3.0", val) - - def test_get_network_emptystring(self): - """ - Verify get_network('device') correctly returns IPv4 network address. - It returns network address created by MAC address if ETH0_NETWORK has - empty string. - """ - context = {"ETH0_NETWORK": ""} - net = ds.OpenNebulaNetwork(context, mock.Mock()) - val = net.get_network("eth0", MACADDR) - self.assertEqual("10.18.1.0", val) - def test_get_field(self): """ Verify get_field('device', 'name') returns *context* value. diff --git a/tests/unittests/sources/vmware/test_vmware_config_file.py b/tests/unittests/sources/vmware/test_vmware_config_file.py index 2fc2e21c..e09fdfe4 100644 --- a/tests/unittests/sources/vmware/test_vmware_config_file.py +++ b/tests/unittests/sources/vmware/test_vmware_config_file.py @@ -50,18 +50,8 @@ class TestVmwareConfigFile(CiTestCase): self.assertEqual(2, len(cf), "insert size") self.assertEqual("foo", cf["PASSWORD|-PASS"], "password") self.assertTrue("PASSWORD|-PASS" in cf, "hasPassword") - self.assertFalse( - cf.should_keep_current_value("PASSWORD|-PASS"), "keepPassword" - ) - self.assertFalse( - cf.should_remove_current_value("PASSWORD|-PASS"), "removePassword" - ) self.assertFalse("FOO" in cf, "hasFoo") - self.assertTrue(cf.should_keep_current_value("FOO"), "keepFoo") - self.assertFalse(cf.should_remove_current_value("FOO"), "removeFoo") self.assertTrue("BAR" in cf, "hasBar") - self.assertFalse(cf.should_keep_current_value("BAR"), "keepBar") - self.assertTrue(cf.should_remove_current_value("BAR"), "removeBar") def test_configfile_without_instance_id(self): """ @@ -95,7 +85,6 @@ class TestVmwareConfigFile(CiTestCase): self.assertEqual("myhost1", conf.host_name, "hostName") self.assertEqual("Africa/Abidjan", conf.timezone, "tz") - self.assertTrue(conf.utc, "utc") self.assertEqual( ["10.20.145.1", "10.20.145.2"], conf.name_servers, "dns" diff --git a/tests/unittests/test_net_activators.py b/tests/unittests/test_net_activators.py index afd9056a..2a363ec4 100644 --- a/tests/unittests/test_net_activators.py +++ b/tests/unittests/test_net_activators.py @@ -322,28 +322,3 @@ class TestActivatorsBringDown: activator.bring_down_interface("eth0") assert len(m_subp.call_args_list) == 1 assert m_subp.call_args_list[0] == expected_call_list[0] - - @patch("cloudinit.subp.subp", return_value=("", "")) - def test_bring_down_interfaces( - self, m_subp, activator, expected_call_list, available_mocks - ): - activator.bring_down_interfaces(["eth0", "eth1"]) - assert expected_call_list == m_subp.call_args_list - - @patch("cloudinit.subp.subp", return_value=("", "")) - def test_bring_down_all_interfaces_v1( - self, m_subp, activator, expected_call_list, available_mocks - ): - network_state = parse_net_config_data(load(V1_CONFIG)) - activator.bring_down_all_interfaces(network_state) - for call in m_subp.call_args_list: - assert call in expected_call_list - - @patch("cloudinit.subp.subp", return_value=("", "")) - def test_bring_down_all_interfaces_v2( - self, m_subp, activator, expected_call_list, available_mocks - ): - network_state = parse_net_config_data(load(V2_CONFIG)) - activator.bring_down_all_interfaces(network_state) - for call in m_subp.call_args_list: - assert call in expected_call_list |