Merge ~mertkirpici/charm-cloudsupport:lp/1998094 into charm-cloudsupport:main

Proposed by Mert Kirpici
Status: Merged
Approved by: Erhan Sunar
Approved revision: c74eba447e5a32f4297ce957f83ffd493df45431
Merged at revision: 4267ca5f99fca5ccea77db7211de7a3711c7c3ac
Proposed branch: ~mertkirpici/charm-cloudsupport:lp/1998094
Merge into: charm-cloudsupport:main
Diff against target: 153 lines (+27/-4)
8 files modified
files/plugins/stale_server_check.py (+3/-0)
lib/lib_cloudsupport.py (+3/-0)
lib/os_testing.py (+12/-0)
lib/qssh.py (+2/-0)
tests/functional/tests/modules/setup.py (+1/-0)
tests/functional/tests/modules/test_cloudsupport.py (+1/-0)
tests/functional/tests/modules/test_utils.py (+1/-0)
tox.ini (+4/-4)
Reviewer Review Type Date Requested Status
Erhan Sunar (community) Approve
prod-jenkaas-bootstack (community) continuous-integration Needs Fixing
Eric Chen Approve
Ramesh Sattaru (community) Approve
Review via email: mp+433725@code.launchpad.net

Commit message

Close LP #1998094

Description of the change

flake8 6.0.0 does not like it when the inline comments are on the same
line as the ignored rule.

To post a comment you must log in.
Revision history for this message
Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mert Kirpici (mertkirpici) wrote :

The failed CI run is not relevant to this PR. This PR is about fixing the lint target. See:
https://jenkins.canonical.com/bootstack/job/lp-charm-test-functest/1414/console

The current failure is due to functests, for which the work is still in progress.

Revision history for this message
Ramesh Sattaru (rameshcan) :
review: Approve
Revision history for this message
Eric Chen (eric-chen) :
review: Approve
Revision history for this message
prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Erhan Sunar (esunar) wrote :

LGTM

review: Approve
Revision history for this message
Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 4267ca5f99fca5ccea77db7211de7a3711c7c3ac

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/files/plugins/stale_server_check.py b/files/plugins/stale_server_check.py
2index ff383d4..8de4070 100755
3--- a/files/plugins/stale_server_check.py
4+++ b/files/plugins/stale_server_check.py
5@@ -23,6 +23,7 @@ class NrpeStatus(IntEnum):
6
7
8 def nrpe_check():
9+ """Perform the nrpe check."""
10 args = parse_args()
11 crit_servers, warn_servers = get_stale_servers(
12 args.name_prefix, args.crit_days, args.warn_days, args.ignored_servers_uuids
13@@ -54,6 +55,7 @@ def nrpe_check():
14
15
16 def parse_args():
17+ """Parse the command line arguments."""
18 ap = argparse.ArgumentParser()
19 ap.add_argument("--cloud-name", dest="cloud_name", type=str, required=True)
20 ap.add_argument("--name-prefix", dest="name_prefix", type=str, required=True)
21@@ -71,6 +73,7 @@ def parse_args():
22
23
24 def get_stale_servers(name_prefix, crit_days, warn_days, ignored_servers=None):
25+ """Get the stale servers."""
26 crit_servers = []
27 warn_servers = []
28 server_search_pattern = "^{}".format(re.escape(name_prefix))
29diff --git a/lib/lib_cloudsupport.py b/lib/lib_cloudsupport.py
30index 8ec1d75..1fd5ffb 100644
31--- a/lib/lib_cloudsupport.py
32+++ b/lib/lib_cloudsupport.py
33@@ -47,13 +47,16 @@ class CloudSupportHelper:
34
35 @property
36 def check_stale_server(self):
37+ """Get the stale-server-check config option value."""
38 return self.charm_config.get("stale-server-check")
39
40 @property
41 def cloud_name(self):
42+ """Get the cloud-name config option value."""
43 return self.charm_config.get("cloud-name")
44
45 def install_dependencies(self):
46+ """Install charm dependencies."""
47 fetch.apt_install(["python3-openstackclient"], fatal=True)
48
49 def verify_config(self):
50diff --git a/lib/os_testing.py b/lib/os_testing.py
51index a5988ef..4cb4f68 100644
52--- a/lib/os_testing.py
53+++ b/lib/os_testing.py
54@@ -323,6 +323,12 @@ def delete_instance(nodes, pattern, cloud_name="cloud1"):
55
56
57 def get_instances(instance=None, cloud_name="cloud1"):
58+ """Get the list of instance ids from the cloud.
59+
60+ :param instance: get particular instance if specified
61+ :param cloud_name: the cloud name to get the instances from
62+ :return: list of instances
63+ """
64 if not instance:
65 instances = [
66 i.id
67@@ -338,6 +344,12 @@ def get_instances(instance=None, cloud_name="cloud1"):
68
69
70 def is_ovn_used(hypervisor_hostname, cloud_name="cloud1"):
71+ """Check is OVN used in a particular cloud.
72+
73+ :param hypervisor_hostname: the hostname of the hypervisor machine
74+ :param cloud_name: the cloud name the check is performed on
75+ :return: boolean value for the condition
76+ """
77 if (
78 len(
79 list(
80diff --git a/lib/qssh.py b/lib/qssh.py
81index a14e8dd..a733462 100644
82--- a/lib/qssh.py
83+++ b/lib/qssh.py
84@@ -44,6 +44,7 @@ def get_port(srv, network=None):
85
86
87 def build_ssh_command_line(ip, net):
88+ """Build the ssh command."""
89 dhcp_agent = next(con().network.network_hosting_dhcp_agents(net))
90 cmdline = (
91 """ssh -o 'ProxyCommand=ssh -l ubuntu {} "sudo ip netns exec qdhcp-{} """
92@@ -53,6 +54,7 @@ def build_ssh_command_line(ip, net):
93
94
95 def get_ssh_command_line(instance, network=None):
96+ """Print the ssh command."""
97 srv = con().compute.find_server(instance)
98 if not srv:
99 raise QsshError("Can't find {}".format(instance))
100diff --git a/tests/functional/tests/modules/setup.py b/tests/functional/tests/modules/setup.py
101index 2ab534d..a6dd88f 100644
102--- a/tests/functional/tests/modules/setup.py
103+++ b/tests/functional/tests/modules/setup.py
104@@ -24,6 +24,7 @@ cloudinit-userdata: |
105
106
107 def model_config():
108+ """Set the model configuration."""
109 tmp = Path(deployment_env.get_tmpdir())
110 priv_file, pub_file = gen_test_ssh_keys(tmp)
111 with pub_file.open() as f:
112diff --git a/tests/functional/tests/modules/test_cloudsupport.py b/tests/functional/tests/modules/test_cloudsupport.py
113index 4af0d5a..25508da 100644
114--- a/tests/functional/tests/modules/test_cloudsupport.py
115+++ b/tests/functional/tests/modules/test_cloudsupport.py
116@@ -19,6 +19,7 @@ logger = logging.getLogger(__name__)
117
118
119 def gen_clouds_yaml(creds_dict):
120+ """Generate and return the clouds.yaml content."""
121 template = textwrap.dedent(
122 """
123 clouds:
124diff --git a/tests/functional/tests/modules/test_utils.py b/tests/functional/tests/modules/test_utils.py
125index b9bbede..86dfd3b 100644
126--- a/tests/functional/tests/modules/test_utils.py
127+++ b/tests/functional/tests/modules/test_utils.py
128@@ -29,5 +29,6 @@ def gen_test_ssh_keys(tmpdir):
129
130
131 def get_priv_key(tmpdir):
132+ """Return the private key contents."""
133 priv_file = tmpdir / "test_id_rsa"
134 return priv_file.open().read()
135diff --git a/tox.ini b/tox.ini
136index 81c6399..201691a 100644
137--- a/tox.ini
138+++ b/tox.ini
139@@ -42,10 +42,10 @@ deps =
140
141 [flake8]
142 ignore =
143- D102 #TODO Missing docstring in public method
144- D103 #TODO Missing docstring in public function
145- N818 #exception should be named with an Error suffix
146- W503 #line break before binary operator (conflict with black)
147+ #exception should be named with an Error suffix
148+ N818
149+ #line break before binary operator (conflict with black)
150+ W503
151 exclude =
152 .git,
153 .venv,

Subscribers

People subscribed via source and target branches

to all changes: