LVOL Overview
LVOL Overview
LVOL refers to the logical volume management module in AIX systems. It is used to create, remove, and modify attributes of logical volumes.
How to Use LVOL
The module supports various actions such as creating a logical volume, removing a logical volume, and modifying the attributes of an existing logical volume. It requires specifying the volume group name, logical volume name, and other attributes like size, type, and policy. The module ensures that the logical volume is created with the specified attributes or modified if it already exists. If the state is set to 'absent', the module will remove the specified logical volume. The module also supports additional options like specifying the strip size, number of copies, and extra options for the mklv
chlv
Example Usage
This section provides examples of how to use the LVOL module to create, extend, and remove logical volumes.
Examples of creating logical volumes with different attributes.
EXAMPLES = r'''
- name: Create a logical volume of 64M
ibm.power_aix.lvol:
vg: test1vg
lv: test1lv
size: "64M"
state: present
- name: Create a logical volume of 10 logical partitions with disks testdisk1 and testdisk2
ibm.power_aix.lvol:
vg: test2vg
lv: test2lv
size: "10"
pv_list: testdisk1, testdisk2
state: present
- name: Create a logical volume of 32M with a minimum placement policy
ibm.power_aix.lvol:
vg: rootvg
lv: test4lv
size: "32M"
policy: minimum
state: present
Main Functions
There are several main functions in this module. Some of them are create_lv
extend_lv
modify_lv
remove_lv
create_lv
extend_lv
create_lv
create_lv
The create_lv
lv_attributes
The create_lv
def create_lv(module, name):
"""
Creates a logical volume with the attributes provided in the
lv_attributes field.
arguments:
module (dict): The Ansible module
name (str): Logical Volume Name
note:
Exits with fail_json in case of error
return:
none
"""
opts = ''
lv_type = module.params['lv_type']
strip_size = module.params['strip_size']
copies = module.params['copies']
policy = module.params['policy']
vg = module.params['vg']
num_log_part = module.params['size']
extend_lv
extend_lv
The extend_lv
The extend_lv
def extend_lv(module, name, init_props):
"""
Extend a logical volume with the given new size.
arguments:
module (dict): The Ansible module
name (str): Logical Volume Name
init_props (str): Initial properties of the logical volume
note:
The new size must be large than the original size.
return:
none
"""
# get lvid to fetch additonal information
pattern = r"^LV IDENTIFIER:\s+(\w+\.\d+)"
lvid = re.search(pattern, init_props, re.MULTILINE).group(1)
# get the physical partition size (PP size) for converting
# size with prefixes B/b, K/k, M/m, and G/g into corresponding
# number of logical partitions
# also fetch the current lv size in logical partions (LPs)
modify_lv
modify_lv
The modify_lv
lv_attributes
The modify_lv
def modify_lv(module, name, init_props):
"""
Modify a logical volume with the attributes provided in the
lv_attributes field.
arguments:
module (dict): The Ansible module
name (str): Logical Volume Name
init_props (str): Initial properties of the logical volume
note:
Exits with fail_json in case of error
return:
none
"""
new_name = module.params['lv_new_name']
copies = module.params['copies']
policy = module.params['policy']
lv_type = module.params['lv_type']
# -a position, -b badblocks, -d schedule, -R preferredRead,
# -L label, -o y/n, -p permission, -r relocate, -s strict,
# -u upperbound, -v verify, -w mirrorwriteconsistency, -x maxumum
remove_lv
remove_lv
The remove_lv
The remove_lv
def remove_lv(module, name):
"""
Remove the logical volume without confirmation.
arguments:
module (dict): The Ansible module
name (str): Logical Volume Name
note:
Exits with fail_json in case of error
return:
none
"""
cmd = f'rmlv -f {name}'
success_msg = f"Logical volume {name} removed."
fail_msg = f"Failed to remove the logical volume: {name}"
lv_run_cmd(module, cmd, success_msg, fail_msg, None)
This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human