Skip to content

Commit 1212531

Browse files
GullapalliAkhilHaroon-Dweikat-NtxabhimutantAbhishekism9450deepakm-ntnx
authored
v2.1.0 release branch for v4 based module support for prism, data policies, data protection, lcm and volumes (#780)
Co-authored-by: Haroon Dweikat Ntx <[email protected]> Co-authored-by: Abhishek <[email protected]> Co-authored-by: Abhishekism9450 <[email protected]> Co-authored-by: Abhishek <[email protected]> Co-authored-by: Deepak Muley <[email protected]> Co-authored-by: Frederic M <[email protected]> Co-authored-by: ArtemProt <[email protected]> Co-authored-by: Gevorg <[email protected]> Co-authored-by: Pradeepsingh Bhati <[email protected]> Co-authored-by: abhinavbansal29 <[email protected]> Co-authored-by: akli-ime <[email protected]>
1 parent 15b6709 commit 1212531

File tree

401 files changed

+28140
-3334
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

401 files changed

+28140
-3334
lines changed

GNUmakefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ fmt:
2222
goimports -w ./client
2323
goimports -w ./utils
2424

25+
2526
fmtcheck:
27+
@echo "Running fmtcheck"
2628
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
29+
@echo "fmtcheck done"
2730

2831
errcheck:
2932
@sh -c "'$(CURDIR)/scripts/errcheck.sh'"

examples/address_group_v2/main.tf

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,25 @@ provider "nutanix" {
1616
insecure = true
1717
}
1818

19-
# Add Address group.
20-
resource "nutanix_address_groups_v2" "example_1" {
21-
name = "address_group"
19+
20+
21+
# Create Address group with ipv4 addresses
22+
resource "nutanix_address_groups_v2" "ipv4-address" {
23+
name = "address_group_ipv4_address"
2224
description = "address group description"
2325
ipv4_addresses {
2426
value = "10.0.0.0"
2527
prefix_length = 24
2628
}
29+
ipv4_addresses {
30+
value = "172.0.0.0"
31+
prefix_length = 24
32+
}
2733
}
2834

29-
# Add Address group. with ip range
30-
resource "nutanix_address_groups_v2" "example_2" {
31-
name = "address_group"
35+
# Create Address group. with ip range
36+
resource "nutanix_address_groups_v2" "ip-ranges" {
37+
name = "address_group_ip_ranges"
3238
description = "address group description"
3339
ip_ranges {
3440
start_ip = "10.0.0.1"
@@ -37,9 +43,24 @@ resource "nutanix_address_groups_v2" "example_2" {
3743
}
3844

3945
# list add address group
40-
data "nutanix_address_groups_v2" "example" {}
46+
data "nutanix_address_groups_v2" "list-address-groups" {
47+
depends_on = [nutanix_address_groups_v2.ipv4-address, nutanix_address_groups_v2.ip-ranges]
48+
}
4149

4250
# list add address group with filter
4351
data "nutanix_address_groups_v2" "example-filter" {
44-
filter = "name eq 'address_group'"
52+
filter = "name eq '${nutanix_address_groups_v2.ipv4-address.name}'"
53+
depends_on = [nutanix_address_groups_v2.ipv4-address, nutanix_address_groups_v2.ip-ranges]
54+
}
55+
56+
# list add address group with order by
57+
data "nutanix_address_groups_v2" "example-order-by" {
58+
order_by = "name desc"
59+
depends_on = [nutanix_address_groups_v2.ipv4-address, nutanix_address_groups_v2.ip-ranges]
60+
}
61+
62+
# list add address group select
63+
data "nutanix_address_groups_v2" "example-select" {
64+
select = "name,description,ipRanges"
65+
depends_on = [nutanix_address_groups_v2.ipv4-address, nutanix_address_groups_v2.ip-ranges]
4566
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
terraform {
2+
required_providers {
3+
nutanix = {
4+
source = "nutanix/nutanix"
5+
version = "2.1"
6+
}
7+
}
8+
}
9+
10+
#defining nutanix configuration
11+
provider "nutanix" {
12+
username = var.nutanix_username
13+
password = var.nutanix_password
14+
endpoint = var.nutanix_endpoint
15+
port = 9440
16+
insecure = true
17+
}
18+
19+
#pull cluster data
20+
data "nutanix_clusters_v2" "clusters" {}
21+
22+
#pull desired cluster data from setup
23+
locals {
24+
cluster_ext_id = [
25+
for cluster in data.nutanix_clusters_v2.clusters.cluster_entities :
26+
cluster.ext_id if cluster.config[0].cluster_function[0] != "PRISM_CENTRAL"
27+
][0]
28+
}
29+
30+
// Create a volume group
31+
resource "nutanix_volume_group_v2" "vg1" {
32+
name = "volume-group-example-001235"
33+
description = "Create Volume group with spec"
34+
should_load_balance_vm_attachments = false
35+
sharing_status = "SHARED"
36+
target_name = "volumegroup-test-001235"
37+
created_by = "example"
38+
cluster_reference = local.cluster_ext_id
39+
iscsi_features {
40+
enabled_authentications = "CHAP"
41+
target_secret = "pass.1234567890"
42+
}
43+
44+
storage_features {
45+
flash_mode {
46+
is_enabled = true
47+
}
48+
}
49+
usage_type = "USER"
50+
is_hidden = false
51+
52+
# ignore changes to target_secret, target secret will not be returned in terraform plan output
53+
lifecycle {
54+
ignore_changes = [
55+
iscsi_features[0].target_secret
56+
]
57+
}
58+
}
59+
60+
61+
62+
#creating category
63+
resource "nutanix_category_v2" "vg-category" {
64+
key = "category_example_key"
65+
value = "category_example_value"
66+
description = "category example to associate with volume group"
67+
}
68+
69+
70+
# Associate categories to volume group
71+
resource "nutanix_associate_category_to_volume_group_v2" "attach_category" {
72+
ext_id = nutanix_volume_group_v2.vg1.id
73+
categories {
74+
ext_id = nutanix_category_v2.vg-category.id
75+
}
76+
}
77+
78+
79+
# pull associated category data using list categories data source
80+
data "nutanix_categories_v2" "associated_vg" {
81+
filter = "extId eq '${nutanix_category_v2.vg-category.id}'"
82+
expand = "associations"
83+
depends_on = [nutanix_associate_category_to_volume_group_v2.attach_category]
84+
}
85+
86+
# pull associated category data fetch category data source
87+
data "nutanix_category_v2" "associated_vg" {
88+
ext_id = nutanix_category_v2.vg-category.id
89+
expand = "associations"
90+
depends_on = [nutanix_associate_category_to_volume_group_v2.attach_category]
91+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#define values to the variables to be used in terraform file
2+
nutanix_username = "admin"
3+
nutanix_password = "password"
4+
nutanix_endpoint = "10.xx.xx.xx"
5+
nutanix_port = 9440
Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
1-
2-
#variable definations
3-
variable "nutanix_username" {
4-
type = string
5-
}
6-
variable "nutanix_password" {
7-
type = string
8-
}
9-
variable "nutanix_endpoint" {
10-
type = string
11-
}
12-
variable "nutanix_port" {
13-
type = string
14-
}
15-
variable "vm_uuid" {
16-
type = string
17-
}
18-
variable "subnet_uuid" {
19-
type = string
20-
}
1+
#define the type of variables to be used in terraform file
2+
variable "nutanix_username" {
3+
type = string
4+
}
5+
variable "nutanix_password" {
6+
type = string
7+
}
8+
variable "nutanix_endpoint" {
9+
type = string
10+
}
11+
variable "nutanix_port" {
12+
type = string
13+
}

examples/authorization_policies_v2/main.tf

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,54 @@ provider "nutanix" {
2020
insecure = true
2121
}
2222

23-
# create authorization policy
24-
resource "nutanix_authorization_policy_v2" "auth_policy_example" {
25-
role = "<role_uuid>"
26-
display_name = "<acp name>"
27-
description = "<acp description>"
28-
authorization_policy_type = "<acp type>"
29-
# identity and entity will defined as a json string
23+
24+
# fetch operations
25+
data "nutanix_operations_v2" "operation-list" {
26+
filter = "startswith(displayName, 'Create_')"
27+
}
28+
29+
# create role
30+
resource "nutanix_roles_v2" "role" {
31+
display_name = "role_auth_example"
32+
description = "role for authorization policy"
33+
operations = [
34+
data.nutanix_operations_v2.operation-list.operations[0].ext_id,
35+
data.nutanix_operations_v2.operation-list.operations[1].ext_id,
36+
data.nutanix_operations_v2.operation-list.operations[2].ext_id,
37+
data.nutanix_operations_v2.operation-list.operations[3].ext_id
38+
]
39+
}
40+
41+
resource "nutanix_authorization_policy_v2" "ap-example" {
42+
role = nutanix_roles_v2.role.id
43+
display_name = "auth_policy_example"
44+
description = "authorization policy example"
45+
authorization_policy_type = "USER_DEFINED"
3046
identities {
31-
reserved = "<identity_uuid>" # ex : "{\"user\":{\"uuid\":{\"anyof\":[\"00000000-0000-0000-0000-000000000000\"]}}}"
47+
reserved = "{\"user\":{\"uuid\":{\"anyof\":[\"00000000-0000-0000-0000-000000000000\"]}}}"
3248
}
3349
entities {
34-
reserved = "<entity_uuid>" # ex : "{\"images\":{\"*\":{\"eq\":\"*\"}}}"
50+
reserved = "{\"images\":{\"*\":{\"eq\":\"*\"}}}"
51+
}
52+
entities {
53+
reserved = "{\"marketplace_item\":{\"owner_uuid\":{\"eq\":\"SELF_OWNED\"}}}"
3554
}
3655
}
3756

3857
#get authorization policy by id
3958
data "nutanix_authorization_policy_v2" "example" {
40-
ext_id = nutanix_authorization_policy_v2.auth_policy_example.id
59+
ext_id = nutanix_authorization_policy_v2.ap-example.id
4160
}
4261

4362

4463
#list of authorization policies, with limit and filter
45-
data "nutanix_authorization_policies_v2" "examples" {
64+
data "nutanix_authorization_policies_v2" "filtered-ap" {
65+
filter = "displayName eq '${nutanix_authorization_policy_v2.ap-example.display_name}'"
4666
limit = 2
47-
filter = "display_name eq '<acp name>'"
67+
}
68+
69+
# list of authorization policies, with select
70+
data "nutanix_authorization_policies_v2" "select-ap" {
71+
select = "extId,displayName,description,authorizationPolicyType"
72+
depends_on = [nutanix_authorization_policy_v2.ap-example]
4873
}

examples/authorization_policies_v2/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
#variable definations
2+
#variable definitions
33
variable "nutanix_username" {
44
type = string
55
}

examples/categories_v2/main.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ resource "nutanix_category_v2" "example" {
2727

2828

2929
#pull all categories data
30-
data "nutanix_categories_v2" "clusters" {}
30+
data "nutanix_categories_v2" "categories-list" {}
3131

3232
# pull all categories with limit and filter
33-
data "nutanix_categories_v2" "example" {
33+
data "nutanix_categories_v2" "filtered-categories" {
3434
limit = 2
35-
filter = "key eq 'category_example_key'"
35+
filter = "key eq '${nutanix_category_v2.example.key}'"
3636
}
3737

3838
# get category by ext id
39-
data "nutanix_category_v2" "example" {
40-
ext_id = resource.nutanix_category_v2.example.ext_id
39+
data "nutanix_category_v2" "get-category" {
40+
ext_id = nutanix_category_v2.example.id
4141
}

0 commit comments

Comments
 (0)