Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dead code #5887

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions cloudinit/cmd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,6 @@ def print_exc(msg=""):
sys.stderr.write("\n")


DEPRECATE_BOOT_STAGE_MESSAGE = (
"Triggering cloud-init boot stages outside of intial system boot is not a"
" fully supported operation which can lead to incomplete or incorrect"
" configuration. As such, cloud-init is deprecating this feature in the"
" future. If you currently use cloud-init in this way,"
" please file an issue describing in detail your use case so that"
" cloud-init can better support your needs:"
" https://github.com/canonical/cloud-init/issues/new"
)


def welcome(action, msg=None):
if not msg:
msg = welcome_format(action)
Expand Down
2 changes: 0 additions & 2 deletions cloudinit/config/cc_growpart.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
from cloudinit.distros import ALL_DISTROS, Distro
from cloudinit.settings import PER_ALWAYS

MODULE_DESCRIPTION = """\
"""
frequency = PER_ALWAYS
meta: MetaSchema = {
"id": "cc_growpart",
Expand Down
2 changes: 0 additions & 2 deletions cloudinit/config/cc_grub_dpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
from cloudinit.settings import PER_INSTANCE
from cloudinit.subp import ProcessExecutionError

MODULE_DESCRIPTION = """\
"""
meta: MetaSchema = {
"id": "cc_grub_dpkg",
"distros": ["ubuntu", "debian"],
Expand Down
1 change: 0 additions & 1 deletion cloudinit/config/cc_landscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from cloudinit.settings import PER_INSTANCE

LSC_CLIENT_CFG_FILE = "/etc/landscape/client.conf"
LS_DEFAULT_FILE = "/etc/default/landscape-client"

# defaults taken from stock client.conf in landscape-client 11.07.1.1-0ubuntu2
LSC_BUILTIN_CFG = {
Expand Down
23 changes: 10 additions & 13 deletions cloudinit/config/cc_reset_rmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,8 @@
# Author: Aman Kumar Sinha <amansi26@in.ibm.com>
#
# This file is part of cloud-init. See LICENSE file for license information.
"""Reset RMC: Reset rsct node id"""
import logging
import os

from cloudinit import subp, util
from cloudinit.cloud import Cloud
from cloudinit.config import Config
from cloudinit.config.schema import MetaSchema
from cloudinit.distros import ALL_DISTROS
from cloudinit.settings import PER_INSTANCE
"""Reset RMC: Reset rsct node id

# Since this module is undocumented, this variable is unused.
# Keeping it here for documentation purposes
MODULE_DESCRIPTION = """\
Reset RMC module is IBM PowerVM Hypervisor specific

Reliable Scalable Cluster Technology (RSCT) is a set of software components,
Expand All @@ -36,6 +24,15 @@

Prerequisite of using this module is to install RSCT packages.
"""
import logging
import os

from cloudinit import subp, util
from cloudinit.cloud import Cloud
from cloudinit.config import Config
from cloudinit.config.schema import MetaSchema
from cloudinit.distros import ALL_DISTROS
from cloudinit.settings import PER_INSTANCE

meta: MetaSchema = {
"id": "cc_reset_rmc",
Expand Down
1 change: 0 additions & 1 deletion cloudinit/config/cc_ubuntu_pro.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from cloudinit.config.schema import MetaSchema
from cloudinit.settings import PER_INSTANCE

PRO_URL = "https://ubuntu.com/pro"
DEPRECATED_KEYS = set(["ubuntu-advantage", "ubuntu_advantage"])

meta: MetaSchema = {
Expand Down
13 changes: 0 additions & 13 deletions cloudinit/config/cc_yum_add_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,6 @@
from cloudinit.config.schema import MetaSchema
from cloudinit.settings import PER_INSTANCE

COPR_BASEURL = (
"https://download.copr.fedorainfracloud.org/results/@cloud-init/"
"cloud-init-dev/epel-8-$basearch/"
)
COPR_GPG_URL = (
"https://download.copr.fedorainfracloud.org/results/@cloud-init/"
"cloud-init-dev/pubkey.gpg"
)
EPEL_TESTING_BASEURL = (
"https://download.copr.fedorainfracloud.org/results/@cloud-init/"
"cloud-init-dev/pubkey.gpg"
)

meta: MetaSchema = {
"id": "cc_yum_add_repo",
"distros": [
Expand Down
11 changes: 2 additions & 9 deletions cloudinit/config/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@
# If we change the location of versions.schema.json in github, we need
# to provide an updated PR to
# https://github.com/SchemaStore/schemastore.
VERSIONED_USERDATA_SCHEMA_FILE = "versions.schema.cloud-config.json"

# When bumping schema version due to incompatible changes:
# 1. Add a new schema-cloud-config-v#.json
# 2. change the USERDATA_SCHEMA_FILE to cloud-init-schema-v#.json
Expand Down Expand Up @@ -638,7 +636,6 @@ def netplan_validate_network_schema(
_, marks = safeyaml.load_with_marks(src_content)
print(
annotated_cloudconfig_file(
net_cfg,
src_content,
marks,
schema_errors=errors,
Expand Down Expand Up @@ -811,11 +808,9 @@ def validate_cloudconfig_schema(
class _Annotator:
def __init__(
self,
cloudconfig: dict,
original_content: str,
schemamarks: dict,
):
self._cloudconfig = cloudconfig
self._original_content = original_content
self._schemamarks = schemamarks

Expand Down Expand Up @@ -916,7 +911,6 @@ def annotate(


def annotated_cloudconfig_file(
cloudconfig: dict,
original_content: str,
schemamarks: dict,
*,
Expand All @@ -934,7 +928,7 @@ def annotated_cloudconfig_file(

@return Annotated schema
"""
return _Annotator(cloudconfig, original_content, schemamarks).annotate(
return _Annotator(original_content, schemamarks).annotate(
schema_errors or [], schema_deprecations or []
)

Expand Down Expand Up @@ -1111,7 +1105,7 @@ def validate_cloudconfig_file(
if annotate:
print(
annotated_cloudconfig_file(
{}, content, {}, schema_errors=schema_error.schema_errors
content, {}, schema_errors=schema_error.schema_errors
)
)
raise schema_error from e
Expand Down Expand Up @@ -1161,7 +1155,6 @@ def validate_cloudconfig_file(
if annotate:
print(
annotated_cloudconfig_file(
cloudconfig,
content,
marks,
schema_errors=errors,
Expand Down
4 changes: 1 addition & 3 deletions cloudinit/distros/package_management/apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ def run_package_command(self, command, args=None, pkgs=None):
full_command.extend(pkglist)

self._wait_for_apt_command(
short_cmd=command,
subp_kwargs={
"args": full_command,
"update_env": self.environment,
Expand All @@ -199,11 +198,10 @@ def _apt_lock_available(self):
return True

def _wait_for_apt_command(
self, short_cmd, subp_kwargs, timeout=APT_LOCK_WAIT_TIMEOUT
self, subp_kwargs, timeout=APT_LOCK_WAIT_TIMEOUT
):
"""Wait for apt install to complete.

short_cmd: Name of command like "upgrade" or "install"
subp_kwargs: kwargs to pass to subp
"""
start_time = time.monotonic()
Expand Down
20 changes: 0 additions & 20 deletions cloudinit/net/eni.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,26 +576,6 @@ def render_network_state(
)


def network_state_to_eni(network_state, header=None, render_hwaddress=False):
# render the provided network state, return a string of equivalent eni
eni_path = "etc/network/interfaces"
renderer = Renderer(
config={
"eni_path": eni_path,
"eni_header": header,
"netrules_path": None,
}
)
if not header:
header = ""
if not header.endswith("\n"):
header += "\n"
contents = renderer._render_interfaces(
network_state, render_hwaddress=render_hwaddress
)
return header + contents


def available(target=None):
expected = ["ifquery", "ifup", "ifdown"]
search = ["/sbin", "/usr/sbin"]
Expand Down
24 changes: 0 additions & 24 deletions cloudinit/sources/DataSourceScaleway.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,30 +255,6 @@ def ds_detect():
if "scaleway" in cmdline:
return True

def _set_urls_on_ip_version(self, proto, urls):

if proto not in ["ipv4", "ipv6"]:
LOG.debug("Invalid IP version : %s", proto)
return []

filtered_urls = []
for url in urls:
# Numeric IPs
address = urlparse(url).netloc
if address[0] == "[":
address = address[1:-1]
addr_proto = socket.getaddrinfo(
address, None, proto=socket.IPPROTO_TCP
)[0][0]
if addr_proto == socket.AF_INET and proto == "ipv4":
filtered_urls += [url]
continue
elif addr_proto == socket.AF_INET6 and proto == "ipv6":
filtered_urls += [url]
continue

return filtered_urls

def _get_data(self):

# The DataSource uses EventType.BOOT so we are called more than once.
Expand Down
12 changes: 0 additions & 12 deletions cloudinit/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1811,18 +1811,6 @@ def hash_blob(blob, routine: str, mlen=None) -> str:
return digest


def hash_buffer(f: io.BufferedIOBase) -> bytes:
"""Hash the content of a binary buffer using SHA1.

@param f: buffered binary stream to hash.
@return: digested data as bytes.
"""
hasher = hashlib.sha1()
for chunk in iter(lambda: f.read(io.DEFAULT_BUFFER_SIZE), b""):
hasher.update(chunk)
return hasher.digest()


def is_user(name):
try:
if pwd.getpwnam(name):
Expand Down
8 changes: 0 additions & 8 deletions tests/unittests/config/test_cc_landscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ def test_handler_restarts_landscape_client(self, m_subp, tmpdir):
mycloud = get_cloud("ubuntu")
mycloud.distro = mock.MagicMock()
cfg = {"landscape": {"client": {}}}
default_fn = tmpdir.join("default")
wrap_and_call(
"cloudinit.config.cc_landscape",
{
"LSC_CLIENT_CFG_FILE": {
"new": tmpdir.join("client.conf").strpath
},
"LS_DEFAULT_FILE": {"new": default_fn.strpath},
},
cc_landscape.handle,
"notimportant",
Expand Down Expand Up @@ -87,7 +85,6 @@ def test_handler_installs_client_from_ppa_and_supports_overrides(
"""Call landscape-config with any filesystem overrides."""
mycloud = get_cloud("ubuntu")
mycloud.distro = mock.MagicMock()
default_fn = tmpdir.join("default")
client_fn = tmpdir.join("client.conf")
client_fn.write("[client]\ndata_path = /var/lib/data\n")
cfg = {
Expand Down Expand Up @@ -119,7 +116,6 @@ def test_handler_installs_client_from_ppa_and_supports_overrides(
"cloudinit.config.cc_landscape",
{
"LSC_CLIENT_CFG_FILE": {"new": client_fn.strpath},
"LS_DEFAULT_FILE": {"new": default_fn.strpath},
},
cc_landscape.handle,
"notimportant",
Expand All @@ -139,7 +135,6 @@ def test_handler_writes_merged_client_config_file_with_defaults(
# Write existing sparse client.conf file
client_fn = tmpdir.join("client.conf")
client_fn.write("[client]\ncomputer_title = My PC\n")
default_fn = tmpdir.join("default")
mycloud = get_cloud("ubuntu")
mycloud.distro = mock.MagicMock()
cfg = {"landscape": {"client": {}}}
Expand Down Expand Up @@ -168,7 +163,6 @@ def test_handler_writes_merged_client_config_file_with_defaults(
"cloudinit.config.cc_landscape",
{
"LSC_CLIENT_CFG_FILE": {"new": client_fn.strpath},
"LS_DEFAULT_FILE": {"new": default_fn.strpath},
},
cc_landscape.handle,
"notimportant",
Expand All @@ -185,7 +179,6 @@ def test_handler_writes_merged_provided_cloudconfig_with_defaults(
# Write empty sparse client.conf file
client_fn = tmpdir.join("client.conf")
client_fn.write("")
default_fn = tmpdir.join("default")
mycloud = get_cloud("ubuntu")
mycloud.distro = mock.MagicMock()
cfg = {"landscape": {"client": {"computer_title": 'My" PC'}}}
Expand Down Expand Up @@ -214,7 +207,6 @@ def test_handler_writes_merged_provided_cloudconfig_with_defaults(
"cloudinit.config.cc_landscape",
{
"LSC_CLIENT_CFG_FILE": {"new": client_fn.strpath},
"LS_DEFAULT_FILE": {"new": default_fn.strpath},
},
cc_landscape.handle,
"notimportant",
Expand Down
11 changes: 4 additions & 7 deletions tests/unittests/config/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

from cloudinit import features, performance
from cloudinit.config.schema import (
VERSIONED_USERDATA_SCHEMA_FILE,
SchemaProblem,
SchemaType,
SchemaValidationError,
Expand Down Expand Up @@ -57,6 +56,7 @@

M_PATH = "cloudinit.config.schema."
DEPRECATED_LOG_LEVEL = 35
VERSIONED_USERDATA_SCHEMA_FILE = "versions.schema.cloud-config.json"


def get_schemas() -> dict:
Expand Down Expand Up @@ -973,9 +973,8 @@ class TestAnnotatedCloudconfigFile:
def test_annotated_cloudconfig_file_no_schema_errors(self):
"""With no schema_errors, print the original content."""
content = b"ntp:\n pools: [ntp1.pools.com]\n"
parse_cfg, schemamarks = load_with_marks(content)
_, schemamarks = load_with_marks(content)
assert content == annotated_cloudconfig_file(
parse_cfg,
content,
schemamarks=schemamarks,
schema_errors=[],
Expand Down Expand Up @@ -1005,14 +1004,13 @@ def test_annotated_cloudconfig_file_schema_annotates_and_adds_footer(self):

"""
)
parsed_config, schemamarks = load_with_marks(content[13:])
_, schemamarks = load_with_marks(content[13:])
schema_errors = [
SchemaProblem("ntp", "Some type error"),
SchemaProblem("ntp.pools.0", "-99 is not a string"),
SchemaProblem("ntp.pools.1", "75 is not a string"),
]
assert expected == annotated_cloudconfig_file(
parsed_config,
content,
schemamarks=schemamarks,
schema_errors=schema_errors,
Expand All @@ -1038,13 +1036,12 @@ def test_annotated_cloudconfig_file_annotates_separate_line_items(self):
- 75 # E2
"""
)
parsed_config, schemamarks = load_with_marks(content[13:])
_, schemamarks = load_with_marks(content[13:])
schema_errors = [
SchemaProblem("ntp.pools.0", "-99 is not a string"),
SchemaProblem("ntp.pools.1", "75 is not a string"),
]
assert expected in annotated_cloudconfig_file(
parsed_config,
content,
schemamarks=schemamarks,
schema_errors=schema_errors,
Expand Down
Loading