From b5271952657084c9266065a555c8f2743e97ccd7 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 15 Mar 2021 16:42:06 -0500 Subject: [PATCH] cephadm: expected 2 blank lines, found 1 (E302) Signed-off-by: Michael Fritch (cherry picked from commit dea779803445cc83fa0a63570d0068f572ccbd20) # Conflicts: # src/cephadm/cephadm - whitespace --- src/cephadm/cephadm | 36 ++++++++++++++++++++++++++++-------- src/cephadm/tox.ini | 1 - 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index ef2740f32642c..ba042573b5c3d 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -100,6 +100,7 @@ logger: logging.Logger = None # type: ignore ################################## + class BaseConfig: def __init__(self): @@ -195,6 +196,7 @@ logging_config = { } } + class termcolor: yellow = '\033[93m' red = '\033[31m' @@ -309,6 +311,8 @@ class Monitoring(object): return version ################################## + + def populate_files(config_dir, config_files, uid, gid): # type: (str, Dict, int, int) -> None """create config files for different services""" @@ -321,6 +325,7 @@ def populate_files(config_dir, config_files, uid, gid): os.fchmod(f.fileno(), 0o600) f.write(config_content) + class NFSGanesha(object): """Defines a NFS-Ganesha container""" @@ -618,6 +623,7 @@ class CephIscsi(object): ################################## + class HAproxy(object): """Defines an HAproxy container""" daemon_type = 'haproxy' @@ -956,6 +962,7 @@ def get_supported_daemons(): ################################## + class PortOccupiedError(Error): pass @@ -1014,6 +1021,7 @@ def check_ip_port(ctx, ip, port): ################################## + # this is an abbreviated version of # https://github.com/benediktschmitt/py-filelock/blob/master/filelock.py # that drops all of the compatibility (this is Unix/Linux only). @@ -1332,6 +1340,7 @@ except ImportError: asyncio.set_event_loop(None) loop.close() + def call(ctx: CephadmContext, command: List[str], desc: Optional[str] = None, @@ -2578,6 +2587,7 @@ def deploy_daemon(ctx, fsid, daemon_type, daemon_id, c, uid, gid, call_throws(ctx, ['systemctl', 'restart', get_unit_name(fsid, daemon_type, daemon_id)]) + def _write_container_cmd_to_bash(ctx, file_obj, container, comment=None, background=False): # type: (CephadmContext, IO[str], CephContainer, Optional[str], Optional[bool]) -> None if comment: @@ -2863,6 +2873,7 @@ def update_firewalld(ctx, daemon_type): firewall.open_ports(fw_ports) firewall.apply_rules() + def install_base_units(ctx, fsid): # type: (CephadmContext, str) -> None """ @@ -3205,6 +3216,7 @@ def _pull_image(ctx, image): time.sleep(sleep_secs) raise RuntimeError('Failed command: %s: maximum retries reached' % cmd_str) + ################################## @@ -3238,8 +3250,9 @@ def get_image_info_from_inspect(out, image): r['repo_digests'] = digests[1:-1].split(' ') return r - ################################## + + def check_subnet(subnets: str) -> Tuple[int, List[int], str]: """Determine whether the given string is a valid subnet @@ -3266,6 +3279,7 @@ def check_subnet(subnets: str) -> Tuple[int, List[int], str]: return rc, list(versions), ", ".join(errors) + def unwrap_ipv6(address): # type: (str) -> str if address.startswith('[') and address.endswith(']'): @@ -4011,6 +4025,7 @@ def command_bootstrap(ctx): ################################## + def command_registry_login(ctx: CephadmContext): if ctx.registry_json: logger.info("Pulling custom registry login info from %s." % ctx.registry_json) @@ -4036,6 +4051,7 @@ def command_registry_login(ctx: CephadmContext): "options or --registry-json option") return 0 + def registry_login(ctx: CephadmContext, url, username, password): logger.info("Logging into custom registry.") try: @@ -4748,9 +4764,9 @@ def get_daemon_description(ctx, fsid, name, detail=False, legacy_dir=None): return d raise Error('Daemon not found: {}. See `cephadm ls`'.format(name)) - ################################## + @default_image def command_adopt(ctx): # type: (CephadmContext) -> None @@ -5139,9 +5155,9 @@ def _stop_and_disable(ctx, unit_name): logger.info('Disabling old systemd unit %s...' % unit_name) call_throws(ctx, ['systemctl', 'disable', unit_name]) - ################################## + def command_rm_daemon(ctx): # type: (CephadmContext) -> None l = FileLock(ctx, ctx.fsid) @@ -5243,9 +5259,9 @@ def command_rm_cluster(ctx): if os.path.exists(files[n]): os.remove(files[n]) - ################################## + def check_time_sync(ctx, enabler=None): # type: (CephadmContext, Optional[Packager]) -> bool units = [ @@ -5852,6 +5868,7 @@ def command_install(ctx: CephadmContext): ################################## + def get_ipv4_address(ifname): # type: (str) -> str def _extract(sock, offset): @@ -5945,8 +5962,9 @@ def read_file(path_list, file_name=''): return content return "Unknown" - ################################## + + class HostFacts(): _dmi_path_list = ['/sys/class/dmi/id'] _nic_path_list = ['/sys/class/net'] @@ -6409,14 +6427,15 @@ class HostFacts(): ################################## + def command_gather_facts(ctx: CephadmContext): """gather_facts is intended to provide host releated metadata to the caller""" host = HostFacts(ctx) print(host.dump()) - ################################## + def command_verify_prereqs(ctx: CephadmContext): if ctx.service_type == 'haproxy' or ctx.service_type == 'keepalived': out, err, code = call( @@ -6485,6 +6504,7 @@ class CephadmHTTPServer(ThreadingMixIn, HTTPServer): cephadm_cache: CephadmCache token: str + class CephadmDaemonHandler(BaseHTTPRequestHandler): server: CephadmHTTPServer api_version = 'v1' @@ -7095,9 +7115,9 @@ def command_exporter(ctx: CephadmContext): exporter.run() - ################################## + def systemd_target_state(target_name: str, subsystem: str = 'ceph') -> bool: # TODO: UNITTEST return os.path.exists( @@ -7160,9 +7180,9 @@ def command_maintenance(ctx: CephadmContext): else: return f"success - systemd target {target} enabled and started" - ################################## + def _get_parser(): # type: () -> argparse.ArgumentParser parser = argparse.ArgumentParser( diff --git a/src/cephadm/tox.ini b/src/cephadm/tox.ini index 04931165f3d75..751884995d7f4 100644 --- a/src/cephadm/tox.ini +++ b/src/cephadm/tox.ini @@ -5,7 +5,6 @@ skipsdist=true [flake8] max-line-length = 100 ignore = - E302, E303, E305, E306, -- 2.39.5