Skip to content

Commit

Permalink
more codacy fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Sachitanand Shelake <[email protected]>
  • Loading branch information
sachitanands committed Jan 30, 2022
1 parent e9fe71a commit 4cac866
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 25 deletions.
3 changes: 3 additions & 0 deletions src/setup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@
# For any questions about this software or licensing,
# please email [email protected] or [email protected].

"""
init class for rgw
"""
10 changes: 8 additions & 2 deletions src/setup/error.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# CORTX-Py-Utils: CORTX Python common library.
#!/usr/bin/python3

# Copyright (c) 2021 Seagate Technology LLC and/or its Affiliates
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
Expand All @@ -16,7 +17,12 @@
from cortx.utils.errors import BaseError

class SetupError(BaseError):
"""Generic Exception with error code and output."""
"""
Generic Exception with error code and output.
"""

def __init__(self, rc, message_id, *message_args):
"""
Initalize error message paramters.
"""
super().__init__(rc, message_id=message_id, *message_args)
36 changes: 27 additions & 9 deletions src/setup/rgw.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,53 +16,71 @@


class Rgw:
""" Represents Utils and Performs setup related actions """
"""
Represents Utils and Performs setup related actions.
"""

@staticmethod
def validate(phase: str):
""" Perform validtions """
"""
Perform validtions
"""

# Perform RPM validations
return 0

@staticmethod
def post_install(config_path: str):
""" Performs post install operations """
"""
Performs post install operations
"""

return 0

@staticmethod
def config(config_path: str):
"""Performs configurations."""
"""
Performs configurations.
"""

return 0

@staticmethod
def init(config_path: str):
""" Perform initialization """
"""
Perform initialization
"""

return 0

@staticmethod
def test(config_path: str, plan: str):
""" Perform configuration testing """
"""
Perform configuration testing
"""

return 0

@staticmethod
def reset(config_path: str):
"""Remove/Delete all the data/logs that was created by user/testing."""
"""
Remove/Delete all the data/logs that was created by user/testing.
"""

return 0

@staticmethod
def cleanup(pre_factory: bool, config_path: str):
"""Remove/Delete all the data that was created after post install."""
"""
Remove/Delete all the data that was created after post install.
"""

return 0

@staticmethod
def upgrade(config_path: str):
"""Perform upgrade steps."""
"""
Perform upgrade steps.
"""

return 0
57 changes: 43 additions & 14 deletions src/setup/rgw_setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/env python3
#!/usr/bin/python3

# Copyright (c) 2021 Seagate Technology LLC and/or its Affiliates
# This program is free software: you can redistribute it and/or modify
Expand All @@ -14,30 +14,39 @@
# For any questions about this software or licensing,
# please email [email protected] or [email protected].

import os
import sys
import errno
import inspect
import argparse
import traceback

from cortx.utils.log import Log
from cortx.utils.cmd_framework import Cmd
from cortx.rgw.setup import Rgw
from setup import Rgw
from error import SetupError

class SetupCmdBase(cmd):
"""
Setup cmd base class.
"""

def __init__(self, *args):
"""
Initialize super class members
"""
super().__init__(*args)

def add_args(parser):
parser.add_argument('--services', default='services', help='services')
parser.add_argument('--config', default='config_url', help='config')

class PostInstallCmd(SetupCmdBase):
""" PostInstall Setup Cmd """
"""
PostInstall Setup Cmd
"""

name = 'post_install'

def __init__(self, args: dict):
"""Initialize super class members"""
super().__init__(args)

def process(self):
Expand All @@ -47,21 +56,27 @@ def process(self):


class PrepareCmd(SetupCmdBase):
""" Prepare Setup Cmd """
"""
Prepare Setup Cmd
"""
name = 'prepare'

def __init__(self, args: dict):
"""Initialize super class members"""
super().__init__(args)

def process(self):
return 0


class ConfigCmd(SetupCmdBase):
""" Setup Config Cmd """
"""
Setup Config Cmd
"""
name = 'config'

def __init__(self, args):
"""Initialize super class members"""
super().__init__(args)

def process(self):
Expand All @@ -71,10 +86,13 @@ def process(self):


class InitCmd(SetupCmdBase):
""" Init Setup Cmd """
"""
Init Setup Cmd
"""
name = 'init'

def __init__(self, args):
"""Initialize super class members"""
super().__init__(args)
self.config_path = args.config

Expand All @@ -85,10 +103,13 @@ def process(self):


class TestCmd(SetupCmdBase):
""" Test Setup Cmd """
"""
Test Setup Cmd
"""
name = 'test'

def __init__(self, args):
"""Initialize super class members"""
super().__init__(args)
self.config_path = args.config
# Default test_plan is 'sanity'
Expand All @@ -101,10 +122,13 @@ def process(self):


class ResetCmd(SetupCmdBase):
""" Reset Setup Cmd """
"""
Reset Setup Cmd
"""
name = 'reset'

def __init__(self, args):
""" Initialize super class members """
super().__init__(args)
self.config_path = args.config

Expand All @@ -115,10 +139,13 @@ def process(self):


class CleanupCmd(SetupCmdBase):
""" Cleanup Setup Cmd """
"""
Cleanup Setup Cmd
"""
name = 'cleanup'

def __init__(self, args: dict):
"""Initialize super class members"""
super().__init__(args)

def process(self):
Expand All @@ -128,10 +155,13 @@ def process(self):


class UpgradeCmd(SetupCmdBase):
"""Upgrade Setup Cmd."""
"""
Upgrade Setup Cmd
"""
name = 'upgrade'

def __init__(self, args: dict):
"""Initialize super class members"""
super().__init__(args)

def process(self):
Expand All @@ -141,7 +171,6 @@ def process(self):


def main():
from cortx.utils.conf_store import Conf
argv = sys.argv

Log.init() # TODO
Expand Down

0 comments on commit 4cac866

Please sign in to comment.