Skip to content

Commit

Permalink
tests: add flake8 to tox.ini
Browse files Browse the repository at this point in the history
this:
- adds flake8 to tox.ini
- addresses all flake8 errors

Signed-off-by: Guillaume Abrioux <[email protected]>
  • Loading branch information
guits committed Feb 12, 2024
1 parent ead0331 commit 55b872b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
24 changes: 9 additions & 15 deletions library/ceph_authtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,18 @@
from ansible.module_utils.basic import AnsibleModule
try:
from ansible.module_utils.ca_common import container_exec, \
is_containerized, \
fatal
is_containerized
except ImportError:
from module_utils.ca_common import container_exec, \
is_containerized, \
fatal
is_containerized
import datetime
import json
import os
import struct
import time
import base64
import socket


class KeyringExists(Exception):
pass


def build_cmd(create_keyring=False,
gen_key=False,
add_key=False,
Expand All @@ -34,7 +29,6 @@ def build_cmd(create_keyring=False,
c = container_exec('ceph-authtool',
container_image)


if name:
c.extend(['-n', name])
if create_keyring:
Expand All @@ -54,6 +48,7 @@ def build_cmd(create_keyring=False,

return c


def run_module():
module_args = dict(
name=dict(type='str', required=False),
Expand All @@ -71,9 +66,6 @@ def run_module():
add_file_common_args=True,
)




cmd = []
changed = False

Expand Down Expand Up @@ -121,12 +113,14 @@ def run_module():
if rc != 0:
module.fail_json(msg='non-zero return code', **result)

#file_args = module.load_file_common_arguments(module.params)
#module.set_fs_attributes_if_different(file_args, False)
# file_args = module.load_file_common_arguments(module.params)
# module.set_fs_attributes_if_different(file_args, False)
module.exit_json(**result)


def main():
run_module()


if __name__ == '__main__':
main()
3 changes: 1 addition & 2 deletions library/ceph_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Author: Guillaume Abrioux <[email protected]>

from __future__ import absolute_import, division, print_function
from typing import List, Tuple
__metaclass__ = type

from ansible.module_utils.basic import AnsibleModule # type: ignore
Expand Down Expand Up @@ -167,7 +166,7 @@ def main() -> None:

if action == 'set':
if value.lower() == current_value:
out = 'who={} option={} value={} already set. Skipping.'.format(who, option, value, container_image=container_image)
out = 'who={} option={} value={} already set. Skipping.'.format(who, option, value)
else:
rc, cmd, out, err = set_option(module, who, option, value, container_image=container_image)
changed = True
Expand Down
19 changes: 19 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ envlist = centos-{container,non_container}-{all_daemons,all_daemons_ipv6,colloca
centos-non_container-{switch_to_containers}
infra_lv_create
migrate_ceph_disk_to_ceph_volume
flake8

skipsdist = True

Expand Down Expand Up @@ -419,3 +420,21 @@ commands=
cephadm_adopt: {[cephadm-adopt]commands}

vagrant destroy --force

[testenv:flake8]
max-line-length = 100
ignore =
E501,
W503,
exclude =
.tox \
.vagrant \
__pycache__ \
*.pyc \
templates \
.eggs
statistics = True
deps =
flake8
commands =
flake8 --max-line-length=160 ./library ./module_utils/ ./tests/library/ ./tests/module_utils/ {posargs}

0 comments on commit 55b872b

Please sign in to comment.