From b0cf6e63a6f1710b1eabbcc258b02a8e93f80e30 Mon Sep 17 00:00:00 2001 From: Haroon-Dweikat-Ntx Date: Tue, 21 Jan 2025 16:03:06 +0200 Subject: [PATCH] docs and examples for associate category to VG --- .../main.tf | 64 +++++++++++++++ .../terraform.tfvars | 5 ++ .../variables.tf | 13 +++ ...ociate_category_to_volume_group_v2_test.go | 8 +- ..._category_to_volume_group_v2.html.markdown | 82 +++++++++++++++++++ 5 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 examples/associate_category_to_volume_group_v2/main.tf create mode 100644 examples/associate_category_to_volume_group_v2/terraform.tfvars create mode 100644 examples/associate_category_to_volume_group_v2/variables.tf create mode 100644 website/docs/r/associate_category_to_volume_group_v2.html.markdown diff --git a/examples/associate_category_to_volume_group_v2/main.tf b/examples/associate_category_to_volume_group_v2/main.tf new file mode 100644 index 000000000..ba81a6c28 --- /dev/null +++ b/examples/associate_category_to_volume_group_v2/main.tf @@ -0,0 +1,64 @@ +terraform { + required_providers { + nutanix = { + source = "nutanix/nutanix" + version = "2.1" + } + } +} + +#defining nutanix configuration +provider "nutanix" { + username = var.nutanix_username + password = var.nutanix_password + endpoint = var.nutanix_endpoint + port = 9440 + insecure = true +} + +// Create a volume group +resource "nutanix_volume_group_v2" "example"{ + name = "test_volume_group" + description = "Test Volume group with min spec and no Auth" + should_load_balance_vm_attachments = false + sharing_status = "SHARED" + target_name = "volumegroup-test-0" + created_by = "Test" + cluster_reference = "" + iscsi_features { + enabled_authentications = "CHAP" + target_secret = "1234567891011" + } + + storage_features { + flash_mode { + is_enabled = true + } + } + usage_type = "USER" + is_hidden = false + + lifecycle { + ignore_changes = [ + iscsi_features[0].target_secret + ] + } +} + + +# List categories +data "nutanix_categories_v2" "categories"{} + +# Associate categories to volume group +resource "nutanix_associate_category_to_volume_group_v2" "example"{ + ext_id = nutanix_volume_group_v2.example.id + categories{ + ext_id = data.nutanix_categories_v2.categories.categories.0.ext_id + } + categories{ + ext_id = data.nutanix_categories_v2.categories.categories.1.ext_id + } + categories{ + ext_id = data.nutanix_categories_v2.categories.categories.2.ext_id + } +} \ No newline at end of file diff --git a/examples/associate_category_to_volume_group_v2/terraform.tfvars b/examples/associate_category_to_volume_group_v2/terraform.tfvars new file mode 100644 index 000000000..867888ffc --- /dev/null +++ b/examples/associate_category_to_volume_group_v2/terraform.tfvars @@ -0,0 +1,5 @@ +#define values to the variables to be used in terraform file +nutanix_username = "admin" +nutanix_password = "password" +nutanix_endpoint = "10.xx.xx.xx" +nutanix_port = 9440 diff --git a/examples/associate_category_to_volume_group_v2/variables.tf b/examples/associate_category_to_volume_group_v2/variables.tf new file mode 100644 index 000000000..dcd130ec8 --- /dev/null +++ b/examples/associate_category_to_volume_group_v2/variables.tf @@ -0,0 +1,13 @@ +#define the type of variables to be used in terraform file +variable "nutanix_username" { + type = string +} +variable "nutanix_password" { + type = string +} +variable "nutanix_endpoint" { + type = string +} +variable "nutanix_port" { + type = string +} diff --git a/nutanix/services/volumesv2/resource_nutanix_associate_category_to_volume_group_v2_test.go b/nutanix/services/volumesv2/resource_nutanix_associate_category_to_volume_group_v2_test.go index c95c6797b..26d0a1a99 100644 --- a/nutanix/services/volumesv2/resource_nutanix_associate_category_to_volume_group_v2_test.go +++ b/nutanix/services/volumesv2/resource_nutanix_associate_category_to_volume_group_v2_test.go @@ -59,7 +59,13 @@ resource "nutanix_associate_category_to_volume_group_v2" "test" { ext_id = nutanix_volume_group_v2.test.id categories{ ext_id = data.nutanix_categories_v2.categories.categories.0.ext_id - } + } + categories{ + ext_id = data.nutanix_categories_v2.categories.categories.1.ext_id + } + categories{ + ext_id = data.nutanix_categories_v2.categories.categories.2.ext_id + } } ` diff --git a/website/docs/r/associate_category_to_volume_group_v2.html.markdown b/website/docs/r/associate_category_to_volume_group_v2.html.markdown new file mode 100644 index 000000000..ed776d537 --- /dev/null +++ b/website/docs/r/associate_category_to_volume_group_v2.html.markdown @@ -0,0 +1,82 @@ +--- +layout: "nutanix" +page_title: "NUTANIX: nutanix_associate_category_to_volume_group_v2" +sidebar_current: "docs-nutanix-resource-associate-category-to-volume-group-v2" +description: |- + This operation submits a request to Creates a new Volume Disk. +--- + +# nutanix_volume_group_v2 + +Provides a resource to Creates a new Volume Disk. + +## Example Usage + +```hcl + +resource "nutanix_volume_group_v2" "example"{ + name = "test_volume_group" + description = "Test Volume group with min spec and no Auth" + should_load_balance_vm_attachments = false + sharing_status = "SHARED" + target_name = "volumegroup-test-0" + created_by = "Test" + cluster_reference = "" + iscsi_features { + enabled_authentications = "CHAP" + target_secret = "1234567891011" + } + + storage_features { + flash_mode { + is_enabled = true + } + } + usage_type = "USER" + is_hidden = false + + lifecycle { + ignore_changes = [ + iscsi_features[0].target_secret + ] + } +} + + +# List categories +data "nutanix_categories_v2" "categories"{} + +# Associate categories to volume group +resource "nutanix_associate_category_to_volume_group_v2" "example"{ + ext_id = nutanix_volume_group_v2.example.id + categories{ + ext_id = data.nutanix_categories_v2.categories.categories.0.ext_id + } + categories{ + ext_id = data.nutanix_categories_v2.categories.categories.1.ext_id + } + categories{ + ext_id = data.nutanix_categories_v2.categories.categories.2.ext_id + } +} +``` + +## Argument Reference + +The following arguments are supported: + +* `ext_id `: -(Required) The external identifier of the Volume Group. +* `categories`: -(Required) The category to be associated/disassociated with the Volume Group. This is a mandatory field. + + +### categories + +The categories attribute supports the following: + +* `ext_id`: -(Required) The external identifier of the category. +* `name`: -(Optional) Name of entity that's represented by this reference +* `uris`: -(Optional) URI of entities that's represented by this reference. +* `entity_type`: -(Optional) Type of entity that's represented by this reference. Default value is "CATEGORY". Valid values are: + * "CATEGORY". + +See detailed information in [Nutanix Associate/Disassociate category to/from a Volume Group V4](https://developers.nutanix.com/api-reference?namespace=volumes&version=v4.0#tag/VolumeGroups/operation/associateCategory).