Full Code of vmware/ansible-for-nsxt for AI

master 57b2df630fab cached
241 files
1.2 MB
267.4k tokens
534 symbols
1 requests
Download .txt
Showing preview only (1,306K chars total). Download the full file or copy to clipboard to get everything.
Repository: vmware/ansible-for-nsxt
Branch: master
Commit: 57b2df630fab
Files: 241
Total size: 1.2 MB

Directory structure:
gitextract_w6d1_2mv/

├── .gitignore
├── CONTRIBUTING.md
├── LICENSE.txt
├── README.md
├── galaxy.yml
├── meta/
│   └── runtime.yml
├── plugins/
│   ├── doc_fragments/
│   │   └── vmware_nsxt.py
│   ├── module_utils/
│   │   ├── __init__.py
│   │   ├── common_utils.py
│   │   ├── nsxt_base_resource.py
│   │   ├── nsxt_resource_urls.py
│   │   ├── policy_communicator.py
│   │   ├── policy_resource_specs/
│   │   │   ├── __init__.py
│   │   │   ├── l2_bridge_ep_profile.py
│   │   │   └── security_policy.py
│   │   ├── upgrade_reverse_order.py
│   │   ├── vcenter_utils.py
│   │   └── vmware_nsxt.py
│   └── modules/
│       ├── __init__.py
│       ├── nsxt_certificates.py
│       ├── nsxt_certificates_facts.py
│       ├── nsxt_cluster_profiles.py
│       ├── nsxt_cluster_profiles_facts.py
│       ├── nsxt_deploy_ova.py
│       ├── nsxt_edge_clusters.py
│       ├── nsxt_edge_clusters_facts.py
│       ├── nsxt_fabric_compute_managers.py
│       ├── nsxt_fabric_compute_managers_facts.py
│       ├── nsxt_global_manager_active.py
│       ├── nsxt_global_manager_enable_service.py
│       ├── nsxt_global_manager_registration.py
│       ├── nsxt_ip_blocks.py
│       ├── nsxt_ip_blocks_facts.py
│       ├── nsxt_ip_pools.py
│       ├── nsxt_ip_pools_facts.py
│       ├── nsxt_licenses.py
│       ├── nsxt_licenses_facts.py
│       ├── nsxt_local_manager_registration.py
│       ├── nsxt_local_managers_compatibility.py
│       ├── nsxt_local_managers_facts.py
│       ├── nsxt_logical_ports.py
│       ├── nsxt_logical_ports_facts.py
│       ├── nsxt_logical_router_ports.py
│       ├── nsxt_logical_router_ports_facts.py
│       ├── nsxt_logical_router_static_routes.py
│       ├── nsxt_logical_routers.py
│       ├── nsxt_logical_routers_facts.py
│       ├── nsxt_logical_switches.py
│       ├── nsxt_logical_switches_facts.py
│       ├── nsxt_manager_auto_deployment.py
│       ├── nsxt_manager_auto_deployment_facts.py
│       ├── nsxt_manager_status.py
│       ├── nsxt_policy_bfd_profile.py
│       ├── nsxt_policy_gateway_policy.py
│       ├── nsxt_policy_group.py
│       ├── nsxt_policy_ip_block.py
│       ├── nsxt_policy_ip_block_facts.py
│       ├── nsxt_policy_ip_pool.py
│       ├── nsxt_policy_ip_pool_facts.py
│       ├── nsxt_policy_l2_bridge_ep_profile.py
│       ├── nsxt_policy_security_policy.py
│       ├── nsxt_policy_segment.py
│       ├── nsxt_policy_tier0.py
│       ├── nsxt_policy_tier1.py
│       ├── nsxt_principal_identities.py
│       ├── nsxt_principal_identities_facts.py
│       ├── nsxt_repo_sync.py
│       ├── nsxt_repo_sync_facts.py
│       ├── nsxt_rest.py
│       ├── nsxt_route_advertise.py
│       ├── nsxt_transport_node_collections.py
│       ├── nsxt_transport_node_collections_facts.py
│       ├── nsxt_transport_node_profiles.py
│       ├── nsxt_transport_node_profiles_facts.py
│       ├── nsxt_transport_nodes.py
│       ├── nsxt_transport_nodes_facts.py
│       ├── nsxt_transport_zones.py
│       ├── nsxt_transport_zones_facts.py
│       ├── nsxt_upgrade_eula_accept.py
│       ├── nsxt_upgrade_eula_accept_facts.py
│       ├── nsxt_upgrade_groups.py
│       ├── nsxt_upgrade_groups_facts.py
│       ├── nsxt_upgrade_history.py
│       ├── nsxt_upgrade_plan.py
│       ├── nsxt_upgrade_plan_facts.py
│       ├── nsxt_upgrade_postchecks.py
│       ├── nsxt_upgrade_pre_post_checks_facts.py
│       ├── nsxt_upgrade_prechecks.py
│       ├── nsxt_upgrade_run.py
│       ├── nsxt_upgrade_status_summary_facts.py
│       ├── nsxt_upgrade_uc.py
│       ├── nsxt_upgrade_uc_facts.py
│       ├── nsxt_upgrade_upload_mub.py
│       ├── nsxt_upgrade_upload_mub_facts.py
│       ├── nsxt_uplink_profiles.py
│       ├── nsxt_uplink_profiles_facts.py
│       ├── nsxt_vidm.py
│       ├── nsxt_virtual_ip.py
│       ├── nsxt_virtual_ip_facts.py
│       └── nsxt_vm_tags.py
└── tests/
    ├── playbooks/
    │   ├── mp/
    │   │   ├── answerfile.yml
    │   │   ├── answerfile_9x.yml
    │   │   ├── answerfile_attach_tnp_to_cluster.yml
    │   │   ├── answerfile_attach_tnp_to_cluster_9x.yml
    │   │   ├── answerfile_tn.yml
    │   │   ├── answerfile_tn_9x.yml
    │   │   ├── test_attach_tnp_to_cluster.yml
    │   │   ├── test_attach_tnp_to_cluster_9x.yml
    │   │   ├── test_basic_topology.yml
    │   │   ├── test_basic_topology_9x.yml
    │   │   ├── test_certificates.yml
    │   │   ├── test_certificates_facts.yml
    │   │   ├── test_cluster_profiles.yml
    │   │   ├── test_cluster_profiles_facts.yml
    │   │   ├── test_compute_managers.yml
    │   │   ├── test_compute_managers_facts.yml
    │   │   ├── test_configure_transport_node.yml
    │   │   ├── test_configure_transport_node_9x.yml
    │   │   ├── test_edge_clusters.yml
    │   │   ├── test_edge_clusters_facts.yml
    │   │   ├── test_global_manager_enable_service.yml
    │   │   ├── test_global_manager_registration.yml
    │   │   ├── test_global_managers_active.yml
    │   │   ├── test_ip_blocks.yml
    │   │   ├── test_ip_blocks_facts.yml
    │   │   ├── test_ip_pools.yml
    │   │   ├── test_ip_pools_facts.yml
    │   │   ├── test_licenses.yml
    │   │   ├── test_licenses_facts.yml
    │   │   ├── test_local_manager_registration.yml
    │   │   ├── test_local_managers_compatibility.yml
    │   │   ├── test_local_managers_facts.yml
    │   │   ├── test_logical_ports.yml
    │   │   ├── test_logical_ports_facts.yml
    │   │   ├── test_logical_router_ports.yml
    │   │   ├── test_logical_router_ports_facts.yml
    │   │   ├── test_logical_router_static_route.yml
    │   │   ├── test_logical_routers.yml
    │   │   ├── test_logical_routers_facts.yml
    │   │   ├── test_logical_switches.yml
    │   │   ├── test_logical_switches_facts.yml
    │   │   ├── test_manager_auto_deployment.yml
    │   │   ├── test_manager_auto_deployment_facts.yml
    │   │   ├── test_manager_status.yml
    │   │   ├── test_ovf_deployment.yml
    │   │   ├── test_principal_identities.yml
    │   │   ├── test_principal_identities_facts.yml
    │   │   ├── test_repo_sync.yml
    │   │   ├── test_repo_sync_facts.yml
    │   │   ├── test_rest.yml
    │   │   ├── test_route_advertise.yml
    │   │   ├── test_transport_node_collections.yml
    │   │   ├── test_transport_node_collections_facts.yml
    │   │   ├── test_transport_node_profiles.yml
    │   │   ├── test_transport_node_profiles_facts.yml
    │   │   ├── test_transport_nodes.yml
    │   │   ├── test_transport_nodes_edge.yml
    │   │   ├── test_transport_nodes_edge_9x.yml
    │   │   ├── test_transport_nodes_facts.yml
    │   │   ├── test_transport_nodes_host.yml
    │   │   ├── test_transport_nodes_host_9x.yml
    │   │   ├── test_transport_zones.yml
    │   │   ├── test_transport_zones_facts.yml
    │   │   ├── test_upgrade_eula_accept.yml
    │   │   ├── test_upgrade_eula_accept_facts.yml
    │   │   ├── test_upgrade_groups.yml
    │   │   ├── test_upgrade_groups_facts.yml
    │   │   ├── test_upgrade_history_facts.yml
    │   │   ├── test_upgrade_plan.yml
    │   │   ├── test_upgrade_plan_facts.yml
    │   │   ├── test_upgrade_postchecks.yml
    │   │   ├── test_upgrade_pre_post_checks_facts.yml
    │   │   ├── test_upgrade_prechecks.yml
    │   │   ├── test_upgrade_run.yml
    │   │   ├── test_upgrade_status_summary_facts.yml
    │   │   ├── test_upgrade_uc.yml
    │   │   ├── test_upgrade_uc_facts.yml
    │   │   ├── test_upgrade_upload_mub.yml
    │   │   ├── test_upgrade_upload_mub_facts.yml
    │   │   ├── test_uplink_profiles.yml
    │   │   ├── test_uplink_profiles_9x.yml
    │   │   ├── test_uplink_profiles_facts.yml
    │   │   ├── test_vidm.yml
    │   │   ├── test_virtual_ip.yml
    │   │   └── test_virtual_ip_facts.yml
    │   ├── policy/
    │   │   ├── test_nsxt_policy_bfd_profile.yaml
    │   │   ├── test_nsxt_policy_gateway_policy.yml
    │   │   ├── test_nsxt_policy_group.yml
    │   │   ├── test_nsxt_policy_ip_block.yml
    │   │   ├── test_nsxt_policy_ip_pool.yml
    │   │   ├── test_nsxt_policy_l2_bridge_ep_profile.yml
    │   │   ├── test_nsxt_policy_security_policy.yml
    │   │   ├── test_nsxt_policy_segment.yml
    │   │   ├── test_nsxt_policy_tier0.yml
    │   │   ├── test_nsxt_policy_tier1.yml
    │   │   └── test_vm_tags.yaml
    │   └── topologies/
    │       ├── deploy_nsx_cluster/
    │       │   ├── 01_deploy_first_node.yml
    │       │   ├── 02_configure_compute_manager.yml
    │       │   ├── 03_deploy_second_third_node.yml
    │       │   ├── 04_add_nsx_license.yml
    │       │   ├── README.md
    │       │   └── deploy_nsx_cluster_vars.yml
    │       ├── misc/
    │       │   └── create_and_attach_t0_t1_routers.yml
    │       ├── policy_modules/
    │       │   ├── 01_create_t0_gateway.yml
    │       │   ├── 02_create_t1_gateway.yml
    │       │   ├── 03_create_segments.yml
    │       │   ├── 04_create_groups.yml
    │       │   ├── 05_create_security_policy.yml
    │       │   ├── README.md
    │       │   ├── build_topology.yml
    │       │   ├── build_topology_vars.yml
    │       │   └── cleanup_topology.yml
    │       ├── setup_infra/
    │       │   ├── 01_setup_transport_zones.yml
    │       │   ├── 01_setup_transport_zones_9x.yml
    │       │   ├── 02_setup_TEP_IP_Pools.yml
    │       │   ├── 03_setup_transport_node_profiles.yml
    │       │   ├── 03_setup_transport_node_profiles_9x.yml
    │       │   ├── 04_setup_transport_nodes.yml
    │       │   ├── 04_setup_transport_nodes_9x.yml
    │       │   ├── 05_setup_edge_cluster.yml
    │       │   ├── 06_setup_transport_node_collections.yml
    │       │   ├── README.md
    │       │   ├── setup_infra_vars.yml
    │       │   └── setup_infra_vars_9x.yml
    │       └── upgrade/
    │           ├── 01_upgrade_upload_mub.yml
    │           ├── 02_upgrade_accept_eula.yml
    │           ├── 03_upgrade_uc.yml
    │           ├── 04_upgrade_update_plan.yml
    │           ├── 05_upgrade_update_groups.yml
    │           ├── 06_upgrade_prechecks.yml
    │           ├── 07_upgrade_run.yml
    │           ├── README.md
    │           ├── check_upgrade_groups_facts.yml
    │           ├── check_upgrade_pre_post_checks_facts.yml
    │           ├── check_upgrade_status_summary_facts.yml
    │           └── upgrade_vars.yml
    └── unit/
        ├── __init__.py
        └── plugins/
            ├── __init__.py
            └── module_utils/
                ├── __init__.py
                ├── test_nsxt_base_resource.py
                └── test_policy_communicator.py

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
# build products...
*.py[co]
# Mac OS X stuff...
.DS_Store
# test output
*.retry
# JetBrains project dir
.idea


================================================
FILE: CONTRIBUTING.md
================================================


# Contributing to ansible-for-nsxt

The ansible-for-nsxt project team welcomes contributions from the community. Before you start working with ansible-for-nsxt, please read our [Developer Certificate of Origin](https://cla.vmware.com/dco). All contributions to this repository must be signed as described on that page. Your signature certifies that you wrote the patch or have the right to pass it on as an open-source patch.

## Community

## Getting Started

## Contribution Flow

This is a rough outline of what a contributor's workflow looks like:

- Create a topic branch from where you want to base your work
- Make commits of logical units
- Make sure your commit messages are in the proper format (see below)
- Push your changes to a topic branch in your fork of the repository
- Submit a pull request

Example:

``` shell
git remote add upstream https://github.com/vmware/ansible-for-nsxt.git
git checkout -b my-new-feature master
git commit -a
git push origin my-new-feature
```

### Staying In Sync With Upstream

When your branch gets out of sync with the vmware/master branch, use the following to update:

``` shell
git checkout my-new-feature
git fetch -a
git pull --rebase upstream master
git push --force-with-lease origin my-new-feature
```

### Updating pull requests

If your PR fails to pass CI or needs changes based on code review, you'll most likely want to squash these changes into
existing commits.

If your pull request contains a single commit or your changes are related to the most recent commit, you can simply
amend the commit.

``` shell
git add .
git commit --amend
git push --force-with-lease origin my-new-feature
```

If you need to squash changes into an earlier commit, you can use:

``` shell
git add .
git commit --fixup <commit>
git rebase -i --autosquash master
git push --force-with-lease origin my-new-feature
```

Be sure to add a comment to the PR indicating your new changes are ready to review, as GitHub does not generate a
notification when you git push.

### Code Style

### Formatting Commit Messages

We follow the conventions on [How to Write a Git Commit Message](http://chris.beams.io/posts/git-commit/).

Be sure to include any related GitHub issue references in the commit message.  See
[GFM syntax](https://guides.github.com/features/mastering-markdown/#GitHub-flavored-markdown) for referencing issues
and commits.

## Reporting Bugs and Creating Issues

When opening a new issue, try to roughly follow the commit message format conventions above.

## Repository Structure


================================================
FILE: LICENSE.txt
================================================
ansible-for-nsxt

Copyright (c) 2018 VMware, Inc.  All rights reserved				
SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only

This code is Dual Licensed BSD 2-Clause or GPLv3

===============================================================================

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. 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.

===============================================================================

                    GNU GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <https://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 <https://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
<https://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
<https://www.gnu.org/licenses/why-not-lgpl.html>.


================================================
FILE: README.md
================================================
# Ansible for NSX-T

## Overview
This repository contains NSX-T Ansible Modules, which one can use with
Ansible to work with [VMware NSX-T Data Center][vmware-nsxt].

[vmware-nsxt]: https://www.vmware.com/products/nsx.html

For general information about Ansible, visit the [GitHub project page][an-github].

[an-github]: https://github.com/ansible/ansible

These modules are maintained by [VMware](https://www.vmware.com/).

Documentation on the NSX platform can be found at the [NSX-T Documentation page](https://docs.vmware.com/en/VMware-NSX-T/index.html)

## NSX Compatibility

The following versions of NSX are supported:

 * NSX-T 4.2
 * NSX-T 4.1
 * NSX-T 4.0
 * NSX-T 3.2
 * NSX-T 3.1
 * NSX-T 3.0
 * NSX-T 2.5.1

## Prerequisites

Using Ansible-for-nsxt requires the following packages to be installated. Installation steps differ based on the platform (Mac/iOS, Ubuntu, Debian, CentOS, RHEL etc). Please follow the links below to pick the right platform.

* Ansible >= 2.10.x [Ansible Installation Documentation](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html)
* Python3 >= 3.6.x [Python Documentation](https://www.python.org/downloads/)
* pip3 >= 9.x Python Installation [PIP installation](https://pip.pypa.io/en/stable/installing/)
* PyVmOmi - Python library for vCenter api. Installation via pip: [pyVmomi installation](https://pypi.org/project/pyvmomi/)
* OVF Tools >= 4.4.x - Ovftool is used for ovf deployment [OVFTool Download and Installation](https://code.vmware.com/web/tool/4.4.0/ovf)

## Installation

ansible-for-nsxt modules are distributed as Ansible Galaxy collection. Please use the following command to install it

```
ansible-galaxy collection install git+https://github.com/vmware/ansible-for-nsxt
```

Specify latest supported release branch

```
ansible-galaxy collection install git+https://github.com/vmware/ansible-for-nsxt.git,v3.2.0
```

## Usage

Once installed, the modules can be directly run with ansible-playbook. For example, you can run:

```
ansible-playbook  test_logical_switches.yml
```

The modules require you to provide details about how to authenticate with NSX-T.


### Using modules in the tests folder

There are complete workflow example modules in the tests/playbooks folder. To use them, edit the corresponding vars file if rqeuired. Then run using ansible-playbook. For example,

```
ansible-playbook 01_create_t0_gateway.yml
```


### Supported NSX Objects/Workflows
The modules in this repository are focused on enabling automation of installation workflows of NSX-T. We have modules that support the legacy MP and new Policy API.

#### MP API
MP API modules can be used to configure an NSX resource with one-to-one mapping.

### Branch Information
This repository has different branches with each branch providing support for upto a specific NSX-T release. Below is the list:
* Master: Latest code, under development
* v3.2.0: NSX-T 3.2.x and below
* v3.0.1: NSX-T 3.1.x and below
* v3.0.0: NSX-T 3.0.x and below
* v1.1.0: NSX-T 2.4, NSX-T 2.5
* v1.0.0: NSX-T 2.3

##### Deployment and installation modules

* nsxt_deploy_ova
* nsxt_licenses
* nsxt_manager_status
* nsxt_licenses_facts
* nsxt_edge_clusters
* nsxt_edge_clusters_facts
* nsxt_fabric_compute_managers
* nsxt_fabric_compute_managers_facts
* nsxt_ip_pools
* nsxt_ip_pools_facts
* nsxt_uplink_profiles
* nsxt_uplink_profiles_facts
* nsxt_transport_zones
* nsxt_transport_zones_facts
* nsxt_transport_nodes
* nsxt_transport_nodes_facts
* nsxt_transport_node_collections
* nsxt_transport_node_collections_facts
* nsxt_transport_node_profiles
* nsxt_transport_node_profiles_facts
* nsxt_controller_manager_auto_deployment

###### Logical networking modules
* nsxt_logical_ports
* nsxt_logical_ports_facts
* nsxt_logical_routers
* nsxt_logical_routers_facts
* nsxt_logical_router_ports
* nsxt_logical_router_ports_facts
* nsxt_logical_router_static_routes
* nsxt_logical_switches
* nsxt_logical_switches_facts
* nsxt_ip_blocks
* nsxt_ip_blocks_facts

#### Policy API
Policy API modules are aggregated such that logical constructs related to an NSX resource can be configured using a single playbook. They can be identified with prefix *nsxt_policy_*. The below list outlines the supported modules and the resources that can be configured through a module.

Note that the Policy modules are supported only for NSX-T 3.0 and above.

1. Tier-0 Gateway (nsxt_policy_tier0)
   1. Tier-0 Locale Services
   2. Tier-0 Static Routes
   3. Tier-0 Interface
   4. Tier-0 BGP
   5. Tier-0 BGP Neighbors
   6. Tier-0 VRF
   7. Tier-0 BFD Peers
2. Tier-1 Gateway (nsxt_policy_tier1)
   1. Tier-1 Locale Services
   2. Tier-1 Static Routes
   3. Tier-1 Interface
3. Segment (nsxt_policy_segment)
   1. Segment Port
4. Policy Group (nsxt_policy_group)
5. Security Policy and Firewall rules (nsxt_policy_security_policy)
6. IP Pools (nsxt_policy_ip_pool)
   1. IP Address Pool Block Subnet
   2. IP Address Pool Static Subnet
7. IP Blocks (nsxt_policy_ip_block)
8. BFD Profile (nsxt_policy_bfd_profile)
9. VM Tags (nsxt_vm_tags)
10. Gateway Policy (nsxt_policy_gateway_policy)
11. L2 Bridge Endpoint Profile (nsxt_policy_l2_bridge_ep_profile)

Note that to add a new modules in Policy API, it's base class name should be added in the BASE_RESOURCES in module_utils/nsxt_base_resource.py

## Build & Run

### Install PyVmOmi
```
pip install --upgrade pyvmomi pyvim requests ssl
```
### Download and Install Ovf tool 4.3 - [Ovftool](https://my.vmware.com/web/vmware/details?downloadGroup=OVFTOOL430&productId=742)
(Note: Using ovftool version 4.0/4.1 causes OVA/OVF deployment failure with Error: cURL error: SSL connect error\nCompleted with errors\n)

### Authentication

#### Using MP API
Ansible-for-nsxt supports two types of authentication using MP API.
1. Basic server authentication
2. Certificate based authentication

##### Basic server authentication
In basic server authentication, client has to explicitly provide NSX username and password for the NSX manager. The credentials have to be listed in ansible-playbook.

##### Certificate based authentication
In certificate based authentication, client has to register their certificates to NSX manager using nsxt_certificates task. After registering the certificates, client has to create its own principal identity on NSX manager using nsxt_principal_identities taks.
The process of certificate registration and creation of principal identity has to be done using basic server authentication. Use test_certificates.yml and test_principal_identities.yml to match the values according to the client's environment.
```
ansible-playbook test_certificates.yml -vvv
ansible-playbook test_principal_identities -vvv
```
The path of the .p12 file i.e the file containing public and private key has to be set to an environment variable named NSX_MANAGER_CERT_PATH. 
**Note:** Make sure NSX_MANAGER_CERT_PATH is set in the same remote host, where modules would be executed. 

###### Generating certificates?
Following commands can be used in order to generate certificates.
```
openssl req -newkey rsa:2048 -extensions usr_cert -nodes -keyout nsx_certificate.key -x509 -days 365 -out nsx_certificate.crt -subj "/C=US/ST=California/L=PaloAlto/O=VMware/CN=certauth-test" -sha256

openssl pkcs12 -export -out nsx_certificate.pfx -inkey nsx_certificate.key -in nsx_certificate.crt

openssl pkcs12 -in nsx_certificate.pfx -out nsx_certificate.p12 -nodes
```

The nsx_certificate.crt file generated as output from the above command contains the public key certificate.
the file nsx_certificate.p12 file contains the public and private key generated. The path of nsx_certificate.p12 file has to be set in the environment variable NSX_MANAGER_CERT_PATH.

Note: usr_cert tells OpenSSL to generate a client certificate. This must be defined in openssl.cnf.

#### Validate CA in MP API

To validate ceritificate authority (CA), set NSX_MANAGER_CA_PATH environment variable on Ansible control node pointing to CA certificate of NSX manager and pass validate_certs as ``True`` in ansible playbook.

#### Using Policy API
All the Policy API based Ansible Modules provide the following authentication mechanisms:

##### Basic Authentication
This is the same as in MP API. It can be used by specifying the following fields in the playbook:
1. **username**: The username to authenticate with the NSX manager
2. **password**: The password to authenticate with the NSX manager

For example:
```yaml
- hosts: localhost
  tasks:
    - name: Update Tier0
      nsxt_policy_tier0:
        hostname: "default"
        username: admin
        password: my-password
        validate_certs: False
        display_name: test-tier0-1
        state: present
```

##### Prinicipal Identity
There are 2 ways to consume the Principal Identity certificates.

###### Using Environment variable
This is same as explained in the previous section: **Certificate based authentication**

###### Specifying in the playbook
By specifying the following fields in the playbook:
1. **nsx_cert_path**: Path to the certificate created for the Principal Identity using which the CRUD operations should be performed. If the certificate is a .p12 file, only this attribute is required. Otherwise, *nsx_key_path* is also required.
2. **nsx_key_path**: Path to the certificate key created for the Principal Identity using which the CRUD operations should be performed

For example:
```yaml
- hosts: localhost
  tasks:
    - name: Update Tier0
      nsxt_policy_tier0:
        hostname: "default"
        nsx_cert_path: /root/com.vmware.nsx.ncp/nsx.crt
        nsx_key_path: /root/com.vmware.nsx.ncp/nsx.key
        validate_certs: False
        display_name: test-tier0-1
        state: present
```

##### vIDM
When NSX-T is configured to use VMware Identity Manager (vIDM) for authentication, you can supply an Authorization header with an authentication type of *Remote*. The header content should consist of a base64-encoded string containing the username@domain and password separated by a single colon (":") character, as specified in RFC 1945 section 11.1.

For example, to authenticate a request using the credentials of user jsmith@example.com with password Sk2LkPM!, include the following key:value pair under **request_headers** in the playbook::
- Authorization: 'Remote anNtaXRoQGV4YW1wbGUuY29tOlNrMkxrUE0h'

For example:
```yaml
- hosts: localhost
  tasks:
    - name: Update Tier0
      nsxt_policy_tier0:
        hostname: "default"
        request_headers:
          Authorization: 'Remote anNtaXRoQGV4YW1wbGUuY29tOlNrMkxrUE0h'
        validate_certs: False
        display_name: test-tier0-1
        state: present
```

##### SSL Verification
You can use the flag *validate_certs* to perform SSL verification. You can also specify the path to a CA bundle using the paratemer *ca_path* in the playbook.

For example:
```yaml
- hosts: localhost
  tasks:
    - name: Update Tier0
      nsxt_policy_tier0:
        hostname: "default"
        nsx_cert_path: /root/com.vmware.nsx.ncp/nsx.crt
        nsx_key_path: /root/com.vmware.nsx.ncp/nsx.key
        validate_certs: True
        ca_path: /path/to/my/ca-bundle
        display_name: test-tier0-1
        state: present
```

# Contributing

The ansible-for-nsxt project team welcomes contributions from the community. Before you start working with ansible-for-nsxt, please read our [Developer Certificate of Origin](https://cla.vmware.com/dco). All contributions to this repository must be signed as described on that page. Your signature certifies that you wrote the patch or have the right to pass it on as an open-source patch. For more detailed information, refer to [CONTRIBUTING.md](CONTRIBUTING.md).

Please open a Pull-Request against the Master branch.

# Support

Released NSX-T Ansible modules are fully supported by VMware. The released modules are available in the specific numbered release branches:
* v3.2.0
* v3.0.1
* v3.0.0
* v1.1.0
* v1.0.0

They are also available for download from VMware's download page.

The *master* branch contains the latest development code which is community supported.

For bugs and feature requests, please open a Github Issue and label it appropriately.


# License
Copyright (c) 2020 VMware, Inc.  All rights reserved

The NSX-T Ansible modules in this repository are available under [BSD-2 license or GPLv3](LICENSE.txt) applies to all parts of the ansible-for-nsxt.
You may not use them except in compliance with the License.


================================================
FILE: galaxy.yml
================================================
namespace: vmware

name: ansible_for_nsxt

version: 1.0.0

readme: README.md

authors:
- Gautam Verma @ggverma (https://vmware.slack.com/archives/CTE293BSS)
- Rahul Raghuvanshi @r-raghu (https://vmware.slack.com/archives/CTE293BSS)

description: Ansible Modules for NSX-t

license:
- GPL-3.0-only
- BSD-2-Clause-FreeBSD

license_file: LICENSE.txt 

tags: [vmware, ansible, nsxt]

dependencies: {}

repository: https://github.com/vmware/ansible-for-nsxt

documentation: https://github.com/vmware/ansible-for-nsxt

homepage: https://github.com/vmware/ansible-for-nsxt

issues: https://github.com/vmware/ansible-for-nsxt/issues

build_ignore: []


================================================
FILE: meta/runtime.yml
================================================
requires_ansible: ">=2.9"


================================================
FILE: plugins/doc_fragments/vmware_nsxt.py
================================================
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright 2021 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only
#
# 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.


class ModuleDocFragment(object):

    # VMware NSX-T documentation fragment
    DOCUMENTATION = """
options:
    hostname:
        description: Deployed NSX manager hostname.
        required: true
        type: str
    username:
        description: The username to authenticate with the NSX manager.
        type: str
    password:
        description:
            - The password to authenticate with the NSX manager.
            - Must be specified if username is specified
        type: str
    ca_path:
        description: Path to the CA bundle to be used to verify host's SSL
                     certificate
        type: str
    nsx_cert_path:
        description: Path to the certificate created for the Principal
                     Identity using which the CRUD operations should be
                     performed
        type: str
    nsx_key_path:
        description:
            - Path to the certificate key created for the Principal Identity
              using which the CRUD operations should be performed
            - Must be specified if nsx_cert_path is specified
        type: str
    request_headers:
        description: HTTP request headers to be sent to the host while making
                     any request
        type: dict
    display_name:
        description:
            - Display name.
            - If resource ID is not specified, display_name will be used as ID.
        required: false
        type: str
    state:
        choices:
        - present
        - absent
        description: "State can be either 'present' or 'absent'.
                    'present' is used to create or update resource.
                    'absent' is used to delete resource."
        required: true
    validate_certs:
        description: Enable server certificate verification.
        type: bool
        default: False
    tags:
        description: Opaque identifiers meaningful to the API user.
        type: dict
        suboptions:
            scope:
                description: Tag scope.
                required: true
                type: str
            tag:
                description: Tag value.
                required: true
                type: str
    create_or_update_subresource_first:
        type: bool
        default: false
        description:
            - Can be used to create subresources first.
            - Can be specified for each subresource.
    delete_subresource_first:
        type: bool
        default: true
        description:
            - Can be used to delete subresources first.
            - Can be specified for each subresource.
    achieve_subresource_state_if_del_parent:
        type: bool
        default: false
        description:
            - Can be used to achieve the state of subresources even if
              the parent(base) resource's state is absent.
            - Can be specified for each subresource.
    do_wait_till_create:
        type: bool
        default: false
        description:
            - Can be used to wait for the realization of subresource before the
              request to create the next resource is sent to the Manager.
            - Can be specified for each subresource.
    """


================================================
FILE: plugins/module_utils/__init__.py
================================================


================================================
FILE: plugins/module_utils/common_utils.py
================================================
#!/usr/bin/python
# -*- coding: utf-8 -*-

# Copyright 2019 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only
# 
# 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.
import time
from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import request
from ansible.module_utils._text import to_native
import ipaddress

def check_if_valid_ip(address):
    '''
    params:
    - ip_address: IP Address in string format
    result:
    checks if the IP address is valid or not.
    '''
    try:
        ip = ipaddress.ip_address(address)
        if isinstance(ip, ipaddress.IPv4Address):
            ip_octets = address.split('.')
            valid_ip_octets = [int(ip_octet) for ip_octet in ip_octets]
            valid_ip_octets = [ip_octet for ip_octet in valid_ip_octets if ip_octet >= 0 and ip_octet<=255]
            return len(ip_octets) == 4 and len(valid_ip_octets) == 4
        elif isinstance(ip, ipaddress.IPv6Address):
            return True
    except ValueError:
        return False

def traverse_and_retrieve_value(object , attribute_list):
    '''
    params:
    - object: Object where value is to be searched from attribute list
    - attribute_list: List to be used for searching attribute value
    '''
    if object is None:
        return None
    for attribute in attribute_list:
        if object.__contains__(attribute):
            object = object[attribute]
        else:
            raise Exception('AttributeError: Attribute value \"%s\" not found '
                            'while traversing.' % attribute)
    return object

def get_attribute_from_endpoint(module, manager_url, endpoint, mgr_username, 
                                mgr_password, validate_certs, attribute_name,
                                fail_on_error=True):
    '''
    params:
    - endpoint: API endpoint.
    - attribute_name: Name of attribute whose value is required
    result:
    attribute value of the attribute name provided.
    '''
    try:
        (rc, resp) = request(manager_url+ endpoint, headers=dict(Accept='application/json'),
                      url_username=mgr_username, url_password=mgr_password, 
                      validate_certs=validate_certs, ignore_errors=True)
    except Exception as err:
        if fail_on_error:
            module.fail_json(msg='Error while retrieving'
                             ' %s. Error [%s]' % (attribute_name, to_native(err)))
        else:
            return None
    if resp.__contains__(attribute_name):
        return resp[attribute_name]
    return None

def get_id_from_display_name_results(module, manager_url, endpoint, mgr_username, 
                                     mgr_password, validate_certs, 
                                     search_attribute_list, return_attribute_list, 
                                     display_name, fail_module=True):
    '''
    params:
    - endpoint: API endpoint.
    - search_attribute_list: List of name attribute the depth to be searched in the result object
    - return_attribute_list: List of name attribute the depth to be returned in the result object
    - display_name: The name to be matched
    - id_attribute: id_attribute whose value is to be returned
    '''
    try:
        (rc, resp) = request(manager_url+ endpoint, headers=dict(Accept='application/json'),
                      url_username=mgr_username, url_password=mgr_password, 
                      validate_certs=validate_certs, ignore_errors=True)
    except Exception as err:
        module.fail_json(msg='Error while converting the passed name to'
                             ' ID. Error [%s]' % to_native(err))
    try:
        for result in resp['results']:
            if traverse_and_retrieve_value(result, search_attribute_list) == display_name:
                return traverse_and_retrieve_value(result, return_attribute_list)
    except Exception as err:
        module.fail_json(msg='Error while getting id from display name. Error [%s]' % to_native(err))
    if fail_module:
        module.fail_json(msg='No id exist with display name %s' % display_name)
    else:
        return None

def wait_for_operation_to_execute(manager_url, endpoint, mgr_username, 
                                  mgr_password, validate_certs, attribute_list,
                                  desired_attribute_values, undesired_attribute_values,
                                  time_out=10800):
    '''
    params:
    - endpoint: API endpoint.
    - attribute_list: The attribute whose value should become the desired attribute value
    - desired_attribute_value: The desired attribute value
    
    Function will wait till the attribute value derived from going deep to attribute list
    becomes equal to desired_attribute_value.
    '''
    operation_time = 0
    while True:
        try:
            (rc, resp) = request(manager_url + endpoint, headers=dict(Accept='application/json'),
                                 url_username=mgr_username, url_password=mgr_password, 
                                 validate_certs=validate_certs, ignore_errors=True)
        except Exception as err:
            pass
        try:
            retrieved_value = traverse_and_retrieve_value(resp, attribute_list)
            if retrieved_value in desired_attribute_values:
                return None
            if retrieved_value in undesired_attribute_values:
                raise Exception(resp)
        except Exception as err:
            pass
        time.sleep(10)
        operation_time = operation_time + 10
        if operation_time > time_out:
            raise Exception('Operation timed out.')

def clean_and_get_params(args=None, extra_args_to_remove=[]):
    '''
    params:
    - args: All the arguments to be removed
    '''
    args_to_remove = ['state', 'username', 'password', 'port', 'hostname', 'validate_certs']
    args_to_remove.extend(extra_args_to_remove)
    for key in args_to_remove:
        args.pop(key, None)
    for key, value in args.copy().items():
        if value == None:
            args.pop(key, None)
    return args

def get_upgrade_orchestrator_node(module, mgr_hostname, mgr_username, mgr_password,
                               headers, validate_certs):
    '''
    params:
    - mgr_hostname: Any one of the manager node in manager cluster

    Returns the upgrade orchestrator node  
    '''
    try:
        (rc, resp) = request('https://%s/api/v1/node/services/install-upgrade' % mgr_hostname,
               headers=headers, url_username=mgr_username, url_password=mgr_password, 
                             validate_certs=validate_certs, ignore_errors=True)
    except Exception as err:
        module.fail_json(changed=True, msg='Error getting ip address of the upgrade'
                        ' orchestrator node. Error: {}'.format(err))
    return resp['service_properties']['enabled_on'];


================================================
FILE: plugins/module_utils/nsxt_base_resource.py
================================================
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright 2018 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only
#
# 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.


from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.policy_communicator import PolicyCommunicator
from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.policy_communicator import DuplicateRequestError

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils._text import to_native

import sys
if sys.version_info[0] < 3:
    raise Exception("Must be using Python 3")

from abc import ABC, abstractmethod

import time
import json

import inspect
# Add all the base resources that can be configured in the
# Policy API here. Required to infer base resource params.
BASE_RESOURCES = {"NSXTSegment", "NSXTTier0", "NSXTTier1",
                  "NSXTSecurityPolicy", "NSXTPolicyGroup",
                  "NSXTIpBlock", "NSXTIpPool", "NSXTBFDProfile",
                  "NSXTGatewayPolicy", "NSXTL2BridgeEpProfile"}


class NSXTBaseRealizableResource(ABC):

    INCORRECT_ARGUMENT_NAME_VALUE = "error_invalid_parameter"

    def realize(self, supports_check_mode=True,
                successful_resource_exec_logs=[],
                baseline_arg_names=[], resource_params=None):
        # must call this method to realize the creation, update, or deletion of
        # resource

        self.resource_class = self.__class__

        if not hasattr(self, "_arg_spec"):
            # Base resource
            self._make_ansible_arg_spec(
                supports_check_mode=supports_check_mode)

        if not hasattr(self, 'module'):
            self.module = AnsibleModule(
                argument_spec=self._arg_spec,
                supports_check_mode=supports_check_mode)

            self.set_baseline_args(baseline_arg_names)

        # Infer manager credentials
        mgr_hostname = self.module.params['hostname']
        mgr_username = self.module.params['username']
        mgr_password = self.module.params['password']
        nsx_cert_path = self.module.params['nsx_cert_path']
        nsx_key_path = self.module.params['nsx_key_path']

        request_headers = self.module.params['request_headers']
        ca_path = self.module.params['ca_path']
        validate_certs = self.module.params['validate_certs']

        # Each manager has an associated PolicyCommunicator
        self.policy_communicator = PolicyCommunicator.get_instance(
            mgr_hostname, mgr_username, mgr_password, nsx_cert_path,
            nsx_key_path, request_headers, ca_path, validate_certs)

        if resource_params is None:
            resource_params = self.module.params

        self.resource_params = resource_params

        self._state = self.get_attribute('state', resource_params)
        if not (hasattr(self, 'id') and self.id):
            if self.get_resource_name() in BASE_RESOURCES:
                self.id = self._get_id_using_attr_name(
                    None, resource_params,
                    self.get_resource_base_url(self.baseline_args),
                    self.get_spec_identifier(),
                    fail_if_not_found=False)
            else:
                self.id = self._get_id_using_attr_name(
                    None, resource_params,
                    self.get_resource_base_url(self._parent_info),
                    self.get_spec_identifier(),
                    fail_if_not_found=False)
                if self.id is None:
                    self.id = self.infer_resource_id(self._parent_info)
                if self.id is None:
                    self.module.fail_json(
                        msg="Please specify either id or display_name for "
                            "resource {}".format(str(
                                self.get_spec_identifier())))

        # Extract the resource params from module
        self.nsx_resource_params = self._extract_nsx_resource_params(
            resource_params)

        # parent_info is passed to subresources of a resource automatically
        if not hasattr(self, "_parent_info"):
            self._parent_info = {}
        self.update_parent_info(self._parent_info)

        try:
            # get existing resource schema
            _, self.existing_resource = self._send_request_to_API(
                suffix="/" + self.id, ignore_error=False,
                accepted_error_codes=set([404]))
            self.existing_resource_revision = self.existing_resource[
                '_revision']
            # As Policy API's PATCH requires all attributes to be filled,
            # we fill the missing resource params (the params not specified)
            # by user using the existing params
            self._fill_missing_resource_params(
                self.existing_resource, self.nsx_resource_params)
        except Exception as err:
            # the resource does not exist currently on the manager
            self.existing_resource = None
            self.existing_resource_revision = None
        finally:
            self._clean_none_resource_params(
                self.existing_resource, self.nsx_resource_params)
        self._achieve_state(resource_params, successful_resource_exec_logs)

    @classmethod
    def get_spec_identifier(cls):
        # Can be overriden in the subclass to provide different
        # unique_arg_identifier. It is used to infer which args belong to which
        # subresource.
        # By default, class name is used for subresources.
        return cls.get_resource_name()

    def get_state(self):
        return self._state

    def get_parent_info(self):
        return self._parent_info

    def infer_resource_id(self, parent_info):
        # This is called when the user has not specified the ID or
        # display_name of any child resource or its sub-resources
        pass

    @staticmethod
    @abstractmethod
    def get_resource_base_url(parent_info):
        # Must be overridden by the subclass
        raise NotImplementedError

    @staticmethod
    @abstractmethod
    def get_resource_spec():
        # Must be overridden by the subclass
        raise NotImplementedError

    @classmethod
    def get_resource_name(cls):
        return cls.__name__

    def create_or_update_subresource_first(self):
        # return True if subresource should be created/updated before parent
        # resource
        return self.resource_params.get(
            "create_or_update_subresource_first", False)

    def delete_subresource_first(self):
        # return True if subresource should be deleted before parent resource
        return self.resource_params.get("delete_subresource_first", True)

    def achieve_subresource_state_if_del_parent(self):
        # return True if this resource is to be realized with its own specified
        # state irrespective of the state of its parent resource.
        return self.resource_params.get(
            "achieve_subresource_state_if_del_parent", False)

    def do_wait_till_create(self):
        # By default, we do not wait for the parent resource to be created or
        # updated before its subresource is to be realized.
        return self.resource_params.get("do_wait_till_create", False)

    @staticmethod
    def get_resource_update_priority():
        # this priority can be used to create/delete subresources
        # at the same level in a particular order.
        # by default, it returns 1 so the resources are created/updated/
        # deleted in a fixed but random order.
        # should be overloaded in subclass to specify its priority.
        # for creation or update, we iterate in descending order.
        # for deletion, we iterate in ascending order.
        return 1

    def set_arg_spec(self, arg_spec):
        self._arg_spec = arg_spec

    def set_ansible_module(self, ansible_module):
        self.module = ansible_module

    def set_parent_info(self, parent_info):
        self._parent_info = parent_info

    def achieve_subresource_state(
            self, resource_params, successful_resource_exec_logs):
        """
            Achieve the state of each sub-resource.
        """
        for sub_resource_class in self._get_sub_resources_class_of(
                self.resource_class):
            if sub_resource_class.allows_multiple_resource_spec():
                children_resource_spec = (resource_params.get(
                    sub_resource_class.get_spec_identifier()) or [])
            else:
                children_resource_spec = ([resource_params.get(
                    sub_resource_class.get_spec_identifier())] or [])

            # Update the parent pointer
            my_parent = self._parent_info.get('_parent', '')
            self._update_parent_info()

            for resource_param_spec in children_resource_spec:
                if resource_param_spec is not None:
                    sub_resource = sub_resource_class()

                    sub_resource.set_arg_spec(self._arg_spec)
                    sub_resource.set_ansible_module(self.module)

                    sub_resource.set_parent_info(self._parent_info)

                    sub_resource.realize(
                        successful_resource_exec_logs=(
                            successful_resource_exec_logs),
                        resource_params=resource_param_spec)

            # Restore the parent pointer
            self._parent_info['_parent'] = my_parent

    def update_resource_params(self, nsx_resource_params):
        # Can be used to updates the params of resource before making
        # the API call.
        # Should be overridden in the subclass if needed
        pass

    def check_for_update(self, existing_params, resource_params):
        """
            resource_params: dict
            existing_params: dict
            Compares the existing_params with resource_params and returns
            True if they are different. At a base level, it traverses the
            params and matches one-to-one. If the value to be matched is a
            - dict, it traverses that also.
            - list, it merely compares the order.
            Can be overriden in the subclass for specific custom checking.
            Returns true if the params differ
        """
        if not existing_params:
            return False
        for k, v in resource_params.items():
            if k not in existing_params:
                return True
            elif type(v).__name__ == 'dict':
                if self.check_for_update(existing_params[k], v):
                    return True
            elif v != existing_params[k]:
                def compare_lists(list1, list2):
                    # Returns True if list1 and list2 differ
                    try:
                        # If the lists can be converted into sets, do so and
                        # compare lists as sets.
                        set1 = set(list1)
                        set2 = set(list2)
                        return set1 != set2
                    except Exception:
                        return True
                if type(v).__name__ == 'list':
                    if compare_lists(v, existing_params[k]):
                        return True
                    continue
                return True
        return False

    def update_parent_info(self, parent_info):
        # Override this and fill in self._parent_info if that is to be passed
        # to the sub-resource
        # By default, parent's id is passed
        parent_info[self.get_spec_identifier() + "_id"] = self.id

    def get_attribute(self, attribute, resource_params):
        """
            attribute: String
            resource_params: Parameters of the resource
        """
        if (attribute == "state" and
                self.get_resource_name() not in BASE_RESOURCES):
            # if parent has absent state, subresources should have absent
            # state if . So, irrespective of what user specifies, if parent
            # is to be deleted, the child resources will be deleted.
            # override achieve_subresource_state_if_del_parent
            # in resource class to change this behavior
            if (self._parent_info["_parent"].get_state() == "absent" and
                    not self.achieve_subresource_state_if_del_parent()):
                return "absent"
        return resource_params.get(
            attribute, self.INCORRECT_ARGUMENT_NAME_VALUE)

    def set_baseline_args(self, baseline_arg_names):
        # Can be overriden in subclass
        self.baseline_args = {}
        for baseline_arg_name in baseline_arg_names:
            self.baseline_args[baseline_arg_name] = self.module.params[
                baseline_arg_name]

    def do_resource_params_have_attr_with_id_or_display_name(self, attr):
        if (attr + "_id" in self.nsx_resource_params or
                attr + "_display_name" in self.nsx_resource_params):
            return True
        return False

    def get_id_using_attr_name_else_fail(self, attr_name, params,
                                         resource_base_url, resource_type):
        return self._get_id_using_attr_name(
            attr_name, params, resource_base_url, resource_type,
            fail_if_not_found=True)

    def exit_with_failure(self, msg, **kwargs):
        self.module.fail_json(msg=msg, **kwargs)

    def skip_delete(self):
        """
        Override in subclass if this resource is skipped to be deleted.
        Note that the children of this resource will still be deleted unless
        they override this method as well.
        """
        return False

    @classmethod
    def is_required_in_spec(cls):
        """
        Override in subclass if this resource is optional to be specified
        in the ansible playbook.
        """
        return False

    @classmethod
    def allows_multiple_resource_spec(cls):
        """
        Override in the resource class definition with False if only one
        resource can be associated with the parent. By default, we accept
        multiple
        """
        return True

    def _get_id_using_attr_name(self, attr_name, params,
                                resource_base_url, resource_type,
                                fail_if_not_found=True):
        # Pass attr_name '' or None to infer base resource's ID
        id_identifier = 'id'
        display_name_identifier = 'display_name'
        if attr_name:
            id_identifier = attr_name + "_id"
            display_name_identifier = attr_name + "_display_name"
        if id_identifier in params and params[id_identifier]:
            return params.pop(id_identifier)
        if (display_name_identifier in params and
                params[display_name_identifier]):
            resource_display_name = params.pop(display_name_identifier)
            # Use display_name as ID if ID is not specified.
            return (self.get_id_from_display_name(
                resource_base_url, resource_display_name, resource_type,
                not fail_if_not_found) or resource_display_name)
        if fail_if_not_found:
            # Incorrect usage of Ansible Module
            self.module.fail_json(
                msg="Please specify either {} id or display_name for the "
                    "resource {}".format(attr_name, str(resource_type)))

    def get_id_from_display_name(self, resource_base_url,
                                 resource_display_name,
                                 resource_type, ignore_not_found_error=True):
        try:
            # Get the id from the Manager
            (_, resp) = self._send_request_to_API(
                resource_base_url=resource_base_url)
            matched_resource = None
            for resource in resp:
                if (resource.__contains__('display_name') and
                        resource['display_name'] == resource_display_name):
                    if matched_resource is None:
                        matched_resource = resource
                    else:
                        # Multiple resources with same display_name!
                        # Ask the user to specify ID instead.
                        self.module.fail_json(
                            msg="Multiple {} found with display_name {}. "
                                "Please specify the resource using id in "
                                "the playbook.".format(resource_type,
                                                       resource_display_name))
            if matched_resource is not None:
                return matched_resource['id']
            else:
                if ignore_not_found_error:
                    return None
                else:
                    # No resource found with this display_name
                    self.module.fail_json(
                        msg="No {} found with display_name {} for the "
                            "specified configuration.".format(
                                resource_type, resource_display_name))
        except Exception as e:
            # Manager replied with invalid URL. It means that the resource
            # does not exist on the Manager. So, return the display_name
            return resource_display_name

    def _update_parent_info(self):
        # This update is always performed and should not be overriden by the
        # subresource's class
        self._parent_info["_parent"] = self

    def _make_ansible_arg_spec(self, supports_check_mode=True):
        """
            We read the arg_spec of all the resources associated that
            are associated with this resource and create one complete
            arg_spec.
        """
        if self.get_resource_name() in BASE_RESOURCES:
            self._arg_spec = {}
            # Update it with VMware arg spec
            self._arg_spec.update(
                PolicyCommunicator.get_vmware_argument_spec())

            # ... then update it with top most resource spec ...
            self._update_arg_spec_with_resource(
                self.resource_class, self._arg_spec)
            # Update with all sub-resources arg spec
            for sub_resources_class in self._get_sub_resources_class_of(
                    self.resource_class):
                self._update_arg_spec_with_all_resources(
                    sub_resources_class, self._arg_spec)

    def _update_arg_spec_with_resource(self, resource_class, arg_spec):
        # updates _arg_spec with resource_class's arg_spec
        resource_arg_spec = self._get_base_arg_spec_of_resource()
        resource_arg_spec.update(self._get_base_arg_spec_of_nsx_resource())
        resource_arg_spec.update(resource_class.get_resource_spec())
        if resource_class.__name__ not in BASE_RESOURCES:
            arg_spec.update(
                {
                    resource_class.get_spec_identifier(): dict(
                        options=resource_arg_spec,
                        required=resource_class.is_required_in_spec(),
                        type='dict',
                    )
                })
            if resource_class.allows_multiple_resource_spec():
                arg_spec[resource_class.get_spec_identifier()]['type'] = 'list'
                arg_spec[resource_class.get_spec_identifier()]['elements'] = (
                    'dict')
        else:
            arg_spec.update(resource_arg_spec)
        return resource_arg_spec

    def _update_arg_spec_with_all_resources(self, resource_class, arg_spec):
        # updates _arg_spec with resource_class's arg_spec and all it's
        # sub-resources
        resource_arg_spec = self._update_arg_spec_with_resource(
            resource_class, arg_spec)
        # go to each child of resource_class and update it
        for sub_resources_class in self._get_sub_resources_class_of(
                resource_class):
            self._update_arg_spec_with_all_resources(
                sub_resources_class, resource_arg_spec)

    def _get_base_arg_spec_of_nsx_resource(self):
        resource_base_arg_spec = {}
        resource_base_arg_spec.update(
            # these are the base args for any NSXT Resource
            display_name=dict(
                required=False,
                type='str'
            ),
            description=dict(
                required=False,
                type='str'
            ),
            tags=dict(
                required=False,
                type='list',
                elements='dict',
                options=dict(
                    scope=dict(
                        required=True,
                        type='str'
                    ),
                    tag=dict(
                        required=True,
                        type='str'
                    )
                )
            )
        )
        return resource_base_arg_spec

    def _get_base_arg_spec_of_resource(self):
        resource_base_arg_spec = {}
        resource_base_arg_spec.update(
            id=dict(
                type='str'
            ),
            state=dict(
                required=True,
                type='str',
                choices=['present', 'absent']
            ),
            create_or_update_subresource_first=dict(
                default=False,
                type='bool'
            ),
            delete_subresource_first=dict(
                default=True,
                type='bool'
            ),
            achieve_subresource_state_if_del_parent=dict(
                default=False,
                type='bool'
            ),
            do_wait_till_create=dict(
                default=False,
                type='bool'
            )
        )
        return resource_base_arg_spec

    def _extract_nsx_resource_params(self, resource_params):
        # extract the params belonging to this resource only.
        filtered_params = {}

        def filter_with_spec(spec):
            for key in spec.keys():
                if (key in resource_params and
                        resource_params[key] is not None):
                    filtered_params[key] = resource_params[key]

        filter_with_spec(self.get_resource_spec())
        filter_with_spec(self._get_base_arg_spec_of_nsx_resource())
        return filtered_params

    def _achieve_present_state(self, successful_resource_exec_logs):
        self.update_resource_params(self.nsx_resource_params)
        is_resource_updated = self.check_for_update(
            self.existing_resource, self.nsx_resource_params)
        if not is_resource_updated:
            # Either the resource does not exist or it exists but was not
            # updated in the YAML.
            if self.module.check_mode:
                successful_resource_exec_logs.append({
                    "changed": True,
                    "debug_out": self.resource_params,
                    "id": '12345',
                    "resource_type": self.get_resource_name()
                })
                return
            try:
                if self.existing_resource:
                    # Resource already exists
                    successful_resource_exec_logs.append({
                        "changed": False,
                        "id": self.id,
                        "message": "%s with id %s already exists." %
                        (self.get_resource_name(), self.id),
                        "resource_type": self.get_resource_name()
                    })
                    return
                # Create a new resource
                _, resp = self._send_request_to_API(
                    suffix="/" + self.id, method='PATCH',
                    data=self.nsx_resource_params)
                if self.do_wait_till_create() and not self._wait_till_create():
                    raise Exception

                successful_resource_exec_logs.append({
                    "changed": True,
                    "id": self.id,
                    "body": str(resp),
                    "message": "%s with id %s created." %
                    (self.get_resource_name(), self.id),
                    "resource_type": self.get_resource_name()
                })
            except Exception as err:
                srel = successful_resource_exec_logs
                self.module.fail_json(msg="Failed to add %s with id %s."
                                          "Request body [%s]. Error[%s]."
                                          % (self.get_resource_name(),
                                             self.id, self.nsx_resource_params,
                                             to_native(err)
                                             ),
                                      successfully_updated_resources=srel)
        else:
            # The resource exists and was updated in the YAML.
            if self.module.check_mode:
                successful_resource_exec_logs.append({
                    "changed": True,
                    "debug_out": self.resource_params,
                    "id": self.id,
                    "resource_type": self.get_resource_name()
                })
                return
            self.nsx_resource_params['_revision'] = \
                self.existing_resource['_revision']
            try:
                _, patch_resp = self._send_request_to_API(
                    suffix="/"+self.id, method="PATCH",
                    data=self.nsx_resource_params)
                # Get the resource again and compare version numbers
                _, updated_resource_spec = self._send_request_to_API(
                    suffix="/"+self.id, method="GET")
                if updated_resource_spec[
                        '_revision'] != self.existing_resource_revision:
                    successful_resource_exec_logs.append({
                        "changed": True,
                        "id": self.id,
                        "body": str(patch_resp),
                        "message": "%s with id %s updated." %
                        (self.get_resource_name(), self.id),
                        "resource_type": self.get_resource_name()
                    })
                else:
                    successful_resource_exec_logs.append({
                        "changed": False,
                        "id": self.id,
                        "message": "%s with id %s already exists." %
                        (self.get_resource_name(), self.id),
                        "resource_type": self.get_resource_name()
                    })
            except Exception as err:
                srel = successful_resource_exec_logs
                self.module.fail_json(msg="Failed to update %s with id %s."
                                          "Request body [%s]. Error[%s]." %
                                          (self.get_resource_name(), self.id,
                                           self.nsx_resource_params, to_native(
                                               err)
                                           ),
                                      successfully_updated_resources=srel)

    def _achieve_absent_state(self, successful_resource_exec_logs):
        if self.skip_delete():
            return

        if self.existing_resource is None:
            successful_resource_exec_logs.append({
                "changed": False,
                "msg": 'No %s exist with id %s' %
                (self.get_resource_name(), self.id),
                "resource_type": self.get_resource_name()
            })
            return
        if self.module.check_mode:
            successful_resource_exec_logs.append({
                "changed": True,
                "debug_out": self.resource_params,
                "id": self.id,
                "resource_type": self.get_resource_name()
            })
            return
        try:
            self._send_request_to_API(suffix="/" + self.id, method='DELETE')
            self._wait_till_delete()
            successful_resource_exec_logs.append({
                "changed": True,
                "id": self.id,
                "message": "%s with id %s deleted." %
                (self.get_resource_name(), self.id)
            })
        except Exception as err:
            srel = successful_resource_exec_logs
            self.module.fail_json(msg="Failed to delete %s with id %s. "
                                      "Error[%s]." % (self.get_resource_name(),
                                                      self.id, to_native(err)),
                                  successfully_updated_resources=srel)

    def _send_request_to_API(self, suffix="", ignore_error=False,
                             method='GET', data=None,
                             resource_base_url=None,
                             accepted_error_codes=set()):
        try:
            if not resource_base_url:
                if self.get_resource_name() not in BASE_RESOURCES:
                    resource_base_url = (self.resource_class.
                                         get_resource_base_url(
                                             parent_info=self._parent_info))
                else:
                    resource_base_url = (self.resource_class.
                                         get_resource_base_url(
                                             baseline_args=self.baseline_args))
            if not suffix:
                rc, resp = self.policy_communicator.get_all_results(
                    resource_base_url, ignore_errors=ignore_error)
            else:
                rc, resp = self.policy_communicator.request(
                    resource_base_url + suffix,
                    ignore_errors=ignore_error, method=method, data=data)
            return rc, resp

        except DuplicateRequestError:
            self.module.fail_json(msg='Duplicate request')
        except Exception as e:
            if (e.args[0] not in accepted_error_codes and
                    self.get_resource_name() in BASE_RESOURCES):
                msg = ('Received {} from NSX Manager. Please try '
                       'again. '.format(e.args[0]))
                if len(e.args) == 2 and e.args[1] and (
                        'error_message' in e.args[1]):
                    msg += e.args[1]['error_message']
                self.module.fail_json(msg=msg)
            raise e

    def get_all_resources_from_nsx(self):
        rc, resp = self._send_request_to_API()
        if rc != 200:
            self.module.fail_json(
                "Invalid URL to retrieve all configured {} NSX "
                "resources".format(self.get_spec_identifier()))
        return resp

    def _achieve_state(self, resource_params,
                       successful_resource_exec_logs=[]):
        """
            Achieves `present` or `absent` state as specified in the YAML.
        """
        if self.id == self.INCORRECT_ARGUMENT_NAME_VALUE:
            # The resource was not specified in the YAML.
            # So, no need to realize it.
            return
        if (self._state == "present" and
                self.create_or_update_subresource_first()):
            self.achieve_subresource_state(
                resource_params, successful_resource_exec_logs)
        if self._state == "absent" and self.delete_subresource_first():
            self.achieve_subresource_state(
                resource_params, successful_resource_exec_logs)

        if self._state == 'present':
            self._achieve_present_state(
                successful_resource_exec_logs)
        else:
            self._achieve_absent_state(successful_resource_exec_logs)

        if self._state == "present" and not (
                self.create_or_update_subresource_first()):
            self.achieve_subresource_state(
                resource_params,
                successful_resource_exec_logs=successful_resource_exec_logs)

        if self._state == "absent" and not self.delete_subresource_first():
            self.achieve_subresource_state(
                resource_params, successful_resource_exec_logs)

        if self.get_resource_name() in BASE_RESOURCES:
            changed = False
            for successful_resource_exec_log in successful_resource_exec_logs:
                if successful_resource_exec_log["changed"]:
                    changed = True
                    break
            srel = successful_resource_exec_logs
            self.module.exit_json(changed=changed,
                                  successfully_updated_resources=srel)

    def _get_sub_resources_class_of(self, resource_class):
        subresources = []
        for attr in resource_class.__dict__.values():
            if (inspect.isclass(attr) and
                    issubclass(attr, NSXTBaseRealizableResource)):
                subresources.append(attr)
        if hasattr(self, "_state") and self._state == "present":
            subresources.sort(key=lambda subresource:
                              subresource().get_resource_update_priority(),
                              reverse=True)
        else:
            subresources.sort(key=lambda subresource:
                              subresource().get_resource_update_priority(),
                              reverse=False)
        for subresource in subresources:
            yield subresource

    def _wait_till_delete(self):
        """
            Periodically checks if the resource still exists on the API server
            every 10 seconds. Returns after it has been deleted.
        """
        while True:
            try:
                self._send_request_to_API(
                    suffix="/" + self.id, accepted_error_codes=set([404]))
                time.sleep(10)
            except DuplicateRequestError:
                self.module.fail_json(msg='Duplicate request')
            except Exception:
                return

    def _wait_till_create(self):
        FAILED_STATES = ["failed"]
        IN_PROGRESS_STATES = ["pending", "in_progress"]
        SUCCESS_STATES = ["partial_success", "success"]
        try:
            count = 0
            while True:
                rc, resp = self._send_request_to_API(
                    suffix="/" + self.id, accepted_error_codes=set([404]))
                if 'state' in resp:
                    if any(resp['state'] in progress_status for progress_status
                            in IN_PROGRESS_STATES):
                        time.sleep(10)
                        count = count + 1
                        if count == 90:
                            # Wait for max 15 minutes for host to realize
                            return False
                    elif any(resp['state'] in progress_status for
                             progress_status in SUCCESS_STATES):
                        return True
                    else:
                        # Failed State
                        return False
                else:
                    if rc != 200:
                        time.sleep(1)
                        count = count + 1
                        if count == 90:
                            # Wait for max 15 minutes for host to realize
                            return False
                    else:
                        return True
        except Exception as err:
            return False

    def _fill_missing_resource_params(self, existing_params, resource_params):
        """
            resource_params: dict
            existing_params: dict
            Fills resource_params with the key:value from existing_params if
            missing in the former.
        """
        if not existing_params:
            return
        for k, v in existing_params.items():
            if k not in resource_params:
                resource_params[k] = v
            elif type(v).__name__ == 'dict':
                self._fill_missing_resource_params(v, resource_params[k])

    def _clean_none_resource_params(self, existing_params, resource_params):
        keys_to_remove = []
        for k, v in resource_params.items():
            if v is None and (
                    existing_params is None or k not in existing_params):
                keys_to_remove.append(k)
        for key in keys_to_remove:
            resource_params.pop(key)
        for k, v in resource_params.items():
            if type(v).__name__ == 'dict':
                self._clean_none_resource_params(existing_params, v)


================================================
FILE: plugins/module_utils/nsxt_resource_urls.py
================================================
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright 2020 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only
#
# 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.

# Hidden or not exposed URLS
_SITE_URL = '/infra/sites'
_DOMAIN_URL = '/infra/domains'
_ENFORCEMENT_POINT_URL = _SITE_URL + '/{}/enforcement-points'

IP_BLOCK_URL = '/infra/ip-blocks'

IP_POOL_URL = '/infra/ip-pools'
IP_ADDRESS_POOL_SUBNET_URL = IP_POOL_URL + '/{}/ip-subnets'

POLICY_GROUP_URL = _DOMAIN_URL + '/{}/groups'

SECURITY_POLICY_URL = _DOMAIN_URL + '/{}/security-policies'

SEGMENT_URL = '/infra/segments'
SEGMENT_PORT_URL = SEGMENT_URL + '/{}/ports'

TRANSPORT_ZONE_URL = _ENFORCEMENT_POINT_URL + '/{}/transport-zones'

L2_BRIDGE_EP_PROFILE_URL = _ENFORCEMENT_POINT_URL + '/{}/edge-bridge-profiles'

TIER_0_URL = '/infra/tier-0s'
TIER_0_STATIC_ROUTE_URL = TIER_0_URL + '/{}/static-routes'
TIER_0_LOCALE_SERVICE_URL = TIER_0_URL + '/{}/locale-services'
TIER_0_LS_INTERFACE_URL = TIER_0_LOCALE_SERVICE_URL + '/{}/interfaces'
TIER_0_BGP_NEIGHBOR_URL = TIER_0_LOCALE_SERVICE_URL + '/{}/bgp/neighbors'
TIER_0_BFD_PEERS = TIER_0_STATIC_ROUTE_URL + '/bfd-peers'

TIER_1_URL = '/infra/tier-1s'
TIER_1_STATIC_ROUTE_URL = TIER_1_URL + '/{}/static-routes'
TIER_1_LOCALE_SERVICE_URL = TIER_1_URL + '/{}/locale-services'
TIER_1_LS_INTERFACE_URL = TIER_1_LOCALE_SERVICE_URL + '/{}/interfaces'
TIER_1_BGP_NEIGHBOR_URL = TIER_1_LOCALE_SERVICE_URL + '/{}/bgp/neighbors'

IPV6_DAD_PROFILE_URL = '/infra/ipv6-dad-profiles'
IPV6_NDRA_PROFILE_URL = '/infra/ipv6-ndra-profiles'

DHCP_RELAY_CONFIG_URL = '/infra/dhcp-relay-configs'

EDGE_CLUSTER_URL = _ENFORCEMENT_POINT_URL + '/{}/edge-clusters'
EDGE_NODE_URL = EDGE_CLUSTER_URL + '/{}/edge-nodes'

VM_LIST_URL = '/virtual-machines'
VM_UPDATE_URL = '/virtual-machines'

BFD_PROFILE_URL = '/infra/bfd-profiles'

GATEWAY_POLICY_URL = _DOMAIN_URL + '/{}/gateway-policies'


================================================
FILE: plugins/module_utils/policy_communicator.py
================================================
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright 2018 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only
#
# 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.


import json
import hashlib

from ansible.module_utils.urls import open_url
from ansible.module_utils.six.moves.urllib.error import HTTPError
from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import get_certificate_file_path
from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import is_json

import six.moves.urllib.parse as urlparse


class PolicyCommunicator:

    __instances = dict()

    @staticmethod
    def check_for_authorization_header(request_headers):
        if 'Authorization' in request_headers:
            return True
        return False

    @staticmethod
    def get_instance(mgr_hostname, mgr_username=None, mgr_password=None,
                     nsx_cert_path=None, nsx_key_path=None, request_headers={},
                     ca_path=None, validate_certs=True):
        """
            Returns an instance of PolicyCommunicator associated with
            (mgr_hostname, mgr_username, mgr_password) or
            (mgr_hostname, nsx_cert_path, nsx_key_path)
        """
        if mgr_username is not None:
            if mgr_password is None:
                raise InvalidInstanceRequest("mgr_password ")
            key = tuple([mgr_hostname, mgr_username, mgr_password])
        elif nsx_cert_path is not None:
            if not nsx_cert_path.endswith('.p12') and nsx_key_path is None:
                raise InvalidInstanceRequest("nsx_key_path")
            key = tuple([mgr_hostname, nsx_cert_path, nsx_key_path])
        elif get_certificate_file_path('NSX_MANAGER_CERT_PATH') is not None:
            nsx_cert_path = get_certificate_file_path('NSX_MANAGER_CERT_PATH')
            key = tuple([mgr_hostname, nsx_cert_path])
        elif PolicyCommunicator.check_for_authorization_header(
                request_headers):
            key = tuple([request_headers['Authorization']])
        else:
            raise InvalidInstanceRequest("(mgr_username, mgr_password) or"
                                         "(nsx_cert_path, nsx_key_path), or "
                                         "environment variable "
                                         "'NSX_MANAGER_CERT_PATH'")
        if key not in PolicyCommunicator.__instances:
            PolicyCommunicator(key, mgr_hostname, mgr_username, mgr_password,
                               nsx_cert_path, nsx_key_path, request_headers,
                               ca_path, validate_certs)
        return PolicyCommunicator.__instances.get(key)

    def __init__(self, key, mgr_hostname, mgr_username, mgr_password,
                 nsx_cert_path, nsx_key_path, request_headers,
                 ca_path, validate_certs):
        if key in PolicyCommunicator.__instances:
            raise Exception("The associated PolicyCommunicator is"
                            " already present! Please use getInstance to"
                            " retrieve it.")
        else:
            self.use_basic_auth = False
            if mgr_username is not None:
                self.use_basic_auth = True
            self.mgr_username = mgr_username
            self.mgr_password = mgr_password
            self.nsx_cert_path = nsx_cert_path
            self.nsx_key_path = nsx_key_path

            self.request_headers = request_headers or {}
            self.request_headers.update({
                'Accept': 'application/json',
                'Content-Type': 'application/json'})

            self.ca_path = ca_path
            self.validate_certs = validate_certs

            self.policy_url = 'https://{}/policy/api/v1'.format(mgr_hostname)
            self.fabric_url = 'https://{}/api/v1/fabric'.format(mgr_hostname)
            self.active_requests = set()

            PolicyCommunicator.__instances[key] = self

    @staticmethod
    def get_vmware_argument_spec():
        return dict(
            hostname=dict(type='str', required=True),
            username=dict(type='str', required=False),
            password=dict(type='str', required=False, no_log=True),
            port=dict(type='int', default=443),
            validate_certs=dict(type='bool', required=False, default=True),
            nsx_cert_path=dict(type='str', required=False),
            nsx_key_path=dict(type='str', required=False),
            request_headers=dict(type='dict'),
            ca_path=dict(type='str')
        )

    def get_all_results(self, url, ignore_errors=False):
        NULL_CURSOR_PREFIX = '0000'
        rc, concatenate_response = self.request(
            url, ignore_errors=ignore_errors)
        if rc != 200:
            return rc, None
        cursor = concatenate_response.get('cursor', NULL_CURSOR_PREFIX)
        op = '&' if urlparse.urlparse(url).query else '?'
        url += op + 'cursor='
        while cursor and not cursor.startswith(NULL_CURSOR_PREFIX):
            rc, page = self.request(url + cursor, ignore_errors)
            if rc != 200:
                return rc, None
            concatenate_response['results'].extend(page.get('results', []))
            cursor = page.get('cursor', NULL_CURSOR_PREFIX)
        return rc, concatenate_response['results']

    def request(self, url, data=None, method='GET',
                use_proxy=True, force=False, last_mod_time=None,
                timeout=300, http_agent=None, ignore_errors=False, base_url='policy'):
        if base_url == 'policy':
            # prepend the policy url
            # this is the default behavior if base_url is not specified
            url = self.policy_url + url
        elif base_url == 'fabric':
            # prepend the fabric url
            url = self.fabric_url + url
        else:
            raise Exception("invalid base_url specified in request call")
        # create a request ID associated with this request
        request_id = self._get_request_id(url, data, method)
        if self.register_request(request_id):
            # new request
            try:
                # connect to the API server
                if data is not None:
                    data = json.dumps(data)
                response = open_url(url=url, data=data,
                                    headers=self.request_headers,
                                    method=method,
                                    use_proxy=use_proxy, force=force,
                                    last_mod_time=last_mod_time,
                                    timeout=timeout,
                                    validate_certs=self.validate_certs,
                                    url_username=self.mgr_username,
                                    url_password=self.mgr_password,
                                    http_agent=http_agent,
                                    force_basic_auth=self.use_basic_auth,
                                    client_cert=self.nsx_cert_path,
                                    client_key=self.nsx_key_path,
                                    ca_path=self.ca_path)
            except HTTPError as err:
                response = err
            resp_code = response.getcode()
            resp_raw_data = response.read().decode('utf-8')

            # request completed by the server
            self.active_requests.remove(request_id)

            try:
                resp_data = resp_raw_data
                # infer the response
                if resp_raw_data and is_json(resp_raw_data):
                    resp_data = json.loads(resp_raw_data)
            except Exception as e:
                if not ignore_errors:
                    raise Exception(resp_code, resp_raw_data)

            # return the approprate response code and data
            if resp_code >= 400 and not ignore_errors:
                raise Exception(resp_code, resp_data)
            if resp_data is not None and 'error_code' in resp_data:
                raise Exception(resp_data['error_code'], resp_data)
            else:
                return resp_code, resp_data
        else:
            raise DuplicateRequestError

    def _get_request_id(self, url, data=None, method='GET'):
        """
            Creates a hash from url, data, and method that can be used
            as a request ID.
        """
        request = dict()
        request["data"] = data
        request['request_url'] = url
        request['request_method'] = method

        return hashlib.sha256(
            json.dumps(request, sort_keys=True).encode('utf-8')).hexdigest()

    def register_request(self, request_id):
        """
            This creates a hash from URL and data and stores it in a cache.
            If a same hash is created, the request is identified as a duplicate
            and it returns False. Otherwise, returns True.
        """
        if request_id in self.active_requests:
            return False
        self.active_requests.add(request_id)
        return True


class DuplicateRequestError(Exception):
    pass


class InvalidInstanceRequest(Exception):

    message = "Invalid instance Request, missing {}"

    def __init__(self, missing_fields):
        super(Exception, self).__init__(self.message.format(missing_fields))


================================================
FILE: plugins/module_utils/policy_resource_specs/__init__.py
================================================


================================================
FILE: plugins/module_utils/policy_resource_specs/l2_bridge_ep_profile.py
================================================
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright 2020 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only
#
# 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.

SPEC = dict(
    edge_nodes_info=dict(
        required=True,
        type='list',
        elements='dict',
        options=dict(
            # Note that only default site_id and
            # enforcementpoint_id are used
            site_id=dict(
                type='str',
                default="default"
            ),
            enforcementpoint_id=dict(
                type='str',
                default="default"
            ),
            edge_cluster_id=dict(
                type='str'
            ),
            edge_cluster_display_name=dict(
                type='str'
            ),
            edge_node_id=dict(
                type='str'
            ),
            edge_node_display_name=dict(
                type='str'
            )
        )
    ),
    enforcementpoint_id=dict(
        type='str',
        default="default"
    ),
    failover_mode=dict(
        required=False,
        default="PREEMPTIVE",
        choices=["PREEMPTIVE", "NON_PREEMPTIVE"],
        type='str'
    ),
    ha_mode=dict(
        required=False,
        type='str',
        default="ACTIVE_STANDBY",
        choices=["ACTIVE_STANDBY"]
    ),
    site_id=dict(
        type='str',
        default="default"
    ),
)


================================================
FILE: plugins/module_utils/policy_resource_specs/security_policy.py
================================================
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright 2020 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only
#
# 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.

SPEC = dict(
    category=dict(
        required=False,
        type='str'
    ),
    comments=dict(
        required=False,
        type='str'
    ),
    connectivity_strategy=dict(
        required=False,
        type='str',
        choices=['WHITELIST', 'BLACKLIST', 'WHITELIST_ENABLE_LOGGING',
                 'BLACKLIST_ENABLE_LOGGING', 'NONE']
    ),
    domain_id=dict(
        required=False,
        type='str',
        default="default"
    ),
    locked=dict(
        required=False,
        type='bool'
    ),
    scheduler_path=dict(
        required=False,
        type='str'
    ),
    scope=dict(
        required=False,
        type='list'
    ),
    sequence_number=dict(
        required=False,
        type='int'
    ),
    stateful=dict(
        required=False,
        type='bool'
    ),
    rules=dict(
        required=False,
        type='list',
        elements='dict',
        options=dict(
            action=dict(
                required=True,
                type='str',
                choices=["ALLOW", "DROP", "REJECT"]
            ),
            description=dict(
                required=False,
                type='str'
            ),
            destination_groups=dict(
                required=True,
                type='list'
            ),
            destinations_excluded=dict(
                required=False,
                type='bool',
                default=False
            ),
            direction=dict(
                required=False,
                default="IN_OUT",
                type='str',
                choices=["IN_OUT", "IN", "OUT"]
            ),
            disabled=dict(
                required=False,
                type='bool',
                default=False
            ),
            display_name=dict(
                type='str'
            ),
            id=dict(
                type='str'
            ),
            ip_protocol=dict(
                type='str',
                choices=['IPV4', 'IPV6', 'IPV4_IPV6']
            ),
            logged=dict(
                type='bool',
                default=False
            ),
            notes=dict(
                type='str'
            ),
            profiles=dict(
                type='list',
                elements='str'
            ),
            scope=dict(
                type='list',
                elements='str'
            ),
            sequence_number=dict(
                required=False,
                type='int'
            ),
            service_entries=dict(
                type='list',
                elements='dict'
            ),
            services=dict(
                required=True,
                type='list'
            ),
            source_groups=dict(
                required=True,
                type='list'
            ),
            sources_excluded=dict(
                required=False,
                type='bool',
                default=False
            ),
            tag=dict(
                type='str'
            ),
            tags=dict(
                type='list',
                elements='dict',
                options=dict(
                    scope=dict(
                        type='str'
                    ),
                    tag=dict(
                        type='str'
                    )
                )
            ),
        )
    ),
    tcp_strict=dict(
        required=False,
        type='bool'
    )
)


================================================
FILE: plugins/module_utils/upgrade_reverse_order.py
================================================
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright 2019 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only
#
# 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.

from __future__ import absolute_import, division, print_function
import time
from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import request
from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.common_utils import get_upgrade_orchestrator_node
from ansible.module_utils._text import to_native


UPGRADE_API = '/upgrade/plan?action=upgrade'
UPGRADE_STATUS_SUMMARY_API = '/upgrade/status-summary'
MP_UPGRADE_DONE = False

def check_upgrade_status_at_start(module, manager_url, mgr_username, mgr_password, validate_certs):
   global MP_UPGRADE_DONE

   endpoint = "/upgrade/upgrade-unit-groups?sync=true"
   call_get_sync(manager_url, endpoint, mgr_username, mgr_password, validate_certs)
   
   upgrade_status_summary = get_upgrade_status_summary(module, manager_url, mgr_username, mgr_password, validate_certs , False)

   overall_upgrade_status = upgrade_status_summary['overall_upgrade_status']

   if overall_upgrade_status == 'PAUSED' :
      if upgrade_status_summary['component_status'][0]['status'] == 'SUCCESS':
         MP_UPGRADE_DONE = True

   return overall_upgrade_status

def get_upgrade_status_summary(module, manager_url, mgr_username, mgr_password, validate_certs , ignore_errors):
  '''
  Get the upgrade status summary
  '''

  try:
        (rc, resp) = request(manager_url+ UPGRADE_STATUS_SUMMARY_API, headers=dict(Accept='application/json'),
                      url_username=mgr_username, url_password=mgr_password, 
                      validate_certs=validate_certs, ignore_errors=ignore_errors)
  except Exception as err:
          if ignore_errors:
             return None
          else:
            module.fail_json(msg='Error while triggering api:'
                            ' %s. Error [%s]' % (manager_url+ UPGRADE_STATUS_SUMMARY_API, to_native(err)))
  return resp

def call_get_sync(managerUrl, endpoint, mgrUsername, mgrPassword, validateCerts):
    request(managerUrl + endpoint, method='GET', url_username=mgrUsername, url_password=mgrPassword,
            validate_certs=validateCerts, ignore_errors=True)

def check_component_upgrade_completion_status(module, manager_url, mgr_username, mgr_password, validate_certs):
   global MP_UPGRADE_DONE
   count_upgrade_status_api_no_resp = 0
   component_upgrade_start_time = time.time()

   while True:
      upgrade_status_summary = get_upgrade_status_summary(module, manager_url, mgr_username, mgr_password, validate_certs , True)

      if upgrade_status_summary == None:
        count_upgrade_status_api_no_resp +=1

      elif upgrade_status_summary.__contains__('overall_upgrade_status'):
         overall_upgrade_status = upgrade_status_summary['overall_upgrade_status']

         if overall_upgrade_status == 'SUCCESS':
            module.exit_json(changed=True, message='System has been upgraded successfully!!!')
            
         elif overall_upgrade_status == 'PAUSED':
            check_component_statuses(module , upgrade_status_summary['component_status'])
            if not MP_UPGRADE_DONE:
                MP_UPGRADE_DONE = True
            return
        
      elapsed_time = time.time() - component_upgrade_start_time
      if MP_UPGRADE_DONE and count_upgrade_status_api_no_resp >= 5:
        module.fail_json(msg='Error while triggering api:'
                    ' %s. API failed 5 times' %UPGRADE_STATUS_SUMMARY_API)
      elif not MP_UPGRADE_DONE and elapsed_time > 3600 :
         module.fail_json(msg='MP component upgrade took longer than 1hr, System upgrade failed')

      time.sleep(30)
       

def check_component_statuses(module, component_status_list):
    for component_status in component_status_list:
        if component_status['status'] == 'FAILED':
            module.fail_json(msg='Failed to upgrade system as Component : %s'
                        'has Status : %s ' %(component_status['component_type'], component_status['status']))
      
   

def execute_upgrade(module, manager_url, mgr_username, mgr_password, validate_certs):
   global MP_UPGRADE_DONE
   headers = dict(Accept="application/json")
   headers['Content-Type'] = 'application/json'

   while True:
      try:
        (rc, resp) = request(manager_url+ UPGRADE_API,
                        data='', headers=headers, method='POST', 
                        url_username=mgr_username, url_password=mgr_password, 
                        validate_certs=validate_certs, ignore_errors=False)
      except Exception as err:
        module.fail_json(msg="Failed while upgrading component")

      time.sleep(30)

      check_component_upgrade_completion_status(module, manager_url, mgr_username, mgr_password, validate_certs)

      

def trigger_upgrade_reverse_order(module, mgr_hostname, mgr_username, mgr_password, validate_certs):

    headers = dict(Accept="application/json")
    headers['Content-Type'] = 'application/json'

    mgr_hostname = get_upgrade_orchestrator_node(module, mgr_hostname, mgr_username, 
                                            mgr_password, headers, validate_certs)
    
    manager_url = 'https://{}/api/v1'.format(mgr_hostname)

    upgrade_status = check_upgrade_status_at_start(module, manager_url, mgr_username,
                                          mgr_password, validate_certs)

    if upgrade_status == 'IN_PROGRESS' or upgrade_status == 'PAUSING':
      module.fail_json(msg='Upgrade is in state: %s, can\'t continue' % upgrade_status)

    elif upgrade_status == 'SUCCESS':
      module.exit_json(changed=False, message='Upgrade state is SUCCESS. No need to'
                    ' continue.')
      
    elif upgrade_status == 'NOT_STARTED' or upgrade_status == 'PAUSED':
      execute_upgrade(module, manager_url, mgr_username, mgr_password, validate_certs)

================================================
FILE: plugins/module_utils/vcenter_utils.py
================================================
#!/usr/bin/python
# -*- coding: utf-8 -*-

# Copyright 2019 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only
# 
# 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.
import ssl
import requests
import atexit

try:
    from pyvim import connect
except:
    from pyVim import connect
from pyVmomi import vmodl
from pyVmomi import vim


def establish_vcenter_connection(module, vCenter_host, username, password, ignore_ssl_verification):
    """
    params:
    - vCenter_host: vCenter host IP
    - username: vCenter username
    - password: vCenter password
    result:
    Retrieves vCenter information from service instance and returns as content object.
    """
    if ignore_ssl_verification is False:
        try:
            sslContext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
            sslContext.verify_mode = ssl.CERT_NONE
            service_instance = connect.SmartConnect(host=vCenter_host,
                                                    user=username,
                                                    pwd=password,
                                                    port=443,
                                                    sslContext=sslContext)
            if not service_instance:
                module.fail_json(msg="Could not connect to the specified vCenter "
                                     "host using specified username and password")

            atexit.register(connect.Disconnect, service_instance)
        except vmodl.MethodFault as error:
            module.fail_json(msg="Caught vmodl fault while connecting to vCenter: " + error.msg)
    else:
        try:
            service_instance = connect.SmartConnect(host=vCenter_host,
                                                    user=username,
                                                    pwd=password,
                                                    port=443)
            if not service_instance:
                module.fail_json(msg="Could not connect to the specified vCenter "
                                     "host using specified username and password")

            atexit.register(connect.Disconnect, service_instance)
        except (requests.ConnectionError, ssl.SSLError):
            try:
                sslContext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
                sslContext.verify_mode = ssl.CERT_NONE
                service_instance = connect.SmartConnect(host=vCenter_host,
                                                        user=username,
                                                        pwd=password,
                                                        port=443,
                                                        sslContext=sslContext)
                if not service_instance:
                    module.fail_json(msg="Could not connect to the specified vCenter "
                                         "host using specified username and password")

                atexit.register(connect.Disconnect, service_instance)
            except vmodl.MethodFault as error:
                module.fail_json(msg="Caught vmodl fault while connecting to vCenter: " + error.msg)
    return service_instance.RetrieveContent()


def get_resource_id_from_name(module, vCenter_host, username, password,
                              resource_type, resource_name, ignore_ssl_verification):
    """
    params:
    - resource_type: Type of vCenter resource. Accepted values 'host', 'cluster', 'storage' and 'network'.
    - resource_name: Name of the resource.
    result:
    - moref id of the resource name and type given.
    """
    try:
        content = establish_vcenter_connection(module, vCenter_host, username, password, ignore_ssl_verification)
        if resource_type == 'host':
            objview = content.viewManager.CreateContainerView(content.rootFolder,
                                                              [vim.HostSystem], True)
        elif resource_type == 'cluster':
            objview = content.viewManager.CreateContainerView(content.rootFolder,
                                                              [vim.ClusterComputeResource], True)
        elif resource_type == 'storage':
            objview = content.viewManager.CreateContainerView(content.rootFolder,
                                                              [vim.Datastore], True)
        elif resource_type == 'network':
            objview = content.viewManager.CreateContainerView(content.rootFolder,
                                                              [vim.Network], True)
        else:
            module.fail_json(msg='Resource type provided by user either doesn\'t'
                                 ' exist or is not supported')
        all_resources = objview.view
        objview.Destroy()
        for resource in all_resources:
            if resource.name == resource_name:
                return resource._moId
        module.fail_json(msg='%s doesnt exist in %s' % (resource_name,
                                                        resource_type))
    except vmodl.MethodFault as error:
        print("Caught vmodl fault while fetching info from vCenter: " + error.msg)
        return -1


def get_data_network_id_from_name(module, vCenter_host, username, password,
                                  data_network_name_list, ignore_ssl_verification):
    """
    params:
    - data_network_name_list: List of data network names
    result:
    list of data network ids.
    """
    try:
        content = establish_vcenter_connection(module, vCenter_host, username, password, ignore_ssl_verification)
        objview = content.viewManager.CreateContainerView(content.rootFolder,
                                                          [vim.Network], True)
        all_networks = objview.view
        objview.Destroy()
        network_dict = {}
        for network in all_networks:
            network_dict[network.name] = network._moId
        data_network_id_list = []
        for data_network_name in data_network_name_list:
            if data_network_name in network_dict:
                data_network_id_list.append(str(network_dict[data_network_name]))
            else:
                module.fail_json(msg='data network %s doesnt exist in the available'
                                     'list of networks' % data_network_name)
        return data_network_id_list
    except vmodl.MethodFault as error:
        print("Caught vmodl fault while fetching info from vCenter: " + error.msg)


================================================
FILE: plugins/module_utils/vmware_nsxt.py
================================================
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright 2018 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only
# 
# 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.

import json, os, re
from ansible.module_utils.urls import open_url
from ansible.module_utils.six.moves.urllib.error import HTTPError
from ansible.module_utils._text import to_native

import six.moves.urllib.parse as urlparse

def vmware_argument_spec():
    return dict(
        hostname=dict(type='str', required=True),
        username=dict(type='str', required=False),
        password=dict(type='str', required=False, no_log=True),
        port=dict(type='int', default=443),
        validate_certs=dict(type='bool', required=False, default=True),
    )

def request(url, data=None, headers=None, method='GET', use_proxy=True,
            force=False, last_mod_time=None, timeout=300, validate_certs=True,
            url_username=None, url_password=None, http_agent=None, force_basic_auth=True, ignore_errors=False):
    '''
    The main function which hits the request to the manager. Username and password are given the topmost priority.
    In case username and password are not provided if the environment variable is set.
    Authentication fails if the details are not correct.
    '''
    if url_username is None or url_password is None:
        force_basic_auth = False
        client_cert = get_certificate_file_path('NSX_MANAGER_CERT_PATH')
        if client_cert is None:
            raise Exception('It seems that either you have not passed your username password correctly or '
                'your path for NSX_MANAGER_CERT_PATH is not set correctly.')
    else:
        client_cert = None

    if method == 'GET':
        return get_all_results(
            url, data, headers, method, use_proxy, force, last_mod_time,
            timeout, validate_certs, url_username, url_password, http_agent,
            force_basic_auth, ignore_errors, client_cert)
    return _request(
        url, data, headers, method, use_proxy, force, last_mod_time, timeout,
        validate_certs, url_username, url_password, http_agent,
        force_basic_auth, ignore_errors, client_cert)

def get_all_results(
        url, data, headers, method, use_proxy, force, last_mod_time, timeout,
        validate_certs, url_username, url_password, http_agent,
        force_basic_auth, ignore_errors, client_cert):
    rc, resp = _request(
        url, data, headers, method, use_proxy, force, last_mod_time, timeout,
        validate_certs, url_username, url_password, http_agent,
        force_basic_auth, ignore_errors, client_cert)
    if rc != 200:
        return rc, None
    cursor = resp.get('cursor')
    op = '&' if urlparse.urlparse(url).query else '?'
    url += op + 'cursor='
    NULL_CURSOR_PREFIX = '0000'
    while cursor and not cursor.startswith(NULL_CURSOR_PREFIX):
        rc, page = _request(
            url + cursor, data, headers, method, use_proxy, force,
            last_mod_time, timeout, validate_certs, url_username,
            url_password, http_agent, force_basic_auth, ignore_errors,
            client_cert)
        if rc != 200:
            return rc, None
        resp['results'].extend(page.get('results', []))
        cursor = page.get('cursor')
    return rc, resp

def _request(url, data, headers, method, use_proxy,
             force, last_mod_time, timeout, validate_certs,
             url_username, url_password, http_agent, force_basic_auth,
             ignore_errors, client_cert):
    ca_path = get_certificate_file_path('NSX_MANAGER_CA_PATH')
    resp_data = None
    try:
        r = open_url(
            url=url, data=data, headers=headers, method=method,
            use_proxy=use_proxy, force=force, last_mod_time=last_mod_time,
            timeout=timeout, validate_certs=validate_certs,
            url_username=url_username, url_password=url_password,
            http_agent=http_agent, client_cert=client_cert,
            force_basic_auth=force_basic_auth, ca_path=ca_path)
    except HTTPError as err:
        r = err

    try:
        raw_data = r.read().decode('utf-8')
        if raw_data:
            if is_json(raw_data):
                resp_data = json.loads(raw_data)
            else:
                resp_data = raw_data
    except Exception:
        if not ignore_errors:
            raise

    resp_code = r.getcode()

    if resp_code >= 400 and not ignore_errors:
        raise Exception(resp_code, resp_data)
    if not (resp_data is None) and resp_data.__contains__('error_code'):
        raise Exception (resp_data['error_code'], resp_data)
    return resp_code, resp_data

def get_certificate_string(crt_file):
    '''
    param: crt_file is the file containing the public key string
    result: returns the public key(client certificate) string to be passed to the payload
    how: String matching
    '''
    f = open(crt_file, 'r')
    file_content = f.read()
    file_content = file_content.split("\n")
    certificate_string = ""
    got_line_start = False
    for string in file_content:
        if string == "-----BEGIN CERTIFICATE-----":
            got_line_start = True
            certificate_string = certificate_string + string + "\n"
        elif string == "-----END CERTIFICATE-----":
            certificate_string = certificate_string + "\n" + string
            break
        elif got_line_start:
            certificate_string = certificate_string + string
        else:
            pass
    f.close()
    return certificate_string

def get_private_key_string(p12_file):
    '''
    param: p12_file is the file containing the private key string
    result: returns the private key string to be passed to the payload
    how: String matching
    '''
    f = open(p12_file, 'r')
    file_content = f.read()
    file_content = file_content.split("\n")
    certificate_string = ""
    got_start_line = False
    for string in file_content:
        if re.match("-+BEGIN[ \w]+PRIVATE[ ]+KEY-+", string):
            got_start_line = True
            certificate_string = certificate_string + string + "\n"
        elif re.match("-+END[ \w]+PRIVATE[ ]+KEY-+", string):
            certificate_string = certificate_string + "\n" + string
            break
        elif got_start_line:
            certificate_string = certificate_string + string
        else:
            pass
    f.close()
    return certificate_string

def get_certificate_file_path(environment_variable):
    return os.getenv(environment_variable)

def get_vc_ip_from_display_name(module, manager_url, mgr_username, mgr_password,
                                validate_certs, endpoint, display_name,
                                exit_if_not_found=True):
    '''
    param:
    display_name: Display name of the vC
    result:
    IP of the vC name provided
    '''
    try:
      (rc, resp) = request(manager_url+ endpoint, headers=dict(Accept='application/json'),
                      url_username=mgr_username, url_password=mgr_password,
                      validate_certs=validate_certs, ignore_errors=True)
    except Exception as err:
      module.fail_json(msg='Error occured while retrieving vCenter IP for %s. '
                           'Error [%s]' % (display_name, to_native(err)))

    for result in resp['results']:
        if result.__contains__('display_name') and result['display_name'] == display_name:
            return result['server']
    if exit_if_not_found:
        module.fail_json(msg='vCenter with display name %s doesn\'t exist.' % display_name)
        return -1

def is_json(myjson):
    '''
    Param:
    myjson: String to be checked
    result:
    Checks if the string is valid json or not.
    '''
    try:
        json_object = json.loads(myjson)
    except ValueError as e:
        return False
    return True

def version_tuple(v):
    return tuple(map(int, (v.split("."))))[:3] # Ignore build number

def get_nsx_version(module, manager_url, mgr_username, mgr_password, validate_certs):
    try:
        (rc, resp) = request(manager_url+ '/node/version', headers=dict(Accept='application/json'),
                             url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True)
    except Exception as err:
        module.fail_json(msg='Failed to retrieve NSX version. Error [%s]' % (to_native(err)))
    return resp

def validate_nsx_mp_support(module, manager_url, mgr_username, mgr_password, validate_certs, err_msg=None):
    version = get_nsx_version(module, manager_url, mgr_username, mgr_password, validate_certs)

    # MP resources deprecated since v9.0.0
    if version_tuple(version["product_version"]) >= version_tuple("9.0.0"):
        if err_msg is None:
            err_msg = 'NSX v9.0.0 and above do not support MP resources.'
        module.fail_json(msg=err_msg)


================================================
FILE: plugins/modules/__init__.py
================================================


================================================
FILE: plugins/modules/nsxt_certificates.py
================================================
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright 2018 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only
#
# 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.

from __future__ import absolute_import, division, print_function
__metaclass__ = type


ANSIBLE_METADATA = {'metadata_version': '1.1',
                    'status': ['preview'],
                    'supported_by': 'community'}

DOCUMENTATION = '''
---
module: nsxt_certificates
short_description: 'Add a New Certificate'
description: "Adds a new private-public certificate or a chain of certificates (CAs) and, 
              optionally, a private key that can be applied to one of the user-facing 
              components (appliance management or edge). The certificate and the key 
              should be stored in PEM format. If no private key is provided, the 
              certificate is used as a client certificate in the trust store."
version_added: '2.7'
author: 'Kommireddy Akhilesh'
options:
    hostname:
        description: 'Deployed NSX manager hostname.'
        required: true
        type: str
    username:
        description: 'The username to authenticate with the NSX manager.'
        required: true
        type: str
    password:
        description: 'The password to authenticate with the NSX manager.'
        required: true
        type: str
    display_name:
        description: 'Identifier to use when displaying entity in logs or GUI'
        required: true
        type: str
    pem_encoded_file:
        description: 'File containing pem encoded certificate data'
        required: true
        type: str
    private_key_file:
        description: 'File containing private key data'
        required: false
        type: str
    passphrase:
        description: 'Password for private key encryption'
        required: false
        type: str
    description:
        description: 'Description of this resource'
        required: false
        type: str
    id:
        description: 'Unique identifier of this resource'
        required: false
        type: str
    key_algo:
        description: 'Key algorithm contained in this certificate'
        required: false
        type: str
    resource_type:
        description: 'Must be set to the value TrustObjectData'
        required: false
        type: str
    tags:
        description: Opaque identifier meaninful to API user
        required: false
        type: Array of Tag
    state:
        choices:
            - present
            - absent
        description: "State can be either 'present' or 'absent'.
                      'present' is used to create or update resource.
                      'absent' is used to delete resource."
        required: true

'''

EXAMPLES = '''
- hosts: 127.0.0.1
  connection: local
  become: yes
  vars_files:
    - answerfile.yml
  tasks:
    - name: Add a new certificate
      nsxt_certificates:
        hostname: "{{hostname}}"
        username: "{{username}}"
        password: "{{password}}"
        validate_certs: False
        display_name: "Certificate_file"
        pem_encoded_file: "/Path/to/crt/file"
        passphrase: "paraphrase"
        state: "present"
'''

RETURN = '''# '''

import json, time
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request, get_certificate_string, get_private_key_string
from ansible.module_utils._text import to_native

def update_params_with_pem_encoding(certificate_params):
    '''
    params: Parameters passed to the certificate
    result: Updated parameters. Files are replaced with the public and private strings. 
    '''
    certificate_params['pem_encoded'] = get_certificate_string (certificate_params.pop('pem_encoded_file', None))
    if certificate_params.get('private_key_file') is not None:
        certificate_params['private_key'] = get_private_key_string (certificate_params.pop('private_key_file', None))
    return certificate_params

def get_certificate_params(args=None):
    args_to_remove = ['state', 'username', 'password', 'port', 'hostname', 'validate_certs']
    for key in args_to_remove:
        args.pop(key, None)
    for key, value in args.copy().items():
        if value == None:
            args.pop(key, None)
    return args

def get_certificates(module, manager_url, mgr_username, mgr_password, validate_certs):
  try:
    (rc, resp) = request(manager_url+ '/trust-management/certificates', headers=dict(Accept='application/json'),
                      url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True)
  except Exception as err:
    module.fail_json(msg='Error accessing trust management certificates. Error [%s]' % (to_native(err)))
  return resp

def get_certificate_with_display_name(module, manager_url, mgr_username, mgr_password, validate_certs, display_name):
  '''
  result: returns the certificate object with the display name provided
  '''
  certificates = get_certificates(module, manager_url, mgr_username, mgr_password, validate_certs)
  for certificate in certificates['results']:
     if certificate.__contains__('display_name') and certificate['display_name'] == display_name:
        return certificate
  return None

def main():
  argument_spec = dict()
  argument_spec.update(hostname=dict(type='str', required=True),
                       username=dict(type='str', required=True),
                       password=dict(type='str', required=True, no_log=True),
                       port=dict(type='int', default=443),
                       validate_certs=dict(type='bool', requried=False, default=True),
                       display_name=dict(required=True, type='str'),
                       pem_encoded_file=dict(required=False, type='str', no_log=True), 
                       private_key_file=dict(required=False, type='str', no_log=True),
                       passphrase=dict(required=False, type='str', no_log=True),
                       description=dict(required=False, type='str'),
                       id=dict(required=False, type='str'),
                       key_algo=dict(required=False, type='str'),
                       resource_type=dict(required=False, type='str'),
                       tags=dict(required=False, type='list'),
                    state=dict(required=True, choices=['present', 'absent']))
  '''
  Core function of the module reponsible for adding and deleting the certififcate.
  '''

  module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
  certificate_params = get_certificate_params(module.params.copy())
  state = module.params['state']
  mgr_hostname = module.params['hostname']
  mgr_username = module.params['username']
  mgr_password = module.params['password']
  validate_certs = module.params['validate_certs']
  display_name = module.params['display_name']

  manager_url = 'https://{}/api/v1'.format(mgr_hostname)

  certificate_with_display_name = get_certificate_with_display_name(module, manager_url, mgr_username, mgr_password, validate_certs, display_name)


  if state == 'present':
    # add the certificate
    if certificate_with_display_name:
      module.fail_json(msg="Certificate with display name \'%s\' already exists." % display_name)  
    try:
      certificate_params = update_params_with_pem_encoding(certificate_params)
      headers = dict(Accept="application/json")
      headers['Content-Type'] = 'application/json'
      request_data = json.dumps(certificate_params)
      (rc, resp) = request(manager_url+ '/trust-management/certificates?action=import', data=request_data, headers=headers, method='POST',
                              url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True)
    except Exception as err:
      module.fail_json(msg="Failed to add certificate.\n Error: [%s].\n Request_body[%s]." % (to_native(err), request_data))

    time.sleep(5)
    module.exit_json(changed=True, result=resp, message="certificate created. Response: [%s]" % str(resp))

  elif state == 'absent': 
    #Delete the certificate   
    if not certificate_with_display_name:
      module.fail_json(msg="Certificate with display name \'%s\' doesn't exists." % display_name)
    certificate_id = certificate_with_display_name['id']
    try:
       (rc, resp) = request(manager_url+ '/trust-management/certificates/' + certificate_id, method='DELETE',
                            url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True)
    except Exception as err:
      module.fail_json(msg="Failed to delete certificate with display name \'%s\'. Error[%s]." % (display_name, to_native(err)))

    time.sleep(5)
    module.exit_json(changed=True, object_name=certificate_id, message="Certificate with certificate id: %s deleted." % certificate_id)


if __name__ == '__main__':
    main()


================================================
FILE: plugins/modules/nsxt_certificates_facts.py
================================================
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright 2020 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only
# 
# 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.

from __future__ import absolute_import, division, print_function
__metaclass__ = type


ANSIBLE_METADATA = {'metadata_version': '1.1',
                    'status': ['preview'],
                    'supported_by': 'community'}

DOCUMENTATION = '''
---
module: nsxt_certificates_facts
short_description: List all existing certificates
description: Returns all certificate information viewable by the user, including each
             certificate's UUID; resource_type (for example, certificate_self_signed,
             certificate_ca, or certificate_signed); pem_encoded data; and history of the
             certificate (who created or modified it and when). For additional
             information, include the ?details=true modifier at the end of the request
             URI.
version_added: "2.7"
author: Rahul Raghuvanshi
options:
    hostname:
        description: Deployed NSX manager hostname.
        required: true
        type: str
    username:
        description: The username to authenticate with the NSX manager.
        required: true
        type: str
    password:
        description: The password to authenticate with the NSX manager.
        required: true
        type: str


'''

EXAMPLES = '''
- name: List all existing certificates
  nsxt_certificates_facts:
      hostname: "10.192.167.137"
      username: "admin"
      password: "Admin!23Admin"
      validate_certs: False
'''

RETURN = '''# '''

import json
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request
from ansible.module_utils._text import to_native

def main():
  argument_spec = vmware_argument_spec()

  module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)

  mgr_hostname = module.params['hostname']
  mgr_username = module.params['username']
  mgr_password = module.params['password']
  validate_certs = module.params['validate_certs']

  manager_url = 'https://{}/api/v1'.format(mgr_hostname)

  changed = False
  try:
    (rc, resp) = request(manager_url+ '/trust-management/certificates', headers=dict(Accept='application/json'),
                    url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True)
  except Exception as err:
    module.fail_json(msg='Error accessing transport zone. Error [%s]' % (to_native(err)))

  module.exit_json(changed=changed, **resp)
if __name__ == '__main__':
	main()


================================================
FILE: plugins/modules/nsxt_cluster_profiles.py
================================================
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright 2020 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only
#
# 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.

from __future__ import absolute_import, division, print_function
__metaclass__ = type

ANSIBLE_METADATA = {'metadata_version': '1.1',
                    'status': ['preview'],
                    'supported_by': 'community'}


DOCUMENTATION = '''
---
module: nsxt_cluster_profiles
short_description: 'Create a Cluster Profile'
description: "Create a cluster profile. The resource_type is required."
version_added: '2.7'
author: 'Kommireddy Akhilesh'
options:
    hostname:
        description: 'Deployed NSX manager hostname.'
        required: true
        type: str
    username:
        description: 'The username to authenticate with the NSX manager.'
        required: true
        type: str
    password:
        description: 'The password to authenticate with the NSX manager.'
        required: true
        type: str
    display_name:
        description: 'Display name'
        required: true
        type: str
    description:
        description: Description of the resource
        required: false
        type: str
    
    state:
        choices:
            - present
            - absent
        description: "State can be either 'present' or 'absent'.
                      'present' is used to create or update resource.
                      'absent' is used to delete resource."
        required: true

    
'''

EXAMPLES = '''
  - name: Create Cluster Profiles
    nsxt_cluster_profiles:
      hostname: "10.192.167.137"
      username: "admin"
      password: "Admin!23Admin"
      validate_certs: False `
      resource_type: EdgeHighAvailabilityProfile
      display_name: edge-cluster-profile-East
      bfd_probe_interval: 1000
      bfd_declare_dead_multiple: 3
      bfd_allowed_hops: 1
      state: present
'''

RETURN = '''# '''

import json
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request
from ansible.module_utils._text import to_native


def get_cluster_profiles_params(args=None):
    args_to_remove = ['state', 'username', 'password', 'port', 'hostname', 'validate_certs']
    for key in args_to_remove:
        args.pop(key, None)
    for key, value in args.copy().items():
        if value == None:
            args.pop(key, None)
    return args

def get_cluster_profiles(module, manager_url, mgr_username, mgr_password, validate_certs):
    try:
      (rc, resp) = request(manager_url+ '/cluster-profiles', headers=dict(Accept='application/json'),
                      url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True)
    except Exception as err:
      module.fail_json(msg='Error accessing edge clusters. Error [%s]' % (to_native(err)))
    return resp

def get_id_from_display_name(module, manager_url, mgr_username, mgr_password, validate_certs, endpoint, display_name):
    try:
      (rc, resp) = request(manager_url+ endpoint, headers=dict(Accept='application/json'),
                      url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True)
    except Exception as err:
      module.fail_json(msg='Error accessing id for display name %s. Error [%s]' % (display_name, to_native(err)))

    for result in resp['results']:
        if result.__contains__('display_name') and result['display_name'] == display_name:
            return result['id']
    module.fail_json(msg='No id exist with display name %s' % display_name)

def cmp_dict(dict1, dict2):
    for k2, v2 in dict2.items():
        found = False
        if k2 not in dict1:
            continue
        if type(v2) != list and dict1[k2] != dict2[k2]:
            return False
        for obj2 in v2:
            for obj1 in dict1[k2]:
                if all(item in obj1.items() for item in obj2.items()):
                           found = True
        if not found:
            return False
    return True

def get_cluster_profiles_from_display_name(module, manager_url, mgr_username, mgr_password, validate_certs, display_name):
    cluster_profiles = get_cluster_profiles(module, manager_url, mgr_username, mgr_password, validate_certs)
    for cluster_profile in cluster_profiles['results']:
        if cluster_profile.__contains__('display_name') and cluster_profile['display_name'] == display_name:
            return cluster_profile
    return None

# def ordered(obj):
#     if isinstance(obj, dict):
#         return sorted((k, ordered(v)) for k, v in obj.items())
#     if isinstance(obj, list):
#         return sorted(ordered(x) for x in obj)
#     else:
#         return obj

def check_for_update(module, manager_url, mgr_username, mgr_password, validate_certs, cluster_profiles_body):
    existing_edge_cluster = get_cluster_profiles_from_display_name(module, manager_url, mgr_username, mgr_password, validate_certs, cluster_profiles_body['display_name'])
    if existing_edge_cluster is None:
        return False
    if existing_edge_cluster.__contains__('description') and not cluster_profiles_body.__contains__('description'):
        return True
    if not existing_edge_cluster.__contains__('description') and cluster_profiles_body.__contains__('description'):
        return True
    if existing_edge_cluster.__contains__('description') and cluster_profiles_body.__contains__('description') and \
        existing_edge_cluster['description'] != cluster_profiles_body['description']:
        return True
    if existing_edge_cluster.__contains__('bfd_allowed_hops') and not cluster_profiles_body.__contains__('bfd_allowed_hops'):
        return True
    if not existing_edge_cluster.__contains__('bfd_allowed_hops') and cluster_profiles_body.__contains__('bfd_allowed_hops'):
        return True
    if existing_edge_cluster.__contains__('bfd_allowed_hops') and cluster_profiles_body.__contains__('bfd_allowed_hops') and \
        existing_edge_cluster['bfd_allowed_hops'] != cluster_profiles_body['bfd_allowed_hops']:
        return True
    if existing_edge_cluster.__contains__('bfd_declare_dead_multiple') and not cluster_profiles_body.__contains__('bfd_declare_dead_multiple'):
        return True
    if not existing_edge_cluster.__contains__('bfd_declare_dead_multiple') and cluster_profiles_body.__contains__('bfd_declare_dead_multiple'):
        return True
    if existing_edge_cluster.__contains__('bfd_declare_dead_multiple') and cluster_profiles_body.__contains__('bfd_declare_dead_multiple') and \
        existing_edge_cluster['bfd_declare_dead_multiple'] != cluster_profiles_body['bfd_declare_dead_multiple']:
        return True
    if existing_edge_cluster.__contains__('standby_relocation_config') and not cluster_profiles_body.__contains__('standby_relocation_config'):
        return True
    if not existing_edge_cluster.__contains__('standby_relocation_config') and cluster_profiles_body.__contains__('standby_relocation_config'):
        return True
    if existing_edge_cluster.__contains__('standby_relocation_config') and cluster_profiles_body.__contains__('standby_relocation_config') and \
        not cmp_dict(existing_edge_cluster['standby_relocation_config'], cluster_profiles_body['standby_relocation_config']):
        return True
    return False

def update_params_with_id (module, manager_url, mgr_username, mgr_password, validate_certs, cluster_profile_params):
    return cluster_profile_params

def get_profile_id_from_profile_name(module, manager_url, mgr_username, mgr_password, validate_certs, display_name):
    cluster_profiles = get_cluster_profiles(module, manager_url, mgr_username, mgr_password, validate_certs)
    for cluster_profile in cluster_profiles['results']:
        if cluster_profile.__contains__('display_name') and cluster_profile['display_name'] == display_name:
            return cluster_profile['id']
    module.fail_json(msg='No id exist with display name %s' % display_name)

def update_params_with_profile_id(module, manager_url, mgr_username, mgr_password, validate_certs, edge_cluster_params):
    if edge_cluster_params.__contains__('cluster_profile_bindings'):
        for cluster_profile in edge_cluster_params['cluster_profile_bindings']:
            cluster_profile_name = cluster_profile.pop('profile_name', None)
            cluster_profile['profile_id'] = get_profile_id_from_profile_name(module, manager_url, mgr_username, mgr_password, validate_certs, cluster_profile_name)
    return edge_cluster_params

def main():
  argument_spec = vmware_argument_spec()
  argument_spec.update(display_name=dict(required=True, type='str'),
                        description=dict(required=False, type='str'),
                        resource_type=dict(required=True, type='str'),
                        bfd_allowed_hops=dict(required=False, type='int'),
                        bfd_declare_dead_multiple=dict(required=False, type='int'),
                        bfd_probe_interval=dict(required=False, type='int'),
                        standby_relocation_config=dict(required=False, type=dict,
                        standby_relocation_threshold=dict(required=False, type='int')),
                        tags=dict(required=False, type='list'),
                        state=dict(required=True, choices=['present', 'absent']))

  module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
  cluster_profile_params = get_cluster_profiles_params(module.params.copy())
  state = module.params['state']
  mgr_hostname = module.params['hostname']
  mgr_username = module.params['username']
  mgr_password = module.params['password']
  validate_certs = module.params['validate_certs']
  display_name = module.params['display_name']

  manager_url = 'https://{}/api/v1'.format(mgr_hostname)

  cluster_profiles_dict = get_cluster_profiles_from_display_name (module, manager_url, mgr_username, mgr_password, validate_certs, display_name)
  cluster_profile_id, revision = None, None
  if cluster_profiles_dict:
    cluster_profile_id = cluster_profiles_dict['id']
    revision = cluster_profiles_dict['_revision']

  if state == 'present':
    body = update_params_with_id(module, manager_url, mgr_username, mgr_password, validate_certs, cluster_profile_params)
    updated = check_for_update(module, manager_url, mgr_username, mgr_password, validate_certs, body)
    headers = dict(Accept="application/json")
    headers['Content-Type'] = 'application/json'

    if not updated:
      # add the edge_cluster
      request_data = json.dumps(body)
      if module.check_mode:
        module.exit_json(changed=True, debug_out=str(request_data), id='12345')
      try:
          if cluster_profile_id:
            module.exit_json(changed=False, id=cluster_profile_id, message="Cluster profile with display_name %s already exist."% module.params['display_name'])
          (rc, resp) = request(manager_url+ '/cluster-profiles', data=request_data, headers=headers, method='POST',
                                url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True)
      except Exception as err:
                module.fail_json(msg="Failed to add cluster profile. Request body [%s]. Error[%s]." % (request_data, to_native(err)))
      module.exit_json(changed=True, id=resp["id"], body= str(resp), message="Cluster profile with display name %s created." % module.params['display_name'])
    else:
      if module.check_mode:
        module.exit_json(changed=True, debug_out=str(json.dumps(edge_cluster_params)), id=cluster_profile_id)
      body['_revision'] = revision # update current revision
      request_data = json.dumps(body)
      id = cluster_profile_id
      try:
          (rc, resp) = request(manager_url+ '/cluster-profiles/%s' % id, data=request_data, headers=headers, method='PUT',
                                url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True)
      except Exception as err:
          module.fail_json(msg="Failed to update cluster profile with id %s. Request body [%s]. Error[%s]." % (id, request_data, to_native(err)))
      module.exit_json(changed=True, id=resp["id"], body= str(resp), message="Cluster profile with id %s updated." % id)

  elif state == 'absent':
    # delete the edge cluster
    id = cluster_profile_id
    if id is None:
        module.exit_json(changed=False, msg='No cluster profile exist with display name %s' % display_name)

    if module.check_mode:
        module.exit_json(changed=True, debug_out=str(json.dumps(edge_cluster_params)), id=id)
    try:
        (rc, resp) = request(manager_url + "/cluster-profiles/%s" % id, method='DELETE',
                              url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs)
    except Exception as err:
        module.fail_json(msg="Failed to delete cluster profile with id %s. Error[%s]." % (id, to_native(err)))

    module.exit_json(changed=True, id=id, message="Cluster profile with id %s deleted." % id)


if __name__ == '__main__':
    main()


================================================
FILE: plugins/modules/nsxt_cluster_profiles_facts.py
================================================
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright 2018 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only
# 
# 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.

from __future__ import absolute_import, division, print_function
__metaclass__ = type

ANSIBLE_METADATA = {'metadata_version': '1.1',
                    'status': ['preview'],
                    'supported_by': 'community'}


DOCUMENTATION = '''
---
module: nsxt_cluster_profiles_facts
short_description: List Cluster Profiles
description: Returns paginated list of cluster profiles
             Cluster profiles define policies for edge cluster and bridge cluster.

version_added: "2.7"
author: Kommireddy Akhilesh
options:
    hostname:
        description: Deployed NSX manager hostname.
        required: true
        type: str
    username:
        description: The username to authenticate with the NSX manager.
        required: true
        type: str
    password:
        description: The password to authenticate with the NSX manager.
        required: true
        type: str
'''

EXAMPLES = '''
- name: List Cluster Profiles
  nsxt_cluster_profiles_facts:
    hostname: "10.192.167.137"
    username: "admin"
    password: "Admin!23Admin"
    validate_certs: False
'''

RETURN = '''# '''

import json
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request
from ansible.module_utils._text import to_native

def main():
  argument_spec = vmware_argument_spec()
  module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)

  mgr_hostname = module.params['hostname']
  mgr_username = module.params['username']
  mgr_password = module.params['password']
  validate_certs = module.params['validate_certs']
  manager_url = 'https://{}/api/v1'.format(mgr_hostname)

  changed = False
  try:
    (rc, resp) = request(manager_url+ '/cluster-profiles', headers=dict(Accept='application/json'),
                    url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True)
  except Exception as err:
    module.fail_json(msg='Error accessing list of edge cluster. Error [%s]' % (to_native(err)))

  module.exit_json(changed=changed, **resp)
if __name__ == '__main__':
	main()


================================================
FILE: plugins/modules/nsxt_deploy_ova.py
================================================
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright 2018 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only
#
# 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.

from __future__ import absolute_import, division, print_function
__metaclass__ = type

ANSIBLE_METADATA = {'metadata_version': '1.1',
                    'status': ['preview'],
                    'supported_by': 'community'}


DOCUMENTATION = '''
---
module: nsxt_deploy_ova
short_description: Deploys NSXT Manager
description: Deploys NSXT Manager
version_added: "2.7"
author: Rahul Raghuvanshi
options:
    hostname:
        description: Deployed NSX manager hostname.
        required: true
        type: str
    username:
        description: The username to authenticate with the NSX manager.
        required: true
        type: str
    password:
        description: The password to authenticate with the NSX manager.
        required: true
        type: str
    ovftool_path:
        description: Path of ovf tool
        type: 'str'
    folder:
        description:  vCenter folder
        required: false
        type: 'str'
    datacenter:
        description: Datacenter name
        required: true 
        type: 'str'
    datastore:
        description: Data Store
        required: true
        type: 'str'
    portgroup:
        description: Port group
        required: true
        type: 'str'
    portgroup_ext:
        description: External Portgroup
        type: 'str'
    portgroup_transport:
        description: Transport Port Group
        type: 'str'
    cluster:
        description: vCenter Cluster
        required: true
        type: 'str'
    vmname:
        description: Name of VM
        required: true
        type: 'str'
    hostname:
        description: Name of host
        required: true 
        type: 'str'
    dns_server:
        description: DNS server address
        required: true
        type: 'str'
    ntp_server:
        description: NTP Server Address
        required: true
        type: 'str'
    dns_domain:
        description: DNS Domain name
        required: true
        type: 'str'
    gateway:
        description: Gateway Address
        required: true
        type: 'str'
    gateway6_0:
        description: Gateway6 Address
        required: false
        type: 'str'
    ip_address:
        description: IP Address
        required: true
        type: 'str'
    ip_address6_0:
        description: IPv6 Address
        required: false
        type: 'str'
    netmask:
        description: Netmask
        required: true
        type: 'str'
    netmask6_0:
        description: Netmask6
        required: true
        type: 'str'
    admin_password:
        description: Admin Password
        required: true
        type: 'str'
        no_log: true
    cli_password:
        description: CLI Password
        required: true
        type: 'str'
        no_log: true
    ssh_enabled:
        description: If ssh is enabled
        default: false
    allow_ssh_root_login:
        description: If SSH root login is allowed
        default: false
    deployment_size:
        description: Size of the deployment
        default: 'medium'
        type: 'str'
    path_to_ova:
        description: Path to OVA file
        required: true
        type: 'str'
    ova_file:
        description: OVA File name
        required: true
        type: 'str'
    disk_mode:
        description: Disk mode to used. Thin or thick.
        default: 'thin'
    vcenter:
        description: vCenter name
        required: true
        type: 'str'
    vcenter_user:
        description: vCenter username
        required: true
        type: 'str'
    vcenter_passwd:
        description: vCenter password
        required: true
        type: 'str'
        no_log: true
    extra_para:
        description: Extra Parameters
        required: false
        type: 'str'
    role:
        description: Roles
        required: true
        type: 'str'
    ip_protocol:
        description: IP Protocol
        required: false
        type: 'str'
requirements:
    - PyVmOmi - Python library for vCenter api.
    - OVF Tools - Ovftool is used for ovf deployment.
'''

EXAMPLES = '''
- name: Deploy NSX Manager OVA
  deploy_ova:
    ovftool_path: "{{ ovfToolPath }}"
    datacenter: "private_dc"
    datastore: "data store"
    portgroup: "VM Network"
    cluster: "nsxt_cluster"
    vmname: "nsxt-manager"
    hostname: "nsxt-manager-10"
    dns_server: "10.161.244.213"
    dns_domain: "eng.vmware.com"
    ntp_server: "123.108.200.124"
    gateway: "10.112.203.253"
    gateway6_0: "2620:124:6020:1045::253"
    ip_address: "10.112.201.24"
    ip_address6_0: "2620:124:6020:1045::1a"
    netmask: "255.255.224.0"
    netmask6_0: "64"
    admin_password: "Admin!23Admin"
    cli_password: "Admin!23Admin"
    path_to_ova: "http://build-squid.eng.vmware.com/build/mts/release/bora-8411846/publish/nsx-unified-appliance/exports/ovf"
    ova_file: "nsx-unified-appliance-2.2.0.0.0.8411854.ovf"
    vcenter: "10.161.244.213"
    vcenter_user: "administrator@vsphere.local"
    vcenter_passwd: "Admin!23"
    deployment_size: "small"
    role: "nsx-manager nsx-controller"
    ip_protocol: IPv6

'''

RETURN = '''# '''
import requests
import ssl

from pyVim.connect import SmartConnect
from pyVmomi import vim, vmodl


def find_virtual_machine(content, searched_vm_name):
    virtual_machines = get_all_objs(content, [vim.VirtualMachine])
    for vm in virtual_machines:
        if vm.name == searched_vm_name:
            return vm
    return None


def get_all_objs(content, vimtype):
    obj = {}
    container = content.viewManager.CreateContainerView(content.rootFolder, vimtype, True)
    for managed_object_ref in container.view:
        obj.update({managed_object_ref: managed_object_ref.name})
    return obj


def connect_to_api(vchost, vc_user, vc_pwd):
    try:
        service_instance = SmartConnect(host=vchost, user=vc_user, pwd=vc_pwd)
    except (requests.ConnectionError, ssl.SSLError):
        try:
            context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
            context.load_default_certs()
            service_instance = SmartConnect(host=vchost, user=vc_user, pwd=vc_pwd, sslContext=context)
        except Exception as e:
            raise Exception(e)
    return service_instance.RetrieveContent()


def main():
    module = AnsibleModule(
        argument_spec=dict(
            ovftool_path=dict(type='str'),
            folder=dict(required=False, type='str'),
            datacenter=dict(required=True, type='str'),
            datastore=dict(required=True, type='str'),
            portgroup=dict(required=True, type='str'),
            portgroup_ext=dict(type='str'),
            portgroup_transport=dict(type='str'),
            cluster=dict(required=True, type='str'),
            vmname=dict(required=True, type='str'),
            hostname=dict(required=True, type='str'),
            dns_server=dict(required=True, type='str'),
            ntp_server=dict(required=True, type='str'),
            dns_domain=dict(required=True, type='str'),
            gateway=dict(required=True, type='str'),
            gateway6_0=dict(type='str'),
            ip_address=dict(required=True, type='str'),
            ip_address6_0=dict(type='str'),
            netmask=dict(required=True, type='str'),
            netmask6_0=dict(type='str'),
            admin_password=dict(required=True, type='str', no_log=True),
            cli_password=dict(required=True, type='str', no_log=True),
            ssh_enabled=dict(default=False),
            allow_ssh_root_login=dict(default=False),
            deployment_size=dict(default='medium', type='str'),
            path_to_ova=dict(required=True, type='str'),
            ova_file=dict(required=True, type='str'),
            disk_mode=dict(default='thin'),
            vcenter=dict(required=True, type='str'),
            vcenter_user=dict(required=True, type='str'),
            vcenter_passwd=dict(required=True, type='str', no_log=True),
            extra_para=dict(type='str'),
            role=dict(required=True, type='str'),
            ip_protocol=dict(required=False, type='str')
        ),
        supports_check_mode=True,
        required_together=[['gateway6_0', 'ip_address6_0', 'netmask6_0'], ['portgroup_ext', 'portgroup_transport']]
    )

    try:
        content = connect_to_api(module.params['vcenter'], module.params['vcenter_user'],
                                 module.params['vcenter_passwd'])
    except vim.fault.InvalidLogin:
        module.fail_json(msg='exception while connecting to vCenter, login failure, check username and password')
    except requests.exceptions.ConnectionError:
        module.fail_json(msg='exception while connecting to vCenter, check hostname, FQDN or IP')

    nsx_manager_vm = find_virtual_machine(content, module.params['vmname'])

    if nsx_manager_vm:
        module.exit_json(changed=False, msg='A VM with the name {} was already present'.format(module.params['vmname']))

    ovftool_exec = '{}/ovftool'.format(module.params['ovftool_path'])
    ovf_command = [ovftool_exec]

    ovf_base_options = ['--acceptAllEulas', '--skipManifestCheck', '--X:injectOvfEnv', '--powerOn', '--noSSLVerify',
                        '--allowExtraConfig', '--diskMode={}'.format(module.params['disk_mode']),
                        '--datastore={}'.format(module.params['datastore']),
                        '--name={}'.format(module.params['vmname'])
                        ]

    if module.params['ip_protocol']:
        ovf_base_options.extend(['--ipProtocol={}'.format(module.params['ip_protocol'])])

    if module.params['portgroup_ext']:
        ovf_base_options.extend(['--net:Network 0={}'.format(module.params['portgroup']),
                                 '--net:Network 1={}'.format(module.params['portgroup_ext']),
                                 '--net:Network 2={}'.format(module.params['portgroup_transport']),
                                 '--net:Network 3={}'.format(module.params['portgroup'])])
    else:
        ovf_base_options.extend(['--network={}'.format(module.params['portgroup'])])
    ovf_command.extend(ovf_base_options)

    ovf_deployement_size = ['--deploymentOption={}'.format(module.params['deployment_size'])]
    ovf_command.extend(ovf_deployement_size)

    ovf_ext_prop = ['--prop:nsx_hostname={}'.format(module.params['hostname']),
                    '--prop:nsx_dns1_0={}'.format(module.params['dns_server']),
                    '--prop:nsx_domain_0={}'.format(module.params['dns_domain']),
                    '--prop:nsx_ntp_0={}'.format(module.params['ntp_server']),
                    '--prop:nsx_gateway_0={}'.format(module.params['gateway']),
                    '--prop:nsx_ip_0={}'.format(module.params['ip_address']),
                    '--prop:nsx_netmask_0={}'.format(module.params['netmask']),
                    '--prop:nsx_passwd_0={}'.format(module.params['admin_password']),
                    '--prop:nsx_cli_passwd_0={}'.format(module.params['cli_password']),
                    '--prop:nsx_isSSHEnabled={}'.format(module.params['ssh_enabled']),
                    '--prop:nsx_allowSSHRootLogin={}'.format(module.params['allow_ssh_root_login']),
                    '--prop:nsx_role={}'.format(module.params['role'])]
    ovf_command.extend(ovf_ext_prop)

    if module.params['extra_para']:
        ovf_command.extend(['--prop:extraPara={}'.format(module.params['extra_para'])])

    if module.params['gateway6_0']:
        ovf_command.extend(['--prop:nsx_gateway6_0={}'.format(module.params['gateway6_0'])])

    if module.params['ip_address6_0']:
        ovf_command.extend(['--prop:nsx_ip6_0={}'.format(module.params['ip_address6_0'])])

    if module.params['netmask6_0']:
        ovf_command.extend(['--prop:nsx_netmask6_0={}'.format(module.params['netmask6_0'])])

    ova_file = '{}/{}'.format(module.params['path_to_ova'], module.params['ova_file'])
    ovf_command.append(ova_file)

    vi_string = 'vi://{}:{}@{}/'.format(module.params['vcenter_user'],
                                        module.params['vcenter_passwd'], module.params['vcenter'])
    if module.params.__contains__('folder') and module.params['folder']:
        vi_string = vi_string + module.params['folder']

    vi_string = vi_string + '/{}/host/{}/'.format(module.params['datacenter'], module.params['cluster'])

    ovf_command.append(vi_string)

    if module.check_mode:
        module.exit_json(changed=True, debug_out=ovf_command)

    ova_tool_result = module.run_command(ovf_command)

    if ova_tool_result[0] != 0:
        module.fail_json(msg='Failed to deploy OVA, error message from ovftool is: {}, the comand was {}'.format(ova_tool_result[1], ovf_command))

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

from ansible.module_utils.basic import *

if __name__ == '__main__':
    main()


================================================
FILE: plugins/modules/nsxt_edge_clusters.py
================================================
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright 2018 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only
#
# 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.

from __future__ import absolute_import, division, print_function
__metaclass__ = type

ANSIBLE_METADATA = {'metadata_version': '1.1',
                    'status': ['preview'],
                    'supported_by': 'community'}


DOCUMENTATION = '''
---
module: nsxt_edge_clusters
short_description: 'Create Edge Cluster'
description: "Creates a new edge cluster.
              It only supports homogeneous members.
              The TransportNodes backed by EdgeNode are only allowed in cluster members.
              DeploymentType (VIRTUAL_MACHINE|PHYSICAL_MACHINE) of these EdgeNodes is
              recommended to be the same. EdgeCluster supports members of different
              deployment types."
version_added: '2.7'
author: 'Rahul Raghuvanshi'
options:
    hostname:
        description: 'Deployed NSX manager hostname.'
        required: true
        type: str
    username:
        description: 'The username to authenticate with the NSX manager.'
        required: true
        type: str
    password:
        description: 'The password to authenticate with the NSX manager.'
        required: true
        type: str
    cluster_profile_bindings:
        description: 'Edge cluster profile bindings'
        required: false
        type: 'array of ClusterProfileTypeIdEntry'
    display_name:
        description: 'Display name'
        required: true
        type: str
    description:
        description: Description of the resource
        required: false
        type: str
    members:
        description: "EdgeCluster only supports homogeneous members.
        These member should be backed by either EdgeNode or PublicCloudGatewayNode.
        TransportNode type of these nodes should be the same.
        DeploymentType (VIRTUAL_MACHINE|PHYSICAL_MACHINE) of these EdgeNodes is
        recommended to be the same. EdgeCluster supports members of different
        deployment types."
        required: false
        type: 'array of EdgeClusterMember'
    allocation_rules:
        description: Allocation rules for auto placement
        required: false
        type: list
    enable_inter_site_forwarding:
        description: Flag to enable inter site forwarding
        required: false
        type: bool
    node_rtep_ips:
        description: Remote tunnel endpoint ip address
        required: false
        type: list
    member_node_type:
        description: Node type of the cluster members
        required: false
        type: dict
        EdgeDeploymentType:
            description: Supported edge deployment type.
            required: false
            type: str
    deployment_type:
        description: Deplloyment type of the cluster members
        required: false
        type: dict
        EdgeDeploymentType:
            description: Supported edge deployment type.
            required: false
            type: str
    state:
        choices:
            - present
            - absent
        description: "State can be either 'present' or 'absent'.
                      'present' is used to create or update resource.
                      'absent' is used to delete resource."
        required: true

    
'''

EXAMPLES = '''
  - name: Create Edge Cluster
    nsxt_edge_clusters:
      hostname: "10.192.167.137"
      username: "admin"
      password: "Admin!23Admin"
      validate_certs: False
      display_name: edge-cluster-1  `
      cluster_profile_bindings:
        - profile_name: "nsx-edge-profile"
          resource_type: EdgeHighAvailabilityProfile
      members:
        - transport_node_name: "TN_1"
      state: present
'''

RETURN = '''# '''

import json
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request
from ansible.module_utils._text import to_native


def get_edge_cluster_params(args=None):
    args_to_remove = ['state', 'username', 'password', 'port', 'hostname', 'validate_certs']
    for key in args_to_remove:
        args.pop(key, None)
    for key, value in args.copy().items():
        if value == None:
            args.pop(key, None)
    return args

def get_edge_clusters(module, manager_url, mgr_username, mgr_password, validate_certs):
    try:
      (rc, resp) = request(manager_url+ '/edge-clusters', headers=dict(Accept='application/json'),
                      url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True)
    except Exception as err:
      module.fail_json(msg='Error accessing edge clusters. Error [%s]' % (to_native(err)))
    return resp

def get_id_from_display_name(module, manager_url, mgr_username, mgr_password, validate_certs, endpoint, display_name):
    try:
      (rc, resp) = request(manager_url+ endpoint, headers=dict(Accept='application/json'),
                      url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True)
    except Exception as err:
      module.fail_json(msg='Error accessing id for display name %s. Error [%s]' % (display_name, to_native(err)))

    for result in resp['results']:
        if result.__contains__('display_name') and result['display_name'] == display_name:
            return result['id']
    module.fail_json(msg='No id exist with display name %s' % display_name)

def get_edge_clusters_from_display_name(module, manager_url, mgr_username, mgr_password, validate_certs, display_name):
    edge_clusters = get_edge_clusters(module, manager_url, mgr_username, mgr_password, validate_certs)
    for edge_cluster in edge_clusters['results']:
        if edge_cluster.__contains__('display_name') and edge_cluster['display_name'] == display_name:
            return edge_cluster
    return None

# def ordered(obj):
#     if isinstance(obj, dict):
#         return sorted((k, ordered(v)) for k, v in obj.items())
#     if isinstance(obj, list):
#         return sorted(ordered(x) for x in obj)
#     else:
#         return obj

def check_for_update(module, manager_url, mgr_username, mgr_password, validate_certs, edge_cluster_with_id):
    existing_edge_cluster = get_edge_clusters_from_display_name(module, manager_url, mgr_username, mgr_password, validate_certs, edge_cluster_with_id['display_name'])
    if existing_edge_cluster is None:
        return False
    if existing_edge_cluster.__contains__('description') and not edge_cluster_with_id.__contains__('description'):
        return True
    if not existing_edge_cluster.__contains__('description') and edge_cluster_with_id.__contains__('description'):
        return True
    if existing_edge_cluster.__contains__('description') and edge_cluster_with_id.__contains__('description') and \
        existing_edge_cluster['description'] != edge_cluster_with_id['description']:
        return True
    if existing_edge_cluster.__contains__('members') and not edge_cluster_with_id.__contains__('members'):
        return True
    if not existing_edge_cluster.__contains__('members') and edge_cluster_with_id.__contains__('members'):
        return True
    if existing_edge_cluster.__contains__('members') and edge_cluster_
Download .txt
gitextract_w6d1_2mv/

├── .gitignore
├── CONTRIBUTING.md
├── LICENSE.txt
├── README.md
├── galaxy.yml
├── meta/
│   └── runtime.yml
├── plugins/
│   ├── doc_fragments/
│   │   └── vmware_nsxt.py
│   ├── module_utils/
│   │   ├── __init__.py
│   │   ├── common_utils.py
│   │   ├── nsxt_base_resource.py
│   │   ├── nsxt_resource_urls.py
│   │   ├── policy_communicator.py
│   │   ├── policy_resource_specs/
│   │   │   ├── __init__.py
│   │   │   ├── l2_bridge_ep_profile.py
│   │   │   └── security_policy.py
│   │   ├── upgrade_reverse_order.py
│   │   ├── vcenter_utils.py
│   │   └── vmware_nsxt.py
│   └── modules/
│       ├── __init__.py
│       ├── nsxt_certificates.py
│       ├── nsxt_certificates_facts.py
│       ├── nsxt_cluster_profiles.py
│       ├── nsxt_cluster_profiles_facts.py
│       ├── nsxt_deploy_ova.py
│       ├── nsxt_edge_clusters.py
│       ├── nsxt_edge_clusters_facts.py
│       ├── nsxt_fabric_compute_managers.py
│       ├── nsxt_fabric_compute_managers_facts.py
│       ├── nsxt_global_manager_active.py
│       ├── nsxt_global_manager_enable_service.py
│       ├── nsxt_global_manager_registration.py
│       ├── nsxt_ip_blocks.py
│       ├── nsxt_ip_blocks_facts.py
│       ├── nsxt_ip_pools.py
│       ├── nsxt_ip_pools_facts.py
│       ├── nsxt_licenses.py
│       ├── nsxt_licenses_facts.py
│       ├── nsxt_local_manager_registration.py
│       ├── nsxt_local_managers_compatibility.py
│       ├── nsxt_local_managers_facts.py
│       ├── nsxt_logical_ports.py
│       ├── nsxt_logical_ports_facts.py
│       ├── nsxt_logical_router_ports.py
│       ├── nsxt_logical_router_ports_facts.py
│       ├── nsxt_logical_router_static_routes.py
│       ├── nsxt_logical_routers.py
│       ├── nsxt_logical_routers_facts.py
│       ├── nsxt_logical_switches.py
│       ├── nsxt_logical_switches_facts.py
│       ├── nsxt_manager_auto_deployment.py
│       ├── nsxt_manager_auto_deployment_facts.py
│       ├── nsxt_manager_status.py
│       ├── nsxt_policy_bfd_profile.py
│       ├── nsxt_policy_gateway_policy.py
│       ├── nsxt_policy_group.py
│       ├── nsxt_policy_ip_block.py
│       ├── nsxt_policy_ip_block_facts.py
│       ├── nsxt_policy_ip_pool.py
│       ├── nsxt_policy_ip_pool_facts.py
│       ├── nsxt_policy_l2_bridge_ep_profile.py
│       ├── nsxt_policy_security_policy.py
│       ├── nsxt_policy_segment.py
│       ├── nsxt_policy_tier0.py
│       ├── nsxt_policy_tier1.py
│       ├── nsxt_principal_identities.py
│       ├── nsxt_principal_identities_facts.py
│       ├── nsxt_repo_sync.py
│       ├── nsxt_repo_sync_facts.py
│       ├── nsxt_rest.py
│       ├── nsxt_route_advertise.py
│       ├── nsxt_transport_node_collections.py
│       ├── nsxt_transport_node_collections_facts.py
│       ├── nsxt_transport_node_profiles.py
│       ├── nsxt_transport_node_profiles_facts.py
│       ├── nsxt_transport_nodes.py
│       ├── nsxt_transport_nodes_facts.py
│       ├── nsxt_transport_zones.py
│       ├── nsxt_transport_zones_facts.py
│       ├── nsxt_upgrade_eula_accept.py
│       ├── nsxt_upgrade_eula_accept_facts.py
│       ├── nsxt_upgrade_groups.py
│       ├── nsxt_upgrade_groups_facts.py
│       ├── nsxt_upgrade_history.py
│       ├── nsxt_upgrade_plan.py
│       ├── nsxt_upgrade_plan_facts.py
│       ├── nsxt_upgrade_postchecks.py
│       ├── nsxt_upgrade_pre_post_checks_facts.py
│       ├── nsxt_upgrade_prechecks.py
│       ├── nsxt_upgrade_run.py
│       ├── nsxt_upgrade_status_summary_facts.py
│       ├── nsxt_upgrade_uc.py
│       ├── nsxt_upgrade_uc_facts.py
│       ├── nsxt_upgrade_upload_mub.py
│       ├── nsxt_upgrade_upload_mub_facts.py
│       ├── nsxt_uplink_profiles.py
│       ├── nsxt_uplink_profiles_facts.py
│       ├── nsxt_vidm.py
│       ├── nsxt_virtual_ip.py
│       ├── nsxt_virtual_ip_facts.py
│       └── nsxt_vm_tags.py
└── tests/
    ├── playbooks/
    │   ├── mp/
    │   │   ├── answerfile.yml
    │   │   ├── answerfile_9x.yml
    │   │   ├── answerfile_attach_tnp_to_cluster.yml
    │   │   ├── answerfile_attach_tnp_to_cluster_9x.yml
    │   │   ├── answerfile_tn.yml
    │   │   ├── answerfile_tn_9x.yml
    │   │   ├── test_attach_tnp_to_cluster.yml
    │   │   ├── test_attach_tnp_to_cluster_9x.yml
    │   │   ├── test_basic_topology.yml
    │   │   ├── test_basic_topology_9x.yml
    │   │   ├── test_certificates.yml
    │   │   ├── test_certificates_facts.yml
    │   │   ├── test_cluster_profiles.yml
    │   │   ├── test_cluster_profiles_facts.yml
    │   │   ├── test_compute_managers.yml
    │   │   ├── test_compute_managers_facts.yml
    │   │   ├── test_configure_transport_node.yml
    │   │   ├── test_configure_transport_node_9x.yml
    │   │   ├── test_edge_clusters.yml
    │   │   ├── test_edge_clusters_facts.yml
    │   │   ├── test_global_manager_enable_service.yml
    │   │   ├── test_global_manager_registration.yml
    │   │   ├── test_global_managers_active.yml
    │   │   ├── test_ip_blocks.yml
    │   │   ├── test_ip_blocks_facts.yml
    │   │   ├── test_ip_pools.yml
    │   │   ├── test_ip_pools_facts.yml
    │   │   ├── test_licenses.yml
    │   │   ├── test_licenses_facts.yml
    │   │   ├── test_local_manager_registration.yml
    │   │   ├── test_local_managers_compatibility.yml
    │   │   ├── test_local_managers_facts.yml
    │   │   ├── test_logical_ports.yml
    │   │   ├── test_logical_ports_facts.yml
    │   │   ├── test_logical_router_ports.yml
    │   │   ├── test_logical_router_ports_facts.yml
    │   │   ├── test_logical_router_static_route.yml
    │   │   ├── test_logical_routers.yml
    │   │   ├── test_logical_routers_facts.yml
    │   │   ├── test_logical_switches.yml
    │   │   ├── test_logical_switches_facts.yml
    │   │   ├── test_manager_auto_deployment.yml
    │   │   ├── test_manager_auto_deployment_facts.yml
    │   │   ├── test_manager_status.yml
    │   │   ├── test_ovf_deployment.yml
    │   │   ├── test_principal_identities.yml
    │   │   ├── test_principal_identities_facts.yml
    │   │   ├── test_repo_sync.yml
    │   │   ├── test_repo_sync_facts.yml
    │   │   ├── test_rest.yml
    │   │   ├── test_route_advertise.yml
    │   │   ├── test_transport_node_collections.yml
    │   │   ├── test_transport_node_collections_facts.yml
    │   │   ├── test_transport_node_profiles.yml
    │   │   ├── test_transport_node_profiles_facts.yml
    │   │   ├── test_transport_nodes.yml
    │   │   ├── test_transport_nodes_edge.yml
    │   │   ├── test_transport_nodes_edge_9x.yml
    │   │   ├── test_transport_nodes_facts.yml
    │   │   ├── test_transport_nodes_host.yml
    │   │   ├── test_transport_nodes_host_9x.yml
    │   │   ├── test_transport_zones.yml
    │   │   ├── test_transport_zones_facts.yml
    │   │   ├── test_upgrade_eula_accept.yml
    │   │   ├── test_upgrade_eula_accept_facts.yml
    │   │   ├── test_upgrade_groups.yml
    │   │   ├── test_upgrade_groups_facts.yml
    │   │   ├── test_upgrade_history_facts.yml
    │   │   ├── test_upgrade_plan.yml
    │   │   ├── test_upgrade_plan_facts.yml
    │   │   ├── test_upgrade_postchecks.yml
    │   │   ├── test_upgrade_pre_post_checks_facts.yml
    │   │   ├── test_upgrade_prechecks.yml
    │   │   ├── test_upgrade_run.yml
    │   │   ├── test_upgrade_status_summary_facts.yml
    │   │   ├── test_upgrade_uc.yml
    │   │   ├── test_upgrade_uc_facts.yml
    │   │   ├── test_upgrade_upload_mub.yml
    │   │   ├── test_upgrade_upload_mub_facts.yml
    │   │   ├── test_uplink_profiles.yml
    │   │   ├── test_uplink_profiles_9x.yml
    │   │   ├── test_uplink_profiles_facts.yml
    │   │   ├── test_vidm.yml
    │   │   ├── test_virtual_ip.yml
    │   │   └── test_virtual_ip_facts.yml
    │   ├── policy/
    │   │   ├── test_nsxt_policy_bfd_profile.yaml
    │   │   ├── test_nsxt_policy_gateway_policy.yml
    │   │   ├── test_nsxt_policy_group.yml
    │   │   ├── test_nsxt_policy_ip_block.yml
    │   │   ├── test_nsxt_policy_ip_pool.yml
    │   │   ├── test_nsxt_policy_l2_bridge_ep_profile.yml
    │   │   ├── test_nsxt_policy_security_policy.yml
    │   │   ├── test_nsxt_policy_segment.yml
    │   │   ├── test_nsxt_policy_tier0.yml
    │   │   ├── test_nsxt_policy_tier1.yml
    │   │   └── test_vm_tags.yaml
    │   └── topologies/
    │       ├── deploy_nsx_cluster/
    │       │   ├── 01_deploy_first_node.yml
    │       │   ├── 02_configure_compute_manager.yml
    │       │   ├── 03_deploy_second_third_node.yml
    │       │   ├── 04_add_nsx_license.yml
    │       │   ├── README.md
    │       │   └── deploy_nsx_cluster_vars.yml
    │       ├── misc/
    │       │   └── create_and_attach_t0_t1_routers.yml
    │       ├── policy_modules/
    │       │   ├── 01_create_t0_gateway.yml
    │       │   ├── 02_create_t1_gateway.yml
    │       │   ├── 03_create_segments.yml
    │       │   ├── 04_create_groups.yml
    │       │   ├── 05_create_security_policy.yml
    │       │   ├── README.md
    │       │   ├── build_topology.yml
    │       │   ├── build_topology_vars.yml
    │       │   └── cleanup_topology.yml
    │       ├── setup_infra/
    │       │   ├── 01_setup_transport_zones.yml
    │       │   ├── 01_setup_transport_zones_9x.yml
    │       │   ├── 02_setup_TEP_IP_Pools.yml
    │       │   ├── 03_setup_transport_node_profiles.yml
    │       │   ├── 03_setup_transport_node_profiles_9x.yml
    │       │   ├── 04_setup_transport_nodes.yml
    │       │   ├── 04_setup_transport_nodes_9x.yml
    │       │   ├── 05_setup_edge_cluster.yml
    │       │   ├── 06_setup_transport_node_collections.yml
    │       │   ├── README.md
    │       │   ├── setup_infra_vars.yml
    │       │   └── setup_infra_vars_9x.yml
    │       └── upgrade/
    │           ├── 01_upgrade_upload_mub.yml
    │           ├── 02_upgrade_accept_eula.yml
    │           ├── 03_upgrade_uc.yml
    │           ├── 04_upgrade_update_plan.yml
    │           ├── 05_upgrade_update_groups.yml
    │           ├── 06_upgrade_prechecks.yml
    │           ├── 07_upgrade_run.yml
    │           ├── README.md
    │           ├── check_upgrade_groups_facts.yml
    │           ├── check_upgrade_pre_post_checks_facts.yml
    │           ├── check_upgrade_status_summary_facts.yml
    │           └── upgrade_vars.yml
    └── unit/
        ├── __init__.py
        └── plugins/
            ├── __init__.py
            └── module_utils/
                ├── __init__.py
                ├── test_nsxt_base_resource.py
                └── test_policy_communicator.py
Download .txt
SYMBOL INDEX (534 symbols across 90 files)

FILE: plugins/doc_fragments/vmware_nsxt.py
  class ModuleDocFragment (line 22) | class ModuleDocFragment(object):

FILE: plugins/module_utils/common_utils.py
  function check_if_valid_ip (line 19) | def check_if_valid_ip(address):
  function traverse_and_retrieve_value (line 38) | def traverse_and_retrieve_value(object , attribute_list):
  function get_attribute_from_endpoint (line 54) | def get_attribute_from_endpoint(module, manager_url, endpoint, mgr_usern...
  function get_id_from_display_name_results (line 78) | def get_id_from_display_name_results(module, manager_url, endpoint, mgr_...
  function wait_for_operation_to_execute (line 108) | def wait_for_operation_to_execute(manager_url, endpoint, mgr_username,
  function clean_and_get_params (line 142) | def clean_and_get_params(args=None, extra_args_to_remove=[]):
  function get_upgrade_orchestrator_node (line 156) | def get_upgrade_orchestrator_node(module, mgr_hostname, mgr_username, mg...

FILE: plugins/module_utils/nsxt_base_resource.py
  class NSXTBaseRealizableResource (line 46) | class NSXTBaseRealizableResource(ABC):
    method realize (line 50) | def realize(self, supports_check_mode=True,
    method get_spec_identifier (line 144) | def get_spec_identifier(cls):
    method get_state (line 151) | def get_state(self):
    method get_parent_info (line 154) | def get_parent_info(self):
    method infer_resource_id (line 157) | def infer_resource_id(self, parent_info):
    method get_resource_base_url (line 164) | def get_resource_base_url(parent_info):
    method get_resource_spec (line 170) | def get_resource_spec():
    method get_resource_name (line 175) | def get_resource_name(cls):
    method create_or_update_subresource_first (line 178) | def create_or_update_subresource_first(self):
    method delete_subresource_first (line 184) | def delete_subresource_first(self):
    method achieve_subresource_state_if_del_parent (line 188) | def achieve_subresource_state_if_del_parent(self):
    method do_wait_till_create (line 194) | def do_wait_till_create(self):
    method get_resource_update_priority (line 200) | def get_resource_update_priority():
    method set_arg_spec (line 210) | def set_arg_spec(self, arg_spec):
    method set_ansible_module (line 213) | def set_ansible_module(self, ansible_module):
    method set_parent_info (line 216) | def set_parent_info(self, parent_info):
    method achieve_subresource_state (line 219) | def achieve_subresource_state(
    method update_resource_params (line 254) | def update_resource_params(self, nsx_resource_params):
    method check_for_update (line 260) | def check_for_update(self, existing_params, resource_params):
    method update_parent_info (line 298) | def update_parent_info(self, parent_info):
    method get_attribute (line 304) | def get_attribute(self, attribute, resource_params):
    method set_baseline_args (line 322) | def set_baseline_args(self, baseline_arg_names):
    method do_resource_params_have_attr_with_id_or_display_name (line 329) | def do_resource_params_have_attr_with_id_or_display_name(self, attr):
    method get_id_using_attr_name_else_fail (line 335) | def get_id_using_attr_name_else_fail(self, attr_name, params,
    method exit_with_failure (line 341) | def exit_with_failure(self, msg, **kwargs):
    method skip_delete (line 344) | def skip_delete(self):
    method is_required_in_spec (line 353) | def is_required_in_spec(cls):
    method allows_multiple_resource_spec (line 361) | def allows_multiple_resource_spec(cls):
    method _get_id_using_attr_name (line 369) | def _get_id_using_attr_name(self, attr_name, params,
    method get_id_from_display_name (line 393) | def get_id_from_display_name(self, resource_base_url,
    method _update_parent_info (line 430) | def _update_parent_info(self):
    method _make_ansible_arg_spec (line 435) | def _make_ansible_arg_spec(self, supports_check_mode=True):
    method _update_arg_spec_with_resource (line 456) | def _update_arg_spec_with_resource(self, resource_class, arg_spec):
    method _update_arg_spec_with_all_resources (line 478) | def _update_arg_spec_with_all_resources(self, resource_class, arg_spec):
    method _get_base_arg_spec_of_nsx_resource (line 489) | def _get_base_arg_spec_of_nsx_resource(self):
    method _get_base_arg_spec_of_resource (line 519) | def _get_base_arg_spec_of_resource(self):
    method _extract_nsx_resource_params (line 549) | def _extract_nsx_resource_params(self, resource_params):
    method _achieve_present_state (line 563) | def _achieve_present_state(self, successful_resource_exec_logs):
    method _achieve_absent_state (line 660) | def _achieve_absent_state(self, successful_resource_exec_logs):
    method _send_request_to_API (line 696) | def _send_request_to_API(self, suffix="", ignore_error=False,
    method get_all_resources_from_nsx (line 732) | def get_all_resources_from_nsx(self):
    method _achieve_state (line 740) | def _achieve_state(self, resource_params,
    method _get_sub_resources_class_of (line 783) | def _get_sub_resources_class_of(self, resource_class):
    method _wait_till_delete (line 800) | def _wait_till_delete(self):
    method _wait_till_create (line 815) | def _wait_till_create(self):
    method _fill_missing_resource_params (line 850) | def _fill_missing_resource_params(self, existing_params, resource_para...
    method _clean_none_resource_params (line 865) | def _clean_none_resource_params(self, existing_params, resource_params):

FILE: plugins/module_utils/policy_communicator.py
  class PolicyCommunicator (line 33) | class PolicyCommunicator:
    method check_for_authorization_header (line 38) | def check_for_authorization_header(request_headers):
    method get_instance (line 44) | def get_instance(mgr_hostname, mgr_username=None, mgr_password=None,
    method __init__ (line 77) | def __init__(self, key, mgr_hostname, mgr_username, mgr_password,
    method get_vmware_argument_spec (line 108) | def get_vmware_argument_spec():
    method get_all_results (line 121) | def get_all_results(self, url, ignore_errors=False):
    method request (line 138) | def request(self, url, data=None, method='GET',
    method _get_request_id (line 199) | def _get_request_id(self, url, data=None, method='GET'):
    method register_request (line 212) | def register_request(self, request_id):
  class DuplicateRequestError (line 224) | class DuplicateRequestError(Exception):
  class InvalidInstanceRequest (line 228) | class InvalidInstanceRequest(Exception):
    method __init__ (line 232) | def __init__(self, missing_fields):

FILE: plugins/module_utils/upgrade_reverse_order.py
  function check_upgrade_status_at_start (line 26) | def check_upgrade_status_at_start(module, manager_url, mgr_username, mgr...
  function get_upgrade_status_summary (line 42) | def get_upgrade_status_summary(module, manager_url, mgr_username, mgr_pa...
  function call_get_sync (line 59) | def call_get_sync(managerUrl, endpoint, mgrUsername, mgrPassword, valida...
  function check_component_upgrade_completion_status (line 63) | def check_component_upgrade_completion_status(module, manager_url, mgr_u...
  function check_component_statuses (line 96) | def check_component_statuses(module, component_status_list):
  function execute_upgrade (line 104) | def execute_upgrade(module, manager_url, mgr_username, mgr_password, val...
  function trigger_upgrade_reverse_order (line 124) | def trigger_upgrade_reverse_order(module, mgr_hostname, mgr_username, mg...

FILE: plugins/module_utils/vcenter_utils.py
  function establish_vcenter_connection (line 26) | def establish_vcenter_connection(module, vCenter_host, username, passwor...
  function get_resource_id_from_name (line 81) | def get_resource_id_from_name(module, vCenter_host, username, password,
  function get_data_network_id_from_name (line 119) | def get_data_network_id_from_name(module, vCenter_host, username, password,

FILE: plugins/module_utils/vmware_nsxt.py
  function vmware_argument_spec (line 22) | def vmware_argument_spec():
  function request (line 31) | def request(url, data=None, headers=None, method='GET', use_proxy=True,
  function get_all_results (line 58) | def get_all_results(
  function _request (line 84) | def _request(url, data, headers, method, use_proxy,
  function get_certificate_string (line 120) | def get_certificate_string(crt_file):
  function get_private_key_string (line 145) | def get_private_key_string(p12_file):
  function get_certificate_file_path (line 170) | def get_certificate_file_path(environment_variable):
  function get_vc_ip_from_display_name (line 173) | def get_vc_ip_from_display_name(module, manager_url, mgr_username, mgr_p...
  function is_json (line 197) | def is_json(myjson):
  function version_tuple (line 210) | def version_tuple(v):
  function get_nsx_version (line 213) | def get_nsx_version(module, manager_url, mgr_username, mgr_password, val...
  function validate_nsx_mp_support (line 221) | def validate_nsx_mp_support(module, manager_url, mgr_username, mgr_passw...

FILE: plugins/modules/nsxt_certificates.py
  function update_params_with_pem_encoding (line 120) | def update_params_with_pem_encoding(certificate_params):
  function get_certificate_params (line 130) | def get_certificate_params(args=None):
  function get_certificates (line 139) | def get_certificates(module, manager_url, mgr_username, mgr_password, va...
  function get_certificate_with_display_name (line 147) | def get_certificate_with_display_name(module, manager_url, mgr_username,...
  function main (line 157) | def main():

FILE: plugins/modules/nsxt_certificates_facts.py
  function main (line 68) | def main():

FILE: plugins/modules/nsxt_cluster_profiles.py
  function get_cluster_profiles_params (line 87) | def get_cluster_profiles_params(args=None):
  function get_cluster_profiles (line 96) | def get_cluster_profiles(module, manager_url, mgr_username, mgr_password...
  function get_id_from_display_name (line 104) | def get_id_from_display_name(module, manager_url, mgr_username, mgr_pass...
  function cmp_dict (line 116) | def cmp_dict(dict1, dict2):
  function get_cluster_profiles_from_display_name (line 131) | def get_cluster_profiles_from_display_name(module, manager_url, mgr_user...
  function check_for_update (line 146) | def check_for_update(module, manager_url, mgr_username, mgr_password, va...
  function update_params_with_id (line 180) | def update_params_with_id (module, manager_url, mgr_username, mgr_passwo...
  function get_profile_id_from_profile_name (line 183) | def get_profile_id_from_profile_name(module, manager_url, mgr_username, ...
  function update_params_with_profile_id (line 190) | def update_params_with_profile_id(module, manager_url, mgr_username, mgr...
  function main (line 197) | def main():

FILE: plugins/modules/nsxt_cluster_profiles_facts.py
  function main (line 63) | def main():

FILE: plugins/modules/nsxt_deploy_ova.py
  function find_virtual_machine (line 217) | def find_virtual_machine(content, searched_vm_name):
  function get_all_objs (line 225) | def get_all_objs(content, vimtype):
  function connect_to_api (line 233) | def connect_to_api(vchost, vc_user, vc_pwd):
  function main (line 246) | def main():

FILE: plugins/modules/nsxt_edge_clusters.py
  function get_edge_cluster_params (line 133) | def get_edge_cluster_params(args=None):
  function get_edge_clusters (line 142) | def get_edge_clusters(module, manager_url, mgr_username, mgr_password, v...
  function get_id_from_display_name (line 150) | def get_id_from_display_name(module, manager_url, mgr_username, mgr_pass...
  function get_edge_clusters_from_display_name (line 162) | def get_edge_clusters_from_display_name(module, manager_url, mgr_usernam...
  function check_for_update (line 177) | def check_for_update(module, manager_url, mgr_username, mgr_password, va...
  function update_params_with_id (line 200) | def update_params_with_id (module, manager_url, mgr_username, mgr_passwo...
  function get_cluster_profiles (line 208) | def get_cluster_profiles(module, manager_url, mgr_username, mgr_password...
  function get_profile_id_from_profile_name (line 216) | def get_profile_id_from_profile_name(module, manager_url, mgr_username, ...
  function update_params_with_profile_id (line 223) | def update_params_with_profile_id(module, manager_url, mgr_username, mgr...
  function main (line 230) | def main():

FILE: plugins/modules/nsxt_edge_clusters_facts.py
  function main (line 65) | def main():

FILE: plugins/modules/nsxt_fabric_compute_managers.py
  function get_fabric_compute_manager_params (line 143) | def get_fabric_compute_manager_params(args=None):
  function get_thumb (line 152) | def get_thumb(module):
  function get_fabric_compute_managers (line 174) | def get_fabric_compute_managers(module, manager_url, mgr_username, mgr_p...
  function get_compute_manager_from_display_name (line 182) | def get_compute_manager_from_display_name(module, manager_url, mgr_usern...
  function wait_till_create (line 189) | def wait_till_create(id, module, manager_url, mgr_username, mgr_password...
  function wait_till_delete (line 213) | def wait_till_delete(id, module, manager_url, mgr_username, mgr_password...
  function check_for_update (line 223) | def check_for_update(module, manager_url, mgr_username, mgr_password, va...
  function main (line 241) | def main():

FILE: plugins/modules/nsxt_fabric_compute_managers_facts.py
  function main (line 64) | def main():

FILE: plugins/modules/nsxt_global_manager_active.py
  function get_global_managers (line 71) | def get_global_managers(module, url, mgr_username, mgr_password, validat...
  function get_global_manager_from_id (line 81) | def get_global_manager_from_id(module, url, mgr_username, mgr_password, ...
  function wait_till_switchover_complete (line 89) | def wait_till_switchover_complete(module, url, mgr_username, mgr_passwor...
  function main (line 110) | def main():

FILE: plugins/modules/nsxt_global_manager_enable_service.py
  function get_global_manager_params (line 75) | def get_global_manager_params(args=None):
  function get_global_managers (line 85) | def get_global_managers(module, url, mgr_username, mgr_password, validat...
  function get_global_manager_from_id (line 95) | def get_global_manager_from_id(module, url, mgr_username, mgr_password, ...
  function main (line 102) | def main():

FILE: plugins/modules/nsxt_global_manager_registration.py
  function get_global_manager_params (line 137) | def get_global_manager_params(args=None):
  function get_global_managers (line 150) | def get_global_managers(module, url, mgr_username, mgr_password, validat...
  function get_global_manager_from_id (line 160) | def get_global_manager_from_id(module, url, mgr_username, mgr_password, ...
  function check_for_update (line 168) | def check_for_update(module, url, mgr_username, mgr_password, validate_c...
  function main (line 178) | def main():

FILE: plugins/modules/nsxt_ip_blocks.py
  function get_ip_block_params (line 91) | def get_ip_block_params(args=None):
  function get_ip_blocks (line 100) | def get_ip_blocks(module, manager_url, mgr_username, mgr_password, valid...
  function get_ip_block_from_display_name (line 108) | def get_ip_block_from_display_name(module, manager_url, mgr_username, mg...
  function check_for_update (line 115) | def check_for_update(module, manager_url, mgr_username, mgr_password, va...
  function main (line 123) | def main():

FILE: plugins/modules/nsxt_ip_blocks_facts.py
  function main (line 66) | def main():

FILE: plugins/modules/nsxt_ip_pools.py
  function get_ip_pool_params (line 101) | def get_ip_pool_params(args=None):
  function get_ip_pools (line 110) | def get_ip_pools(module, manager_url, mgr_username, mgr_password, valida...
  function get_ip_pool_from_display_name (line 118) | def get_ip_pool_from_display_name(module, manager_url, mgr_username, mgr...
  function check_for_update (line 133) | def check_for_update(module, manager_url, mgr_username, mgr_password, va...
  function main (line 141) | def main():

FILE: plugins/modules/nsxt_ip_pools_facts.py
  function main (line 68) | def main():

FILE: plugins/modules/nsxt_licenses.py
  function get_license_params (line 80) | def get_license_params(args=None):
  function check_license_exist (line 89) | def check_license_exist(module, manager_url, mgr_username, mgr_password,...
  function main (line 98) | def main():

FILE: plugins/modules/nsxt_licenses_facts.py
  function main (line 65) | def main():

FILE: plugins/modules/nsxt_local_manager_registration.py
  function get_local_manager_params (line 128) | def get_local_manager_params(args=None):
  function get_local_managers (line 140) | def get_local_managers(module, url, mgr_username, mgr_password, validate...
  function get_local_manager_by_id (line 148) | def get_local_manager_by_id(module, url, mgr_username, mgr_password, val...
  function check_for_update (line 155) | def check_for_update(module, url, mgr_username, mgr_password, validate_c...
  function main (line 164) | def main():

FILE: plugins/modules/nsxt_local_managers_compatibility.py
  function get_local_manager_params (line 95) | def get_local_manager_params(args=None):
  function main (line 105) | def main():

FILE: plugins/modules/nsxt_local_managers_facts.py
  function main (line 66) | def main():

FILE: plugins/modules/nsxt_logical_ports.py
  function get_logical_port_params (line 189) | def get_logical_port_params(args=None):
  function get_logical_ports (line 198) | def get_logical_ports(module, manager_url, mgr_username, mgr_password, v...
  function get_logical_port_from_display_name (line 206) | def get_logical_port_from_display_name(module, manager_url, mgr_username...
  function get_transport_nodes (line 214) | def get_transport_nodes(module, manager_url, mgr_username, mgr_password,...
  function get_tn_from_display_name (line 222) | def get_tn_from_display_name(module, manager_url, mgr_username, mgr_pass...
  function get_id_from_display_name (line 229) | def get_id_from_display_name(module, manager_url, mgr_username, mgr_pass...
  function update_params_with_id (line 241) | def update_params_with_id (module, manager_url, mgr_username, mgr_passwo...
  function check_for_update (line 269) | def check_for_update(module, manager_url, mgr_username, mgr_password, va...
  function main (line 285) | def main():

FILE: plugins/modules/nsxt_logical_ports_facts.py
  function main (line 67) | def main():

FILE: plugins/modules/nsxt_logical_router_ports.py
  function get_logical_router_port_params (line 392) | def get_logical_router_port_params(args=None):
  function get_logical_router_ports (line 401) | def get_logical_router_ports(module, manager_url, mgr_username, mgr_pass...
  function get_lr_port_from_display_name (line 409) | def get_lr_port_from_display_name(module, manager_url, mgr_username, mgr...
  function get_id_from_display_name (line 416) | def get_id_from_display_name(module, manager_url, mgr_username, mgr_pass...
  function update_params_with_id (line 429) | def update_params_with_id (module, manager_url, mgr_username, mgr_passwo...
  function check_for_update (line 439) | def check_for_update(module, manager_url, mgr_username, mgr_password, va...
  function main (line 462) | def main():

FILE: plugins/modules/nsxt_logical_router_ports_facts.py
  function main (line 70) | def main():

FILE: plugins/modules/nsxt_logical_router_static_routes.py
  function get_body_object (line 112) | def get_body_object(body):
  function get_logical_router_static_route_params (line 120) | def get_logical_router_static_route_params(args=None):
  function get_id_from_display_name (line 129) | def get_id_from_display_name(module, manager_url, mgr_username, mgr_pass...
  function update_params_with_id (line 142) | def update_params_with_id (module, manager_url, mgr_username, mgr_passwo...
  function get_logical_router_static_routes (line 147) | def get_logical_router_static_routes(module, manager_url, mgr_username, ...
  function get_lr_static_route_from_network (line 155) | def get_lr_static_route_from_network(module, manager_url, mgr_username, ...
  function get_lr_static_route_from_display_name (line 162) | def get_lr_static_route_from_display_name(module, manager_url, mgr_usern...
  function check_for_update (line 169) | def check_for_update(module, manager_url, mgr_username, mgr_password, va...
  function main (line 197) | def main():

FILE: plugins/modules/nsxt_logical_routers.py
  function get_logical_router_params (line 214) | def get_logical_router_params(args=None):
  function get_logical_routers (line 223) | def get_logical_routers(module, manager_url, mgr_username, mgr_password,...
  function get_lr_from_display_name (line 231) | def get_lr_from_display_name(module, manager_url, mgr_username, mgr_pass...
  function get_id_from_display_name (line 238) | def get_id_from_display_name(module, manager_url, mgr_username, mgr_pass...
  function update_params_with_id (line 250) | def update_params_with_id (module, manager_url, mgr_username, mgr_passwo...
  function get_id_from_display_name_uplink (line 302) | def get_id_from_display_name_uplink(module, manager_url, mgr_username, m...
  function check_for_update (line 326) | def check_for_update(module, manager_url, mgr_username, mgr_password, va...
  function main (line 382) | def main():
  function checkRedundantUplinkPortIds (line 487) | def checkRedundantUplinkPortIds(existingHaVipConfigs, newHaVipConfigs):
  function compareTags (line 498) | def compareTags(existing_logical_router, new_logical_router):
  function ordered (line 502) | def ordered(obj):

FILE: plugins/modules/nsxt_logical_routers_facts.py
  function main (line 66) | def main():

FILE: plugins/modules/nsxt_logical_switches.py
  function get_logical_switch_params (line 192) | def get_logical_switch_params(args=None):
  function get_logical_switches (line 201) | def get_logical_switches(module, manager_url, mgr_username, mgr_password...
  function get_lswitch_from_display_name (line 209) | def get_lswitch_from_display_name(module, manager_url, mgr_username, mgr...
  function get_id_from_display_name (line 216) | def get_id_from_display_name(module, manager_url, mgr_username, mgr_pass...
  function update_params_with_id (line 228) | def update_params_with_id (module, manager_url, mgr_username, mgr_passwo...
  function check_for_update (line 254) | def check_for_update(module, manager_url, mgr_username, mgr_password, va...
  function main (line 278) | def main():

FILE: plugins/modules/nsxt_logical_switches_facts.py
  function main (line 62) | def main():

FILE: plugins/modules/nsxt_manager_auto_deployment.py
  function get_node_params (line 121) | def get_node_params(args=None):
  function get_nodes (line 130) | def get_nodes(module, manager_url, mgr_username, mgr_password, validate_...
  function check_node_exist (line 138) | def check_node_exist(existing_nodes_data, module):
  function get_id_from_display_name (line 146) | def get_id_from_display_name(module, manager_url, mgr_username, mgr_pass...
  function update_params_with_id (line 159) | def update_params_with_id (module, manager_url, mgr_username, mgr_passwo...
  function wait_till_create (line 166) | def wait_till_create(vm_id, module, manager_url, mgr_username, mgr_passw...
  function wait_till_delete (line 181) | def wait_till_delete(vm_id, module, manager_url, mgr_username, mgr_passw...
  function get_node_id_from_name (line 197) | def get_node_id_from_name(module, manager_url, mgr_username, mgr_passwor...
  function inject_vcenter_info (line 214) | def inject_vcenter_info(module, manager_url, mgr_username, mgr_password,...
  function main (line 284) | def main():

FILE: plugins/modules/nsxt_manager_auto_deployment_facts.py
  function main (line 60) | def main():

FILE: plugins/modules/nsxt_manager_status.py
  function main (line 64) | def main():

FILE: plugins/modules/nsxt_policy_bfd_profile.py
  class NSXTBFDProfile (line 86) | class NSXTBFDProfile(NSXTBaseRealizableResource):
    method get_resource_spec (line 88) | def get_resource_spec():
    method get_resource_base_url (line 103) | def get_resource_base_url(baseline_args=None):

FILE: plugins/modules/nsxt_policy_gateway_policy.py
  class NSXTGatewayPolicy (line 300) | class NSXTGatewayPolicy(NSXTBaseRealizableResource):
    method get_resource_spec (line 302) | def get_resource_spec():
    method get_resource_base_url (line 311) | def get_resource_base_url(baseline_args):
    method update_resource_params (line 315) | def update_resource_params(self, nsx_resource_params):

FILE: plugins/modules/nsxt_policy_group.py
  class NSXTPolicyGroup (line 127) | class NSXTPolicyGroup(NSXTBaseRealizableResource):
    method get_resource_spec (line 129) | def get_resource_spec():
    method get_resource_base_url (line 152) | def get_resource_base_url(baseline_args):
    method update_resource_params (line 157) | def update_resource_params(self, nsx_resource_params):

FILE: plugins/modules/nsxt_policy_ip_block.py
  class NSXTIpBlock (line 81) | class NSXTIpBlock(NSXTBaseRealizableResource):
    method get_resource_spec (line 83) | def get_resource_spec():
    method get_resource_base_url (line 94) | def get_resource_base_url(baseline_args=None):

FILE: plugins/modules/nsxt_policy_ip_block_facts.py
  function main (line 63) | def main():

FILE: plugins/modules/nsxt_policy_ip_pool.py
  class NSXTIpPool (line 253) | class NSXTIpPool(NSXTBaseRealizableResource):
    method get_resource_spec (line 255) | def get_resource_spec():
    method get_resource_base_url (line 260) | def get_resource_base_url(baseline_args=None):
    method update_parent_info (line 263) | def update_parent_info(self, parent_info):
    class NSXTIpAddressPoolBlockSubnet (line 266) | class NSXTIpAddressPoolBlockSubnet(NSXTBaseRealizableResource):
      method get_spec_identifier (line 267) | def get_spec_identifier(self):
      method get_spec_identifier (line 272) | def get_spec_identifier(cls):
      method get_resource_spec (line 276) | def get_resource_spec():
      method get_resource_base_url (line 303) | def get_resource_base_url(parent_info):
      method update_resource_params (line 308) | def update_resource_params(self, nsx_resource_params):
    class NSXTIpAddressPoolStaticSubnet (line 318) | class NSXTIpAddressPoolStaticSubnet(NSXTBaseRealizableResource):
      method get_spec_identifier (line 319) | def get_spec_identifier(self):
      method get_spec_identifier (line 324) | def get_spec_identifier(cls):
      method get_resource_spec (line 328) | def get_resource_spec():
      method get_resource_base_url (line 371) | def get_resource_base_url(parent_info):
      method update_resource_params (line 376) | def update_resource_params(self, nsx_resource_params):

FILE: plugins/modules/nsxt_policy_ip_pool_facts.py
  function main (line 65) | def main():

FILE: plugins/modules/nsxt_policy_l2_bridge_ep_profile.py
  class NSXTL2BridgeEpProfile (line 131) | class NSXTL2BridgeEpProfile(NSXTBaseRealizableResource):
    method get_resource_spec (line 133) | def get_resource_spec():
    method get_resource_base_url (line 137) | def get_resource_base_url(baseline_args=None):
    method update_resource_params (line 141) | def update_resource_params(self, nsx_resource_params):

FILE: plugins/modules/nsxt_policy_security_policy.py
  class NSXTSecurityPolicy (line 332) | class NSXTSecurityPolicy(NSXTBaseRealizableResource):
    method get_resource_spec (line 334) | def get_resource_spec():
    method get_resource_base_url (line 338) | def get_resource_base_url(baseline_args):
    method update_resource_params (line 342) | def update_resource_params(self, nsx_resource_params):

FILE: plugins/modules/nsxt_policy_segment.py
  class NSXTSegment (line 769) | class NSXTSegment(NSXTBaseRealizableResource):
    method get_resource_spec (line 771) | def get_resource_spec():
    method get_resource_base_url (line 1079) | def get_resource_base_url(baseline_args=None):
    method update_resource_params (line 1082) | def update_resource_params(self, nsx_resource_params):
    method _updateSubnetsAsPerIpvType (line 1132) | def _updateSubnetsAsPerIpvType(self, nsx_resource_params):
    method _remove_ipv6_subnet_attrs (line 1142) | def _remove_ipv6_subnet_attrs(self, dhcp_config):
    method _remove_ipv4_subnet_attrs (line 1148) | def _remove_ipv4_subnet_attrs(self, dhcp_config):
    method update_parent_info (line 1151) | def update_parent_info(self, parent_info):
    class NSXTSegmentPort (line 1154) | class NSXTSegmentPort(NSXTBaseRealizableResource):
      method get_spec_identifier (line 1155) | def get_spec_identifier(self):
      method get_spec_identifier (line 1159) | def get_spec_identifier(cls):
      method get_resource_spec (line 1163) | def get_resource_spec():
      method get_resource_base_url (line 1272) | def get_resource_base_url(parent_info):

FILE: plugins/modules/nsxt_policy_tier0.py
  class NSXTTier0 (line 1255) | class NSXTTier0(NSXTBaseRealizableResource):
    method get_resource_spec (line 1257) | def get_resource_spec():
    method get_resource_base_url (line 1424) | def get_resource_base_url(baseline_args=None):
    method update_resource_params (line 1427) | def update_resource_params(self, nsx_resource_params):
    method update_parent_info (line 1480) | def update_parent_info(self, parent_info):
    class NSXTTier0StaticRoutes (line 1483) | class NSXTTier0StaticRoutes(NSXTBaseRealizableResource):
      method get_resource_update_priority (line 1485) | def get_resource_update_priority():
      method get_spec_identifier (line 1489) | def get_spec_identifier(self):
      method get_spec_identifier (line 1493) | def get_spec_identifier(cls):
      method get_resource_spec (line 1497) | def get_resource_spec():
      method get_resource_base_url (line 1526) | def get_resource_base_url(parent_info):
      method update_parent_info (line 1530) | def update_parent_info(self, parent_info):
    class NSXTTier0SRBFDPeer (line 1533) | class NSXTTier0SRBFDPeer(NSXTBaseRealizableResource):
      method get_spec_identifier (line 1534) | def get_spec_identifier(self):
      method get_spec_identifier (line 1539) | def get_spec_identifier(cls):
      method get_resource_spec (line 1543) | def get_resource_spec():
      method get_resource_base_url (line 1567) | def get_resource_base_url(parent_info):
      method update_resource_params (line 1571) | def update_resource_params(self, nsx_resource_params):
    class NSXTTier0LocaleService (line 1580) | class NSXTTier0LocaleService(NSXTBaseRealizableResource):
      method get_spec_identifier (line 1581) | def get_spec_identifier(self):
      method get_spec_identifier (line 1585) | def get_spec_identifier(cls):
      method infer_resource_id (line 1588) | def infer_resource_id(self, parent_info):
      method get_resource_spec (line 1608) | def get_resource_spec():
      method get_resource_base_url (line 1739) | def get_resource_base_url(parent_info):
      method update_resource_params (line 1743) | def update_resource_params(self, nsx_resource_params):
      method update_parent_info (line 1800) | def update_parent_info(self, parent_info):
      class NSXTTier0Interface (line 1803) | class NSXTTier0Interface(NSXTBaseRealizableResource):
        method get_spec_identifier (line 1804) | def get_spec_identifier(self):
        method get_spec_identifier (line 1810) | def get_spec_identifier(cls):
        method get_resource_spec (line 1814) | def get_resource_spec():
        method get_resource_base_url (line 1898) | def get_resource_base_url(parent_info):
        method update_resource_params (line 1904) | def update_resource_params(self, nsx_resource_params):
      class NSXTTier0LocaleServiceBGP (line 1942) | class NSXTTier0LocaleServiceBGP(NSXTBaseRealizableResource):
        method __init__ (line 1943) | def __init__(self):
        method skip_delete (line 1947) | def skip_delete(self):
        method get_spec_identifier (line 1950) | def get_spec_identifier(self):
        method get_spec_identifier (line 1956) | def get_spec_identifier(cls):
        method get_resource_spec (line 1960) | def get_resource_spec():
        method get_resource_base_url (line 2030) | def get_resource_base_url(parent_info):
        method allows_multiple_resource_spec (line 2037) | def allows_multiple_resource_spec(cls):
        class NSXTTier0LocaleServiceBGPNeighbor (line 2040) | class NSXTTier0LocaleServiceBGPNeighbor(
          method get_spec_identifier (line 2042) | def get_spec_identifier(self):
          method get_spec_identifier (line 2049) | def get_spec_identifier(cls):
          method get_resource_spec (line 2053) | def get_resource_spec():
          method get_resource_base_url (line 2143) | def get_resource_base_url(parent_info):

FILE: plugins/modules/nsxt_policy_tier1.py
  class NSXTTier1 (line 791) | class NSXTTier1(NSXTBaseRealizableResource):
    method get_resource_spec (line 793) | def get_resource_spec():
    method get_resource_base_url (line 938) | def get_resource_base_url(baseline_args=None):
    method update_resource_params (line 941) | def update_resource_params(self, nsx_resource_params):
    method update_parent_info (line 976) | def update_parent_info(self, parent_info):
    class NSXTTier1StaticRoutes (line 979) | class NSXTTier1StaticRoutes(NSXTBaseRealizableResource):
      method get_spec_identifier (line 980) | def get_spec_identifier(self):
      method get_spec_identifier (line 984) | def get_spec_identifier(cls):
      method get_resource_spec (line 988) | def get_resource_spec():
      method get_resource_base_url (line 1017) | def get_resource_base_url(parent_info):
    class NSXTTier1LocaleService (line 1021) | class NSXTTier1LocaleService(NSXTBaseRealizableResource):
      method get_spec_identifier (line 1022) | def get_spec_identifier(self):
      method get_spec_identifier (line 1026) | def get_spec_identifier(cls):
      method infer_resource_id (line 1029) | def infer_resource_id(self, parent_info):
      method get_resource_spec (line 1049) | def get_resource_spec():
      method get_resource_base_url (line 1194) | def get_resource_base_url(parent_info):
      method update_resource_params (line 1198) | def update_resource_params(self, nsx_resource_params):
      method update_parent_info (line 1266) | def update_parent_info(self, parent_info):
      class NSXTTier1Interface (line 1269) | class NSXTTier1Interface(NSXTBaseRealizableResource):
        method get_spec_identifier (line 1270) | def get_spec_identifier(self):
        method get_spec_identifier (line 1275) | def get_spec_identifier(cls):
        method get_resource_spec (line 1279) | def get_resource_spec():
        method get_resource_base_url (line 1320) | def get_resource_base_url(parent_info):
        method update_resource_params (line 1326) | def update_resource_params(self, nsx_resource_params):

FILE: plugins/modules/nsxt_principal_identities.py
  function get_principal_identity_params (line 121) | def get_principal_identity_params(args=None):
  function get_principal_identity_update_params (line 130) | def get_principal_identity_update_params(args=None):
  function update_params_with_pem_encoding (line 139) | def update_params_with_pem_encoding(principal_id_params):
  function update_params_with_id (line 147) | def update_params_with_id (module, manager_url, mgr_username, mgr_passwo...
  function get_id_from_display_name (line 152) | def get_id_from_display_name(module, manager_url, mgr_username, mgr_pass...
  function get_principal_ids (line 164) | def get_principal_ids(module, manager_url, mgr_username, mgr_password, v...
  function get_principal_id_with_display_name (line 172) | def get_principal_id_with_display_name(module, manager_url, mgr_username...
  function check_for_update (line 183) | def check_for_update(module, manager_url, mgr_username, mgr_password, va...
  function get_certificate_id_with_display_name (line 204) | def get_certificate_id_with_display_name(module, manager_url, mgr_userna...
  function main (line 215) | def main():

FILE: plugins/modules/nsxt_principal_identities_facts.py
  function main (line 63) | def main():

FILE: plugins/modules/nsxt_repo_sync.py
  function main (line 65) | def main():

FILE: plugins/modules/nsxt_repo_sync_facts.py
  function main (line 68) | def main():

FILE: plugins/modules/nsxt_rest.py
  class VMwareNSXTRest (line 160) | class VMwareNSXTRest():
    method __init__ (line 161) | def __init__(self, module):
    method error_code_check (line 188) | def error_code_check(self, info):
    method operate_nsxt (line 197) | def operate_nsxt(self, method, ignore_errors=False):
    method execute (line 214) | def execute(self):
  function main (line 245) | def main():

FILE: plugins/modules/nsxt_route_advertise.py
  function get_advertise_params (line 102) | def get_advertise_params(args=None):
  function get_logical_routers (line 111) | def get_logical_routers(module, manager_url, mgr_username, mgr_password,...
  function get_lr_from_display_name (line 119) | def get_lr_from_display_name(module, manager_url, mgr_username, mgr_pass...
  function get_revision (line 126) | def get_revision(module, manager_url, mgr_username, mgr_password, valida...
  function main (line 135) | def main():

FILE: plugins/modules/nsxt_transport_node_collections.py
  function get_transport_node_collections_params (line 108) | def get_transport_node_collections_params(args=None):
  function get_transport_node_collections (line 117) | def get_transport_node_collections(module, manager_url, mgr_username, mg...
  function get_id_from_display_name (line 125) | def get_id_from_display_name(module, manager_url, mgr_username, mgr_pass...
  function get_transport_node_collection_from_display_name (line 138) | def get_transport_node_collection_from_display_name(module, manager_url,...
  function wait_till_delete (line 145) | def wait_till_delete(id, module, manager_url, mgr_username, mgr_password...
  function get_transport_node_profile_id (line 155) | def get_transport_node_profile_id (module, manager_url, mgr_username, mg...
  function get_compute_collection_id (line 162) | def get_compute_collection_id (module, manager_url, mgr_username, mgr_pa...
  function update_params_with_id (line 176) | def update_params_with_id (module, manager_url, mgr_username, mgr_passwo...
  function check_for_update (line 189) | def check_for_update(module, manager_url, mgr_username, mgr_password, va...
  function main (line 218) | def main():
  function compareTags (line 296) | def compareTags(existing_tnc, new_tnc):
  function ordered (line 300) | def ordered(obj):

FILE: plugins/modules/nsxt_transport_node_collections_facts.py
  function main (line 64) | def main():

FILE: plugins/modules/nsxt_transport_node_profiles.py
  function get_transport_node_profile_params (line 128) | def get_transport_node_profile_params(args=None):
  function get_transport_node_profiles (line 137) | def get_transport_node_profiles(module, manager_url, mgr_username, mgr_p...
  function get_host_switch_id_from_display_name (line 145) | def get_host_switch_id_from_display_name(module, manager_url, mgr_userna...
  function get_id_from_display_name (line 158) | def get_id_from_display_name(module, manager_url, mgr_username, mgr_pass...
  function get_tnp_from_display_name (line 171) | def get_tnp_from_display_name(module, manager_url, mgr_username, mgr_pas...
  function update_params_with_id (line 179) | def update_params_with_id (module, manager_url, mgr_username, mgr_passwo...
  function id_exist_in_list_dict_obj (line 227) | def id_exist_in_list_dict_obj(key, list_obj1, list_obj2):
  function check_for_update (line 242) | def check_for_update(module, manager_url, mgr_username, mgr_password, va...
  function main (line 261) | def main():
  function compareTags (line 346) | def compareTags(existing_tnp, new_tnp):
  function ordered (line 350) | def ordered(obj):

FILE: plugins/modules/nsxt_transport_node_profiles_facts.py
  function main (line 64) | def main():

FILE: plugins/modules/nsxt_transport_nodes.py
  function get_transport_node_params (line 679) | def get_transport_node_params(args=None):
  function get_transport_nodes (line 688) | def get_transport_nodes(module, manager_url, mgr_username, mgr_password,...
  function get_discovered_nodes (line 697) | def get_discovered_nodes(module, manager_url, mgr_username, mgr_password...
  function get_id_from_display_name (line 706) | def get_id_from_display_name(module, manager_url, mgr_username, mgr_pass...
  function get_tn_from_display_name (line 719) | def get_tn_from_display_name(module, manager_url, mgr_username, mgr_pass...
  function get_dn_from_display_name (line 726) | def get_dn_from_display_name(module, manager_url, mgr_username, mgr_pass...
  function get_host_switch_id_from_display_name (line 733) | def get_host_switch_id_from_display_name(module, manager_url, mgr_userna...
  function wait_till_create (line 748) | def wait_till_create(node_id, module, manager_url, mgr_username, mgr_pas...
  function wait_till_delete (line 774) | def wait_till_delete(vm_id, module, manager_url, mgr_username, mgr_passw...
  function cmp_dict (line 784) | def cmp_dict(dict1, dict2): # dict1 contain dict2
  function update_params_with_id (line 801) | def update_params_with_id (module, manager_url, mgr_username, mgr_passwo...
  function id_exist_in_list_dict_obj (line 859) | def id_exist_in_list_dict_obj(key, list_obj1, list_obj2):
  function check_for_update (line 873) | def check_for_update(module, manager_url, mgr_username, mgr_password, va...
  function get_api_cert_thumbprint (line 903) | def get_api_cert_thumbprint(ip_address, module):
  function inject_vcenter_info (line 923) | def inject_vcenter_info(module, manager_url, mgr_username, mgr_password,...
  function main (line 995) | def main():
  function compareTags (line 1178) | def compareTags(existing_transport_node, new_transport_nodes):
  function ordered (line 1182) | def ordered(obj):

FILE: plugins/modules/nsxt_transport_nodes_facts.py
  function main (line 69) | def main():

FILE: plugins/modules/nsxt_transport_zones.py
  function get_transport_zone_params (line 136) | def get_transport_zone_params(args=None):
  function get_transport_zone_baseURL (line 146) | def get_transport_zone_baseURL(transport_zone_params):
  function get_transport_zones (line 154) | def get_transport_zones(module, manager_url, mgr_username, mgr_password,...
  function get_tz_from_display_name (line 165) | def get_tz_from_display_name(module, manager_url, mgr_username, mgr_pass...
  function check_for_update (line 173) | def check_for_update(module, manager_url, mgr_username, mgr_password, va...
  function main (line 202) | def main():

FILE: plugins/modules/nsxt_transport_zones_facts.py
  function main (line 84) | def main():

FILE: plugins/modules/nsxt_upgrade_eula_accept.py
  function main (line 63) | def main():

FILE: plugins/modules/nsxt_upgrade_eula_accept_facts.py
  function main (line 72) | def main():

FILE: plugins/modules/nsxt_upgrade_groups.py
  function update_group_parameters (line 108) | def update_group_parameters(module, manager_url,
  function main (line 123) | def main():

FILE: plugins/modules/nsxt_upgrade_groups_facts.py
  function main (line 60) | def main():

FILE: plugins/modules/nsxt_upgrade_history.py
  function main (line 60) | def main():

FILE: plugins/modules/nsxt_upgrade_plan.py
  function main (line 98) | def main():

FILE: plugins/modules/nsxt_upgrade_plan_facts.py
  function main (line 69) | def main():

FILE: plugins/modules/nsxt_upgrade_postchecks.py
  function wait_for_post_upgrade_checks_to_execute (line 75) | def wait_for_post_upgrade_checks_to_execute(module, manager_url, endpoin...
  function main (line 111) | def main():

FILE: plugins/modules/nsxt_upgrade_pre_post_checks_facts.py
  function main (line 60) | def main():

FILE: plugins/modules/nsxt_upgrade_prechecks.py
  function wait_for_pre_upgrade_checks_to_execute (line 80) | def wait_for_pre_upgrade_checks_to_execute(module, manager_url, endpoint...
  function main (line 115) | def main():

FILE: plugins/modules/nsxt_upgrade_run.py
  function get_upgrade_status (line 67) | def get_upgrade_status(module, manager_url, mgr_username, mgr_password, ...
  function call_get_sync (line 92) | def call_get_sync(managerUrl, endpoint, mgrUsername, mgrPassword, valida...
  function decide_next_step (line 97) | def decide_next_step(module, manager_url, mgr_username, mgr_password,
  function check_continuity (line 131) | def check_continuity(module, manager_url, mgr_username, mgr_password, va...
  function fetch_target_version (line 190) | def fetch_target_version(module, manager_url, mgr_username, mgr_password,
  function main (line 200) | def main():

FILE: plugins/modules/nsxt_upgrade_status_summary_facts.py
  function main (line 60) | def main():

FILE: plugins/modules/nsxt_upgrade_uc.py
  function main (line 63) | def main():

FILE: plugins/modules/nsxt_upgrade_uc_facts.py
  function main (line 62) | def main():

FILE: plugins/modules/nsxt_upgrade_upload_mub.py
  function get_upload_mub_params (line 76) | def get_upload_mub_params(args=None):
  function get_mgr_ip_upgrade_enabled (line 85) | def get_mgr_ip_upgrade_enabled(module, mgr_url, mgr_username, mgr_password,
  function wait_till_upload_done (line 96) | def wait_till_upload_done(module, bundle_id, mgr_url, mgr_username, mgr_...
  function upload_mub (line 113) | def upload_mub(module, mgr_url, mgr_username, mgr_password, validate_cer...
  function main (line 176) | def main():

FILE: plugins/modules/nsxt_upgrade_upload_mub_facts.py
  function main (line 65) | def main():

FILE: plugins/modules/nsxt_uplink_profiles.py
  function get_profile_params (line 165) | def get_profile_params(args=None):
  function get_host_switch_profiles (line 174) | def get_host_switch_profiles(module, manager_url, mgr_username, mgr_pass...
  function get_uplink_profile_from_display_name (line 182) | def get_uplink_profile_from_display_name(module, manager_url, mgr_userna...
  function id_exist_in_list_dict_obj (line 189) | def id_exist_in_list_dict_obj(key, list_obj1, list_obj2):
  function cmp_dict (line 202) | def cmp_dict(dict1, dict2): # dict1 contain dict2
  function check_for_update (line 219) | def check_for_update(module, manager_url, mgr_username, mgr_password, va...
  function main (line 265) | def main():

FILE: plugins/modules/nsxt_uplink_profiles_facts.py
  function main (line 70) | def main():

FILE: plugins/modules/nsxt_vidm.py
  function get_vidm_params (line 108) | def get_vidm_params(args=None):
  function get_vidm (line 118) | def get_vidm(module, url, mgr_username, mgr_password, validate_certs):
  function get_vidm_from_client_id (line 128) | def get_vidm_from_client_id(module, url, mgr_username, mgr_password, val...
  function wait_till_create (line 135) | def wait_till_create(module, url, mgr_username, mgr_password, validate_c...
  function wait_till_delete (line 167) | def wait_till_delete(module, url, mgr_username, mgr_password, validate_c...
  function check_for_update (line 188) | def check_for_update(existing_vidm, vidm_params):
  function main (line 201) | def main():

FILE: plugins/modules/nsxt_virtual_ip.py
  function get_virtual_ip_params (line 92) | def get_virtual_ip_params(args=None):
  function check_for_update (line 101) | def check_for_update(module, manager_url, mgr_username, mgr_password, va...
  function main (line 117) | def main():

FILE: plugins/modules/nsxt_virtual_ip_facts.py
  function main (line 62) | def main():

FILE: plugins/modules/nsxt_vm_tags.py
  function get_resource_spec (line 135) | def get_resource_spec():
  class TagElement (line 150) | class TagElement(object):
    method __init__ (line 151) | def __init__(self, tag):
    method __eq__ (line 155) | def __eq__(self, other):
    method __hash__ (line 160) | def __hash__(self):
  function _fetch_all_tags_on_vm_and_infer_id (line 163) | def _fetch_all_tags_on_vm_and_infer_id(
  function _get_tags_as_set (line 194) | def _get_tags_as_set(tags=[], scope_list=[]):
  function _read_tags_from_module_params (line 207) | def _read_tags_from_module_params(module_params, tag_identifier):
  function realize (line 211) | def realize():

FILE: tests/unit/plugins/module_utils/test_nsxt_base_resource.py
  class SimpleDummyNSXTResource (line 37) | class SimpleDummyNSXTResource(nsxt_base_resource.NSXTBaseRealizableResou...
    method __init__ (line 38) | def __init__(self):
    method get_resource_base_url (line 45) | def get_resource_base_url(baseline_args=None):
    method get_resource_spec (line 49) | def get_resource_spec():
  class NestedDummyNSXTResource (line 57) | class NestedDummyNSXTResource(nsxt_base_resource.NSXTBaseRealizableResou...
    method __init__ (line 58) | def __init__(self):
    method get_resource_base_url (line 65) | def get_resource_base_url(baseline_args=None):
    method get_resource_spec (line 69) | def get_resource_spec():
    class SubDummyResource1 (line 76) | class SubDummyResource1(nsxt_base_resource.NSXTBaseRealizableResource):
      method __init__ (line 78) | def __init__(self):
      method get_resource_update_priority (line 83) | def get_resource_update_priority():
      method get_resource_base_url (line 88) | def get_resource_base_url():
      method get_resource_base_url (line 92) | def get_resource_base_url(parent_info):
      method get_resource_spec (line 98) | def get_resource_spec():
      method achieve_subresource_state_if_del_parent (line 105) | def achieve_subresource_state_if_del_parent(self):
    class SubDummyResource2 (line 110) | class SubDummyResource2(nsxt_base_resource.NSXTBaseRealizableResource):
      method __init__ (line 112) | def __init__(self):
      method get_resource_update_priority (line 117) | def get_resource_update_priority():
      method get_spec_identifier (line 121) | def get_spec_identifier(self):
      method get_spec_identifier (line 127) | def get_spec_identifier(cls):
      method get_resource_base_url (line 131) | def get_resource_base_url(parent_info):
      method get_resource_spec (line 137) | def get_resource_spec():
    class SubDummyResource3 (line 144) | class SubDummyResource3(nsxt_base_resource.NSXTBaseRealizableResource):
      method __init__ (line 147) | def __init__(self):
      method get_resource_update_priority (line 152) | def get_resource_update_priority():
      method get_spec_identifier (line 156) | def get_spec_identifier(self):
      method get_spec_identifier (line 162) | def get_spec_identifier(cls):
      method allows_multiple_resource_spec (line 166) | def allows_multiple_resource_spec(cls):
      method get_resource_base_url (line 170) | def get_resource_base_url(parent_info):
      method get_resource_spec (line 176) | def get_resource_spec():
  class MockAnsible (line 184) | class MockAnsible(object):
    method __init__ (line 185) | def __init__(self, params={}, check_mode=False):
    method fail_json (line 189) | def fail_json(self, *args, **kwargs):
    method exit_json (line 192) | def exit_json(self, *args, **kwargs):
  class NSXTBaseRealizableResourceTestCase (line 196) | class NSXTBaseRealizableResourceTestCase(unittest.TestCase):
    method setUp (line 197) | def setUp(self):
    method tearDown (line 201) | def tearDown(self):
    method test_realize (line 207) | def test_realize(self, mock_policy_communicator):
    method test_check_for_update (line 627) | def test_check_for_update(self):
    method test_get_attribute (line 730) | def test_get_attribute(self):
    method test_extract_nsx_resource_params (line 752) | def test_extract_nsx_resource_params(self):
    method test_send_request_to_API (line 773) | def test_send_request_to_API(self, mock_policy_communicator):
    method test_achieve_present_state (line 837) | def test_achieve_present_state(self, mock_policy_communicator):
    method test_achieve_absent_state (line 940) | def test_achieve_absent_state(self, mock_policy_communicator):
    method test_get_sub_resources_class_of (line 1005) | def test_get_sub_resources_class_of(self):
    method test_fill_missing_resource_params (line 1018) | def test_fill_missing_resource_params(self):

FILE: tests/unit/plugins/module_utils/test_policy_communicator.py
  class PolicyCommunicatorTestCase (line 31) | class PolicyCommunicatorTestCase(unittest.TestCase):
    method setUp (line 32) | def setUp(self):
    method test_get_instance_with_same_credentials (line 36) | def test_get_instance_with_same_credentials(self):
    method test_get_instance_with_different_credentials (line 42) | def test_get_instance_with_different_credentials(self):
    method test_request_success_policy_response_with_success (line 50) | def test_request_success_policy_response_with_success(self, mock_open_...
    method test_request_success_policy_response_with_none (line 68) | def test_request_success_policy_response_with_none(self, mock_open_url):
    method test_request_success_policy_response_with_error (line 87) | def test_request_success_policy_response_with_error(self, mock_open_url):
    method test_request_failure (line 104) | def test_request_failure(self, mock_open_url):
Condensed preview — 241 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,314K chars).
[
  {
    "path": ".gitignore",
    "chars": 111,
    "preview": "# build products...\n*.py[co]\n# Mac OS X stuff...\n.DS_Store\n# test output\n*.retry\n# JetBrains project dir\n.idea\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "chars": 2537,
    "preview": "\n\n# Contributing to ansible-for-nsxt\n\nThe ansible-for-nsxt project team welcomes contributions from the community. Befor"
  },
  {
    "path": "LICENSE.txt",
    "chars": 37421,
    "preview": "ansible-for-nsxt\r\n\r\nCopyright (c) 2018 VMware, Inc.  All rights reserved\t\t\t\t\r\nSPDX-License-Identifier: BSD-2-Clause OR G"
  },
  {
    "path": "README.md",
    "chars": 12475,
    "preview": "# Ansible for NSX-T\n\n## Overview\nThis repository contains NSX-T Ansible Modules, which one can use with\nAnsible to work "
  },
  {
    "path": "galaxy.yml",
    "chars": 643,
    "preview": "namespace: vmware\n\nname: ansible_for_nsxt\n\nversion: 1.0.0\n\nreadme: README.md\n\nauthors:\n- Gautam Verma @ggverma (https://"
  },
  {
    "path": "meta/runtime.yml",
    "chars": 26,
    "preview": "requires_ansible: \">=2.9\"\n"
  },
  {
    "path": "plugins/doc_fragments/vmware_nsxt.py",
    "chars": 4117,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2021 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/module_utils/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "plugins/module_utils/common_utils.py",
    "chars": 7602,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-"
  },
  {
    "path": "plugins/module_utils/nsxt_base_resource.py",
    "chars": 37168,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/module_utils/nsxt_resource_urls.py",
    "chars": 2625,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2020 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/module_utils/policy_communicator.py",
    "chars": 10023,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/module_utils/policy_resource_specs/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "plugins/module_utils/policy_resource_specs/l2_bridge_ep_profile.py",
    "chars": 2137,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2020 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/module_utils/policy_resource_specs/security_policy.py",
    "chars": 4338,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2020 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/module_utils/upgrade_reverse_order.py",
    "chars": 6655,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/module_utils/vcenter_utils.py",
    "chars": 7213,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-"
  },
  {
    "path": "plugins/module_utils/vmware_nsxt.py",
    "chars": 9544,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "plugins/modules/nsxt_certificates.py",
    "chars": 9715,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_certificates_facts.py",
    "chars": 3398,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2020 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_cluster_profiles.py",
    "chars": 13952,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2020 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_cluster_profiles_facts.py",
    "chars": 3065,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_deploy_ova.py",
    "chars": 13650,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_edge_clusters.py",
    "chars": 15426,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_edge_clusters_facts.py",
    "chars": 3208,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_fabric_compute_managers.py",
    "chars": 15593,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_fabric_compute_managers_facts.py",
    "chars": 3161,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_global_manager_active.py",
    "chars": 7182,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2021 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_global_manager_enable_service.py",
    "chars": 6558,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2021 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_global_manager_registration.py",
    "chars": 11579,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2021 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_ip_blocks.py",
    "chars": 9027,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_ip_blocks_facts.py",
    "chars": 3306,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_ip_pools.py",
    "chars": 9592,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_ip_pools_facts.py",
    "chars": 3322,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_licenses.py",
    "chars": 6055,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_licenses_facts.py",
    "chars": 3048,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_local_manager_registration.py",
    "chars": 10658,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2021 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_local_managers_compatibility.py",
    "chars": 5303,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2021 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_local_managers_facts.py",
    "chars": 3124,
    "preview": "#!/usr/bin/python\n#\n# Copyright 2021 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n#\n# THIS SOFTW"
  },
  {
    "path": "plugins/modules/nsxt_logical_ports.py",
    "chars": 18778,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_logical_ports_facts.py",
    "chars": 3287,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_logical_router_ports.py",
    "chars": 29634,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_logical_router_ports_facts.py",
    "chars": 3520,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_logical_router_static_routes.py",
    "chars": 13960,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_logical_routers.py",
    "chars": 27847,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_logical_routers_facts.py",
    "chars": 3260,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_logical_switches.py",
    "chars": 18912,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_logical_switches_facts.py",
    "chars": 3015,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_manager_auto_deployment.py",
    "chars": 17238,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_manager_auto_deployment_facts.py",
    "chars": 3070,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_manager_status.py",
    "chars": 3621,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_policy_bfd_profile.py",
    "chars": 3434,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2020 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_policy_gateway_policy.py",
    "chars": 13374,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2020 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_policy_group.py",
    "chars": 6050,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_policy_ip_block.py",
    "chars": 3201,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_policy_ip_block_facts.py",
    "chars": 3107,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_policy_ip_pool.py",
    "chars": 13577,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_policy_ip_pool_facts.py",
    "chars": 3195,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_policy_l2_bridge_ep_profile.py",
    "chars": 6472,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2020 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_policy_security_policy.py",
    "chars": 14988,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_policy_segment.py",
    "chars": 52404,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_policy_tier0.py",
    "chars": 96441,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_policy_tier1.py",
    "chars": 59157,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_principal_identities.py",
    "chars": 14033,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_principal_identities_facts.py",
    "chars": 3059,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_repo_sync.py",
    "chars": 3835,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_repo_sync_facts.py",
    "chars": 3828,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_rest.py",
    "chars": 8843,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Copyright: (c) 2020, sky-joker\n# SPDX-License-Identifier: BSD-2-Clause OR G"
  },
  {
    "path": "plugins/modules/nsxt_route_advertise.py",
    "chars": 7676,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_transport_node_collections.py",
    "chars": 16286,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_transport_node_collections_facts.py",
    "chars": 3162,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_transport_node_profiles.py",
    "chars": 19161,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_transport_node_profiles_facts.py",
    "chars": 3043,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_transport_nodes.py",
    "chars": 64368,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_transport_nodes_facts.py",
    "chars": 3358,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_transport_zones.py",
    "chars": 13794,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_transport_zones_facts.py",
    "chars": 4678,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_upgrade_eula_accept.py",
    "chars": 3796,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_upgrade_eula_accept_facts.py",
    "chars": 4638,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_upgrade_groups.py",
    "chars": 9160,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_upgrade_groups_facts.py",
    "chars": 3100,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_upgrade_history.py",
    "chars": 2983,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_upgrade_plan.py",
    "chars": 6463,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_upgrade_plan_facts.py",
    "chars": 3625,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_upgrade_postchecks.py",
    "chars": 7441,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_upgrade_pre_post_checks_facts.py",
    "chars": 3089,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_upgrade_prechecks.py",
    "chars": 8815,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_upgrade_run.py",
    "chars": 12665,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_upgrade_status_summary_facts.py",
    "chars": 3099,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_upgrade_uc.py",
    "chars": 4043,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_upgrade_uc_facts.py",
    "chars": 2992,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_upgrade_upload_mub.py",
    "chars": 8435,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_upgrade_upload_mub_facts.py",
    "chars": 3425,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_uplink_profiles.py",
    "chars": 15850,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_uplink_profiles_facts.py",
    "chars": 3502,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_vidm.py",
    "chars": 11858,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2021 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_virtual_ip.py",
    "chars": 12732,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_virtual_ip_facts.py",
    "chars": 3042,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "plugins/modules/nsxt_vm_tags.py",
    "chars": 11072,
    "preview": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2020 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL"
  },
  {
    "path": "tests/playbooks/mp/answerfile.yml",
    "chars": 5343,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\nhostname: \"10.192.254.207\"\nuse"
  },
  {
    "path": "tests/playbooks/mp/answerfile_9x.yml",
    "chars": 5558,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\nhostname: \"10.192.254.207\"\nuse"
  },
  {
    "path": "tests/playbooks/mp/answerfile_attach_tnp_to_cluster.yml",
    "chars": 1351,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\nhostname: \"10.161.157.200\"\nuse"
  },
  {
    "path": "tests/playbooks/mp/answerfile_attach_tnp_to_cluster_9x.yml",
    "chars": 1426,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\nhostname: \"10.161.157.200\"\nuse"
  },
  {
    "path": "tests/playbooks/mp/answerfile_tn.yml",
    "chars": 1678,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\nhostname: \"10.161.157.200\"\nuse"
  },
  {
    "path": "tests/playbooks/mp/answerfile_tn_9x.yml",
    "chars": 1531,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\nhostname: \"10.161.157.200\"\nuse"
  },
  {
    "path": "tests/playbooks/mp/test_attach_tnp_to_cluster.yml",
    "chars": 3417,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_attach_tnp_to_cluster_9x.yml",
    "chars": 3310,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_basic_topology.yml",
    "chars": 5814,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_basic_topology_9x.yml",
    "chars": 5694,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_certificates.yml",
    "chars": 578,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_certificates_facts.yml",
    "chars": 435,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_cluster_profiles.yml",
    "chars": 753,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_cluster_profiles_facts.yml",
    "chars": 435,
    "preview": "# Copyright 2020 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_compute_managers.yml",
    "chars": 905,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_compute_managers_facts.yml",
    "chars": 442,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_configure_transport_node.yml",
    "chars": 2156,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_configure_transport_node_9x.yml",
    "chars": 2051,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_edge_clusters.yml",
    "chars": 633,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_edge_clusters_facts.yml",
    "chars": 425,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_global_manager_enable_service.yml",
    "chars": 597,
    "preview": "---\n#\n# Playbook to register Compute Managers with NSX Appliance\n#\n- hosts: 127.0.0.1\n  connection: local\n  become: yes\n"
  },
  {
    "path": "tests/playbooks/mp/test_global_manager_registration.yml",
    "chars": 781,
    "preview": "---\n#\n# Playbook to register Compute Managers with NSX Appliance\n#\n- hosts: 127.0.0.1\n  connection: local\n  become: yes\n"
  },
  {
    "path": "tests/playbooks/mp/test_global_managers_active.yml",
    "chars": 525,
    "preview": "---\n#\n# Playbook to register Compute Managers with NSX Appliance\n#\n- hosts: 127.0.0.1\n  connection: local\n  become: yes\n"
  },
  {
    "path": "tests/playbooks/mp/test_ip_blocks.yml",
    "chars": 482,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_ip_blocks_facts.yml",
    "chars": 402,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_ip_pools.yml",
    "chars": 536,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_ip_pools_facts.yml",
    "chars": 415,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_licenses.yml",
    "chars": 463,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_licenses_facts.yml",
    "chars": 418,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_local_manager_registration.yml",
    "chars": 773,
    "preview": "---\n#\n# Playbook to register Compute Managers with NSX Appliance\n#\n- hosts: 127.0.0.1\n  connection: local\n  become: yes\n"
  },
  {
    "path": "tests/playbooks/mp/test_local_managers_compatibility.yml",
    "chars": 825,
    "preview": "---\n#\n# Playbook to register Compute Managers with NSX Appliance\n#\n- hosts: 127.0.0.1\n  connection: local\n  become: yes\n"
  },
  {
    "path": "tests/playbooks/mp/test_local_managers_facts.yml",
    "chars": 426,
    "preview": "---\n#\n# Playbook to get facts of local managers registered with a global manager\n#\n- hosts: 127.0.0.1\n  connection: loca"
  },
  {
    "path": "tests/playbooks/mp/test_logical_ports.yml",
    "chars": 599,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_logical_ports_facts.yml",
    "chars": 425,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_logical_router_ports.yml",
    "chars": 795,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_logical_router_ports_facts.yml",
    "chars": 439,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_logical_router_static_route.yml",
    "chars": 661,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_logical_routers.yml",
    "chars": 1282,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_logical_routers_facts.yml",
    "chars": 429,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_logical_switches.yml",
    "chars": 548,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_logical_switches_facts.yml",
    "chars": 435,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_manager_auto_deployment.yml",
    "chars": 1841,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_manager_auto_deployment_facts.yml",
    "chars": 475,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_manager_status.yml",
    "chars": 444,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_ovf_deployment.yml",
    "chars": 1478,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_principal_identities.yml",
    "chars": 786,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_principal_identities_facts.yml",
    "chars": 451,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_repo_sync.yml",
    "chars": 419,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_repo_sync_facts.yml",
    "chars": 461,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_rest.yml",
    "chars": 10217,
    "preview": "# Test code for the nsxt_rest module.\n# Copyright: (c) 2020, sky-joker <sky.jokerxx@gmail.com>\n# GNU General Public Lice"
  },
  {
    "path": "tests/playbooks/mp/test_route_advertise.yml",
    "chars": 942,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_transport_node_collections.yml",
    "chars": 710,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_transport_node_collections_facts.yml",
    "chars": 451,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_transport_node_profiles.yml",
    "chars": 778,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_transport_node_profiles_facts.yml",
    "chars": 445,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_transport_nodes.yml",
    "chars": 3480,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_transport_nodes_edge.yml",
    "chars": 798,
    "preview": "# Copyright 2020 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_transport_nodes_edge_9x.yml",
    "chars": 771,
    "preview": "# Copyright 2020 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_transport_nodes_facts.yml",
    "chars": 429,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_transport_nodes_host.yml",
    "chars": 830,
    "preview": "# Copyright 2020 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_transport_nodes_host_9x.yml",
    "chars": 763,
    "preview": "# Copyright 2020 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_transport_zones.yml",
    "chars": 763,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_transport_zones_facts.yml",
    "chars": 429,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_upgrade_eula_accept.yml",
    "chars": 396,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_upgrade_eula_accept_facts.yml",
    "chars": 468,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_upgrade_groups.yml",
    "chars": 596,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_upgrade_groups_facts.yml",
    "chars": 409,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_upgrade_history_facts.yml",
    "chars": 399,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_upgrade_plan.yml",
    "chars": 542,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_upgrade_plan_facts.yml",
    "chars": 435,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_upgrade_postchecks.yml",
    "chars": 459,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_upgrade_pre_post_checks_facts.yml",
    "chars": 430,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_upgrade_prechecks.yml",
    "chars": 438,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_upgrade_run.yml",
    "chars": 418,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_upgrade_status_summary_facts.yml",
    "chars": 419,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_upgrade_uc.yml",
    "chars": 386,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_upgrade_uc_facts.yml",
    "chars": 403,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_upgrade_upload_mub.yml",
    "chars": 578,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_upgrade_upload_mub_facts.yml",
    "chars": 466,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_uplink_profiles.yml",
    "chars": 674,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_uplink_profiles_9x.yml",
    "chars": 659,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_uplink_profiles_facts.yml",
    "chars": 429,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_vidm.yml",
    "chars": 683,
    "preview": "---\n#\n# Playbook to register Compute Managers with NSX Appliance\n#\n- hosts: 127.0.0.1\n  connection: local\n  become: yes\n"
  },
  {
    "path": "tests/playbooks/mp/test_virtual_ip.yml",
    "chars": 558,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/mp/test_virtual_ip_facts.yml",
    "chars": 448,
    "preview": "# Copyright 2019 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n- hosts: 127.0.0.1\n  connectio"
  },
  {
    "path": "tests/playbooks/policy/test_nsxt_policy_bfd_profile.yaml",
    "chars": 426,
    "preview": "- hosts: localhost\n  tasks:\n    - name: Update BFD Profile\n      vmware.ansible_for_nsxt.nsxt_policy_bfd_profile:\n      "
  },
  {
    "path": "tests/playbooks/policy/test_nsxt_policy_gateway_policy.yml",
    "chars": 1301,
    "preview": "# Copyright 2020 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n#\n# Playbook to test Gateway P"
  },
  {
    "path": "tests/playbooks/policy/test_nsxt_policy_group.yml",
    "chars": 747,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n#\n# Playbook to test Policy Gr"
  },
  {
    "path": "tests/playbooks/policy/test_nsxt_policy_ip_block.yml",
    "chars": 525,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n#\n# Playbook to test IP Block\n"
  },
  {
    "path": "tests/playbooks/policy/test_nsxt_policy_ip_pool.yml",
    "chars": 1563,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n#\n# Playbook to test IP Pool\n#"
  },
  {
    "path": "tests/playbooks/policy/test_nsxt_policy_l2_bridge_ep_profile.yml",
    "chars": 724,
    "preview": "# Copyright 2020 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n#\n# Playbook to test L2 Bridge"
  },
  {
    "path": "tests/playbooks/policy/test_nsxt_policy_security_policy.yml",
    "chars": 1290,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n#\n# Playbook to test Security "
  },
  {
    "path": "tests/playbooks/policy/test_nsxt_policy_segment.yml",
    "chars": 2120,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n#\n# Playbook to test Segment\n#"
  },
  {
    "path": "tests/playbooks/policy/test_nsxt_policy_tier0.yml",
    "chars": 3428,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n#\n# Playbook to test Tier0\n#\n-"
  },
  {
    "path": "tests/playbooks/policy/test_nsxt_policy_tier1.yml",
    "chars": 2468,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n#\n# Playbook to test Tier1\n#\n-"
  },
  {
    "path": "tests/playbooks/policy/test_vm_tags.yaml",
    "chars": 578,
    "preview": "- hosts: localhost\n  tasks:\n    - name: Update Tags on VMs\n      vmware.ansible_for_nsxt.nsxt_vm_tags:\n        hostname:"
  },
  {
    "path": "tests/playbooks/topologies/deploy_nsx_cluster/01_deploy_first_node.yml",
    "chars": 1750,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n#\n# Playbook to deploy the fir"
  },
  {
    "path": "tests/playbooks/topologies/deploy_nsx_cluster/02_configure_compute_manager.yml",
    "chars": 918,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n#\n# Playbook to register Compu"
  },
  {
    "path": "tests/playbooks/topologies/deploy_nsx_cluster/03_deploy_second_third_node.yml",
    "chars": 1823,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n#\n# Deploys remaining NSX appl"
  },
  {
    "path": "tests/playbooks/topologies/deploy_nsx_cluster/04_add_nsx_license.yml",
    "chars": 640,
    "preview": "# Copyright 2018 VMware, Inc.\n# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only\n---\n#\n# Playbook to register Compu"
  }
]

// ... and 41 more files (download for full content)

About this extraction

This page contains the full source code of the vmware/ansible-for-nsxt GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 241 files (1.2 MB), approximately 267.4k tokens, and a symbol index with 534 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!