Managing Volume Groups
This document explains the process of managing volume groups. The process involves initializing the module, determining the current state of the volume group, and deciding whether to create, modify, or remove it based on the provided parameters.
The flow starts by initializing the module and setting up the necessary parameters. It then checks the current state of the volume group. If the volume group does not exist, it creates it with the specified properties. If the volume group already exists, it modifies its properties as needed.
Flow drill down
Handling Volume Group Creation and Modification
First, the main
def main():
global result
module = AnsibleModule(
supports_check_mode=False,
argument_spec=dict(
state=dict(type='str', choices=['absent', 'present', 'varyoff', 'varyon'],
default='present'),
vg_name=dict(type='str', required=True),
vg_type=dict(type='str', choices=['none', 'big', 'scalable']),
enhanced_concurrent_vg=dict(type='bool'),
critical_vg=dict(type='bool'),
pvs=dict(type='list', elements='str'),
critical_pvs=dict(type='bool'),
num_lvs=dict(type='int', choices=[256, 512, 1024, 2048, 4096]),
delete_lvs=dict(type='bool'),
num_partitions=dict(type='int', choices=[32, 64, 128, 256, 512, 768, 1024, 2048]),
pp_size=dict(type='int'),
pp_limit=dict(type='int'),
force=dict(type='bool'),
mirror_pool=dict(type='str'),
Creating a Volume Group
Next, if the volume group does not exist, the make_vg
def make_vg(module, vg_name):
"""
Creates volume group
arguments:
module: Ansible module argument spec.
vg_name: Volume group name
note:
Exits with fail_json in case of error
return:
none
"""
pvs = module.params['pvs']
opt = build_vg_opts(module)
vg_type_opt = {
"none": '',
"big": '-B ',
"scalable": '-S ',
}
vg_type = module.params["vg_type"]
Modifying a Volume Group
Then, if the volume group already exists, the change_vg
def change_vg(module, vg_name, init_props):
"""
Modifies volume group
arguments:
module: Ansible module argument spec.
vg_name: Volume group name
init_props: Initial properties of the volume group
note:
Exits with fail_json in case of error
return:
none
"""
major_num = module.params["major_num"]
pp_size = module.params["pp_size"]
mirror_pool = module.params["mirror_pool"]
if major_num or pp_size or mirror_pool:
result['msg'] += "Attributes major_num, pp_size or mirror_pool "
result['msg'] += f"are not supported while changing volume group { vg_name }\n"
# get initial vg type
This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human