Selecting a Valid Alternate Disk
In this document, we will explain the process of selecting a valid alternate disk for installation. The process involves validating the target disk, finding a valid alternate disk, retrieving free physical volumes, and checking volume group membership.
The flow starts with validating the target disk to ensure it is suitable for use as an alternate disk. If the target disk is not specified or invalid, the process searches for a valid alternate disk that meets the necessary criteria. It then retrieves a list of free physical volumes that are not part of any volume group. Finally, it checks if a given disk belongs to any volume group to determine its eligibility for use as an alternate disk.
Flow drill down
Validating the Target Disk
First, the is_valid
def is_valid(module, target_disk):
"""
Check if target disk is valid
- must not belong to a volume group
- must have space big enough for rootvg used PPs
return:
True - target disk can be used for alt_disk
False - target disk cannot be used for alt_disk
"""
nim_client = module.params['nim_client']
force = module.params['force']
# fetch rootvg disk information on the NIM client
rootvg_info = check_rootvg(module)
# fetch physical volume size or the target disk
cmd = [
'/usr/lpp/bos.sysmgt/nim/methods/c_rsh',
nim_client,
'/usr/sbin/bootinfo -s {0}'.format(target_disk)
]
Selecting a Valid Alternate Disk
Next, the find_valid_altdisk
def find_valid_altdisk(module):
"""
Find a valid alternate disk that:
- exists,
- is not part of a VG
- with a correct size
and so can be used.
"""
disk_size_policy = module.params['target_disk_policy']
force = module.params['force']
rootvg_info = check_rootvg(module)
# check rootvg
if rootvg_info['status'] != 0:
results['msg'] = 'Wrong rootvg state'
module.fail_json(**results)
# get pv list
pvs = get_pvs(module)
if pvs is None:
module.fail_json(**results)
Getting Free Physical Volumes
Then, the get_free_pvs
PVs
find_valid_altdisk
def get_free_pvs(module, pvs):
"""
Get the list of free PVs.
return: dictionary with free PVs information
"""
nim_client = module.params["nim_client"]
# hdisk0 000018fa3b12f5cb rootvg active
free_pvs = {}
for pv in pvs.keys():
# Only match disks that have no volume groups
if pvs[pv]['vg'] == 'None':
# Check if the disk has VG info in ODM using getlvodm
if belong_to_vg(module, pv):
continue
# Retrieve disk size
cmd = [
'/usr/lpp/bos.sysmgt/nim/methods/c_rsh',
nim_client,
Checking Volume Group Membership
Finally, the belong_to_vg
def belong_to_vg(module, target_disk):
"""
Check in ODM if target_disk belongs to a volume group.
return:
True - target disk belongs to a volume group
False - target disk does not belong to a volume group
"""
nim_client = module.params['nim_client']
# check if 'target_disk' does not belong to any volume group
cmd = [
'/usr/lpp/bos.sysmgt/nim/methods/c_rsh',
nim_client,
'/usr/sbin/getlvodm -j {0}'.format(target_disk)
]
rc, stdout, stderr = module.run_command(cmd)
# 0516-320 /usr/sbin/getlvodm: Physical volume hdisk1 is not assigned to
# a volume group.
# physical volume belongs to a volume group if 'found' is not null
# pattern = r"0516-320"
pattern = r"0516-320|0516-1396"
found = re.search(pattern, stderr, re.MULTILINE)
This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human