Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Release v1.3 features #220

Merged
merged 111 commits into from
Jul 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
be5d3cf
security rules basic structure #207
Jun 6, 2022
0a0ac53
security rules spec
Jun 8, 2022
932468a
security rules create and delete functionality
Jun 8, 2022
39d1c06
Fix sanity and doc
alaa-bish Jun 8, 2022
1aba83b
security rules update functionality
Jun 9, 2022
15c9e03
security rules info module
Jun 10, 2022
113c877
add integraioson test
alaa-bish Jun 13, 2022
c321677
security rules spec fixes
Jun 14, 2022
c86a530
Merge remote-tracking branch 'origin/feat/security-rules#207' into fe…
Jun 14, 2022
9cb3957
security rules spec fixes
Jun 14, 2022
4fb74ab
security rules spec fixes
Jun 14, 2022
a1a6da0
security rules spec fixes, rule update functionality
Jun 14, 2022
d0d231c
security rules requirements fixes
Jun 15, 2022
9614995
fix sanity
alaa-bish Jun 15, 2022
57ab4fa
security rules requirements and spec generation fixes
Jun 15, 2022
6da84e0
Merge remote-tracking branch 'origin/feat/security-rules#207' into fe…
Jun 15, 2022
cec21a3
security rules requirements and spec generation fixes
Jun 15, 2022
0b92e9b
Add integration test
alaa-bish Jun 15, 2022
d08ce14
sanity fix
alaa-bish Jun 15, 2022
e9181fb
Add integration tests
alaa-bish Jun 16, 2022
c7ae5e2
security rules requirements and spec generation fixes
Jun 20, 2022
6e5486f
sanity fix
alaa-bish Jun 20, 2022
76c3888
Add integration test
alaa-bish Jun 21, 2022
56fab2d
ad_rule -> vdi_rule
Jun 22, 2022
db0fb16
update protocols spec, ability to delete rule
Jun 27, 2022
d7b2aaa
update protocols spec
Jun 28, 2022
8509b8d
updates for protocols spec
Jun 28, 2022
551108f
updates for protocols spec
Jun 28, 2022
11a704a
Fix integration test
alaa-bish Jun 29, 2022
d4e7ec9
updates for isolation rule
Jun 29, 2022
101d7ad
updates for app, ad quarantine rules
Jun 29, 2022
f78f1ed
fix integraton
alaa-bish Jun 30, 2022
53e28c1
Nutanix Image Module (#211)
bhati-pradeep Jun 30, 2022
67359b3
Image placement policy module and its info module (#214)
bhati-pradeep Jun 30, 2022
8381e8d
Add functionality to deattach all the categories from vm using flag r…
bhati-pradeep Jun 30, 2022
017ad0e
list functionality for address/service groups
Jun 30, 2022
07d00a2
Merge remote-tracking branch 'origin/feat/security-rules#207' into fe…
Jun 30, 2022
18d6199
black and isort fixes
Jun 30, 2022
013c4cd
black and isort fixes
Jun 30, 2022
4042ca5
black and isort fixes
Jun 30, 2022
e37e061
black and isort fixes
Jun 30, 2022
3cc648b
update requirements
Jun 30, 2022
a143d79
fixes
Jun 30, 2022
0bc79e4
ADGroup fixes
Jun 30, 2022
97cc00b
ADGroup fixes
Jun 30, 2022
c7a029d
remove default values for fields which are updatable
bhati-pradeep Jun 30, 2022
a74ac28
Doc fix
bhati-pradeep Jun 30, 2022
bef5bab
allow all updates
Jun 30, 2022
3469087
allow all updates
Jun 30, 2022
472777d
Common spec for categories mapping
bhati-pradeep Jun 30, 2022
ab743ac
Formatting
bhati-pradeep Jun 30, 2022
aecee10
Formatting changes
bhati-pradeep Jun 30, 2022
032c1ad
formatting
bhati-pradeep Jun 30, 2022
c0d4074
formatting
bhati-pradeep Jun 30, 2022
e6dc3b4
flake8 changes
bhati-pradeep Jun 30, 2022
5f28a34
Sanity fix
bhati-pradeep Jun 30, 2022
7cc6cc9
config changes
bhati-pradeep Jun 30, 2022
9109103
Update categories in tests
bhati-pradeep Jun 30, 2022
f2b31f9
categories mapping
Jul 1, 2022
6960537
categories mapping optimizations
Jul 1, 2022
ffcf8b8
default_internal_policy fixes
Jul 1, 2022
70a6e58
default_internal_policy fixes
Jul 1, 2022
c914af3
fixes for target categories updating
Jul 1, 2022
649b69a
Fix tests
alaa-bish Jul 1, 2022
278e9ef
fixes for rules description
Jul 1, 2022
32fe071
remove categories mapping and prject reference
Jul 1, 2022
3425aa4
Fix tests
alaa-bish Jul 1, 2022
0c0b240
fix integration
alaa-bish Jul 1, 2022
6b622fb
Merge branch 'feat/1.3' into feat/security-rules#207
Jul 1, 2022
eeae336
Merge pull request #218 from nutanix/feat/security-rules#207
Gevorg-Khachatryan-97 Jul 1, 2022
b79d731
flake8 fix
Jul 1, 2022
4b27cd9
Merge branch 'feat/1.3' into impr/categories-mapping-spec
Jul 1, 2022
83b32dd
Merge pull request #219 from nutanix/impr/categories-mapping-spec
Gevorg-Khachatryan-97 Jul 1, 2022
7bc04af
black and isort fixes
Jul 1, 2022
16406af
black and isort fixes
Jul 1, 2022
ac53a3d
examples fixes
Jul 1, 2022
c29a12c
isolation rule docs fixes
Jul 1, 2022
98aeb46
fix sanity
alaa-bish Jul 1, 2022
b6d2225
galaxy file changes
bhati-pradeep Jul 1, 2022
0e2477c
sanity fix
alaa-bish Jul 1, 2022
eb62ee4
Merge branch 'feat/1.3' of https://github.com/nutanix/nutanix.ansible…
alaa-bish Jul 1, 2022
587c4e9
docs fixes
Jul 1, 2022
92aab2c
Merge remote-tracking branch 'origin/feat/1.3' into feat/1.3
Jul 1, 2022
ac69bdf
vm's create ova and clone example fixes
Jul 1, 2022
f42044f
fix sanity
alaa-bish Jul 1, 2022
69f7269
fix sanity
alaa-bish Jul 1, 2022
5553577
doc fixes
Jul 1, 2022
f012ea7
doc fixes
Jul 1, 2022
7e5ed75
Setup config changes
bhati-pradeep Jul 1, 2022
c0f4024
fix test
bhati-pradeep Jul 1, 2022
1950f82
Security info module fix
bhati-pradeep Jul 2, 2022
dc6ddec
doc fix
bhati-pradeep Jul 2, 2022
2fd5163
Lint fixes
bhati-pradeep Jul 2, 2022
3100f8a
setup config changes
bhati-pradeep Jul 3, 2022
fd5a58f
quarantine rule uuid changes
bhati-pradeep Jul 4, 2022
67be335
sanity fix
alaa-bish Jul 4, 2022
6723739
Update and info module for static routes (#221)
bhati-pradeep Jul 4, 2022
0649d1b
UUID changes
bhati-pradeep Jul 4, 2022
de29e06
Changes for sanity and config
bhati-pradeep Jul 4, 2022
4399c0b
sanity fix
bhati-pradeep Jul 4, 2022
e39f4a8
static routes minor formatting
bhati-pradeep Jul 4, 2022
fef5507
setup config changes
bhati-pradeep Jul 4, 2022
79a2cc2
formatting
bhati-pradeep Jul 4, 2022
d58b12b
Fix bug dynamic inventory bug due to load_params
yannickstruyf3 Jul 4, 2022
75a4ed8
Merge pull request #223 from yannickstruyf3/bugfix/dynamic-inventory-…
Gevorg-Khachatryan-97 Jul 4, 2022
3c343ab
changelog and readme updates
Jul 4, 2022
b4df7c5
Docs changes
bhati-pradeep Jul 4, 2022
413eb34
Change log changes
bhati-pradeep Jul 4, 2022
963aeaa
Update docs
bhati-pradeep Jul 4, 2022
ec6aca8
Docs update
bhati-pradeep Jul 4, 2022
a48ba6e
Minor fix
bhati-pradeep Jul 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## v1.3.0 (4 July 2022)

**Features**

**Prism Central**
- Ansible module for Image Management
- Ansible info module for Image Management
- Ansible module for Image Placement Policy
- Ansible info module for Image Placement Policies
- Ansible module for Network Security Rules
- Ansible info module for Network Security Rules
- Ansible module for VPC Static Routes
- Ansible info module for VPC Static Routes

## v1.2.0 (3 June 2022)

**Features**
Expand Down
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ It is designed keeping simplicity as the core value. Hence it is
## Prism Cenral
> For the 1.1.0 release of the ansible plugin it will have N-2 compatibility with the Prism Central APIs. This release was tested against Prism Central versions pc2022.1.0.2, pc.2021.9.0.5 and pc.2021.8.0.1.
> For the 1.2.0 release of the ansible plugin it will have N-2 compatibility with the Prism Central APIs. This release was tested against Prism Central versions pc.2022.4, pc2022.1.0.2 and pc.2021.9.0.5.
> For the 1.3.0 release of the ansible plugin it will have N-2 compatibility with the Prism Central APIs. This release was tested against Prism Central versions pc.2022.4, pc2022.1.0.2 and pc.2021.9.0.4. Static routes module (ntnx_static_routes) is only supported for PC versions >= pc.2022.1.

Prism Central based examples: https://github.com/nutanix/nutanix.ansible/tree/main/examples/

Expand Down Expand Up @@ -98,24 +99,32 @@ ansible-playbook examples/iaas/iaas.yml

| Name | Description |
| --- | --- |
| ntnx_floating_ips | Create or delete a Floating Ip. |
| ntnx_floating_ips_info | List existing Floating_Ips. |
| ntnx_images | Create, update or delete a image. |
| ntnx_images_info | List existing images. |
| ntnx_image_placement_policy | Create, update or delete a image placement policy. |
| ntnx_image_placement_policies_info | List existing image placement policies. |
| ntnx_pbrs | Create or delete a PBR. |
| ntnx_pbrs_info | List existing PBRs. |
| ntnx_security_rules | Create, update or delete a Security Rule. |
| ntnx_security_rules_info | List existing Security Rules. |
| ntnx_static_routes | Update static routes of a vpc. |
| ntnx_static_routes_info | List existing static routes of a vpc. |
| ntnx_subnets | Create or delete a Subnet. |
| ntnx_subnets_info | List existing Subnets. |
| ntnx_vms | Create or delete a VM. |
| ntnx_vms_clone | Clone VM. |
| ntnx_vms_ova | Create OVA image from VM. |
| ntnx_vms_info | List existing VMs. |
| ntnx_vpcs | Create or delete a VPC. |
| ntnx_vpcs_info | List existing VPCs. |
| ntnx_subnets | Create or delete a Subnet. |
| ntnx_subnets_info | List existing Subnets. |
| ntnx_floating_ips | Create or delete a Floating Ip. |
| ntnx_floating_ips_info | List existing Floating_Ips. |
| ntnx_pbrs | Create or delete a PBR. |
| ntnx_pbrs_info | List existing PBRs. |
| ntnx_foundation | Image nodes and create new cluster. |
| ntnx_foundation_bmc_ipmi_config | Configure IPMI IP address on BMC of nodes. |
| ntnx_foundation_image_upload | Upload hypervisor or AOS image to Foundation VM. |
| ntnx_foundation_aos_packages_info | List the AOS packages uploaded to Foundation. |
| ntnx_foundation_bmc_ipmi_config | Configure IPMI IP address on BMC of nodes. |
| ntnx_foundation_discover_nodes_info | List the nodes discovered by Foundation. |
| ntnx_foundation_hypervisor_images_info | List the hypervisor images uploaded to Foundation. |
| ntnx_foundation_image_upload | Upload hypervisor or AOS image to Foundation VM. |
| ntnx_foundation_node_network_info | Get node network information discovered by Foundation. |
| ntnx_foundation_central | Create a cluster out of nodes registered with Foundation Central. |
| ntnx_foundation_central_api_keys | Create a new api key which will be used by remote nodes to authenticate with Foundation Central. |
Expand All @@ -127,7 +136,7 @@ ansible-playbook examples/iaas/iaas.yml

| Name | Description |
| --- | --- |
| ntnx_vms_inventory | Nutanix VMs inventory source |
| ntnx_prism_vm_inventory | Nutanix VMs inventory source |

# Module documentation and examples
```
Expand Down
3 changes: 1 addition & 2 deletions examples/vm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@
is_overridable: True
register: output

- name: output of list Subnets
- name: output of vm created
debug:
msg: '{{ output }}'

- name: delete VM
ntnx_vms:
state: absent
vm_uuid: "{{output.vm_uuid}}"
register: output
14 changes: 6 additions & 8 deletions examples/vm_operations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,19 @@
ignore_errors: true

- name: create_ova_image while vm is on
ntnx_vms:
ntnx_vms_ova:
state: present
vm_uuid: "{{ vm_uuid }}"
operation: create_ova_image
ova_name: integration_test_VMDK_ova
ova_file_format: VMDK
src_vm_uuid: "{{ vm_uuid }}"
name: integration_test_VMDK_ova
file_format: VMDK
wait: true
register: result
ignore_errors: true

- name: clone vm while it's off also add network and script
ntnx_vms:
ntnx_vms_clone:
state: present
vm_uuid: "{{ vm_uuid }}"
operation: clone
src_vm_uuid: "{{ vm_uuid }}"
networks:
- is_connected: true
subnet:
Expand Down
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace: "nutanix"
name: "ncp"
version: "1.2.0"
version: "1.3.0"
readme: "README.md"
authors:
- "Abhishek Chaudhary (@abhimutant)"
Expand Down
14 changes: 11 additions & 3 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@ requires_ansible: '>=2.11.6'
action_groups:
ntnx:
- ntnx_floating_ips
- ntnx_images
- ntnx_image_placement_policy
- ntnx_pbrs
- ntnx_vms
- ntnx_vpcs
- ntnx_security_rules
- ntnx_static_routes
- ntnx_subnets
- ntnx_vms_ova
- ntnx_vms_clone
- ntnx_vms
- ntnx_vpcs
- ntnx_floating_ips_info
- ntnx_images_info
- ntnx_image_placement_policies_info
- ntnx_pbrs_info
- ntnx_security_rules_info
- ntnx_static_routes_info
- ntnx_subnets_info
- ntnx_vms_info
- ntnx_vpcs_info
- ntnx_subnets_info
- ntnx_foundation_aos_packages_info
- ntnx_foundation_bmc_ipmi_config
- ntnx_foundation_discover_nodes_info
Expand Down
3 changes: 2 additions & 1 deletion plugins/inventory/ntnx_prism_vm_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def __init__(self, host, port, username, password, validate_certs=False):
"nutanix_username": username,
"nutanix_password": password,
"validate_certs": validate_certs,
"load_params_without_defaults": False,
}

def jsonify(self, data):
Expand Down Expand Up @@ -150,7 +151,7 @@ def parse(self, inventory, loader, path, cache=True):
for nics in entity["status"]["resources"]["nic_list"]:
if nics["nic_type"] == "NORMAL_NIC" and nic_count == 0:
for endpoint in nics["ip_endpoint_list"]:
if endpoint["type"] == "ASSIGNED":
if endpoint["type"] in ["ASSIGNED", "LEARNED"]:
vm_ip = endpoint["ip"]
nic_count += 1
continue
Expand Down
17 changes: 13 additions & 4 deletions plugins/module_utils/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def upload(
self,
source,
endpoint=None,
method="POST",
query=None,
raise_error=True,
no_response=False,
Expand All @@ -125,7 +126,7 @@ def upload(
return self._upload_file(
url,
source,
method="POST",
method=method,
raise_error=raise_error,
no_response=no_response,
timeout=timeout,
Expand Down Expand Up @@ -353,13 +354,15 @@ def _fetch_url(
def _upload_file(
self, url, source, method, raise_error=True, no_response=False, timeout=30
):

file_chunks_iterator = FileChunksIterator(source)
headers = copy.deepcopy(self.headers)
headers["Content-Length"] = file_chunks_iterator.length
resp, info = fetch_url(
self.module,
url,
data=FileChunksIterator(source),
data=file_chunks_iterator,
method=method,
headers=self.headers,
headers=headers,
cookies=self.cookies,
timeout=timeout,
)
Expand All @@ -372,6 +375,12 @@ def _upload_file(
resp_json = None

if not raise_error:
# Add error details and status details if any
if not resp_json:
resp_json = {}
if status_code >= 300:
resp_json["error"] = body
resp_json["status_code"] = status_code
return resp_json

if status_code >= 300:
Expand Down
43 changes: 43 additions & 0 deletions plugins/module_utils/prism/address_groups.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This file is part of Ansible
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function

__metaclass__ = type

from .prism import Prism


class AddressGroup(Prism):
def __init__(self, module):
resource_type = "/address_groups"
super(AddressGroup, self).__init__(module, resource_type=resource_type)

def get_uuid(self, value, key="name", raise_error=True, no_response=False):
data = {"filter": "{0}=={1}".format(key, value), "length": 1}
resp = self.list(data, raise_error=raise_error, no_response=no_response)
entities = resp.get("entities") if resp else None
if entities:
for entity in entities:
if entity["address_group"]["name"] == value:
return entity["uuid"]
return None


# Helper functions


def get_address_uuid(config, module):
if "name" in config:
address_group = AddressGroup(module)
name = config["name"]
uuid = address_group.get_uuid(name)
if not uuid:
error = "Address {0} not found.".format(name)
return None, error
elif "uuid" in config:
uuid = config["uuid"]
else:
error = "Config {0} doesn't have name or uuid key".format(config)
return None, error

return uuid, None
75 changes: 75 additions & 0 deletions plugins/module_utils/prism/image_placement_policy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# This file is part of Ansible
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function

from copy import deepcopy

from .prism import Prism
from .spec.categories_mapping import CategoriesMapping

__metaclass__ = type


class ImagePlacementPolicy(Prism):
def __init__(self, module):
resource_type = "/images/placement_policies"
super(ImagePlacementPolicy, self).__init__(module, resource_type=resource_type)
self.build_spec_methods = {
"name": self._build_spec_name,
"desc": self._build_spec_desc,
"categories": CategoriesMapping.build_categories_mapping_spec,
"remove_categories": CategoriesMapping.build_remove_all_categories_spec,
"placement_type": self._build_spec_placement_type,
"image_categories": self._build_spec_image_categories,
"cluster_categories": self._build_spec_cluster_categories,
}

def _get_default_spec(self):
return deepcopy(
{
"api_version": "3.1.0",
"metadata": {
"kind": "image_placement_policy",
},
"spec": {
"name": None,
"resources": {
"image_entity_filter": {
"params": {},
"type": "CATEGORIES_MATCH_ANY",
},
"cluster_entity_filter": {
"params": {},
"type": "CATEGORIES_MATCH_ANY",
},
},
},
}
)

def _build_spec_name(self, payload, name):
payload["spec"]["name"] = name
return payload, None

def _build_spec_desc(self, payload, desc):
payload["spec"]["description"] = desc
return payload, None

def _build_spec_placement_type(self, payload, type):
if type == "hard":
payload["spec"]["resources"]["placement_type"] = "EXACTLY"
else:
payload["spec"]["resources"]["placement_type"] = "AT_LEAST"
return payload, None

def _build_spec_image_categories(self, payload, category_mappings):
payload["spec"]["resources"]["image_entity_filter"][
"params"
] = category_mappings
return payload, None

def _build_spec_cluster_categories(self, payload, category_mappings):
payload["spec"]["resources"]["cluster_entity_filter"][
"params"
] = category_mappings
return payload, None
Loading