diff options
Diffstat (limited to 'ansible_collections/netapp/um_info')
44 files changed, 4959 insertions, 0 deletions
diff --git a/ansible_collections/netapp/um_info/.github/ISSUE_TEMPLATE/bug_report.yml b/ansible_collections/netapp/um_info/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 000000000..71c875355 --- /dev/null +++ b/ansible_collections/netapp/um_info/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,210 @@ +--- +name: 🐛 Bug report +description: Create a report to help us improve + +body: +- type: markdown + attributes: + value: > + **Thank you for wanting to report a bug in netapp.um_info!** + + + ⚠ + Verify first that your issue is not [already reported on + GitHub][issue search] and keep in mind that we may have to keep + the current behavior because [every change breaks someone's + workflow][XKCD 1172]. + We try to be mindful about this. + + Also test if the latest release and devel branch are affected too. + + + **Tip:** If you are seeking community support, please consider + [Join our Slack community][ML||IRC]. + + + + [ML||IRC]: + https://join.slack.com/t/netapppub/shared_invite/zt-njcjx2sh-1VR2mEDvPcJAmPutOnP~mg + + [issue search]: ../search?q=is%3Aissue&type=issues + + [XKCD 1172]: https://xkcd.com/1172/ + + +- type: textarea + attributes: + label: Summary + description: Explain the problem briefly below. + placeholder: >- + When I try to do X with netapp.um_info from the devel branch on GitHub, Y + breaks in a way Z under the env E. Here are all the details I know + about this problem... + validations: + required: true + +- type: input + attributes: + label: Component Name + description: > + Write the short name of the rst file, module, plugin, task or + feature below, *use your best guess if unsure*. + + + **Tip:** Cannot find it in this repository? Please be advised that + the source for some parts of the documentation are hosted outside + of this repository. If the page you are reporting describes + modules/plugins/etc that are not officially supported by the + Ansible Core Engineering team, there is a good chance that it is + coming from one of the [Ansible Collections maintained by the + community][collections org]. If this is the case, please make sure + to file an issue under the appropriate project there instead. + + + [collections org]: /ansible-collections + placeholder: dnf, apt, yum, pip, user etc. + validations: + required: true + +- type: textarea + attributes: + label: Ansible Version + description: >- + Paste verbatim output from `ansible --version` below, under + the prompt line. Please don't wrap it with tripple backticks — your + whole input will be turned into a code snippet automatically. + render: console + value: | + $ ansible --version + placeholder: | + $ ansible --version + ansible [core 2.11.0b4.post0] (detached HEAD ref: refs/) last updated 2021/04/02 00:33:35 (GMT +200) + config file = None + configured module search path = ['~/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] + ansible python module location = ~/src/github/ansible/ansible/lib/ansible + ansible collection location = ~/.ansible/collections:/usr/share/ansible/collections + executable location = bin/ansible + python version = 3.9.0 (default, Oct 26 2020, 13:08:59) [GCC 10.2.0] + jinja version = 2.11.3 + libyaml = True + validations: + required: true + +- type: textarea + attributes: + label: UM_Info Collection Version + description: >- + UM_Info Collection Version. Run `ansible-galaxy collection` and copy the entire output + render: console + value: | + $ ansible-galaxy collection list + validations: + required: true + +- type: textarea + attributes: + label: Playbook + description: >- + The task from the playbook that is give you the issue + render: console + validations: + required: true + +- type: textarea + attributes: + label: Steps to Reproduce + description: | + Describe exactly how to reproduce the problem, using a minimal test-case. It would *really* help us understand your problem if you could also pased any playbooks, configs and commands you used. + + **HINT:** You can paste https://gist.github.com links for larger files. + value: | + <!--- Paste example playbooks or commands between quotes below --> + ```yaml (paste below) + + ``` + placeholder: | + 1. Implement the following playbook: + + ```yaml + --- + # ping.yml + - hosts: all + gather_facts: false + tasks: + - ping: + ... + ``` + 2. Then run `ANSIBLE_DEBUG=1 ansible-playbook ping.yml -vvvvv` + 3. An error occurs. + validations: + required: true + +- type: textarea + attributes: + label: Expected Results + description: >- + Describe what you expected to happen when running the steps above. + placeholder: >- + I expected X to happen because I assumed Y and was shocked + that it did not. + validations: + required: true + +- type: textarea + attributes: + label: Actual Results + description: | + Describe what actually happened. If possible run with extra verbosity (`-vvvv`). + + Paste verbatim command output and don't wrap it with tripple backticks — your + whole input will be turned into a code snippet automatically. + render: console + placeholder: >- + Certificate did not match expected hostname: files.pythonhosted.org. Certificate: {'notAfter': 'Apr 28 19:20:25 2021 GMT', 'subjectAltName': ((u'DNS', 'r.ssl.fastly.net'), (u'DNS', '*.catchpoint.com'), (u'DNS', '*.cnn.io'), (u'DNS', '*.dollarshaveclub.com'), (u'DNS', '*.eater.com'), (u'DNS', '*.fastly.picmonkey.com'), (u'DNS', '*.files.saymedia-content.com'), (u'DNS', '*.ft.com'), (u'DNS', '*.meetupstatic.com'), (u'DNS', '*.nfl.com'), (u'DNS', '*.pagar.me'), (u'DNS', '*.picmonkey.com'), (u'DNS', '*.realself.com'), (u'DNS', '*.sbnation.com'), (u'DNS', '*.shakr.com'), (u'DNS', '*.streamable.com'), (u'DNS', '*.surfly.com'), (u'DNS', '*.theverge.com'), (u'DNS', '*.thrillist.com'), (u'DNS', '*.vox-cdn.com'), (u'DNS', '*.vox.com'), (u'DNS', '*.voxmedia.com'), (u'DNS', 'eater.com'), (u'DNS', 'ft.com'), (u'DNS', 'i.gse.io'), (u'DNS', 'picmonkey.com'), (u'DNS', 'realself.com'), (u'DNS', 'static.wixstatic.com'), (u'DNS', 'streamable.com'), (u'DNS', 'surfly.com'), (u'DNS', 'theverge.com'), (u'DNS', 'vox-cdn.com'), (u'DNS', 'vox.com'), (u'DNS', 'www.joyent.com')), 'subject': ((('countryName', u'US'),), (('stateOrProvinceName', u'California'),), (('localityName', u'San Francisco'),), (('organizationName', u'Fastly, Inc'),), (('commonName', u'r.ssl.fastly.net'),))} + Exception: + Traceback (most recent call last): + File "/usr/local/lib/python2.6/dist-packages/pip/basecommand.py", line 215, in main + status = self.run(options, args) + File "/usr/local/lib/python2.6/dist-packages/pip/commands/install.py", line 335, in run + wb.build(autobuilding=True) + File "/usr/local/lib/python2.6/dist-packages/pip/wheel.py", line 749, in build + self.requirement_set.prepare_files(self.finder) + File "/usr/local/lib/python2.6/dist-packages/pip/req/req_set.py", line 380, in prepare_files + ignore_dependencies=self.ignore_dependencies)) + File "/usr/local/lib/python2.6/dist-packages/pip/req/req_set.py", line 620, in _prepare_file + session=self.session, hashes=hashes) + File "/usr/local/lib/python2.6/dist-packages/pip/download.py", line 821, in unpack_url + hashes=hashes + File "/usr/local/lib/python2.6/dist-packages/pip/download.py", line 659, in unpack_http_url + hashes) + File "/usr/local/lib/python2.6/dist-packages/pip/download.py", line 853, in _download_http_url + stream=True, + File "/usr/local/lib/python2.6/dist-packages/pip/_vendor/requests/sessions.py", line 521, in get + return self.request('GET', url, **kwargs) + File "/usr/local/lib/python2.6/dist-packages/pip/download.py", line 386, in request + return super(PipSession, self).request(method, url, *args, **kwargs) + File "/usr/local/lib/python2.6/dist-packages/pip/_vendor/requests/sessions.py", line 508, in request + resp = self.send(prep, **send_kwargs) + File "/usr/local/lib/python2.6/dist-packages/pip/_vendor/requests/sessions.py", line 618, in send + r = adapter.send(request, **kwargs) + File "/usr/local/lib/python2.6/dist-packages/pip/_vendor/cachecontrol/adapter.py", line 47, in send + resp = super(CacheControlAdapter, self).send(request, **kw) + File "/usr/local/lib/python2.6/dist-packages/pip/_vendor/requests/adapters.py", line 506, in send + raise SSLError(e, request=request) + SSLError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/ef/ab/aa12712415809bf698e719b307419f953e25344e8f42d557533d7a02b276/netapp_lib-2020.7.16-py2-none-any.whl (Caused by SSLError(CertificateError("hostname 'files.pythonhosted.org' doesn't match either of 'r.ssl.fastly.net', '*.catchpoint.com', '*.cnn.io', '*.dollarshaveclub.com', '*.eater.com', '*.fastly.picmonkey.com', '*.files.saymedia-content.com', '*.ft.com', '*.meetupstatic.com', '*.nfl.com', '*.pagar.me', '*.picmonkey.com', '*.realself.com', '*.sbnation.com', '*.shakr.com', '*.streamable.com', '*.surfly.com', '*.theverge.com', '*.thrillist.com', '*.vox-cdn.com', '*.vox.com', '*.voxmedia.com', 'eater.com', 'ft.com', 'i.gse.io', 'picmonkey.com', 'realself.com', 'static.wixstatic.com', 'streamable.com', 'surfly.com', 'theverge.com', 'vox-cdn.com', 'vox.com', 'www.joyent.com'",),)) + ERROR: Command "/usr/bin/python2.6 /root/ansible/test/lib/ansible_test/_data/quiet_pip.py install --disable-pip-version-check -r /root/ansible/test/lib/ansible_test/_data/requirements/units.txt -r tests/unit/requirements.txt -c /root/ansible/test/lib/ansible_test/_data/requirements/constraints.txt" returned exit status 2. + ERROR: Command "docker exec d47eb360db4ce779c1f690db964655b76e68895c4360ff252c46fe7fe6f5c75a /usr/bin/env ANSIBLE_TEST_CONTENT_ROOT=/root/ansible_collections/netapp/ontap LC_ALL=en_US.UTF-8 /usr/bin/python3.6 /root/ansible/bin/ansible-test units --metadata tests/output/.tmp/metadata-9i2qfrcl.json --truncate 200 --redact --color yes --requirements --python default --requirements-mode only" returned exit status 1. + validations: + required: true + + +- type: markdown + attributes: + value: > + *One last thing...* + + + Thank you for your collaboration! + + +... diff --git a/ansible_collections/netapp/um_info/.github/ISSUE_TEMPLATE/feature_request.yml b/ansible_collections/netapp/um_info/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 000000000..126b4b9cd --- /dev/null +++ b/ansible_collections/netapp/um_info/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,100 @@ +--- +name: ✨ Feature request +description: Suggest an idea for this project + +body: +- type: markdown + attributes: + value: > + **Thank you for wanting to suggest a feature for netapp.um_info!** + + 💡 + Before you go ahead with your request, please first consider if it + would be useful for majority of the netapp.um_info users. As a + general rule of thumb, any feature that is only of interest to a + small sub group should be [implemented in a third-party Ansible + Collection][contribute to collections] or maybe even just your + project alone. Be mindful of the fact that the essential + netapp.um_info features have a broad impact. + + + <details> + <summary> + ❗ Every change breaks someone's workflow. + </summary> + + + [![❗ Every change breaks someone's workflow. + ](https://imgs.xkcd.com/comics/workflow.png) + ](https://xkcd.com/1172/) + </details> + + + ⚠ + Verify first that your idea is not [already requested on + GitHub][issue search]. + + Also test if the main branch does not already implement this. + + +- type: textarea + attributes: + label: Summary + description: > + Describe the new feature/improvement you would like briefly below. + + + What's the problem this feature will solve? + + What are you trying to do, that you are unable to achieve + with netapp.um_info as it currently stands? + + + * Provide examples of real-world use cases that this would enable + and how it solves the problem you described. + + * How do you solve this now? + + * Have you tried to work around the problem using other tools? + + * Could there be a different approach to solving this issue? + + placeholder: >- + I am trying to do X with netapp.um_info from the devel branch on GitHub and + I think that implementing a feature Y would be very helpful for me and + every other user of netapp.um_info because of Z. + validations: + required: true + +- type: input + attributes: + label: Component Name + description: > + Write the short name of the module, plugin, task or feature below, + *use your best guess if unsure*. + + + [collections org]: /ansible-collections + placeholder: dnf, apt, yum, pip, user etc. + validations: + required: true + +- type: textarea + attributes: + label: Additional Information + description: | + Describe how the feature would be used, why it is needed and what it would solve. + + **HINT:** You can paste https://gist.github.com links for larger files. + value: | + <!--- Paste example playbooks or commands between quotes below --> + ```yaml (paste below) + + ``` + placeholder: >- + I asked on https://stackoverflow.com/.... and the community + advised me to do X, Y and Z. + validations: + required: true + +... diff --git a/ansible_collections/netapp/um_info/.github/workflows/coverage.yml b/ansible_collections/netapp/um_info/.github/workflows/coverage.yml new file mode 100644 index 000000000..39d5818c9 --- /dev/null +++ b/ansible_collections/netapp/um_info/.github/workflows/coverage.yml @@ -0,0 +1,45 @@ +name: NetApp.um_info Ansible Coverage + +on: + push: + pull_request: + schedule: + - cron: '0 6 * * *' + +jobs: + sanity: + name: Coverage on UM_INFO + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install ansible stable-2.11 + run: pip install https://github.com/ansible/ansible/archive/stable-2.11.tar.gz --disable-pip-version-check + + - name: Make directory to make ansible-test happy + run: | + pwd + mkdir -p ansible_collections/netapp/um_info/ + rsync -av . ansible_collections/netapp/um_info/ --exclude ansible_collections/netapp/um_info/ + + - name: Run Unit Tests + run: ansible-test units --coverage --color --docker --python 3.8 + working-directory: ansible_collections/netapp/um_info/ + + # ansible-test support producing code coverage date + - name: Generate coverage report + run: ansible-test coverage xml -v --requirements --group-by command --group-by version + working-directory: ansible_collections/netapp/um_info/ + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 + with: + working-directory: ansible_collections/netapp/um_info/ + verbose: true
\ No newline at end of file diff --git a/ansible_collections/netapp/um_info/.github/workflows/main.yml b/ansible_collections/netapp/um_info/.github/workflows/main.yml new file mode 100644 index 000000000..fbcf92002 --- /dev/null +++ b/ansible_collections/netapp/um_info/.github/workflows/main.yml @@ -0,0 +1,47 @@ +name: NetApp.um_info Ansible CI + +on: + push: + pull_request: + schedule: + - cron: '0 6 * * *' + +jobs: + sanity: + name: Sanity (${{ matrix.ansible }} on Um_info + runs-on: ubuntu-latest + strategy: + matrix: + ansible: + - stable-2.9 + - stable-2.10 + - stable-2.11 + - stable-2.12 + - devel + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install ansible (${{ matrix.ansible }}) + run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check + + - name: Make directory to make ansible-test happy + run: | + pwd + mkdir -p ansible_collections/netapp/um_info/ + rsync -av . ansible_collections/netapp/um_info/ --exclude ansible_collections/netapp/um_info/ + + + - name: Run sanity tests Um_info + run: ansible-test sanity --docker -v --color + working-directory: ansible_collections/netapp/um_info/ + + - name: Run Unit Tests + run: ansible-test units --docker -v --color + working-directory: ansible_collections/netapp/um_info/ diff --git a/ansible_collections/netapp/um_info/CHANGELOG.rst b/ansible_collections/netapp/um_info/CHANGELOG.rst new file mode 100644 index 000000000..f5d538d11 --- /dev/null +++ b/ansible_collections/netapp/um_info/CHANGELOG.rst @@ -0,0 +1,78 @@ +==================================================== +NetApp Unified Manager Info Collection Release Notes +==================================================== + +.. contents:: Topics + + +v21.8.0 +======= + +Minor Changes +------------- + +- PR1 - allow usage of Ansible module group defaults - for Ansible 2.12+. + +v21.7.0 +======= + +Minor Changes +------------- + +- all modules - ability to trace API calls and responses. +- all modules - new ``max_records`` option to limit the amount of data in a single GET response. + +Bugfixes +-------- + +- all modules - report error when connecting to a server that does not run AIQUM. +- all modules - return all records rather than the first 1000 records (mostly for volumes). +- rename na_um_list_volumes.p to na_um_list_volumes.py + +v21.6.0 +======= + +Minor Changes +------------- + +- na_um_list_aggregates has been renamed na_um_aggregates_info. +- na_um_list_clusters has been renamed na_um_clusters_info. +- na_um_list_nodes has been renamed na_um_nodes_info. +- na_um_list_svms has been renamed na_um_svms_info. +- na_um_list_volumes has been renamed na_um_volumes_info. + +v21.5.0 +======= + +Minor Changes +------------- + +- minor changes to meet Red Hat requirements to be certified. + +v20.7.0 +======= + +Minor Changes +------------- + +- na_um_list_aggregates - Now sort by performance_capacity.used +- na_um_list_nodes - Now sort by performance_capacity.used + +v20.6.0 +======= + +New Modules +----------- + +- netapp.um_info.na_um_list_volumes - NetApp Unified Manager list volumes. + +v20.5.0 +======= + +New Modules +----------- + +- netapp.um_info.na_um_list_aggregates - NetApp Unified Manager list aggregates. +- netapp.um_info.na_um_list_clusters - NetApp Unified Manager list cluster. +- netapp.um_info.na_um_list_nodes - NetApp Unified Manager list nodes. +- netapp.um_info.na_um_list_svms - NetApp Unified Manager list svms. diff --git a/ansible_collections/netapp/um_info/COPYING b/ansible_collections/netapp/um_info/COPYING new file mode 100644 index 000000000..94a9ed024 --- /dev/null +++ b/ansible_collections/netapp/um_info/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. diff --git a/ansible_collections/netapp/um_info/FILES.json b/ansible_collections/netapp/um_info/FILES.json new file mode 100644 index 000000000..0d45bda4d --- /dev/null +++ b/ansible_collections/netapp/um_info/FILES.json @@ -0,0 +1,418 @@ +{ + "files": [ + { + "name": ".", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "requirements.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ec72420df5dfbdce4111f715c96338df3b7cb75f58e478d2449c9720e560de8c", + "format": 1 + }, + { + "name": "plugins", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/doc_fragments", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/doc_fragments/netapp.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "bd4a43b072697053c41ac2c6979513bd8fadd8c80eece1ca2a5454f24ecf85da", + "format": 1 + }, + { + "name": "plugins/module_utils", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/netapp.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "821070453abf1ec684677f43878fdd4ceb66bb30e40aeeb16b35aa71c0294249", + "format": 1 + }, + { + "name": "plugins/module_utils/netapp_module.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cf7052585943d6e39a9b671538947f8de77411805f659c148267099603d26bef", + "format": 1 + }, + { + "name": "plugins/modules", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/modules/na_um_list_volumes.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e155cc127f6b1fb1a7512a52b15077e8bcc71cd2bd36fceb8e5811b43fa6c647", + "format": 1 + }, + { + "name": "plugins/modules/na_um_list_nodes.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c9dc5fee102f858e25be36bd6a4cbc72732fd4d87f5693d9dc9c070360b05b3b", + "format": 1 + }, + { + "name": "plugins/modules/na_um_svms_info.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "810aed45c718629fc7629558a6f1de69bcb30206dbe1b04b8aff4284512b910f", + "format": 1 + }, + { + "name": "plugins/modules/na_um_clusters_info.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fa552cbf9cc2684c8378023e0bd8b338d33f8f826c05812addc5867830999b97", + "format": 1 + }, + { + "name": "plugins/modules/na_um_aggregates_info.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b65dde8d0d786b63ea89d411024d5c36dc56fe45d9472eec7f5c1d3dba47fff8", + "format": 1 + }, + { + "name": "plugins/modules/na_um_list_clusters.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fa552cbf9cc2684c8378023e0bd8b338d33f8f826c05812addc5867830999b97", + "format": 1 + }, + { + "name": "plugins/modules/na_um_list_svms.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "810aed45c718629fc7629558a6f1de69bcb30206dbe1b04b8aff4284512b910f", + "format": 1 + }, + { + "name": "plugins/modules/na_um_nodes_info.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c9dc5fee102f858e25be36bd6a4cbc72732fd4d87f5693d9dc9c070360b05b3b", + "format": 1 + }, + { + "name": "plugins/modules/na_um_volumes_info.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e155cc127f6b1fb1a7512a52b15077e8bcc71cd2bd36fceb8e5811b43fa6c647", + "format": 1 + }, + { + "name": "plugins/modules/na_um_list_aggregates.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b65dde8d0d786b63ea89d411024d5c36dc56fe45d9472eec7f5c1d3dba47fff8", + "format": 1 + }, + { + "name": "tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/unit", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/unit/compat", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/unit/compat/unittest.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cba95d18c5b39c6f49714eacf1ac77452c2e32fa087c03cf01aacd19ae597b0f", + "format": 1 + }, + { + "name": "tests/unit/compat/builtins.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0ca4cac919e166b25e601e11acb01f6957dddd574ff0a62569cb994a5ecb63e1", + "format": 1 + }, + { + "name": "tests/unit/compat/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "tests/unit/compat/mock.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0af958450cf6de3fbafe94b1111eae8ba5a8dbe1d785ffbb9df81f26e4946d99", + "format": 1 + }, + { + "name": "tests/unit/requirements.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "68a61b1d58a722f4ffabaa28da01c9837c93a582ea41c1bfb1c1fd54ea2d8fab", + "format": 1 + }, + { + "name": "tests/unit/plugins", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/unit/plugins/module_utils", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/unit/plugins/module_utils/test_netapp.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a4de097829490ea8016a6227b340a27e23a38f40189f12f80217caa199c608ec", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/test_na_um_volumes_info.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b8a2d4ca0f304a588de4d642da415362f3b15b2926fa12a90117b58b9f71d6d9", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/test_na_um_clusters_info.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "11f9aa85947d440b6a647a2cc6be1cf16d93d69b08ed288a33fa8168836d2521", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/test_na_um_nodes_info.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cf4ded8134d30ed7b82769252addf2094d07b6bf3ec81e7aba0615b290558cfb", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/test_na_um_aggregates_info.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ba3687cb122aa7452f21052b5a6f26448df8356e92e4b78c20cce55c66ea3026", + "format": 1 + }, + { + "name": "tests/unit/plugins/modules/test_na_um_svms_info.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7933824403b197ec756f540be054a5e2c75b5a3a28cf60280cd11493f4c4b235", + "format": 1 + }, + { + "name": "meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "meta/runtime.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "88d46a475f366fffbd8ec430a85972ed1aa180268564bd88434cceaaaf13712c", + "format": 1 + }, + { + "name": "changelogs", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "changelogs/fragments", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "changelogs/fragments/DEVOPS-3962.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f4f9cd51e1471197180cbedd7a89fc1ebbbd5f3daed2ac50a63e1df54e28c0b7", + "format": 1 + }, + { + "name": "changelogs/fragments/DEVOPS-4087.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "549499c7518f654d08f85c8d2774506fa8206db9cfad997a620a874ba55a0b24", + "format": 1 + }, + { + "name": "changelogs/fragments/DEVOPS-4059.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a77590a8f2eefce57127281e067aa0a873c7dee6c29c64b9f24a6aa44ed559fc", + "format": 1 + }, + { + "name": "changelogs/fragments/DEVOPS-2952.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "df2ee1a655d129670751fac00f64cb82d73b66b4b2e4babf1c03eef1958f6784", + "format": 1 + }, + { + "name": "changelogs/fragments/20.7.0.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fc97a5a80d92a3fa6228c00d686e4ce5173facb9ce1d2282905883eb4bec385a", + "format": 1 + }, + { + "name": "changelogs/fragments/DEVOPS-3920.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "819a48b8af6f9be3dc5978af0e690830f15f3090cc9ce1e86532d726809cfb2c", + "format": 1 + }, + { + "name": "changelogs/fragments/DEVOPS-4416.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4224db573f34caeeb956c8728eb343a47bc2729d898001a4c6a671b780dae1bf", + "format": 1 + }, + { + "name": "changelogs/config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "603b6174cae76f0b6d21432d05ba48ec1332b3a24bb910a81d75b1d8c0942914", + "format": 1 + }, + { + "name": "changelogs/changelog.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "dfd5a84377e87d5a796d1b6fe3c534fe0bceb63b8bc1dcd94a8bbf9ea9c86947", + "format": 1 + }, + { + "name": "README.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ae574e5d7e3e4d82a855ed53b06c34a26134d7a9d50e023bf2408b51e0f8a679", + "format": 1 + }, + { + "name": "COPYING", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8ceb4b9ee5adedde47b31e975c1d90c73ad27b6b165a1dcd80c7c545eb65b903", + "format": 1 + }, + { + "name": ".github", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": ".github/workflows", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": ".github/workflows/coverage.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9e4fe7f09274f317cf0b299f8c35a3df98f8d48e5014a7c7523c587593e1a63c", + "format": 1 + }, + { + "name": ".github/workflows/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fa99709b97a6f722ae1a51afaf32ad66aa2d1306b708b8b9c8d723be715ca4c4", + "format": 1 + }, + { + "name": ".github/ISSUE_TEMPLATE", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": ".github/ISSUE_TEMPLATE/feature_request.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "faa5043f7628d0fa7975b9feb2c4d72e73965d0e6f072ca5fa13b00055f773e3", + "format": 1 + }, + { + "name": ".github/ISSUE_TEMPLATE/bug_report.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5b1080b0ad861868077511d5a8fa8b3a84c5abb2cfc13cf4fa10eeaffb2c0957", + "format": 1 + }, + { + "name": "CHANGELOG.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "eff94a97af8456b8fcf2677bf5e05db854239b496bc787834c562f015937fbcf", + "format": 1 + } + ], + "format": 1 +}
\ No newline at end of file diff --git a/ansible_collections/netapp/um_info/MANIFEST.json b/ansible_collections/netapp/um_info/MANIFEST.json new file mode 100644 index 000000000..40b3df1ae --- /dev/null +++ b/ansible_collections/netapp/um_info/MANIFEST.json @@ -0,0 +1,34 @@ +{ + "collection_info": { + "namespace": "netapp", + "name": "um_info", + "version": "21.8.0", + "authors": [ + "NetApp Ansible Team <ng-ansibleteam@netapp.com>" + ], + "readme": "README.md", + "tags": [ + "storage", + "netapp", + "aiqum", + "um", + "ontap" + ], + "description": "NetApp Unified Manager(AIQUM 9.7) Collection", + "license": [], + "license_file": "COPYING", + "dependencies": {}, + "repository": "https://github.com/ansible-collections/netapp.um_info", + "documentation": null, + "homepage": "https://netapp.io/configuration-management-and-automation/", + "issues": "https://github.com/ansible-collections/netapp.um_info/issues" + }, + "file_manifest_file": { + "name": "FILES.json", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cb6c57414d2dfe99a63f715ea33254ca1d6cd458b50fa0cbae778ea41b14ef2c", + "format": 1 + }, + "format": 1 +}
\ No newline at end of file diff --git a/ansible_collections/netapp/um_info/README.md b/ansible_collections/netapp/um_info/README.md new file mode 100644 index 000000000..193bbab59 --- /dev/null +++ b/ansible_collections/netapp/um_info/README.md @@ -0,0 +1,83 @@ +[![Documentation](https://img.shields.io/badge/docs-brightgreen.svg)](https://docs.ansible.com/ansible/devel/collections/netapp/um_info/index.html) +![example workflow](https://github.com/ansible-collections/netapp.um_info/actions/workflows/main.yml/badge.svg) +[![codecov](https://codecov.io/gh/ansible-collections/netapp.um_info/branch/main/graph/badge.svg?token=weBYkksxSi)](https://codecov.io/gh/ansible-collections/netapp.um_info) + + +============================================================= + + netapp.um_info + + NetApp Unified Manager(AIQUM 9.7) Collection + + Copyright (c) 2020 NetApp, Inc. All rights reserved. + Specifications subject to change without notice. + +============================================================= +# Installation +```bash +ansible-galaxy collection install netapp.um_info +``` +To use Collection add the following to the top of your playbook, with out this you will be using Ansible 2.9 version of the module +``` +collections: + - netapp.um_info +``` + +# Module documentation +https://docs.ansible.com/ansible/devel/collections/netapp/um_info/ + +# Code of Conduct +This collection follows the [Ansible project's Code of Conduct](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html). + +# Need help +Join our Slack Channel at [Netapp.io](http://netapp.io/slack) + +# Release Notes + +## 21.8.0 + +#### Minor changes + - all modules - enable usage of Ansible module group defaults - for Ansible 2.12+. + +## 21.7.0 + +#### Minor changes + - all modules - ability to trace API calls and responses. + - all modules - new `max_records` option to limit the amount of data in a single GET response. + +### Bux fixes + - all modules - report error when connecting to a server that does not run AIQUM. + - all modules - return all records rather than the first 1000 records (mostly for volumes). + - rename na_um_list_volumes.p to na_um_list_volumes.py. + +## 21.6.0 +### Minor changes +- na_um_list_aggregates has been renamed na_um_aggregates_info +- na_um_list_clusters has been renamed na_um_clusters_info +- na_um_list_nodes has been renamed na_um_nodes_info +- na_um_list_svms has been renamed na_um_svms_info +- na_um_list_volumes has been renamed na_um_volumes_info + +## 21.5.0 + +### Minor changes +- minor changes to meet Red Hat requirements to be certified. + +## 20.7.0 + +### Minor changes +- na_um_list_aggregates: Now sort by performance_capacity.used +- na_um_list_nodes: Now sort by performance_capacity.used + +## 20.6.0 + +### New Modules +- na_um_list_volumes: list volumes. + +## 20.5.0 + +### New Modules +- na_um_list_aggregates: list aggregates. +- na_um_list_clusters: list clusters. +- na_um_list_nodes: list nodes. +- na_um_list_svms: list svms. diff --git a/ansible_collections/netapp/um_info/changelogs/changelog.yaml b/ansible_collections/netapp/um_info/changelogs/changelog.yaml new file mode 100644 index 000000000..c5d56b307 --- /dev/null +++ b/ansible_collections/netapp/um_info/changelogs/changelog.yaml @@ -0,0 +1,72 @@ +ancestor: null +releases: + 20.5.0: + modules: + - description: NetApp Unified Manager list aggregates. + name: na_um_list_aggregates + namespace: '' + - description: NetApp Unified Manager list cluster. + name: na_um_list_clusters + namespace: '' + - description: NetApp Unified Manager list nodes. + name: na_um_list_nodes + namespace: '' + - description: NetApp Unified Manager list svms. + name: na_um_list_svms + namespace: '' + release_date: '2020-05-06' + 20.6.0: + modules: + - description: NetApp Unified Manager list volumes. + name: na_um_list_volumes + namespace: '' + release_date: '2020-06-03' + 20.7.0: + changes: + minor_changes: + - na_um_list_aggregates - Now sort by performance_capacity.used + - na_um_list_nodes - Now sort by performance_capacity.used + fragments: + - 20.7.0.yaml + release_date: '2020-06-24' + 21.5.0: + changes: + minor_changes: + - minor changes to meet Red Hat requirements to be certified. + fragments: + - DEVOPS-3920.yaml + release_date: '2021-04-21' + 21.6.0: + changes: + minor_changes: + - na_um_list_aggregates has been renamed na_um_aggregates_info. + - na_um_list_clusters has been renamed na_um_clusters_info. + - na_um_list_nodes has been renamed na_um_nodes_info. + - na_um_list_svms has been renamed na_um_svms_info. + - na_um_list_volumes has been renamed na_um_volumes_info. + fragments: + - DEVOPS-3962.yaml + release_date: '2021-05-06' + 21.7.0: + changes: + bugfixes: + - all modules - report error when connecting to a server that does not run AIQUM. + - all modules - return all records rather than the first 1000 records (mostly + for volumes). + - rename na_um_list_volumes.p to na_um_list_volumes.py + minor_changes: + - all modules - ability to trace API calls and responses. + - all modules - new ``max_records`` option to limit the amount of data in a + single GET response. + fragments: + - DEVOPS-2952.yaml + - DEVOPS-4059.yaml + - DEVOPS-4087.yaml + release_date: '2021-07-14' + 21.8.0: + changes: + minor_changes: + - PR1 - allow usage of Ansible module group defaults - for Ansible 2.12+. + fragments: + - DEVOPS-4416.yaml + release_date: '2021-11-03' diff --git a/ansible_collections/netapp/um_info/changelogs/config.yaml b/ansible_collections/netapp/um_info/changelogs/config.yaml new file mode 100644 index 000000000..a39ec8cc2 --- /dev/null +++ b/ansible_collections/netapp/um_info/changelogs/config.yaml @@ -0,0 +1,32 @@ +changelog_filename_template: ../CHANGELOG.rst +changelog_filename_version_depth: 0 +changes_file: changelog.yaml +changes_format: combined +ignore_other_fragment_extensions: true +keep_fragments: true +mention_ancestor: true +new_plugins_after_name: removed_features +notesdir: fragments +prelude_section_name: release_summary +prelude_section_title: Release Summary +sanitize_changelog: true +sections: +- - major_changes + - Major Changes +- - minor_changes + - Minor Changes +- - breaking_changes + - Breaking Changes / Porting Guide +- - deprecated_features + - Deprecated Features +- - removed_features + - Removed Features (previously deprecated) +- - security_fixes + - Security Fixes +- - bugfixes + - Bugfixes +- - known_issues + - Known Issues +title: NetApp Unified Manager Info Collection +trivial_section_name: trivial +use_fqcn: true diff --git a/ansible_collections/netapp/um_info/changelogs/fragments/20.7.0.yaml b/ansible_collections/netapp/um_info/changelogs/fragments/20.7.0.yaml new file mode 100644 index 000000000..75f9b4e46 --- /dev/null +++ b/ansible_collections/netapp/um_info/changelogs/fragments/20.7.0.yaml @@ -0,0 +1,3 @@ +minor_changes: + - na_um_list_aggregates - Now sort by performance_capacity.used + - na_um_list_nodes - Now sort by performance_capacity.used diff --git a/ansible_collections/netapp/um_info/changelogs/fragments/DEVOPS-2952.yaml b/ansible_collections/netapp/um_info/changelogs/fragments/DEVOPS-2952.yaml new file mode 100644 index 000000000..0d0699cc9 --- /dev/null +++ b/ansible_collections/netapp/um_info/changelogs/fragments/DEVOPS-2952.yaml @@ -0,0 +1,4 @@ +minor_changes: + - all modules - new ``max_records`` option to limit the amount of data in a single GET response. +bugfixes: + - all modules - return all records rather than the first 1000 records (mostly for volumes). diff --git a/ansible_collections/netapp/um_info/changelogs/fragments/DEVOPS-3920.yaml b/ansible_collections/netapp/um_info/changelogs/fragments/DEVOPS-3920.yaml new file mode 100644 index 000000000..c3c7f1224 --- /dev/null +++ b/ansible_collections/netapp/um_info/changelogs/fragments/DEVOPS-3920.yaml @@ -0,0 +1,2 @@ +minor_changes: + - minor changes to meet Red Hat requirements to be certified. diff --git a/ansible_collections/netapp/um_info/changelogs/fragments/DEVOPS-3962.yaml b/ansible_collections/netapp/um_info/changelogs/fragments/DEVOPS-3962.yaml new file mode 100644 index 000000000..1d3ef3f86 --- /dev/null +++ b/ansible_collections/netapp/um_info/changelogs/fragments/DEVOPS-3962.yaml @@ -0,0 +1,6 @@ +minor_changes: +- na_um_list_aggregates has been renamed na_um_aggregates_info. +- na_um_list_clusters has been renamed na_um_clusters_info. +- na_um_list_nodes has been renamed na_um_nodes_info. +- na_um_list_svms has been renamed na_um_svms_info. +- na_um_list_volumes has been renamed na_um_volumes_info. diff --git a/ansible_collections/netapp/um_info/changelogs/fragments/DEVOPS-4059.yaml b/ansible_collections/netapp/um_info/changelogs/fragments/DEVOPS-4059.yaml new file mode 100644 index 000000000..824f55f1e --- /dev/null +++ b/ansible_collections/netapp/um_info/changelogs/fragments/DEVOPS-4059.yaml @@ -0,0 +1,2 @@ +bugfixes: + - rename na_um_list_volumes.p to na_um_list_volumes.py diff --git a/ansible_collections/netapp/um_info/changelogs/fragments/DEVOPS-4087.yaml b/ansible_collections/netapp/um_info/changelogs/fragments/DEVOPS-4087.yaml new file mode 100644 index 000000000..836a4b1b2 --- /dev/null +++ b/ansible_collections/netapp/um_info/changelogs/fragments/DEVOPS-4087.yaml @@ -0,0 +1,4 @@ +minor_changes: + - all modules - ability to trace API calls and responses. +bugfixes: + - all modules - report error when connecting to a server that does not run AIQUM. diff --git a/ansible_collections/netapp/um_info/changelogs/fragments/DEVOPS-4416.yaml b/ansible_collections/netapp/um_info/changelogs/fragments/DEVOPS-4416.yaml new file mode 100644 index 000000000..6b4b660a0 --- /dev/null +++ b/ansible_collections/netapp/um_info/changelogs/fragments/DEVOPS-4416.yaml @@ -0,0 +1,2 @@ +minor_changes: + - PR1 - allow usage of Ansible module group defaults - for Ansible 2.12+. diff --git a/ansible_collections/netapp/um_info/meta/runtime.yml b/ansible_collections/netapp/um_info/meta/runtime.yml new file mode 100644 index 000000000..04c66ffeb --- /dev/null +++ b/ansible_collections/netapp/um_info/meta/runtime.yml @@ -0,0 +1,9 @@ +--- +requires_ansible: ">=2.9.10" +action_groups: + netapp_um_info: + - na_um_aggregates_info + - na_um_clusters_info + - na_um_nodes_info + - na_um_svms_info + - na_um_volumes_info diff --git a/ansible_collections/netapp/um_info/plugins/doc_fragments/netapp.py b/ansible_collections/netapp/um_info/plugins/doc_fragments/netapp.py new file mode 100644 index 000000000..0790f109a --- /dev/null +++ b/ansible_collections/netapp/um_info/plugins/doc_fragments/netapp.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- + +# Copyright: (c) 2020, Suhas Bangalore Shekar <bsuhas@netapp.com> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +class ModuleDocFragment(object): + + DOCUMENTATION = r''' +options: + - See respective platform section for more details +requirements: + - See respective platform section for more details +notes: + - Ansible modules are available for the following NetApp Storage Management Platforms: AIQUM 9.7 +''' + + # Documentation fragment for AIQUM (um) + UM = r''' +options: + hostname: + description: + - The hostname or IP address of the Unified Manager instance. + type: str + required: true + username: + description: + - username of the Unified Manager instance. + type: str + required: true + password: + description: + - Password for the specified user. + type: str + required: true + validate_certs: + description: + - If set to C(False), the SSL certificates will not be validated. + - This should only set to C(False) used on personally controlled sites using self-signed certificates. + type: bool + default: True + http_port: + description: + - Override the default port (443) with this port + type: int + feature_flags: + description: + - Enable or disable a new feature. + - This can be used to enable an experimental feature or disable a new feature that breaks backward compatibility. + - Supported keys and values are subject to change without notice. Unknown keys are ignored. + - trace_apis can be set to true to enable tracing, data is written to /tmp/um_apis.log. + type: dict + version_added: 21.7.0 + max_records: + description: + - Maximum number of records retrieved in a single GET request. + - This module loops on GET requests until all available records are fetched. + - If absent, AIQUM uses 1000. + type: int + version_added: 21.7.0 + + +requirements: + - A AIQUM 9.7 system. + - Ansible 2.9 or later. + +notes: + - With the 21.6.0 release, all modules have been renamed to na_um_<module>_info. The old ones will continue to work but will be depecrated in the future. + - The modules prefixed with na_um are built to support the AIQUM 9.7 platform. + - Supports check_mode. +''' diff --git a/ansible_collections/netapp/um_info/plugins/module_utils/netapp.py b/ansible_collections/netapp/um_info/plugins/module_utils/netapp.py new file mode 100644 index 000000000..ba58f56e8 --- /dev/null +++ b/ansible_collections/netapp/um_info/plugins/module_utils/netapp.py @@ -0,0 +1,246 @@ +# This code is part of Ansible, but is an independent component. +# This particular file snippet, and this file snippet only, is BSD licensed. +# Modules you write using this snippet, which is embedded dynamically by Ansible +# still belong to the author of the module, and may assign their own license +# to the complete work. +# +# Copyright (c) 2017, Sumit Kumar <sumit4@netapp.com> +# Copyright (c) 2017, Michael Price <michael.price@netapp.com> +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +''' +common routines for um_info +''' + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import logging +from ansible.module_utils.basic import missing_required_lib +from ansible.module_utils._text import to_native + +try: + from ansible.module_utils.ansible_release import __version__ as ansible_version +except ImportError: + ansible_version = 'unknown' + +COLLECTION_VERSION = "21.8.0" + +try: + import requests + HAS_REQUESTS = True +except ImportError: + HAS_REQUESTS = False + +ERROR_MSG = dict( + no_cserver='This module is expected to run as cluster admin' +) + +LOG = logging.getLogger(__name__) +LOG_FILE = '/tmp/um_apis.log' + + +def na_um_host_argument_spec(): + + return dict( + hostname=dict(required=True, type='str'), + username=dict(required=True, type='str'), + password=dict(required=True, type='str', no_log=True), + validate_certs=dict(required=False, type='bool', default=True), + http_port=dict(required=False, type='int'), + feature_flags=dict(required=False, type='dict', default=dict()), + max_records=dict(required=False, type='int') + ) + + +def has_feature(module, feature_name): + feature = get_feature(module, feature_name) + if isinstance(feature, bool): + return feature + module.fail_json(msg="Error: expected bool type for feature flag: %s" % feature_name) + + +def get_feature(module, feature_name): + ''' if the user has configured the feature, use it + otherwise, use our default + ''' + default_flags = dict( + strict_json_check=True, # if true, fail if response.content in not empty and is not valid json + trace_apis=False, # if true, append REST requests/responses to LOG_FILE + + ) + + if module.params['feature_flags'] is not None and feature_name in module.params['feature_flags']: + return module.params['feature_flags'][feature_name] + if feature_name in default_flags: + return default_flags[feature_name] + module.fail_json(msg="Internal error: unexpected feature flag: %s" % feature_name) + + +class UMRestAPI(object): + ''' send REST request and process response ''' + def __init__(self, module, timeout=60): + self.module = module + self.username = self.module.params['username'] + self.password = self.module.params['password'] + self.hostname = self.module.params['hostname'] + self.verify = self.module.params['validate_certs'] + self.max_records = self.module.params['max_records'] + self.timeout = timeout + if self.module.params.get('http_port') is not None: + self.url = 'https://%s:%d' % (self.hostname, self.module.params['http_port']) + else: + self.url = 'https://%s' % self.hostname + self.errors = list() + self.debug_logs = list() + self.check_required_library() + if has_feature(module, 'trace_apis'): + logging.basicConfig(filename=LOG_FILE, level=logging.DEBUG, format='%(asctime)s %(levelname)-8s %(message)s') + + def check_required_library(self): + if not HAS_REQUESTS: + self.module.fail_json(msg=missing_required_lib('requests')) + + def get_records(self, message, api): + records = list() + try: + if message['total_records'] > 0: + records = message['records'] + if message['total_records'] != len(records): + self.module.warn('Mismatch between received: %d and expected: %d records.' % (len(records), message['total_records'])) + except KeyError as exc: + self.module.fail_json(msg='Error: unexpected response from %s: %s - expecting key: %s' + % (api, message, to_native(exc))) + return records + + def send_request(self, method, api, params, json=None, accept=None): + ''' send http request and process response, including error conditions ''' + url = self.url + api + status_code = None + content = None + json_dict = None + json_error = None + error_details = None + headers = None + if accept is not None: + headers = dict() + # accept is used to turn on/off HAL linking + if accept is not None: + headers['accept'] = accept + + def check_contents(response): + '''json() may fail on an empty value, but it's OK if no response is expected. + To avoid false positives, only report an issue when we expect to read a value. + The first get will see it. + ''' + if method == 'GET' and has_feature(self.module, 'strict_json_check'): + contents = response.content + if len(contents) > 0: + raise ValueError("Expecting json, got: %s" % contents) + + def get_json(response): + ''' extract json, and error message if present ''' + try: + json = response.json() + except ValueError: + check_contents(response) + return None, None + error = json.get('error') + return json, error + + self.log_debug('sending', repr(dict(method=method, url=url, verify=self.verify, params=params, + timeout=self.timeout, json=json, headers=headers))) + try: + response = requests.request(method, url, verify=self.verify, auth=(self.username, self.password), + params=params, timeout=self.timeout, json=json, headers=headers) + content = response.content # for debug purposes + status_code = response.status_code + # If the response was successful, no Exception will be raised + response.raise_for_status() + json_dict, json_error = get_json(response) + except requests.exceptions.HTTPError as err: + __, json_error = get_json(response) + if json_error is None: + self.log_error(status_code, 'HTTP error: %s' % err) + error_details = str(err) + # If an error was reported in the json payload, it is handled below + except requests.exceptions.ConnectionError as err: + self.log_error(status_code, 'Connection error: %s' % err) + error_details = str(err) + except Exception as err: + self.log_error(status_code, 'Other error: %s' % err) + error_details = str(err) + if json_error is not None: + self.log_error(status_code, 'Endpoint error: %d: %s' % (status_code, json_error)) + error_details = json_error + self.log_debug(status_code, content) + return json_dict, error_details + + def get(self, api, params): + + def get_next_api(message): + '''make sure _links is present, and href is present if next is present + return api if next is present, None otherwise + return error if _links or href are missing + ''' + api, error = None, None + if message is None or '_links' not in message: + error = 'Expecting _links key in %s' % message + elif 'next' in message['_links']: + if 'href' in message['_links']['next']: + api = message['_links']['next']['href'] + else: + error = 'Expecting href key in %s' % message['_links']['next'] + return api, error + + method = 'GET' + records = list() + if self.max_records is not None: + if params and 'max_records' not in params: + params['max_records'] = self.max_records + else: + params = dict(max_records=self.max_records) + api = '/api/%s' % api + + while api: + message, error = self.send_request(method, api, params) + if error: + return message, error + api, error = get_next_api(message) + if error: + return message, error + if 'records' in message: + records.extend(message['records']) + params = None # already included in the next link + + if records: + message['records'] = records + return message, error + + def log_error(self, status_code, message): + LOG.error("%s: %s", status_code, message) + self.errors.append(message) + self.debug_logs.append((status_code, message)) + + def log_debug(self, status_code, content): + LOG.debug("%s: %s", status_code, content) + self.debug_logs.append((status_code, content)) diff --git a/ansible_collections/netapp/um_info/plugins/module_utils/netapp_module.py b/ansible_collections/netapp/um_info/plugins/module_utils/netapp_module.py new file mode 100644 index 000000000..f3b95800e --- /dev/null +++ b/ansible_collections/netapp/um_info/plugins/module_utils/netapp_module.py @@ -0,0 +1,51 @@ +# This code is part of Ansible, but is an independent component. +# This particular file snippet, and this file snippet only, is BSD licensed. +# Modules you write using this snippet, which is embedded dynamically by Ansible +# still belong to the author of the module, and may assign their own license +# to the complete work. +# +# Copyright (c) 2020, Laurent Nicolas <laurentn@netapp.com> +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +''' Support class for NetApp ansible modules ''' + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +class NetAppModule(object): + ''' + Common class for NetApp modules + set of support functions to derive actions based + on the current state of the system, and a desired state + ''' + + def __init__(self): + self.changed = False + self.parameters = {} + + def set_parameters(self, ansible_params): + self.parameters = dict() + for param in ansible_params: + if ansible_params[param] is not None: + self.parameters[param] = ansible_params[param] + return self.parameters diff --git a/ansible_collections/netapp/um_info/plugins/modules/na_um_aggregates_info.py b/ansible_collections/netapp/um_info/plugins/modules/na_um_aggregates_info.py new file mode 100644 index 000000000..10a34cfdf --- /dev/null +++ b/ansible_collections/netapp/um_info/plugins/modules/na_um_aggregates_info.py @@ -0,0 +1,163 @@ +#!/usr/bin/python + +# (c) 2020, NetApp, Inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +''' +na_um_list_aggregates +''' + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'certified'} + + +DOCUMENTATION = ''' +module: na_um_aggregates_info +short_description: NetApp Unified Manager list aggregates. +extends_documentation_fragment: + - netapp.um_info.netapp.um +version_added: '20.5.0' +author: NetApp Ansible Team (@carchi8py) <ng-ansibleteam@netapp.com> + +description: +- List Aggregates on AIQUM. +''' + +EXAMPLES = """ +- name: List Aggregates + netapp.um_info.na_um_aggregates_info: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" +""" + +RETURN = """ +records: + description: Returns list of Aggregates information + returned: always + type: list + sample: [{'node': + {'_links': + {'self': + {'href': '...' + } + }, + 'uuid': '...', + 'key': '...', + 'name': '...' + }, + 'snaplock_type': '...', + 'uuid': '...', + 'space': + {'block_storage': + {'available': ..., + 'used': ..., + 'size': ... + }, + 'efficiency': + {'savings': ..., + 'logical_used': ... + } + }, + 'block_storage': + {'hybrid_cache': + {'enabled': ..., + 'size': ... + }, + 'primary': + {'raid_size': ..., + 'raid_type': '...' + }, + 'mirror': + {'state': '...' + } + }, + 'data_encryption': + {'software_encryption_enabled': ... + }, + 'cluster': + {'_links': + {'self': + {'href': '...' + } + }, + 'uuid': '...', + 'key': '...', + 'name': '...' + }, + 'state': '...', + 'create_time': '...', + '_links': + {'self': + {'href': '...' + } + }, + 'key': '...', + 'type': '...', + 'name': '...' + } + ] +""" + +from ansible.module_utils.basic import AnsibleModule +import ansible_collections.netapp.um_info.plugins.module_utils.netapp as netapp_utils +from ansible_collections.netapp.um_info.plugins.module_utils.netapp_module import NetAppModule +from ansible_collections.netapp.um_info.plugins.module_utils.netapp import UMRestAPI + + +class NetAppUMAggregate(object): + ''' aggregates initialize and class methods ''' + + def __init__(self): + self.argument_spec = netapp_utils.na_um_host_argument_spec() + self.module = AnsibleModule( + argument_spec=self.argument_spec, + supports_check_mode=True + ) + + self.na_helper = NetAppModule() + self.parameters = self.na_helper.set_parameters(self.module.params) + + self.rest_api = UMRestAPI(self.module) + + def get_aggregates(self): + """ + Fetch details of aggregates. + :return: + Dictionary of current details if aggregates found + None if aggregates is not found + """ + data = {} + api = "datacenter/storage/aggregates?order_by=performance_capacity.used" + message, error = self.rest_api.get(api, data) + if error: + self.module.fail_json(msg=error) + return self.rest_api.get_records(message, api) + + def apply(self): + """ + Apply action to the aggregates listing + :return: None + """ + current = self.get_aggregates() + if current is not None: + self.na_helper.changed = True + self.module.exit_json(changed=self.na_helper.changed, msg=current) + + +def main(): + """ + Create Aggregate class instance and invoke apply + :return: None + """ + list_aggregates_obj = NetAppUMAggregate() + list_aggregates_obj.apply() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/netapp/um_info/plugins/modules/na_um_clusters_info.py b/ansible_collections/netapp/um_info/plugins/modules/na_um_clusters_info.py new file mode 100644 index 000000000..60baa7a48 --- /dev/null +++ b/ansible_collections/netapp/um_info/plugins/modules/na_um_clusters_info.py @@ -0,0 +1,152 @@ +#!/usr/bin/python + +# (c) 2020, NetApp, Inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +''' +na_um_list_clusters +''' + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'certified'} + + +DOCUMENTATION = ''' +module: na_um_clusters_info +short_description: NetApp Unified Manager list cluster. +extends_documentation_fragment: + - netapp.um_info.netapp.um +version_added: '20.5.0' +author: NetApp Ansible Team (@carchi8py) <ng-ansibleteam@netapp.com> + +description: +- List Cluster on AIQUM. +''' + +EXAMPLES = """ +- name: List Clusters + netapp.um_info.na_um_clusters_info: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" +""" + +RETURN = """ +records: + description: Returns list of Clusters information + returned: always + type: list + sample: [{ + 'name': '...', + 'version': + { + 'generation': ..., + 'major': ..., + 'full': '...', + 'minor': ... + }, + 'management_ip': '...', + 'contact': ..., + '_links': + { + 'self': + { + 'href': '...' + } + }, + 'location': '...', + 'key': '', + 'nodes': + [ + { + 'uptime': ..., + 'uuid': '...', + 'version': + { + 'generation': ..., + 'major': ..., + 'full': '...', + 'minor': ... + }, + '_links': + { + 'self': + { + 'href': '...' + } + }, + 'location': '...', + 'key': '...', + 'serial_number': '...', + 'model': '...', + 'name': '...' + } + ], + 'isSanOptimized': ..., + 'uuid': '...' + } + ] +""" + +from ansible.module_utils.basic import AnsibleModule +import ansible_collections.netapp.um_info.plugins.module_utils.netapp as netapp_utils +from ansible_collections.netapp.um_info.plugins.module_utils.netapp_module import NetAppModule +from ansible_collections.netapp.um_info.plugins.module_utils.netapp import UMRestAPI + + +class NetAppUMCluster(object): + ''' cluster initialize and class methods ''' + + def __init__(self): + self.argument_spec = netapp_utils.na_um_host_argument_spec() + self.module = AnsibleModule( + argument_spec=self.argument_spec, + supports_check_mode=True + ) + + self.na_helper = NetAppModule() + self.parameters = self.na_helper.set_parameters(self.module.params) + + self.rest_api = UMRestAPI(self.module) + + def get_clusters(self): + """ + Fetch details of clusters. + :return: + Dictionary of current details if clusters found + None if clusters is not found + """ + data = {} + api = "datacenter/cluster/clusters" + message, error = self.rest_api.get(api, data) + if error: + self.module.fail_json(msg=error) + return self.rest_api.get_records(message, api) + + def apply(self): + """ + Apply action to the cluster listing + :return: None + """ + current = self.get_clusters() + if current is not None: + self.na_helper.changed = True + self.module.exit_json(changed=self.na_helper.changed, msg=current) + + +def main(): + """ + Create Cluster class instance and invoke apply + :return: None + """ + list_cluster_obj = NetAppUMCluster() + list_cluster_obj.apply() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/netapp/um_info/plugins/modules/na_um_list_aggregates.py b/ansible_collections/netapp/um_info/plugins/modules/na_um_list_aggregates.py new file mode 100644 index 000000000..10a34cfdf --- /dev/null +++ b/ansible_collections/netapp/um_info/plugins/modules/na_um_list_aggregates.py @@ -0,0 +1,163 @@ +#!/usr/bin/python + +# (c) 2020, NetApp, Inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +''' +na_um_list_aggregates +''' + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'certified'} + + +DOCUMENTATION = ''' +module: na_um_aggregates_info +short_description: NetApp Unified Manager list aggregates. +extends_documentation_fragment: + - netapp.um_info.netapp.um +version_added: '20.5.0' +author: NetApp Ansible Team (@carchi8py) <ng-ansibleteam@netapp.com> + +description: +- List Aggregates on AIQUM. +''' + +EXAMPLES = """ +- name: List Aggregates + netapp.um_info.na_um_aggregates_info: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" +""" + +RETURN = """ +records: + description: Returns list of Aggregates information + returned: always + type: list + sample: [{'node': + {'_links': + {'self': + {'href': '...' + } + }, + 'uuid': '...', + 'key': '...', + 'name': '...' + }, + 'snaplock_type': '...', + 'uuid': '...', + 'space': + {'block_storage': + {'available': ..., + 'used': ..., + 'size': ... + }, + 'efficiency': + {'savings': ..., + 'logical_used': ... + } + }, + 'block_storage': + {'hybrid_cache': + {'enabled': ..., + 'size': ... + }, + 'primary': + {'raid_size': ..., + 'raid_type': '...' + }, + 'mirror': + {'state': '...' + } + }, + 'data_encryption': + {'software_encryption_enabled': ... + }, + 'cluster': + {'_links': + {'self': + {'href': '...' + } + }, + 'uuid': '...', + 'key': '...', + 'name': '...' + }, + 'state': '...', + 'create_time': '...', + '_links': + {'self': + {'href': '...' + } + }, + 'key': '...', + 'type': '...', + 'name': '...' + } + ] +""" + +from ansible.module_utils.basic import AnsibleModule +import ansible_collections.netapp.um_info.plugins.module_utils.netapp as netapp_utils +from ansible_collections.netapp.um_info.plugins.module_utils.netapp_module import NetAppModule +from ansible_collections.netapp.um_info.plugins.module_utils.netapp import UMRestAPI + + +class NetAppUMAggregate(object): + ''' aggregates initialize and class methods ''' + + def __init__(self): + self.argument_spec = netapp_utils.na_um_host_argument_spec() + self.module = AnsibleModule( + argument_spec=self.argument_spec, + supports_check_mode=True + ) + + self.na_helper = NetAppModule() + self.parameters = self.na_helper.set_parameters(self.module.params) + + self.rest_api = UMRestAPI(self.module) + + def get_aggregates(self): + """ + Fetch details of aggregates. + :return: + Dictionary of current details if aggregates found + None if aggregates is not found + """ + data = {} + api = "datacenter/storage/aggregates?order_by=performance_capacity.used" + message, error = self.rest_api.get(api, data) + if error: + self.module.fail_json(msg=error) + return self.rest_api.get_records(message, api) + + def apply(self): + """ + Apply action to the aggregates listing + :return: None + """ + current = self.get_aggregates() + if current is not None: + self.na_helper.changed = True + self.module.exit_json(changed=self.na_helper.changed, msg=current) + + +def main(): + """ + Create Aggregate class instance and invoke apply + :return: None + """ + list_aggregates_obj = NetAppUMAggregate() + list_aggregates_obj.apply() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/netapp/um_info/plugins/modules/na_um_list_clusters.py b/ansible_collections/netapp/um_info/plugins/modules/na_um_list_clusters.py new file mode 100644 index 000000000..60baa7a48 --- /dev/null +++ b/ansible_collections/netapp/um_info/plugins/modules/na_um_list_clusters.py @@ -0,0 +1,152 @@ +#!/usr/bin/python + +# (c) 2020, NetApp, Inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +''' +na_um_list_clusters +''' + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'certified'} + + +DOCUMENTATION = ''' +module: na_um_clusters_info +short_description: NetApp Unified Manager list cluster. +extends_documentation_fragment: + - netapp.um_info.netapp.um +version_added: '20.5.0' +author: NetApp Ansible Team (@carchi8py) <ng-ansibleteam@netapp.com> + +description: +- List Cluster on AIQUM. +''' + +EXAMPLES = """ +- name: List Clusters + netapp.um_info.na_um_clusters_info: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" +""" + +RETURN = """ +records: + description: Returns list of Clusters information + returned: always + type: list + sample: [{ + 'name': '...', + 'version': + { + 'generation': ..., + 'major': ..., + 'full': '...', + 'minor': ... + }, + 'management_ip': '...', + 'contact': ..., + '_links': + { + 'self': + { + 'href': '...' + } + }, + 'location': '...', + 'key': '', + 'nodes': + [ + { + 'uptime': ..., + 'uuid': '...', + 'version': + { + 'generation': ..., + 'major': ..., + 'full': '...', + 'minor': ... + }, + '_links': + { + 'self': + { + 'href': '...' + } + }, + 'location': '...', + 'key': '...', + 'serial_number': '...', + 'model': '...', + 'name': '...' + } + ], + 'isSanOptimized': ..., + 'uuid': '...' + } + ] +""" + +from ansible.module_utils.basic import AnsibleModule +import ansible_collections.netapp.um_info.plugins.module_utils.netapp as netapp_utils +from ansible_collections.netapp.um_info.plugins.module_utils.netapp_module import NetAppModule +from ansible_collections.netapp.um_info.plugins.module_utils.netapp import UMRestAPI + + +class NetAppUMCluster(object): + ''' cluster initialize and class methods ''' + + def __init__(self): + self.argument_spec = netapp_utils.na_um_host_argument_spec() + self.module = AnsibleModule( + argument_spec=self.argument_spec, + supports_check_mode=True + ) + + self.na_helper = NetAppModule() + self.parameters = self.na_helper.set_parameters(self.module.params) + + self.rest_api = UMRestAPI(self.module) + + def get_clusters(self): + """ + Fetch details of clusters. + :return: + Dictionary of current details if clusters found + None if clusters is not found + """ + data = {} + api = "datacenter/cluster/clusters" + message, error = self.rest_api.get(api, data) + if error: + self.module.fail_json(msg=error) + return self.rest_api.get_records(message, api) + + def apply(self): + """ + Apply action to the cluster listing + :return: None + """ + current = self.get_clusters() + if current is not None: + self.na_helper.changed = True + self.module.exit_json(changed=self.na_helper.changed, msg=current) + + +def main(): + """ + Create Cluster class instance and invoke apply + :return: None + """ + list_cluster_obj = NetAppUMCluster() + list_cluster_obj.apply() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/netapp/um_info/plugins/modules/na_um_list_nodes.py b/ansible_collections/netapp/um_info/plugins/modules/na_um_list_nodes.py new file mode 100644 index 000000000..27e81ec2e --- /dev/null +++ b/ansible_collections/netapp/um_info/plugins/modules/na_um_list_nodes.py @@ -0,0 +1,145 @@ +#!/usr/bin/python + +# (c) 2020, NetApp, Inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +''' +na_um_list_nodes +''' + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'certified'} + + +DOCUMENTATION = ''' +module: na_um_nodes_info +short_description: NetApp Unified Manager list nodes. +extends_documentation_fragment: + - netapp.um_info.netapp.um +version_added: '20.5.0' +author: NetApp Ansible Team (@carchi8py) <ng-ansibleteam@netapp.com> + +description: +- List Nodes on AIQUM. +''' + +EXAMPLES = """ +- name: List Nodes + netapp.um_info.na_um_nodes_info: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" +""" + +RETURN = """ +records: + description: Returns list of Nodes information + returned: always + type: list + sample: [{'allFlashOptimized': ..., + 'uptime': ..., + 'vendor': '...', + 'uuid': '...', + 'nvramid': '...', + '_links': + {'self': + {'href': '...' + } + }, + 'cluster': + {'_links': + {'self': + {'href': '...' + } + }, + 'uuid': '...', + 'key': '...', + 'name': '...' + }, + 'version': + {'generation': ..., + 'major': ..., + 'full': '...', + 'minor': ... + }, + 'systemid': '...', + 'location': '...', + 'key': ...', + 'is_all_flash_optimized': ..., + 'serial_number': '...', + 'model': '...', + 'ha': + {'partners': + [{'_links': {}, + 'uuid': ..., + 'key': ..., + 'name': ... + }] + }, + 'health': ..., + 'name': '...' + }] +""" + +from ansible.module_utils.basic import AnsibleModule +import ansible_collections.netapp.um_info.plugins.module_utils.netapp as netapp_utils +from ansible_collections.netapp.um_info.plugins.module_utils.netapp_module import NetAppModule +from ansible_collections.netapp.um_info.plugins.module_utils.netapp import UMRestAPI + + +class NetAppUMNode(object): + ''' nodes initialize and class methods ''' + + def __init__(self): + self.argument_spec = netapp_utils.na_um_host_argument_spec() + self.module = AnsibleModule( + argument_spec=self.argument_spec, + supports_check_mode=True + ) + + self.na_helper = NetAppModule() + self.parameters = self.na_helper.set_parameters(self.module.params) + + self.rest_api = UMRestAPI(self.module) + + def get_nodes(self): + """ + Fetch details of nodes. + :return: + Dictionary of current details if nodes found + None if nodes is not found + """ + data = {} + api = "datacenter/cluster/nodes?order_by=performance_capacity.used" + message, error = self.rest_api.get(api, data) + if error: + self.module.fail_json(msg=error) + return self.rest_api.get_records(message, api) + + def apply(self): + """ + Apply action to the nodes listing + :return: None + """ + current = self.get_nodes() + if current is not None: + self.na_helper.changed = True + self.module.exit_json(changed=self.na_helper.changed, msg=current) + + +def main(): + """ + Create Node class instance and invoke apply + :return: None + """ + list_nodes_obj = NetAppUMNode() + list_nodes_obj.apply() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/netapp/um_info/plugins/modules/na_um_list_svms.py b/ansible_collections/netapp/um_info/plugins/modules/na_um_list_svms.py new file mode 100644 index 000000000..2722e9ef6 --- /dev/null +++ b/ansible_collections/netapp/um_info/plugins/modules/na_um_list_svms.py @@ -0,0 +1,174 @@ +#!/usr/bin/python + +# (c) 2020, NetApp, Inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +''' +na_um_list_svms +''' + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'certified'} + + +DOCUMENTATION = ''' +module: na_um_svms_info +short_description: NetApp Unified Manager list svms. +extends_documentation_fragment: + - netapp.um_info.netapp.um +version_added: '20.5.0' +author: NetApp Ansible Team (@carchi8py) <ng-ansibleteam@netapp.com> + +description: +- List SVMs on AIQUM. +''' + +EXAMPLES = """ +- name: List SVMs + netapp.um_info.na_um_svms_info: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" +""" + +RETURN = """ +records: + description: Returns list of SVMs information + returned: always + type: list + sample: [{'fcp': + {'enabled': ... + }, + 'dns': ..., + 'snapshot_policy': + {'_links': {}, + 'uuid': ..., + 'key': '...', + 'name': '...' + }, + 'language': '...', + 'subtype': 'default', + 'aggregates': + [{'_links': + {'self': + {'href': '...' + } + }, + 'uuid': '...', + 'key': '...', + 'name': '...' + }], + 'nvme': + {'enabled': ... + }, + 'ipspace': + {'_links': {}, + 'uuid': '...', + 'key': '...', + 'name': '...' + }, + 'uuid': '...', + 'cluster': + {'_links': + {'self': + {'href': '...' + } + }, + 'uuid': '...', + 'key': '...', + 'name': '...' + }, + 'state': '...', + '_links': + {'self': + {'href': '...' + } + }, + 'key': '...', + 'ldap': + {'enabled': ... + }, + 'nis': + {'domain': ..., + 'enabled': ..., + 'servers': ... + }, + 'cifs': + {'enabled': ..., + 'name': ..., + 'ad_domain': + {'fqdn': ... + } + }, + 'iscsi': + {'enabled': ... + }, + 'nfs': + {'enabled': ... + }, + 'name': '...' + }] +""" + +from ansible.module_utils.basic import AnsibleModule +import ansible_collections.netapp.um_info.plugins.module_utils.netapp as netapp_utils +from ansible_collections.netapp.um_info.plugins.module_utils.netapp_module import NetAppModule +from ansible_collections.netapp.um_info.plugins.module_utils.netapp import UMRestAPI + + +class NetAppUMSVM(object): + ''' svms initialize and class methods ''' + + def __init__(self): + self.argument_spec = netapp_utils.na_um_host_argument_spec() + self.module = AnsibleModule( + argument_spec=self.argument_spec, + supports_check_mode=True + ) + + self.na_helper = NetAppModule() + self.parameters = self.na_helper.set_parameters(self.module.params) + + self.rest_api = UMRestAPI(self.module) + + def get_svms(self): + """ + Fetch details of svms. + :return: + Dictionary of current details if svms found + None if svms is not found + """ + data = {} + api = "datacenter/svm/svms" + message, error = self.rest_api.get(api, data) + if error: + self.module.fail_json(msg=error) + return self.rest_api.get_records(message, api) + + def apply(self): + """ + Apply action to the svms listing + :return: None + """ + current = self.get_svms() + if current is not None: + self.na_helper.changed = True + self.module.exit_json(changed=self.na_helper.changed, msg=current) + + +def main(): + """ + Create SVM class instance and invoke apply + :return: None + """ + list_svms_obj = NetAppUMSVM() + list_svms_obj.apply() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/netapp/um_info/plugins/modules/na_um_list_volumes.py b/ansible_collections/netapp/um_info/plugins/modules/na_um_list_volumes.py new file mode 100644 index 000000000..099213226 --- /dev/null +++ b/ansible_collections/netapp/um_info/plugins/modules/na_um_list_volumes.py @@ -0,0 +1,133 @@ +#!/usr/bin/python + +# (c) 2020, NetApp, Inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +''' +na_um_list_volumes +''' + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'certified'} + + +DOCUMENTATION = ''' +module: na_um_volumes_info +short_description: NetApp Unified Manager list volumes. +extends_documentation_fragment: + - netapp.um_info.netapp.um +version_added: '20.6.0' +author: NetApp Ansible Team (@carchi8py) <ng-ansibleteam@netapp.com> + +description: +- List Volumes on AIQUM. +''' + +EXAMPLES = """ +- name: List Volumes + netapp.um_info.na_um_volumes_info: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" +""" + +RETURN = """ +records: + description: Returns list of Volumes information + returned: always + type: list + sample: [{'style': '...', + 'svm': + {'_links': + {'self': {...} + }, + '...' + }, + 'qos': {...}, + 'name': '...', + 'language': '...', + 'space': {...}, + 'aggregates': + [ + {...} + ], + 'tiering': {...}, + 'autosize': {...}, + 'cluster': {...}, + 'state': '...', + 'create_time': '...', + '_links': + {'self': + {'href': '...' + } + }, + 'key': '...', + 'snapmirror': {...}, + 'snapshot_policy': {...}, + 'type': '...', + 'uuid': '...' + }] +""" + +from ansible.module_utils.basic import AnsibleModule +import ansible_collections.netapp.um_info.plugins.module_utils.netapp as netapp_utils +from ansible_collections.netapp.um_info.plugins.module_utils.netapp_module import NetAppModule +from ansible_collections.netapp.um_info.plugins.module_utils.netapp import UMRestAPI + + +class NetAppUMVolume(object): + ''' volumes initialize and class methods ''' + + def __init__(self): + self.argument_spec = netapp_utils.na_um_host_argument_spec() + self.module = AnsibleModule( + argument_spec=self.argument_spec, + supports_check_mode=True + ) + + self.na_helper = NetAppModule() + self.parameters = self.na_helper.set_parameters(self.module.params) + + self.rest_api = UMRestAPI(self.module) + + def get_volumes(self): + """ + Fetch details of volumes. + :return: + Dictionary of current details if volumes found + None if volumes is not found + """ + data = {} + api = "datacenter/storage/volumes" + message, error = self.rest_api.get(api, data) + if error: + self.module.fail_json(msg=error) + return self.rest_api.get_records(message, api) + + def apply(self): + """ + Apply action to the volumes listing + :return: None + """ + current = self.get_volumes() + if current is not None: + self.na_helper.changed = True + self.module.exit_json(changed=self.na_helper.changed, msg=current) + + +def main(): + """ + Create Volume class instance and invoke apply + :return: None + """ + list_volumes_obj = NetAppUMVolume() + list_volumes_obj.apply() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/netapp/um_info/plugins/modules/na_um_nodes_info.py b/ansible_collections/netapp/um_info/plugins/modules/na_um_nodes_info.py new file mode 100644 index 000000000..27e81ec2e --- /dev/null +++ b/ansible_collections/netapp/um_info/plugins/modules/na_um_nodes_info.py @@ -0,0 +1,145 @@ +#!/usr/bin/python + +# (c) 2020, NetApp, Inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +''' +na_um_list_nodes +''' + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'certified'} + + +DOCUMENTATION = ''' +module: na_um_nodes_info +short_description: NetApp Unified Manager list nodes. +extends_documentation_fragment: + - netapp.um_info.netapp.um +version_added: '20.5.0' +author: NetApp Ansible Team (@carchi8py) <ng-ansibleteam@netapp.com> + +description: +- List Nodes on AIQUM. +''' + +EXAMPLES = """ +- name: List Nodes + netapp.um_info.na_um_nodes_info: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" +""" + +RETURN = """ +records: + description: Returns list of Nodes information + returned: always + type: list + sample: [{'allFlashOptimized': ..., + 'uptime': ..., + 'vendor': '...', + 'uuid': '...', + 'nvramid': '...', + '_links': + {'self': + {'href': '...' + } + }, + 'cluster': + {'_links': + {'self': + {'href': '...' + } + }, + 'uuid': '...', + 'key': '...', + 'name': '...' + }, + 'version': + {'generation': ..., + 'major': ..., + 'full': '...', + 'minor': ... + }, + 'systemid': '...', + 'location': '...', + 'key': ...', + 'is_all_flash_optimized': ..., + 'serial_number': '...', + 'model': '...', + 'ha': + {'partners': + [{'_links': {}, + 'uuid': ..., + 'key': ..., + 'name': ... + }] + }, + 'health': ..., + 'name': '...' + }] +""" + +from ansible.module_utils.basic import AnsibleModule +import ansible_collections.netapp.um_info.plugins.module_utils.netapp as netapp_utils +from ansible_collections.netapp.um_info.plugins.module_utils.netapp_module import NetAppModule +from ansible_collections.netapp.um_info.plugins.module_utils.netapp import UMRestAPI + + +class NetAppUMNode(object): + ''' nodes initialize and class methods ''' + + def __init__(self): + self.argument_spec = netapp_utils.na_um_host_argument_spec() + self.module = AnsibleModule( + argument_spec=self.argument_spec, + supports_check_mode=True + ) + + self.na_helper = NetAppModule() + self.parameters = self.na_helper.set_parameters(self.module.params) + + self.rest_api = UMRestAPI(self.module) + + def get_nodes(self): + """ + Fetch details of nodes. + :return: + Dictionary of current details if nodes found + None if nodes is not found + """ + data = {} + api = "datacenter/cluster/nodes?order_by=performance_capacity.used" + message, error = self.rest_api.get(api, data) + if error: + self.module.fail_json(msg=error) + return self.rest_api.get_records(message, api) + + def apply(self): + """ + Apply action to the nodes listing + :return: None + """ + current = self.get_nodes() + if current is not None: + self.na_helper.changed = True + self.module.exit_json(changed=self.na_helper.changed, msg=current) + + +def main(): + """ + Create Node class instance and invoke apply + :return: None + """ + list_nodes_obj = NetAppUMNode() + list_nodes_obj.apply() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/netapp/um_info/plugins/modules/na_um_svms_info.py b/ansible_collections/netapp/um_info/plugins/modules/na_um_svms_info.py new file mode 100644 index 000000000..2722e9ef6 --- /dev/null +++ b/ansible_collections/netapp/um_info/plugins/modules/na_um_svms_info.py @@ -0,0 +1,174 @@ +#!/usr/bin/python + +# (c) 2020, NetApp, Inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +''' +na_um_list_svms +''' + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'certified'} + + +DOCUMENTATION = ''' +module: na_um_svms_info +short_description: NetApp Unified Manager list svms. +extends_documentation_fragment: + - netapp.um_info.netapp.um +version_added: '20.5.0' +author: NetApp Ansible Team (@carchi8py) <ng-ansibleteam@netapp.com> + +description: +- List SVMs on AIQUM. +''' + +EXAMPLES = """ +- name: List SVMs + netapp.um_info.na_um_svms_info: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" +""" + +RETURN = """ +records: + description: Returns list of SVMs information + returned: always + type: list + sample: [{'fcp': + {'enabled': ... + }, + 'dns': ..., + 'snapshot_policy': + {'_links': {}, + 'uuid': ..., + 'key': '...', + 'name': '...' + }, + 'language': '...', + 'subtype': 'default', + 'aggregates': + [{'_links': + {'self': + {'href': '...' + } + }, + 'uuid': '...', + 'key': '...', + 'name': '...' + }], + 'nvme': + {'enabled': ... + }, + 'ipspace': + {'_links': {}, + 'uuid': '...', + 'key': '...', + 'name': '...' + }, + 'uuid': '...', + 'cluster': + {'_links': + {'self': + {'href': '...' + } + }, + 'uuid': '...', + 'key': '...', + 'name': '...' + }, + 'state': '...', + '_links': + {'self': + {'href': '...' + } + }, + 'key': '...', + 'ldap': + {'enabled': ... + }, + 'nis': + {'domain': ..., + 'enabled': ..., + 'servers': ... + }, + 'cifs': + {'enabled': ..., + 'name': ..., + 'ad_domain': + {'fqdn': ... + } + }, + 'iscsi': + {'enabled': ... + }, + 'nfs': + {'enabled': ... + }, + 'name': '...' + }] +""" + +from ansible.module_utils.basic import AnsibleModule +import ansible_collections.netapp.um_info.plugins.module_utils.netapp as netapp_utils +from ansible_collections.netapp.um_info.plugins.module_utils.netapp_module import NetAppModule +from ansible_collections.netapp.um_info.plugins.module_utils.netapp import UMRestAPI + + +class NetAppUMSVM(object): + ''' svms initialize and class methods ''' + + def __init__(self): + self.argument_spec = netapp_utils.na_um_host_argument_spec() + self.module = AnsibleModule( + argument_spec=self.argument_spec, + supports_check_mode=True + ) + + self.na_helper = NetAppModule() + self.parameters = self.na_helper.set_parameters(self.module.params) + + self.rest_api = UMRestAPI(self.module) + + def get_svms(self): + """ + Fetch details of svms. + :return: + Dictionary of current details if svms found + None if svms is not found + """ + data = {} + api = "datacenter/svm/svms" + message, error = self.rest_api.get(api, data) + if error: + self.module.fail_json(msg=error) + return self.rest_api.get_records(message, api) + + def apply(self): + """ + Apply action to the svms listing + :return: None + """ + current = self.get_svms() + if current is not None: + self.na_helper.changed = True + self.module.exit_json(changed=self.na_helper.changed, msg=current) + + +def main(): + """ + Create SVM class instance and invoke apply + :return: None + """ + list_svms_obj = NetAppUMSVM() + list_svms_obj.apply() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/netapp/um_info/plugins/modules/na_um_volumes_info.py b/ansible_collections/netapp/um_info/plugins/modules/na_um_volumes_info.py new file mode 100644 index 000000000..099213226 --- /dev/null +++ b/ansible_collections/netapp/um_info/plugins/modules/na_um_volumes_info.py @@ -0,0 +1,133 @@ +#!/usr/bin/python + +# (c) 2020, NetApp, Inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +''' +na_um_list_volumes +''' + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'certified'} + + +DOCUMENTATION = ''' +module: na_um_volumes_info +short_description: NetApp Unified Manager list volumes. +extends_documentation_fragment: + - netapp.um_info.netapp.um +version_added: '20.6.0' +author: NetApp Ansible Team (@carchi8py) <ng-ansibleteam@netapp.com> + +description: +- List Volumes on AIQUM. +''' + +EXAMPLES = """ +- name: List Volumes + netapp.um_info.na_um_volumes_info: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" +""" + +RETURN = """ +records: + description: Returns list of Volumes information + returned: always + type: list + sample: [{'style': '...', + 'svm': + {'_links': + {'self': {...} + }, + '...' + }, + 'qos': {...}, + 'name': '...', + 'language': '...', + 'space': {...}, + 'aggregates': + [ + {...} + ], + 'tiering': {...}, + 'autosize': {...}, + 'cluster': {...}, + 'state': '...', + 'create_time': '...', + '_links': + {'self': + {'href': '...' + } + }, + 'key': '...', + 'snapmirror': {...}, + 'snapshot_policy': {...}, + 'type': '...', + 'uuid': '...' + }] +""" + +from ansible.module_utils.basic import AnsibleModule +import ansible_collections.netapp.um_info.plugins.module_utils.netapp as netapp_utils +from ansible_collections.netapp.um_info.plugins.module_utils.netapp_module import NetAppModule +from ansible_collections.netapp.um_info.plugins.module_utils.netapp import UMRestAPI + + +class NetAppUMVolume(object): + ''' volumes initialize and class methods ''' + + def __init__(self): + self.argument_spec = netapp_utils.na_um_host_argument_spec() + self.module = AnsibleModule( + argument_spec=self.argument_spec, + supports_check_mode=True + ) + + self.na_helper = NetAppModule() + self.parameters = self.na_helper.set_parameters(self.module.params) + + self.rest_api = UMRestAPI(self.module) + + def get_volumes(self): + """ + Fetch details of volumes. + :return: + Dictionary of current details if volumes found + None if volumes is not found + """ + data = {} + api = "datacenter/storage/volumes" + message, error = self.rest_api.get(api, data) + if error: + self.module.fail_json(msg=error) + return self.rest_api.get_records(message, api) + + def apply(self): + """ + Apply action to the volumes listing + :return: None + """ + current = self.get_volumes() + if current is not None: + self.na_helper.changed = True + self.module.exit_json(changed=self.na_helper.changed, msg=current) + + +def main(): + """ + Create Volume class instance and invoke apply + :return: None + """ + list_volumes_obj = NetAppUMVolume() + list_volumes_obj.apply() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/netapp/um_info/requirements.txt b/ansible_collections/netapp/um_info/requirements.txt new file mode 100644 index 000000000..663bd1f6a --- /dev/null +++ b/ansible_collections/netapp/um_info/requirements.txt @@ -0,0 +1 @@ +requests
\ No newline at end of file diff --git a/ansible_collections/netapp/um_info/tests/unit/compat/__init__.py b/ansible_collections/netapp/um_info/tests/unit/compat/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/ansible_collections/netapp/um_info/tests/unit/compat/__init__.py diff --git a/ansible_collections/netapp/um_info/tests/unit/compat/builtins.py b/ansible_collections/netapp/um_info/tests/unit/compat/builtins.py new file mode 100644 index 000000000..f60ee6782 --- /dev/null +++ b/ansible_collections/netapp/um_info/tests/unit/compat/builtins.py @@ -0,0 +1,33 @@ +# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com> +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +# +# Compat for python2.7 +# + +# One unittest needs to import builtins via __import__() so we need to have +# the string that represents it +try: + import __builtin__ +except ImportError: + BUILTINS = 'builtins' +else: + BUILTINS = '__builtin__' diff --git a/ansible_collections/netapp/um_info/tests/unit/compat/mock.py b/ansible_collections/netapp/um_info/tests/unit/compat/mock.py new file mode 100644 index 000000000..0972cd2e8 --- /dev/null +++ b/ansible_collections/netapp/um_info/tests/unit/compat/mock.py @@ -0,0 +1,122 @@ +# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com> +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +''' +Compat module for Python3.x's unittest.mock module +''' +import sys + +# Python 2.7 + +# Note: Could use the pypi mock library on python3.x as well as python2.x. It +# is the same as the python3 stdlib mock library + +try: + # Allow wildcard import because we really do want to import all of mock's + # symbols into this compat shim + # pylint: disable=wildcard-import,unused-wildcard-import + from unittest.mock import * +except ImportError: + # Python 2 + # pylint: disable=wildcard-import,unused-wildcard-import + try: + from mock import * + except ImportError: + print('You need the mock library installed on python2.x to run tests') + + +# Prior to 3.4.4, mock_open cannot handle binary read_data +if sys.version_info >= (3,) and sys.version_info < (3, 4, 4): + file_spec = None + + def _iterate_read_data(read_data): + # Helper for mock_open: + # Retrieve lines from read_data via a generator so that separate calls to + # readline, read, and readlines are properly interleaved + sep = b'\n' if isinstance(read_data, bytes) else '\n' + data_as_list = [l + sep for l in read_data.split(sep)] + + if data_as_list[-1] == sep: + # If the last line ended in a newline, the list comprehension will have an + # extra entry that's just a newline. Remove this. + data_as_list = data_as_list[:-1] + else: + # If there wasn't an extra newline by itself, then the file being + # emulated doesn't have a newline to end the last line remove the + # newline that our naive format() added + data_as_list[-1] = data_as_list[-1][:-1] + + for line in data_as_list: + yield line + + def mock_open(mock=None, read_data=''): + """ + A helper function to create a mock to replace the use of `open`. It works + for `open` called directly or used as a context manager. + + The `mock` argument is the mock object to configure. If `None` (the + default) then a `MagicMock` will be created for you, with the API limited + to methods or attributes available on standard file handles. + + `read_data` is a string for the `read` methoddline`, and `readlines` of the + file handle to return. This is an empty string by default. + """ + def _readlines_side_effect(*args, **kwargs): + if handle.readlines.return_value is not None: + return handle.readlines.return_value + return list(_data) + + def _read_side_effect(*args, **kwargs): + if handle.read.return_value is not None: + return handle.read.return_value + return type(read_data)().join(_data) + + def _readline_side_effect(): + if handle.readline.return_value is not None: + while True: + yield handle.readline.return_value + for line in _data: + yield line + + global file_spec + if file_spec is None: + import _io + file_spec = list(set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO)))) + + if mock is None: + mock = MagicMock(name='open', spec=open) + + handle = MagicMock(spec=file_spec) + handle.__enter__.return_value = handle + + _data = _iterate_read_data(read_data) + + handle.write.return_value = None + handle.read.return_value = None + handle.readline.return_value = None + handle.readlines.return_value = None + + handle.read.side_effect = _read_side_effect + handle.readline.side_effect = _readline_side_effect() + handle.readlines.side_effect = _readlines_side_effect + + mock.return_value = handle + return mock diff --git a/ansible_collections/netapp/um_info/tests/unit/compat/unittest.py b/ansible_collections/netapp/um_info/tests/unit/compat/unittest.py new file mode 100644 index 000000000..73a20cf8c --- /dev/null +++ b/ansible_collections/netapp/um_info/tests/unit/compat/unittest.py @@ -0,0 +1,44 @@ +# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com> +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +''' +Compat module for Python2.7's unittest module +''' + +import sys + +import pytest + +# Allow wildcard import because we really do want to import all of +# unittests's symbols into this compat shim +# pylint: disable=wildcard-import,unused-wildcard-import +if sys.version_info < (2, 7): + try: + # Need unittest2 on python2.6 + from unittest2 import * + except ImportError: + print('You need unittest2 installed on python2.6.x to run tests') + + class TestCase: + """ skip everything """ + pytestmark = pytest.mark.skip('Skipping Unit Tests on 2.6 as unittest2 may not be available') +else: + from unittest import * diff --git a/ansible_collections/netapp/um_info/tests/unit/plugins/module_utils/test_netapp.py b/ansible_collections/netapp/um_info/tests/unit/plugins/module_utils/test_netapp.py new file mode 100644 index 000000000..eefca9041 --- /dev/null +++ b/ansible_collections/netapp/um_info/tests/unit/plugins/module_utils/test_netapp.py @@ -0,0 +1,236 @@ +# Copyright (c) 2018 NetApp +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +''' unit tests for module_utils netapp.py ''' +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import json +import os.path +import sys +import tempfile + +import pytest + +from ansible.module_utils.ansible_release import __version__ as ansible_version +from ansible.module_utils import basic +from ansible.module_utils._text import to_bytes +from ansible_collections.netapp.um_info.plugins.module_utils.netapp import COLLECTION_VERSION +from ansible_collections.netapp.um_info.tests.unit.compat.mock import patch + +import ansible_collections.netapp.um_info.plugins.module_utils.netapp as netapp_utils + + +if not netapp_utils.HAS_REQUESTS and sys.version_info < (2, 7): + pytestmark = pytest.mark.skip('Skipping Unit Tests on 2.6 as requests is not be available') + + +def set_module_args(args): + """prepare arguments so that they will be picked up during module creation""" + args = json.dumps({'ANSIBLE_MODULE_ARGS': args}) + basic._ANSIBLE_ARGS = to_bytes(args) # pylint: disable=protected-access + + +class AnsibleFailJson(Exception): + """Exception class to be raised by module.fail_json and caught by the test case""" + + +def fail_json(*args, **kwargs): # pylint: disable=unused-argument + """function to patch over fail_json; package return data into an exception""" + kwargs['failed'] = True + raise AnsibleFailJson(kwargs) + + +SRR = { + # common responses + 'is_rest': (200, {}, None), + 'is_zapi': (400, {}, "Unreachable"), + # 'empty_good': ({}, None), + 'empty_good': (dict(_links=dict(self='me')), None), + 'get_next': (dict(_links=dict(self='me', next=dict(href='next_records'))), None), + 'get_data': (dict(_links=dict(self='me'), records=['data1', 'data2']), None), + 'end_of_sequence': (None, "Unexpected call to send_request"), + 'generic_error': (None, "Expected error"), + 'no__links_error': (dict(), None), + 'no_href_error': (dict(_links=dict(self='me', next=dict())), None), +} + + +def mock_args(feature_flags=None): + args = { + 'hostname': 'test', + 'username': 'test_user', + 'password': 'test_pass!', + } + if feature_flags is not None: + args.update({'feature_flags': feature_flags}) + return args + + +def create_module(args): + argument_spec = netapp_utils.na_um_host_argument_spec() + set_module_args(args) + module = basic.AnsibleModule(argument_spec) + return module + + +def create_restapi_object(args): + module = create_module(args) + module.fail_json = fail_json + rest_api = netapp_utils.UMRestAPI(module) + return rest_api + + +class mockResponse: + def __init__(self, json_data, status_code, raise_action=None): + self.json_data = json_data + self.status_code = status_code + self.content = json_data + self.raise_action = raise_action + + def raise_for_status(self): + pass + + def json(self): + if self.raise_action == 'bad_json': + raise ValueError(self.raise_action) + return self.json_data + + +@patch('ansible_collections.netapp.um_info.plugins.module_utils.netapp.UMRestAPI.send_request') +def test_empty_get(mock_request): + ''' get with no data ''' + mock_request.side_effect = [ + SRR['empty_good'], + SRR['end_of_sequence'], + ] + rest_api = create_restapi_object(mock_args()) + message, error = rest_api.get('api', None) + assert not error + # only one key (_links) + assert len(message) == 1 + + +@patch('ansible_collections.netapp.um_info.plugins.module_utils.netapp.UMRestAPI.send_request') +def test_get_next(mock_request): + ''' get with a next href ''' + mock_request.side_effect = [ + SRR['get_next'], + SRR['get_data'], + SRR['end_of_sequence'], + ] + rest_api = create_restapi_object(mock_args()) + message, error = rest_api.get('api', None) + assert not error + print('empty_get:', message) + assert message['records'] == SRR['get_data'][0]['records'] + + +@patch('ansible_collections.netapp.um_info.plugins.module_utils.netapp.UMRestAPI.send_request') +def test_negative_get_next_no__links(mock_request): + ''' get with a next href ''' + mock_request.side_effect = [ + SRR['no__links_error'], + SRR['end_of_sequence'], + ] + rest_api = create_restapi_object(mock_args()) + message, error = rest_api.get('api', None) + print('error:', error) + assert error + assert 'Expecting _links key in' in error + + +@patch('ansible_collections.netapp.um_info.plugins.module_utils.netapp.UMRestAPI.send_request') +def test_negative_get_next_no_href(mock_request): + ''' get with a next href ''' + mock_request.side_effect = [ + SRR['no_href_error'], + SRR['end_of_sequence'], + ] + rest_api = create_restapi_object(mock_args()) + message, error = rest_api.get('api', None) + print('error:', error) + assert error + assert 'Expecting href key in' in error + + +def test_has_feature_success_default_0(): + ''' existing feature_flag with default of False''' + flag = 'trace_apis' + module = create_module(mock_args()) + value = netapp_utils.has_feature(module, flag) + assert not value + + +def test_has_feature_success_default_1(): + ''' existing feature_flag with default of True''' + flag = 'strict_json_check' + module = create_module(mock_args()) + value = netapp_utils.has_feature(module, flag) + assert value + + +def test_has_feature_success_user_true(): + ''' existing feature_flag with value set to True ''' + flag = 'user_deprecation_warning' + args = dict(mock_args({flag: True})) + module = create_module(args) + value = netapp_utils.has_feature(module, flag) + assert value + + +def test_has_feature_success_user_false(): + ''' existing feature_flag with value set to False ''' + flag = 'user_deprecation_warning' + args = dict(mock_args({flag: False})) + print(args) + module = create_module(args) + value = netapp_utils.has_feature(module, flag) + assert not value + + +def test_has_feature_invalid_key(): + ''' existing feature_flag with unknown key ''' + flag = 'deprecation_warning_bad_key' + module = create_module(mock_args()) + # replace ANsible fail method with ours + module.fail_json = fail_json + with pytest.raises(AnsibleFailJson) as exc: + netapp_utils.has_feature(module, flag) + msg = 'Internal error: unexpected feature flag: %s' % flag + assert exc.value.args[0]['msg'] == msg + + +@patch('requests.request') +def test_empty_get_sent(mock_request): + ''' get with no data ''' + mock_request.return_value = mockResponse(json_data=dict(_links='me'), status_code=200) + rest_api = create_restapi_object(mock_args()) + message, error = rest_api.get('api', None) + assert not error + # only one key (_links) + assert len(message) == 1 + + +@patch('requests.request') +def test_empty_get_sent_bad_json(mock_request): + ''' get with no data ''' + mock_request.return_value = mockResponse(json_data='anything', status_code=200, raise_action='bad_json') + rest_api = create_restapi_object(mock_args()) + message, error = rest_api.get('api', None) + assert error + assert 'Expecting json, got: anything' in error + print('errors:', rest_api.errors) + print('debug:', rest_api.debug_logs) + + +@patch('requests.request') +def test_empty_get_sent_bad_but_empty_json(mock_request): + ''' get with no data ''' + mock_request.return_value = mockResponse(json_data='', status_code=200, raise_action='bad_json') + rest_api = create_restapi_object(mock_args()) + message, error = rest_api.get('api', None) + assert error + assert 'Expecting _links key in None' in error + print('errors:', rest_api.errors) + print('debug:', rest_api.debug_logs) diff --git a/ansible_collections/netapp/um_info/tests/unit/plugins/modules/test_na_um_aggregates_info.py b/ansible_collections/netapp/um_info/tests/unit/plugins/modules/test_na_um_aggregates_info.py new file mode 100644 index 000000000..9d2479484 --- /dev/null +++ b/ansible_collections/netapp/um_info/tests/unit/plugins/modules/test_na_um_aggregates_info.py @@ -0,0 +1,159 @@ +# (c) 2020, NetApp, Inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +""" unit tests for Ansible module: na_um_aggregates_info """ + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type +import json +import pytest +import sys + +from ansible.module_utils import basic +from ansible.module_utils._text import to_bytes +from ansible_collections.netapp.um_info.tests.unit.compat import unittest +from ansible_collections.netapp.um_info.tests.unit.compat.mock import patch, Mock +import ansible_collections.netapp.um_info.plugins.module_utils.netapp as netapp_utils + +from ansible_collections.netapp.um_info.plugins.modules.na_um_aggregates_info\ + import NetAppUMAggregate as my_module # module under test + + +if not netapp_utils.HAS_REQUESTS and sys.version_info < (2, 7): + pytestmark = pytest.mark.skip('Skipping Unit Tests on 2.6 as requests is not be available') + + +# REST API canned responses when mocking send_request +SRR = { + # common responses + 'empty_not_so_good': ({}, None), + 'end_of_sequence': (None, "Unexpected call to send_request"), + 'generic_error': (None, "Expected error"), + 'get_next': (dict(_links=dict(self='me', next=dict(href='next_records'))), None), + 'get_data': (dict(_links=dict(self='me'), records=['data1', 'data2'], total_records=2), None), + 'get_data_missing_field': (dict(_links=dict(self='me'), records=['data1', 'data2']), None), + # module specific responses + 'get_aggregates': {'name': 'ansible'} +} + + +def set_module_args(args): + """prepare arguments so that they will be picked up during module creation""" + args = json.dumps({'ANSIBLE_MODULE_ARGS': args}) + basic._ANSIBLE_ARGS = to_bytes(args) # pylint: disable=protected-access + + +class AnsibleExitJson(Exception): + """Exception class to be raised by module.exit_json and caught by the test case""" + pass + + +class AnsibleFailJson(Exception): + """Exception class to be raised by module.fail_json and caught by the test case""" + pass + + +def exit_json(*args, **kwargs): # pylint: disable=unused-argument + """function to patch over exit_json; package return data into an exception""" + if 'changed' not in kwargs: + kwargs['changed'] = False + raise AnsibleExitJson(kwargs) + + +def fail_json(*args, **kwargs): # pylint: disable=unused-argument + """function to patch over fail_json; package return data into an exception""" + kwargs['failed'] = True + raise AnsibleFailJson(kwargs) + + +class MockUMConnection(object): + ''' mock server connection to Unified Manager host ''' + + def __init__(self): + ''' pass init ''' + + +class TestMyModule(unittest.TestCase): + ''' a group of related Unit Tests ''' + + def setUp(self): + self.mock_module_helper = patch.multiple(basic.AnsibleModule, + exit_json=exit_json, + fail_json=fail_json) + self.mock_module_helper.start() + self.addCleanup(self.mock_module_helper.stop) + self.server = MockUMConnection() + # whether to use a mock or a simulator + self.onbox = False + + def set_default_args(self): + if self.onbox: + hostname = '10.10.10.10' + username = 'admin' + password = 'password' + else: + hostname = 'hostname' + username = 'username' + password = 'password' + return dict({ + 'hostname': hostname, + 'username': username, + 'password': password, + }) + + def test_module_fail_when_required_args_missing(self): + ''' required arguments are reported as errors ''' + with pytest.raises(AnsibleFailJson) as exc: + set_module_args({}) + my_module() + print('Info: %s' % exc.value.args[0]['msg']) + + @patch('ansible_collections.netapp.um_info.plugins.modules.na_um_aggregates_info.NetAppUMAggregate.get_aggregates') + def test_ensure_list_aggregates_get_called(self, get_aggregates): + ''' fetching details of aggregates ''' + set_module_args(self.set_default_args()) + my_obj = my_module() + my_obj.server = self.server + my_obj.get_aggregates = Mock(return_value=SRR['get_aggregates']) + with pytest.raises(AnsibleExitJson) as exc: + my_obj.apply() + assert exc.value.args[0]['changed'] + # to reset na_helper from remembering the previous 'changed' value + + @patch('ansible_collections.netapp.um_info.plugins.modules.na_um_aggregates_info.NetAppUMAggregate.get_aggregates') + def test_ensure_get_called_existing(self, get_aggregates): + ''' test for existing aggregates''' + set_module_args(self.set_default_args()) + my_obj = my_module() + my_obj.get_aggregates = Mock(return_value=SRR['get_aggregates']) + assert my_obj.get_aggregates() is not None + + @patch('ansible_collections.netapp.um_info.plugins.module_utils.netapp.UMRestAPI.send_request') + def test_get_next(self, mock_request): + ''' test for existing aggregates''' + set_module_args(self.set_default_args()) + mock_request.side_effect = [ + SRR['get_next'], + SRR['get_data'], + SRR['end_of_sequence'], + ] + my_obj = my_module() + assert my_obj.get_aggregates() is not None + + @patch('ansible_collections.netapp.um_info.plugins.module_utils.netapp.UMRestAPI.send_request') + def test_negative_get_next(self, mock_request): + ''' test for existing aggregates''' + set_module_args(self.set_default_args()) + mock_request.side_effect = [ + SRR['get_next'], + SRR['get_data_missing_field'], + SRR['end_of_sequence'], + ] + my_obj = my_module() + with pytest.raises(AnsibleFailJson) as exc: + my_obj.get_aggregates() is not None + print(exc.value.args[0]) + msg = 'unexpected response from datacenter/storage/aggregates?order_by=performance_capacity.used' + assert msg in exc.value.args[0]['msg'] + msg = "expecting key: 'total_records'" + assert msg in exc.value.args[0]['msg'] diff --git a/ansible_collections/netapp/um_info/tests/unit/plugins/modules/test_na_um_clusters_info.py b/ansible_collections/netapp/um_info/tests/unit/plugins/modules/test_na_um_clusters_info.py new file mode 100644 index 000000000..c4939adb8 --- /dev/null +++ b/ansible_collections/netapp/um_info/tests/unit/plugins/modules/test_na_um_clusters_info.py @@ -0,0 +1,159 @@ +# (c) 2020, NetApp, Inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +""" unit tests for Ansible module: na_um_clusters_info """ + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type +import json +import pytest +import sys + +from ansible.module_utils import basic +from ansible.module_utils._text import to_bytes +from ansible_collections.netapp.um_info.tests.unit.compat import unittest +from ansible_collections.netapp.um_info.tests.unit.compat.mock import patch, Mock +import ansible_collections.netapp.um_info.plugins.module_utils.netapp as netapp_utils + +from ansible_collections.netapp.um_info.plugins.modules.na_um_clusters_info\ + import NetAppUMCluster as my_module # module under test + + +if not netapp_utils.HAS_REQUESTS and sys.version_info < (2, 7): + pytestmark = pytest.mark.skip('Skipping Unit Tests on 2.6 as requests is not be available') + + +# REST API canned responses when mocking send_request +SRR = { + # common responses + 'empty_good': ({}, None), + 'end_of_sequence': (None, "Unexpected call to send_request"), + 'generic_error': (None, "Expected error"), + 'get_next': (dict(_links=dict(self='me', next=dict(href='next_records'))), None), + 'get_data': (dict(_links=dict(self='me'), records=['data1', 'data2'], total_records=2), None), + 'get_data_missing_field': (dict(_links=dict(self='me'), records=['data1', 'data2']), None), + # module specific responses + 'get_cluster': {'name': 'ansible'} +} + + +def set_module_args(args): + """prepare arguments so that they will be picked up during module creation""" + args = json.dumps({'ANSIBLE_MODULE_ARGS': args}) + basic._ANSIBLE_ARGS = to_bytes(args) # pylint: disable=protected-access + + +class AnsibleExitJson(Exception): + """Exception class to be raised by module.exit_json and caught by the test case""" + pass + + +class AnsibleFailJson(Exception): + """Exception class to be raised by module.fail_json and caught by the test case""" + pass + + +def exit_json(*args, **kwargs): # pylint: disable=unused-argument + """function to patch over exit_json; package return data into an exception""" + if 'changed' not in kwargs: + kwargs['changed'] = False + raise AnsibleExitJson(kwargs) + + +def fail_json(*args, **kwargs): # pylint: disable=unused-argument + """function to patch over fail_json; package return data into an exception""" + kwargs['failed'] = True + raise AnsibleFailJson(kwargs) + + +class MockUMConnection(object): + ''' mock server connection to Unified Manager host ''' + + def __init__(self): + ''' pass init ''' + + +class TestMyModule(unittest.TestCase): + ''' a group of related Unit Tests ''' + + def setUp(self): + self.mock_module_helper = patch.multiple(basic.AnsibleModule, + exit_json=exit_json, + fail_json=fail_json) + self.mock_module_helper.start() + self.addCleanup(self.mock_module_helper.stop) + self.server = MockUMConnection() + # whether to use a mock or a simulator + self.onbox = False + + def set_default_args(self): + if self.onbox: + hostname = '10.10.10.10' + username = 'admin' + password = 'password' + else: + hostname = 'hostname' + username = 'username' + password = 'password' + return dict({ + 'hostname': hostname, + 'username': username, + 'password': password, + }) + + def test_module_fail_when_required_args_missing(self): + ''' required arguments are reported as errors ''' + with pytest.raises(AnsibleFailJson) as exc: + set_module_args({}) + my_module() + print('Info: %s' % exc.value.args[0]['msg']) + + @patch('ansible_collections.netapp.um_info.plugins.modules.na_um_clusters_info.NetAppUMCluster.get_clusters') + def test_ensure_list_cluster_get_called(self, get_cluster): + ''' fetching details of cluster ''' + set_module_args(self.set_default_args()) + my_obj = my_module() + my_obj.server = self.server + my_obj.get_cluster = Mock(return_value=SRR['get_cluster']) + with pytest.raises(AnsibleExitJson) as exc: + my_obj.apply() + assert exc.value.args[0]['changed'] + # to reset na_helper from remembering the previous 'changed' value + + @patch('ansible_collections.netapp.um_info.plugins.modules.na_um_clusters_info.NetAppUMCluster.get_clusters') + def test_ensure_get_called_existing(self, get_cluster): + ''' test for existing cluster''' + set_module_args(self.set_default_args()) + my_obj = my_module() + my_obj.get_cluster = Mock(return_value=SRR['get_cluster']) + assert my_obj.get_cluster() is not None + + @patch('ansible_collections.netapp.um_info.plugins.module_utils.netapp.UMRestAPI.send_request') + def test_get_next(self, mock_request): + ''' test for existing clusters''' + set_module_args(self.set_default_args()) + mock_request.side_effect = [ + SRR['get_next'], + SRR['get_data'], + SRR['end_of_sequence'], + ] + my_obj = my_module() + assert my_obj.get_clusters() is not None + + @patch('ansible_collections.netapp.um_info.plugins.module_utils.netapp.UMRestAPI.send_request') + def test_negative_get_next(self, mock_request): + ''' test for existing clusters''' + set_module_args(self.set_default_args()) + mock_request.side_effect = [ + SRR['get_next'], + SRR['get_data_missing_field'], + SRR['end_of_sequence'], + ] + my_obj = my_module() + with pytest.raises(AnsibleFailJson) as exc: + my_obj.get_clusters() is not None + print(exc.value.args[0]) + msg = 'unexpected response from datacenter/cluster/clusters' + assert msg in exc.value.args[0]['msg'] + msg = "expecting key: 'total_records'" + assert msg in exc.value.args[0]['msg'] diff --git a/ansible_collections/netapp/um_info/tests/unit/plugins/modules/test_na_um_nodes_info.py b/ansible_collections/netapp/um_info/tests/unit/plugins/modules/test_na_um_nodes_info.py new file mode 100644 index 000000000..e5769d1f1 --- /dev/null +++ b/ansible_collections/netapp/um_info/tests/unit/plugins/modules/test_na_um_nodes_info.py @@ -0,0 +1,158 @@ +# (c) 2020, NetApp, Inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +""" unit tests for Ansible module: na_um_nodes_info """ + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type +import json +import pytest +import sys + +from ansible.module_utils import basic +from ansible.module_utils._text import to_bytes +from ansible_collections.netapp.um_info.tests.unit.compat import unittest +from ansible_collections.netapp.um_info.tests.unit.compat.mock import patch, Mock +import ansible_collections.netapp.um_info.plugins.module_utils.netapp as netapp_utils + +from ansible_collections.netapp.um_info.plugins.modules.na_um_nodes_info\ + import NetAppUMNode as my_module # module under test + + +if not netapp_utils.HAS_REQUESTS and sys.version_info < (2, 7): + pytestmark = pytest.mark.skip('Skipping Unit Tests on 2.6 as requests is not be available') + + +# REST API canned responses when mocking send_request +SRR = { + # common responses + 'empty_good': ({}, None), + 'end_of_sequence': (None, "Unexpected call to send_request"), + 'generic_error': (None, "Expected error"), + 'get_next': (dict(_links=dict(self='me', next=dict(href='next_records'))), None), + 'get_data': (dict(_links=dict(self='me'), records=['data1', 'data2'], total_records=2), None), + 'get_data_missing_field': (dict(_links=dict(self='me'), records=['data1', 'data2']), None), + # module specific responses + 'get_nodes': {'name': 'ansible'} +} + + +def set_module_args(args): + """prepare arguments so that they will be picked up during module creation""" + args = json.dumps({'ANSIBLE_MODULE_ARGS': args}) + basic._ANSIBLE_ARGS = to_bytes(args) # pylint: disable=protected-access + + +class AnsibleExitJson(Exception): + """Exception class to be raised by module.exit_json and caught by the test case""" + pass + + +class AnsibleFailJson(Exception): + """Exception class to be raised by module.fail_json and caught by the test case""" + pass + + +def exit_json(*args, **kwargs): # pylint: disable=unused-argument + """function to patch over exit_json; package return data into an exception""" + if 'changed' not in kwargs: + kwargs['changed'] = False + raise AnsibleExitJson(kwargs) + + +def fail_json(*args, **kwargs): # pylint: disable=unused-argument + """function to patch over fail_json; package return data into an exception""" + kwargs['failed'] = True + raise AnsibleFailJson(kwargs) + + +class MockUMConnection(object): + ''' mock server connection to Unified Manager host ''' + + def __init__(self): + ''' pass init ''' + + +class TestMyModule(unittest.TestCase): + ''' a group of related Unit Tests ''' + + def setUp(self): + self.mock_module_helper = patch.multiple(basic.AnsibleModule, + exit_json=exit_json, + fail_json=fail_json) + self.mock_module_helper.start() + self.addCleanup(self.mock_module_helper.stop) + self.server = MockUMConnection() + # whether to use a mock or a simulator + self.onbox = False + + def set_default_args(self): + if self.onbox: + hostname = '10.10.10.10' + username = 'admin' + password = 'password' + else: + hostname = 'hostname' + username = 'username' + password = 'password' + return dict({ + 'hostname': hostname, + 'username': username, + 'password': password, + }) + + def test_module_fail_when_required_args_missing(self): + ''' required arguments are reported as errors ''' + with pytest.raises(AnsibleFailJson) as exc: + set_module_args({}) + my_module() + print('Info: %s' % exc.value.args[0]['msg']) + + @patch('ansible_collections.netapp.um_info.plugins.modules.na_um_nodes_info.NetAppUMNode.get_nodes') + def test_ensure_list_nodes_get_called(self, get_nodes): + ''' fetching details of nodes ''' + set_module_args(self.set_default_args()) + my_obj = my_module() + my_obj.server = self.server + my_obj.get_nodes = Mock(return_value=SRR['get_nodes']) + with pytest.raises(AnsibleExitJson) as exc: + my_obj.apply() + assert exc.value.args[0]['changed'] + + @patch('ansible_collections.netapp.um_info.plugins.modules.na_um_nodes_info.NetAppUMNode.get_nodes') + def test_ensure_get_called_existing(self, get_nodes): + ''' test for existing nodes''' + set_module_args(self.set_default_args()) + my_obj = my_module() + my_obj.get_nodes = Mock(return_value=SRR['get_nodes']) + assert my_obj.get_nodes() is not None + + @patch('ansible_collections.netapp.um_info.plugins.module_utils.netapp.UMRestAPI.send_request') + def test_get_next(self, mock_request): + ''' test for existing nodes''' + set_module_args(self.set_default_args()) + mock_request.side_effect = [ + SRR['get_next'], + SRR['get_data'], + SRR['end_of_sequence'], + ] + my_obj = my_module() + assert my_obj.get_nodes() is not None + + @patch('ansible_collections.netapp.um_info.plugins.module_utils.netapp.UMRestAPI.send_request') + def test_negative_get_next(self, mock_request): + ''' test for existing nodes''' + set_module_args(self.set_default_args()) + mock_request.side_effect = [ + SRR['get_next'], + SRR['get_data_missing_field'], + SRR['end_of_sequence'], + ] + my_obj = my_module() + with pytest.raises(AnsibleFailJson) as exc: + my_obj.get_nodes() is not None + print(exc.value.args[0]) + msg = 'unexpected response from datacenter/cluster/nodes' + assert msg in exc.value.args[0]['msg'] + msg = "expecting key: 'total_records'" + assert msg in exc.value.args[0]['msg'] diff --git a/ansible_collections/netapp/um_info/tests/unit/plugins/modules/test_na_um_svms_info.py b/ansible_collections/netapp/um_info/tests/unit/plugins/modules/test_na_um_svms_info.py new file mode 100644 index 000000000..2eafd508f --- /dev/null +++ b/ansible_collections/netapp/um_info/tests/unit/plugins/modules/test_na_um_svms_info.py @@ -0,0 +1,158 @@ +# (c) 2020, NetApp, Inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +""" unit tests for Ansible module: na_um_svms_info """ + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type +import json +import pytest +import sys + +from ansible.module_utils import basic +from ansible.module_utils._text import to_bytes +from ansible_collections.netapp.um_info.tests.unit.compat import unittest +from ansible_collections.netapp.um_info.tests.unit.compat.mock import patch, Mock +import ansible_collections.netapp.um_info.plugins.module_utils.netapp as netapp_utils + +from ansible_collections.netapp.um_info.plugins.modules.na_um_svms_info\ + import NetAppUMSVM as my_module # module under test + + +if not netapp_utils.HAS_REQUESTS and sys.version_info < (2, 7): + pytestmark = pytest.mark.skip('Skipping Unit Tests on 2.6 as requests is not be available') + + +# REST API canned responses when mocking send_request +SRR = { + # common responses + 'empty_good': ({}, None), + 'end_of_sequence': (None, "Unexpected call to send_request"), + 'generic_error': (None, "Expected error"), + 'get_next': (dict(_links=dict(self='me', next=dict(href='next_records'))), None), + 'get_data': (dict(_links=dict(self='me'), records=['data1', 'data2'], total_records=2), None), + 'get_data_missing_field': (dict(_links=dict(self='me'), records=['data1', 'data2']), None), + # module specific responses + 'get_svms': {'name': 'ansible'} +} + + +def set_module_args(args): + """prepare arguments so that they will be picked up during module creation""" + args = json.dumps({'ANSIBLE_MODULE_ARGS': args}) + basic._ANSIBLE_ARGS = to_bytes(args) # pylint: disable=protected-access + + +class AnsibleExitJson(Exception): + """Exception class to be raised by module.exit_json and caught by the test case""" + pass + + +class AnsibleFailJson(Exception): + """Exception class to be raised by module.fail_json and caught by the test case""" + pass + + +def exit_json(*args, **kwargs): # pylint: disable=unused-argument + """function to patch over exit_json; package return data into an exception""" + if 'changed' not in kwargs: + kwargs['changed'] = False + raise AnsibleExitJson(kwargs) + + +def fail_json(*args, **kwargs): # pylint: disable=unused-argument + """function to patch over fail_json; package return data into an exception""" + kwargs['failed'] = True + raise AnsibleFailJson(kwargs) + + +class MockUMConnection(object): + ''' mock server connection to Unified Manager host ''' + + def __init__(self): + ''' pass init ''' + + +class TestMyModule(unittest.TestCase): + ''' a group of related Unit Tests ''' + + def setUp(self): + self.mock_module_helper = patch.multiple(basic.AnsibleModule, + exit_json=exit_json, + fail_json=fail_json) + self.mock_module_helper.start() + self.addCleanup(self.mock_module_helper.stop) + self.server = MockUMConnection() + # whether to use a mock or a simulator + self.onbox = False + + def set_default_args(self): + if self.onbox: + hostname = '10.10.10.10' + username = 'admin' + password = 'password' + else: + hostname = 'hostname' + username = 'username' + password = 'password' + return dict({ + 'hostname': hostname, + 'username': username, + 'password': password, + }) + + def test_module_fail_when_required_args_missing(self): + ''' required arguments are reported as errors ''' + with pytest.raises(AnsibleFailJson) as exc: + set_module_args({}) + my_module() + print('Info: %s' % exc.value.args[0]['msg']) + + @patch('ansible_collections.netapp.um_info.plugins.modules.na_um_svms_info.NetAppUMSVM.get_svms') + def test_ensure_list_svms_get_called(self, get_svms): + ''' fetching details of svms ''' + set_module_args(self.set_default_args()) + my_obj = my_module() + my_obj.server = self.server + my_obj.get_svms = Mock(return_value=SRR['get_svms']) + with pytest.raises(AnsibleExitJson) as exc: + my_obj.apply() + assert exc.value.args[0]['changed'] + + @patch('ansible_collections.netapp.um_info.plugins.modules.na_um_svms_info.NetAppUMSVM.get_svms') + def test_ensure_get_called_existing(self, get_svms): + ''' test for existing svms''' + set_module_args(self.set_default_args()) + my_obj = my_module() + my_obj.get_svms = Mock(return_value=SRR['get_svms']) + assert my_obj.get_svms() is not None + + @patch('ansible_collections.netapp.um_info.plugins.module_utils.netapp.UMRestAPI.send_request') + def test_get_next(self, mock_request): + ''' test for existing svms''' + set_module_args(self.set_default_args()) + mock_request.side_effect = [ + SRR['get_next'], + SRR['get_data'], + SRR['end_of_sequence'], + ] + my_obj = my_module() + assert my_obj.get_svms() is not None + + @patch('ansible_collections.netapp.um_info.plugins.module_utils.netapp.UMRestAPI.send_request') + def test_negative_get_next(self, mock_request): + ''' test for existing svms''' + set_module_args(self.set_default_args()) + mock_request.side_effect = [ + SRR['get_next'], + SRR['get_data_missing_field'], + SRR['end_of_sequence'], + ] + my_obj = my_module() + with pytest.raises(AnsibleFailJson) as exc: + my_obj.get_svms() is not None + print(exc.value.args[0]) + msg = 'unexpected response from datacenter/svm/svms' + assert msg in exc.value.args[0]['msg'] + msg = "expecting key: 'total_records'" + assert msg in exc.value.args[0]['msg'] diff --git a/ansible_collections/netapp/um_info/tests/unit/plugins/modules/test_na_um_volumes_info.py b/ansible_collections/netapp/um_info/tests/unit/plugins/modules/test_na_um_volumes_info.py new file mode 100644 index 000000000..4c8a267fb --- /dev/null +++ b/ansible_collections/netapp/um_info/tests/unit/plugins/modules/test_na_um_volumes_info.py @@ -0,0 +1,158 @@ +# (c) 2020, NetApp, Inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +""" unit tests for Ansible module: na_um_volumes_info """ + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type +import json +import pytest +import sys + +from ansible.module_utils import basic +from ansible.module_utils._text import to_bytes +from ansible_collections.netapp.um_info.tests.unit.compat import unittest +from ansible_collections.netapp.um_info.tests.unit.compat.mock import patch, Mock +import ansible_collections.netapp.um_info.plugins.module_utils.netapp as netapp_utils + +from ansible_collections.netapp.um_info.plugins.modules.na_um_volumes_info\ + import NetAppUMVolume as my_module # module under test + + +if not netapp_utils.HAS_REQUESTS and sys.version_info < (2, 7): + pytestmark = pytest.mark.skip('Skipping Unit Tests on 2.6 as requests is not be available') + + +# REST API canned responses when mocking send_request +SRR = { + # common responses + 'empty_good': ({}, None), + 'end_of_sequence': (None, "Unexpected call to send_request"), + 'generic_error': (None, "Expected error"), + 'get_next': (dict(_links=dict(self='me', next=dict(href='next_records'))), None), + 'get_data': (dict(_links=dict(self='me'), records=['data1', 'data2'], total_records=2), None), + 'get_data_missing_field': (dict(_links=dict(self='me'), records=['data1', 'data2']), None), + # module specific responses + 'get_volumes': {'name': 'ansible'} +} + + +def set_module_args(args): + """prepare arguments so that they will be picked up during module creation""" + args = json.dumps({'ANSIBLE_MODULE_ARGS': args}) + basic._ANSIBLE_ARGS = to_bytes(args) # pylint: disable=protected-access + + +class AnsibleExitJson(Exception): + """Exception class to be raised by module.exit_json and caught by the test case""" + pass + + +class AnsibleFailJson(Exception): + """Exception class to be raised by module.fail_json and caught by the test case""" + pass + + +def exit_json(*args, **kwargs): # pylint: disable=unused-argument + """function to patch over exit_json; package return data into an exception""" + if 'changed' not in kwargs: + kwargs['changed'] = False + raise AnsibleExitJson(kwargs) + + +def fail_json(*args, **kwargs): # pylint: disable=unused-argument + """function to patch over fail_json; package return data into an exception""" + kwargs['failed'] = True + raise AnsibleFailJson(kwargs) + + +class MockUMConnection(object): + ''' mock server connection to Unified Manager host ''' + + def __init__(self): + ''' pass init ''' + + +class TestMyModule(unittest.TestCase): + ''' a group of related Unit Tests ''' + + def setUp(self): + self.mock_module_helper = patch.multiple(basic.AnsibleModule, + exit_json=exit_json, + fail_json=fail_json) + self.mock_module_helper.start() + self.addCleanup(self.mock_module_helper.stop) + self.server = MockUMConnection() + # whether to use a mock or a simulator + self.onbox = False + + def set_default_args(self): + if self.onbox: + hostname = '10.10.10.10' + username = 'admin' + password = 'password' + else: + hostname = 'hostname' + username = 'username' + password = 'password' + return dict({ + 'hostname': hostname, + 'username': username, + 'password': password, + }) + + def test_module_fail_when_required_args_missing(self): + ''' required arguments are reported as errors ''' + with pytest.raises(AnsibleFailJson) as exc: + set_module_args({}) + my_module() + print('Info: %s' % exc.value.args[0]['msg']) + + @patch('ansible_collections.netapp.um_info.plugins.modules.na_um_volumes_info.NetAppUMVolume.get_volumes') + def test_ensure_list_volumes_get_called(self, get_volumes): + ''' fetching details of volumes ''' + set_module_args(self.set_default_args()) + my_obj = my_module() + my_obj.server = self.server + my_obj.get_volumes = Mock(return_value=SRR['get_volumes']) + with pytest.raises(AnsibleExitJson) as exc: + my_obj.apply() + assert exc.value.args[0]['changed'] + + @patch('ansible_collections.netapp.um_info.plugins.modules.na_um_volumes_info.NetAppUMVolume.get_volumes') + def test_ensure_get_called_existing(self, get_volumes): + ''' test for existing volumes''' + set_module_args(self.set_default_args()) + my_obj = my_module() + my_obj.get_volumes = Mock(return_value=SRR['get_volumes']) + assert my_obj.get_volumes() is not None + + @patch('ansible_collections.netapp.um_info.plugins.module_utils.netapp.UMRestAPI.send_request') + def test_get_next(self, mock_request): + ''' test for existing volumes''' + set_module_args(self.set_default_args()) + mock_request.side_effect = [ + SRR['get_next'], + SRR['get_data'], + SRR['end_of_sequence'], + ] + my_obj = my_module() + assert my_obj.get_volumes() is not None + + @patch('ansible_collections.netapp.um_info.plugins.module_utils.netapp.UMRestAPI.send_request') + def test_negative_get_next(self, mock_request): + ''' test for existing volumes''' + set_module_args(self.set_default_args()) + mock_request.side_effect = [ + SRR['get_next'], + SRR['get_data_missing_field'], + SRR['end_of_sequence'], + ] + my_obj = my_module() + with pytest.raises(AnsibleFailJson) as exc: + my_obj.get_volumes() is not None + print(exc.value.args[0]) + msg = 'unexpected response from datacenter/storage/volumes' + assert msg in exc.value.args[0]['msg'] + msg = "expecting key: 'total_records'" + assert msg in exc.value.args[0]['msg'] diff --git a/ansible_collections/netapp/um_info/tests/unit/requirements.txt b/ansible_collections/netapp/um_info/tests/unit/requirements.txt new file mode 100644 index 000000000..b754473a9 --- /dev/null +++ b/ansible_collections/netapp/um_info/tests/unit/requirements.txt @@ -0,0 +1 @@ +requests ; python_version >= '2.7' |