Skip to content

Commit

Permalink
Adding fix for file_interface failure (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
trisha-dell authored Nov 25, 2024
1 parent efa972f commit 77833ab
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions plugins/modules/file_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,15 @@ def validate_params(self, file_interface_params):
err_msg = "file_interface_id is mutually exclusive with nas_server and ip_address."
self.module.fail_json(msg=err_msg)

def validate_get(self, file_interface_params):
"""Perform validation of parameters of a File interface"""
if file_interface_params['nas_server'] is None and \
file_interface_params['ip_address'] is None and \
file_interface_params['file_interface_id'] is None:
err_msg = "Either file_interface_id or nas_server and ip_address is required" \
" to get file interface details."
self.module.fail_json(msg=err_msg)


def get_powerstore_file_interface_parameters():
"""This method provides the parameters required for the ansible
Expand Down Expand Up @@ -418,18 +427,19 @@ def handle(self, file_interface_obj, file_interface_details):
class FileInterfaceDeleteHandler():
def handle(self, file_interface_obj, file_interface_params, file_interface_details):
if file_interface_params['state'] == 'absent' and file_interface_details:
file_interface_details = file_interface_obj.delete_file_interface(file_interface_params['file_interface_id'])
file_interface_details = file_interface_obj.delete_file_interface(file_interface_details['id'])
file_interface_obj.result['changed'] = True

FileInterfaceExitHandler().handle(file_interface_obj, file_interface_details)


class FileInterfaceModifyHandler():
def handle(self, file_interface_obj, file_interface_params, file_interface_details):
file_interface_obj.validate_get(file_interface_params=file_interface_params)
if file_interface_params['state'] == 'present' and file_interface_details:
modify_dict = file_interface_obj.is_modify_required(file_interface_details, file_interface_params)
if modify_dict:
file_interface_details = file_interface_obj.modify_file_interface_details(file_interface_id=file_interface_params['file_interface_id'],
file_interface_details = file_interface_obj.modify_file_interface_details(file_interface_id=file_interface_details['id'],
modify_params=modify_dict)
file_interface_obj.result['changed'] = True

Expand Down

0 comments on commit 77833ab

Please sign in to comment.