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

cloudinit: remove global disable of pylint W0105 and fix errors #480

Merged
merged 2 commits into from
Jul 13, 2020
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
3 changes: 1 addition & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ jobs=4
[MESSAGES CONTROL]

# Errors and warings with some filtered:
# W0105(pointless-string-statement)
# W0107(unnecessary-pass)
# W0201(attribute-defined-outside-init)
# W0212(protected-access)
Expand All @@ -28,7 +27,7 @@ jobs=4
# W0703(broad-except)
# W1401(anomalous-backslash-in-string)

disable=C, F, I, R, W0105, W0107, W0201, W0212, W0221, W0222, W0223, W0231, W0311, W0511, W0602, W0603, W0611, W0613, W0621, W0622, W0631, W0703, W1401
disable=C, F, I, R, W0107, W0201, W0212, W0221, W0222, W0223, W0231, W0311, W0511, W0602, W0603, W0611, W0613, W0621, W0622, W0631, W0703, W1401


[REPORTS]
Expand Down
41 changes: 19 additions & 22 deletions cloudinit/analyze/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,25 @@
from cloudinit import util
from cloudinit.distros import uses_systemd

# An event:
'''
{
"description": "executing late commands",
"event_type": "start",
"level": "INFO",
"name": "cmd-install/stage-late"
"origin": "cloudinit",
"timestamp": 1461164249.1590767,
},

{
"description": "executing late commands",
"event_type": "finish",
"level": "INFO",
"name": "cmd-install/stage-late",
"origin": "cloudinit",
"result": "SUCCESS",
"timestamp": 1461164249.1590767
}

'''
# Example events:
# {
# "description": "executing late commands",
# "event_type": "start",
# "level": "INFO",
# "name": "cmd-install/stage-late"
# "origin": "cloudinit",
# "timestamp": 1461164249.1590767,
# }
# {
# "description": "executing late commands",
# "event_type": "finish",
# "level": "INFO",
# "name": "cmd-install/stage-late",
# "origin": "cloudinit",
# "result": "SUCCESS",
# "timestamp": 1461164249.1590767
# }

format_key = {
'%d': 'delta',
'%D': 'description',
Expand Down
14 changes: 6 additions & 8 deletions cloudinit/config/cc_resizefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,12 @@ def _can_skip_resize_ufs(mount_point, devpth):
if o == "-f":
frag_sz = int(a)
# check the current partition size
"""
# gpart show /dev/da0
=> 40 62914480 da0 GPT (30G)
40 1024 1 freebsd-boot (512K)
1064 58719232 2 freebsd-ufs (28G)
58720296 3145728 3 freebsd-swap (1.5G)
61866024 1048496 - free - (512M)
"""
# Example output from `gpart show /dev/da0`:
# => 40 62914480 da0 GPT (30G)
# 40 1024 1 freebsd-boot (512K)
# 1064 58719232 2 freebsd-ufs (28G)
# 58720296 3145728 3 freebsd-swap (1.5G)
# 61866024 1048496 - free - (512M)
expect_sz = None
m = re.search('^(/dev/.+)p([0-9])$', devpth)
gpart_res = _get_gpart_output(m.group(1))
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/distros/opensuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def _write_network_config(self, netconfig):
def preferred_ntp_clients(self):
"""The preferred ntp client is dependent on the version."""

"""Allow distro to determine the preferred ntp client list"""
# Allow distro to determine the preferred ntp client list
if not self._preferred_ntp_clients:
distro_info = util.system_info()['dist']
name = distro_info[0]
Expand Down
6 changes: 2 additions & 4 deletions cloudinit/net/eni.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,10 +483,8 @@ def _render_interfaces(self, network_state, render_hwaddress=False):
if searchdomains:
lo['subnets'][0]["dns_search"] = (" ".join(searchdomains))

''' Apply a sort order to ensure that we write out
the physical interfaces first; this is critical for
bonding
'''
# Apply a sort order to ensure that we write out the physical
# interfaces first; this is critical for bonding
order = {
'loopback': 0,
'physical': 1,
Expand Down
14 changes: 6 additions & 8 deletions cloudinit/sources/DataSourceAzure.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,11 @@ def get_resource_disk_on_freebsd(port_id):
port_id = port_id - 2
g1 = "000" + str(port_id)
g0g1 = "{0}-{1}".format(g0, g1)
"""
search 'X' from
'dev.storvsc.X.%pnpinfo:
classid=32412632-86cb-44a2-9b5c-50d1417354f5
deviceid=00000000-0001-8899-0000-000000000000'
"""

# search 'X' from
# 'dev.storvsc.X.%pnpinfo:
# classid=32412632-86cb-44a2-9b5c-50d1417354f5
# deviceid=00000000-0001-8899-0000-000000000000'
sysctl_out = get_dev_storvsc_sysctl()

storvscid = find_storvscid_from_sysctl_pnpinfo(sysctl_out, g0g1)
Expand Down Expand Up @@ -1485,13 +1484,12 @@ def maybe_remove_ubuntu_network_config_scripts(paths=None):


def _is_platform_viable(seed_dir):
"""Check platform environment to report if this datasource may run."""
with events.ReportEventStack(
name="check-platform-viability",
description="found azure asset tag",
parent=azure_ds_reporter
) as evt:

"""Check platform environment to report if this datasource may run."""
asset_tag = util.read_dmi_data('chassis-asset-tag')
if asset_tag == AZURE_CHASSIS_ASSET_TAG:
return True
Expand Down
6 changes: 3 additions & 3 deletions cloudinit/sources/DataSourceHetzner.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def get_data(self):
self.userdata_raw = hc_helper.maybe_b64decode(ud)
self.metadata_full = md

"""hostname is name provided by user at launch. The API enforces
it is a valid hostname, but it is not guaranteed to be resolvable
in dns or fully qualified."""
# hostname is name provided by user at launch. The API enforces it is
# a valid hostname, but it is not guaranteed to be resolvable in dns or
# fully qualified.
self.metadata['instance-id'] = md['instance-id']
self.metadata['local-hostname'] = md['hostname']
self.metadata['network-config'] = md.get('network-config', None)
Expand Down
7 changes: 3 additions & 4 deletions tests/unittests/test_datasource/test_azure_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,10 @@ def test_correct_url_used_for_goalstate(self):
self.GoalState.call_args_list)

def test_certificates_used_to_determine_public_keys(self):
# if register_with_azure_and_fetch_data() isn't passed some info about
# the user's public keys, there's no point in even trying to parse the
# certificates
shim = wa_shim()
"""if register_with_azure_and_fetch_data() isn't passed some info about
the user's public keys, there's no point in even trying to parse
the certificates
"""
mypk = [{'fingerprint': 'fp1', 'path': 'path1'},
{'fingerprint': 'fp3', 'path': 'path3', 'value': ''}]
certs = {'fp1': 'expected-key',
Expand Down
6 changes: 4 additions & 2 deletions tests/unittests/test_reporting_hyperv.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ def test_truncate_stale_kvp_file(self):
@mock.patch('cloudinit.subp.subp')
def test_get_boot_telemetry(self, m_subp, m_sysd):
reporter = HyperVKvpReportingHandler(kvp_file_path=self.tmp_file_path)
datetime_pattern = r"\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]"
r"\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)"
datetime_pattern = (
r"\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]"
r"\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)"
)

# get_boot_telemetry makes two subp calls to systemctl. We provide
# a list of values that the subp calls should return
Expand Down