Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new module: AIX Volume Group creating, resizing, removing #30381

Merged
merged 16 commits into from
Feb 4, 2019

Conversation

kairoaraujo
Copy link
Contributor

SUMMARY

It is a module to manage Volume Groups to AIX Logical Volume
Manager. With this module is able to create, resize and
remove a Volume Group.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

aix_lvg

ANSIBLE VERSION
ansible 2.5.0 (aix_lvg bfeb840b21) last updated 2017/09/14 22:05:36 (GMT +200)
  config file = None
  configured module search path = ['/Users/kairoaraujo/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/kairoaraujo/Dev/aix_lvg/ansible/lib/ansible
  executable location = /Users/kairoaraujo/Dev/aix_lvg/ansible/bin/ansible
  python version = 3.6.2 (v3.6.2:5fd33b5926, Jul 16 2017, 20:11:06) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
ADDITIONAL INFORMATION

None

It is a module to manage Volume Groups to AIX Logical Volume
Manager. With this module is able to create, reisize and
remove a Volume Group.
@ansibot
Copy link
Contributor

ansibot commented Sep 14, 2017

@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 community_review In order to be merged, this PR must follow the community review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. new_module This PR includes a new module. new_plugin This PR includes a new plugin. support:community This issue/PR relates to code supported by the Ansible community. labels Sep 14, 2017
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed community_review In order to be merged, this PR must follow the community review workflow. labels Sep 14, 2017
@molekuul
Copy link
Contributor

Hi,
Nice to see someone is working on AIX, I thought I was the onlyone :-)

I have some remarks on the module:
Ansible modules are to set a status of a configuration, if you want to extend a volumegroup with a disk that's already in this volumegroup, the module should not fail, but should return changed: False, nothing changed.

When a disk is in use by a volumegroup, you exit the module with a fail,
but when the disk is in use as an ASM disk, you set the return to False, and let the create_extend_vg function handle this, why these different approaches?

If you give a list of disks, the module will fail if even one disk will fail the "usage check" is this wat you want?

Checkmode is a mode in Ansible where you check what will be changed when you run the module with these parameters, without actually doing the action. You didn't incorporate this in the module, however you state that you support checkmode.

There are limits of how many PP's a disk can contain. An AIX system calulates the PP size from the size of the disk if you do not specify this. why not let the system decide the value of the PP-size if not specified in the playbook?

When you are removing a pv from a volumegroup, you do not check if the pv is within this volumegroup, so the command will fail, but the result is correct, the disk is not part of the volumegroup, as you want, you should handle this situation better.

Take into account that a volumegroup must be varyon before taking actions on a volumegroup.

I hope you can do anything with my remarks.

Kind regards,

Joris Weijters

@kairoaraujo
Copy link
Contributor Author

Hi @molekuul

Yes, as AIX is my main OS I am writing some modules, I have also almost ready to submit modules for filesystem and mksysb. Remarks are always welcome :)
Please, could you also check out my packaging/os/installp PR #30238 ?

I will go through your remarks and see I'll what I can do.

@kairoaraujo
Copy link
Contributor Author

kairoaraujo commented Sep 15, 2017

Working on @molekuul remarks.

@ansibot
Copy link
Contributor

ansibot commented Sep 15, 2017

@kairoaraujo This PR contains @ mentions in at least one commit message. Those mentions can cause cascading notifications through GitHub and need to be removed. Please squash or amend your commits to remove the mentions.

click here for bot help

fixed suggestion on PR according with standards and PEP8
Removed blank space in the end of line.
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
@kairoaraujo
Copy link
Contributor Author

kairoaraujo commented Sep 16, 2017

Hi @molekuul

I would like ask somethings regarding your remarks

Ansible modules are to set a status of a configuration, if you want to extend a volumegroup with a disk that's already in this volumegroup, the module should not fail, but should return changed: False, nothing changed.

I agree with that point and I'm implementing it.
My doubt is when the disk is already in use by another volume group, it should fail or also return not changed?

When a disk is in use by a volumegroup, you exit the module with a fail,
but when the disk is in use as an ASM disk, you set the return to False, and let the create_extend_vg function handle this, why these different approaches?
If you give a list of disks, the module will fail if even one disk will fail the "usage check" is this wat you want?

My approach is wrong, should be the same return for ASM and VG use. IMHO If you give a list of disks and one disk is wrong it should fail and forces the administrator correct the pool and avoid wrong resizes. Anyway, I'm opened to opinions.

Checkmode is a mode in Ansible where you check what will be changed when you run the module with these parameters, without actually doing the action. You didn't incorporate this in the module, however you state that you support checkmode.

I want to implement it, but I'm quite confused how to do it.

There are limits of how many PP's a disk can contain. An AIX system calulates the PP size from the size of the disk if you do not specify this. why not let the system decide the value of the PP-size if not specified in the playbook?

Totally agree, I'm changing it.

When you are removing a pv from a volumegroup, you do not check if the pv is within this volumegroup, so the command will fail, but the result is correct, the disk is not part of the volumegroup, as you want, you should handle this situation better.

It is treated by AIX as well, but for sure I do it also.

TASK [Reducing datavg with disk from rootvg] **************************************************************************************
fatal: [172.16.100.24]: FAILED! => {"changed": false, "err": "0516-1782 reducevg: Physical volume hdisk0 is not part of volume group datavg.\n0516-884 reducevg: Unable to remove physical volume hdisk0.\n", "failed": true, "msg": "Unable to remove datavg", "rc": 2}

We will have also this situation when the volume group still having filesystems mounted or open lv. I think is better leave it up to AIX, no?

Take into account that a volumegroup must be varyon before taking actions on a volumegroup.

Including this verification on the top.
About this subject, I will also include C(action): varyonv/varyoff it will be useful ;)

Kind regards,
Kairo Araujo

- fixed pep8 and non-written conventions;
- fixed RETURN doc indentation for msg;
- fixed and improved the physical volume verification;
- pp_size, when not specified, is followed from AIX side;
- included volume group verification in the top;
- included state varyon and varyoff to be easy in playbooks;
- removed check_mode
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
@jtyr
Copy link
Contributor

jtyr commented Sep 16, 2017

The Check Mode should be implemented the way that if using ansible-play -C site.yaml, the module doesn't perform any real changes, it just reports whether it would perform any change if run without the Check Mode. In your case, you should just check if there already exists VG of that name or parameters and if not, you should not do any changes but just return a flag that a change would be done if running without a Check Mode. Code-wise it would look like this:

def state_vg(...):
    changed = False

    ...

    if state == 'varyon':
        if vg_state is False:
            changed = True

            if not module.check_mode:
                varyonvg_cmd = module.get_bin_path("varyonvg", True)
                rc, varyonvg_out, err = module.run_command(
                    "%s %s" % (varyonvg_cmd, vg))

                if rc != 0:
                    module.failed_json(msg="...", stdout=out, stderr=err)

    ...

    return changed


def main():
    if state == 'present':
        changed = create_extend_vg(...)
    elif state == 'absent':
        changed = reduce_vg(...)
    elif state == 'varyon' or 'varyoff':
         changed = state_vg(...)

    module.exit_json(changed=True, state=state)

lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
Implemented back the module.check_module to permit be used.
Some corrections regarding module.exit_json() and
module.fail_json().
Some pep8 and non-written conventions
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_lvg.py Outdated Show resolved Hide resolved
- ordered option parameters and pep8 compliance
- removed exit_json() from functions and moved to main()
pep8, two spaces before function
@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed shipit This PR is ready to be merged by Core labels Jan 8, 2019
@ansibot
Copy link
Contributor

ansibot commented Jan 16, 2019

@ansibot ansibot added stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. test This PR relates to tests. labels Jan 16, 2019
@ansibot
Copy link
Contributor

ansibot commented Jan 24, 2019

@kairoaraujo
Copy link
Contributor Author

I will write the integration test for this module as well before merge.

@ansibot
Copy link
Contributor

ansibot commented Jan 29, 2019

@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. and removed ci_verified Changes made in this PR are causing tests to fail. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jan 29, 2019
@ansibot
Copy link
Contributor

ansibot commented Feb 4, 2019

@ansibot

This comment has been minimized.

@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed community_review In order to be merged, this PR must follow the community review workflow. labels Feb 4, 2019
@dagwieers
Copy link
Contributor

rebuild_merge

@ansibot ansibot added shipit This PR is ready to be merged by Core and removed ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Feb 4, 2019
@dagwieers dagwieers merged commit de67b8e into ansible:devel Feb 4, 2019
@ansible ansible locked and limited conversation to collaborators Jul 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 aix AIX community module This issue/PR relates to a module. new_module This PR includes a new module. new_plugin This PR includes a new plugin. shipit This PR is ready to be merged by Core support:community This issue/PR relates to code supported by the Ansible community. test This PR relates to tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants