Handling Alternate Disk Operations
In this document, we will explain the process of handling alternate disk operations. The process involves initializing the environment, performing the specified alternate disk action, finding valid alternate disks, and retrieving physical volumes.
The flow starts with initializing the environment and setting up necessary parameters. Then, it performs the specified alternate disk action, such as copying or cleaning the disk. Next, it finds a valid alternate disk that meets the criteria. Finally, it retrieves the list of physical volumes to identify available disks and their statuses.
Flow drill down
Handling the main logic for alternate disk operations
First, the main
def main():
global results
module = AnsibleModule(
argument_spec=dict(
targets=dict(required=True, type='list', elements='dict'),
action=dict(required=True, type='str',
choices=['alt_disk_copy', 'alt_disk_clean']),
time_limit=dict(type='str'),
vios_status=dict(type='dict'),
nim_node=dict(type='dict'),
disk_size_policy=dict(type='str',
choices=['minimize', 'upper', 'lower', 'nearest'],
default='nearest'),
force=dict(type='bool', default=False),
)
)
results = dict(
changed=False,
Performing alternate disk actions
Next, the alt_disk_action
def alt_disk_action(module, params, action, targets, vios_status, time_limit):
"""
alt_disk_copy / alt_disk_clean operation
For each VIOS tuple,
- retrieve the previous status if any (looking for SUCCESS-HC and SUCCESS-UPDT)
- for each VIOS of the tuple, check the rootvg, find and valid the hdisk for the operation
- unmirror rootvg if necessary
- perform the alt disk copy or cleanup operation
- wait for the copy to finish
- mirror rootvg if necessary
arguments:
module (dict): The Ansible module
params (dict): The parameters for the provided action
action (str): The action to perform
targets (list): The list of VIOS dictionary to perform the action on
vios_status (dict): The previous operation status for each vios (if any)
time_limit (str): The limit of time to perform the operation
return: dictionary containing the altdisk status for each vios tuple
Finding valid alternate disks
Then, the find_valid_altdisk
def find_valid_altdisk(module, params, action, vios_dict, vios_key, rootvg_info, altdisk_op_tab):
"""
Find a valid alternate disk that:
- exists,
- is not part of a VG
- with a correct size
and so can be used.
Sets the altdisk_op_tab accordingly:
altdisk_op_tab[vios_key] = "FAILURE-ALTDC <error message>"
altdisk_op_tab[vios_key] = "SUCCESS-ALTDC"
arguments:
module (dict): The Ansible module
params (dict): The parameters for the provided action
action (str): The action to perform
vios_dict (dict): The list of VIOS dictionary with associated list of hdisks
vios_key (str): The key for altdisk_op_tab status dicionary
rootvg_info (dict): The rootvg information gathered with check_rootvg
altdisk_op_tab (dict): The operation status
Retrieving physical volumes
Finally, the get_pvs
PVs
PVs
def get_pvs(module, vios):
"""
Get the list of PVs on the VIOS.
arguments:
module (dict): The Ansible module
vios (str): The VIOS name
return: dictionary with PVs information
"""
module.debug(f'get_pvs vios: {vios}')
cmd = ['/usr/ios/cli/ioscli', 'lspv']
ret, stdout, stderr = nim_exec(module, vios, cmd)
if ret != 0:
msg = f'Failed to get the PV list on {vios}, lspv returned: {ret} {stderr}'
results['meta'][vios]['messages'].append(msg)
module.log(msg)
return None
# NAME PVID VG STATUS
# hdisk0 000018fa3b12f5cb rootvg active
This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human