Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

CORTX-32833: resolve codacy issues from provisioner repo #6403

Merged
merged 6 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def get_secret_files() -> list:
"""Returns secret files."""
return glob.glob('conf/secret/*')


setup(name='cortx-provisioner',
version=get_version(),
url='https://github.com/Seagate/cortx-provisioner',
Expand Down
6 changes: 2 additions & 4 deletions src/provisioner/provisioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
# For any questions about this software or licensing,
# please email opensource@seagate.com or cortx-questions@seagate.com.

from datetime import datetime
import errno
import os
import time
import socket
from enum import Enum
import time
from urllib.parse import urlparse
from cortx.utils.process import SimpleProcess
from cortx.utils.conf_store import Conf, MappedConf
Expand Down Expand Up @@ -548,8 +546,8 @@ def _validate_provisioning_status(cortx_conf: MappedConf, node_id: str, apply_ph
return True, ret_code

if (not validations_checks.get(apply_phase) or
not validations_checks.get(apply_phase).get(recent_phase) or
not validations_checks.get(apply_phase).get(recent_phase).get(recent_status)):
not validations_checks.get(apply_phase).get(recent_phase) or
not validations_checks.get(apply_phase).get(recent_phase).get(recent_status)):
Log.error('Invalid phase or status.')
ret_code = 1
return False, ret_code
Expand Down
4 changes: 2 additions & 2 deletions src/provisioner/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Validator:
@staticmethod
def process(*args):
"""This interface needs to be implemented in derived class"""
pass
Log.debug("To be implemented in derived class")

@staticmethod
def validate(validations: list, *args):
Expand Down Expand Up @@ -78,7 +78,7 @@ def process(*args):
# if cluster/cortx both keys are not present in file means file is
# empty or file doesn't have required config.
if (Conf.get(ConfigValidator._solution_index, 'cluster') is None and
Conf.get(ConfigValidator._solution_index, 'cortx') is None):
Conf.get(ConfigValidator._solution_index, 'cortx') is None):
raise CortxProvisionerError(errno.EINVAL,
'File is empty OR Cluster config and cortx config is not present in file.')

Expand Down
1 change: 1 addition & 0 deletions test/setup/test_invalid_cluster_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@ def test_invalid_cluster_config(self):
self.assertEqual(rc, 1)
os.remove(cluster_conf_file_path)


if __name__ == '__main__':
unittest.main()
1 change: 1 addition & 0 deletions test/setup/test_invalid_cortx_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ def test_invalid_cortx_config(self):
self.assertEqual(rc, 1)
os.remove(config_conf_file_path)


if __name__ == '__main__':
unittest.main()
1 change: 1 addition & 0 deletions test/setup/test_multiple_storage_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,6 @@ def test_for_multiple_storage_sets(self):
self.assertEqual(rc, 0)
os.remove(cluster_conf_file_path)


tanujashinde0405 marked this conversation as resolved.
Show resolved Hide resolved
if __name__ == '__main__':
unittest.main()
5 changes: 3 additions & 2 deletions test/setup/test_provisioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import unittest
import yaml
from cortx.provisioner.provisioner import CortxProvisioner
from cortx.utils.conf_store import Conf

solution_cluster_url = "yaml://" + os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "cluster.yaml"))
solution_conf_url = "yaml://" + os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "config.yaml"))
Expand All @@ -35,14 +34,15 @@ def check_num_xx_keys(data):
if isinstance(v, dict):
check_num_xx_keys(v)
elif isinstance(v, list):
if not f"num_{k}" in data:
if f"num_{k}" not in data:
return False, f"The key num_{k} is not saved in Gconf"
check_num_xx_keys(v)
if isinstance(data, list):
for v in data:
check_num_xx_keys(v)
return True, "The keys num_xx are saved in gconf"


class TestProvisioner(unittest.TestCase):
"""Test cortx_setup config and cluster functionality."""

Expand Down Expand Up @@ -90,5 +90,6 @@ def test_num_xxx_in_gconf(self):
is_key_present, message = check_num_xx_keys(gconf)
self.assertTrue(is_key_present, message)


if __name__ == '__main__':
unittest.main()