Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonar fixes for critical, major and minor issues #62

Merged
merged 3 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 2 additions & 4 deletions plugins/module_utils/storage/dell/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,5 @@ def get_filter(name, id=None):


def random_uuid_generation():
generate_uuid = ''.join(
[random.choice(string.ascii_lowercase + string.digits) for n in range(32)])

return generate_uuid
"""Generate a random UUID using lowercase letters and digits."""
return ''.join(random.choices(string.ascii_lowercase + string.digits, k=32))
299 changes: 171 additions & 128 deletions plugins/modules/device.py

Large diffs are not rendered by default.

102 changes: 44 additions & 58 deletions plugins/modules/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2391,70 +2391,56 @@ def perform_module_operation(self):

api_version = self.get_api_details()
array_details = self.get_array_details()
sdc = []
sds = []
storage_pool = []
vol = []
snapshot_policy = []
protection_domain = []
device = []
rcgs = []
replication_pair = []
fault_sets = []
service_template = []
managed_device = []
deployment = []
firmware_repository = []

subset = self.module.params['gather_subset']
subset_result_filter = {}
subset_result_wo_param = {}
self.validate_subset(api_version, subset)
if subset is not None:
if 'sdc' in subset:
sdc = self.get_sdc_list(filter_dict=filter_dict)
if 'sds' in subset:
sds = self.get_sds_list(filter_dict=filter_dict)
if 'protection_domain' in subset:
protection_domain = self.get_pd_list(filter_dict=filter_dict)
if 'storage_pool' in subset:
storage_pool = self.get_storage_pool_list(filter_dict=filter_dict)
if 'vol' in subset:
vol = self.get_volumes_list(filter_dict=filter_dict)
if 'snapshot_policy' in subset:
snapshot_policy = self.get_snapshot_policy_list(filter_dict=filter_dict)
if 'device' in subset:
device = self.get_devices_list(filter_dict=filter_dict)
if 'rcg' in subset:
rcgs = self.get_replication_consistency_group_list(filter_dict=filter_dict)
if 'replication_pair' in subset:
replication_pair = self.get_replication_pair_list(filter_dict=filter_dict)
if 'fault_set' in subset:
fault_sets = self.get_fault_sets_list(filter_dict=filter_dict)
if 'managed_device' in subset:
managed_device = self.get_managed_devices_list()
if 'service_template' in subset:
service_template = self.get_service_templates_list()
if 'deployment' in subset:
deployment = self.get_deployments_list()
if 'firmware_repository' in subset:
firmware_repository = self.get_firmware_repository_list()

subset_dict_with_filter = {
"sdc": self.get_sdc_list,
"sds": self.get_sds_list,
"protection_domain": self.get_pd_list,
"storage_pool": self.get_storage_pool_list,
"vol": self.get_volumes_list,
"snapshot_policy": self.get_snapshot_policy_list,
"device": self.get_devices_list,
"rcg": self.get_replication_consistency_group_list,
"replication_pair": self.get_replication_pair_list,
"fault_set": self.get_fault_sets_list,
}

subset_wo_param = {
"managed_device": self.get_managed_devices_list,
"service_template": self.get_service_templates_list,
"deployment": self.get_deployments_list,
"firmware_repository": self.get_firmware_repository_list
}
if subset:
subset_result_filter = {key: subset_dict_with_filter[key](
filter_dict=filter_dict) for key in subset if key in subset_dict_with_filter}
subset_result_wo_param = {key: subset_wo_param[key](
) for key in subset if key in subset_wo_param}

self.module.exit_json(
Array_Details=array_details,
API_Version=api_version,
SDCs=sdc,
SDSs=sds,
Storage_Pools=storage_pool,
Volumes=vol,
Snapshot_Policies=snapshot_policy,
Protection_Domains=protection_domain,
Devices=device,
Replication_Consistency_Groups=rcgs,
Replication_Pairs=replication_pair,
Fault_Sets=fault_sets,
ManagedDevices=managed_device,
ServiceTemplates=service_template,
Deployments=deployment,
FirmwareRepository=firmware_repository
SDCs=subset_result_filter.get("sdc", []),
SDSs=subset_result_filter.get("sds", []),
Storage_Pools=subset_result_filter.get("storage_pool", []),
Volumes=subset_result_filter.get("vol", []),
Snapshot_Policies=subset_result_filter.get("snapshot_policy", []),
Protection_Domains=subset_result_filter.get(
"protection_domain", []),
Devices=subset_result_filter.get("device", []),
Replication_Consistency_Groups=subset_result_filter.get("rcg", []),
Replication_Pairs=subset_result_filter.get("replication_pair", []),
Fault_Sets=subset_result_filter.get("fault_set", []),
ManagedDevices=subset_result_wo_param.get("managed_device", []),
ServiceTemplates=subset_result_wo_param.get(
"service_template", []),
Deployments=subset_result_wo_param.get("deployment", []),
FirmwareRepository=subset_result_wo_param.get(
"firmware_repository", [])
)


Expand Down
28 changes: 20 additions & 8 deletions plugins/modules/replication_consistency_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -962,18 +962,18 @@ def modify_rcg(self, rcg_id, rcg_details):
is_consistent = self.module.params['is_consistent']
activity_mode = self.module.params['activity_mode']
new_rcg_name = self.module.params['new_rcg_name']
changed = False

pause, freeze = self.get_pause_and_freeze_value()
if create_snapshot is True:
changed = self.create_rcg_snapshot(rcg_id)
if rpo and rcg_details['rpoInSeconds'] and \
rpo != rcg_details['rpoInSeconds']:
changed = self.modify_rpo(rcg_id, rpo)

changed = self.create_snap(rcg_id, create_snapshot)

rpo_changed = self.rpo_mod(rcg_id, rcg_details, rpo)

if target_volume_access_mode and \
rcg_details['targetVolumeAccessMode'] != target_volume_access_mode:
changed = \
self.modify_target_volume_access_mode(rcg_id, target_volume_access_mode)
self.modify_target_volume_access_mode(
rcg_id, target_volume_access_mode)
if activity_mode and \
self.modify_activity_mode(rcg_id, rcg_details, activity_mode):
changed = True
Expand All @@ -993,8 +993,20 @@ def modify_rcg(self, rcg_id, rcg_details):
changed = True

rcg_action_status = self.perform_rcg_action(rcg_id, rcg_details)
changed = changed or rcg_action_status

return rpo_changed or changed or rcg_action_status

def rpo_mod(self, rcg_id, rcg_details, rpo):
changed = False
if rpo and rcg_details['rpoInSeconds'] and \
rpo != rcg_details['rpoInSeconds']:
changed = self.modify_rpo(rcg_id, rpo)
return changed

def create_snap(self, rcg_id, create_snapshot):
changed = False
if create_snapshot is True:
changed = self.create_rcg_snapshot(rcg_id)
return changed

def validate_input(self, rcg_params):
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/sdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def get_sdc(self, sdc_name=None, sdc_ip=None, sdc_id=None):
LOG.error(errormsg)
self.module.fail_json(msg=errormsg)

def validate_parameters(self, sdc_name=None, sdc_id=None, sdc_ip=None):
def validate_parameters(self):
"""Validate the input parameters"""

sdc_identifiers = ['sdc_name', 'sdc_id', 'sdc_ip']
Expand Down Expand Up @@ -367,7 +367,7 @@ def perform_module_operation(self):
sdc_details={}
)

self.validate_parameters(sdc_name, sdc_id, sdc_ip)
self.validate_parameters()
sdc_details = self.get_sdc(sdc_name=sdc_name, sdc_id=sdc_id,
sdc_ip=sdc_ip)
id_ip_name = sdc_name or sdc_ip or sdc_id
Expand Down
Loading
Loading