Skip to content

Commit

Permalink
V4 volumes on v4-temp-design-2.0 (#25)
Browse files Browse the repository at this point in the history
* address groups v4

* service groups

* resource for service groups

* crud for service groups

* CRUD for address groups

* data source for network security

* CRUD for network security

* microseg sdk pointing to internals

* datasource for directory services

* CRUD for directory service

* datasource for saml

* CRUD for idp

* delete Operation for directory service

* CRUD for user groups

* datasource for categories

* Crud and tcs for categories

* crud & test for images

* sdk versioning

* templates datasource

* datasource for template versions

* deploy templates

* spec for vms

* info for volume Groups

* add targetPrefix atrribute to volume group/s schema

* create Ops

* CRUD for volume group, Change the names of imported packages to more declarative names.

* CUD ops done

* Get VMs

* fix update for Volume group, working on volume disk -> info done, CRUD there is a bug on update func  CRD works as expected

* VMs

* CRUD for vm disks

* volume group disk CRUD done, fix schema attribute for Vg

* CRUD/ds serial ports

* cdrom CRUD

* insert/eject cdrom

* vm actions power

* List available iscsi clients + Attach/Detach iscsi client to vg

* merge conflict

* Revert "merge conflict"

This reverts commit 7b8edb9e177ed96b19d2d8e0fde52e37647502e8.

* List all the category details that are associated with the Volume Group.

* Attach/Detach an AHV VM from the given Volume Group.

* Iscsi Clients Provider, Fetch an iSCSI client details, List all the iSCSI clients.

* revert pushed unwanted changes

* revert pushed unwanted changes

* acc test for volume group data source and resource

* acceptance test for volume group data source

* volume group data source acctest is done

* acceptance test for volume resource modules, ->  acceptance test done

* Add Description for schema attribute's

* List all the VM attachments for a Volume Group INFO -> Development + Test

* Volume Group examples

* Doc for Volume groups & Attach/Dettach vg to vm

* Docs for Volume Group vm, volume group  iscsi client, available  iscsi clients, Volume Group disks and volume group category info

* refactor volumes test cases to use test_config_v4.json

* revert pushed unwanted changes

* add test_config_v4.json file

* refactor volumes test cases to use test_config_v4.json

* rename volume module from v4 to v2

* Refactor acceptance test cases to be more dynamic and reduce dependency on the JSON configuration file

* rename volume package to volumesv2

* remove other modules

* add examples

* add examples

* ignore vendor

---------

Co-authored-by: Abhishek <[email protected]>
  • Loading branch information
Haroon-Dweikat-Ntx and abhimutant authored Sep 16, 2024
1 parent b1f79db commit 581dcf0
Show file tree
Hide file tree
Showing 65 changed files with 7,004 additions and 8 deletions.
143 changes: 143 additions & 0 deletions examples/volume_disk_2/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#############################################################################
# Example main.tf for Nutanix + Terraform
#
# Author: [email protected]
#
# This script is a quick demo of how to use the following provider objects:
# - providers
# - terraform-provider-nutanix
# - resources
# - nutanix_volume_group_disk_v2
# - data sources
# - nutanix_volume_group_disks_v2
# - nutanix_volume_group_disk_v2
# - script Variables
# - clusterid's for targeting clusters within prism central
#
# Feel free to reuse, comment, and contribute, so that others may learn.
#
#############################################################################
### Define Provider Info for terraform-provider-nutanix
### This is where you define the credentials for ** Prism Central **
###
### NOTE:
### While it may be possible to use Prism Element directly, Nutanix's
### provider is not structured or tested for this. Using Prism Central will
### give the broadest capabilities across the board


terraform {
required_providers {
nutanix = {
source = "nutanix/nutanix"
version = "1.7.0"
}
}
}

#definig nutanix configuration
provider "nutanix" {
username = var.nutanix_username
password = var.nutanix_password
endpoint = var.nutanix_endpoint
port = 9440
insecure = true
}


#pull cluster data
data "nutanix_clusters" "clusters" {
}

#pull desired cluster data from setup
locals {
cluster1 = [
for cluster in data.nutanix_clusters.clusters.entities :
cluster.metadata.uuid if cluster.service_list[0] != "PRISM_CENTRAL"
][0]
}

##########################
### Resources
##########################


# create a voume group
resource "nutanix_volume_group_v2" "volume_group_example" {
name = var.volume_group_name
description = "Test Create Volume group with spec"
should_load_balance_vm_attachments = false
sharing_status = var.volume_group_sharing_status
target_name = "volumegroup-test-001234"
created_by = "example"
cluster_reference = local.cluster1
iscsi_features {
enabled_authentications = "CHAP"
target_secret = var.volume_group_target_secret
}

storage_features {
flash_mode {
is_enabled = true
}
}
usage_type = "USER"
is_hidden = false

# ignore changes to target_secret, target secert will not be returned in terraform plan output
lifecycle {
ignore_changes = [
iscsi_features[0].target_secret
]
}
}

# create a volume group disk, and attach it to the volume group
resource "nutanix_volume_group_disk_v2" "disk_example" {
volume_group_ext_id = resource.nutanix_volume_group_v2.volume_group_example.id
# This Attribute is used to specify the index of the disk in the volume group.
# its Optional, if not provided, the disk will be added at the end of the volume group.
# if provided, the disk will be added at the specified index. make sure the index is unique.
index = 1
description = "create volume disk example"
# disk size in bytes
disk_size_bytes = 5368709120

disk_data_source_reference {
name = "disk1"
ext_id = var.disk_data_source_reference_ext_id
entity_type = "STORAGE_CONTAINER"
uris = ["uri1", "uri2"]
}

disk_storage_features {
flash_mode {
is_enabled = false
}
}

# ignore changes to disk_data_source_reference, disk data source reference will not be returned in terraform plan output
lifecycle {
ignore_changes = [
disk_data_source_reference
]
}
}


##########################
### Data Sources
##########################

# pull all disks in a volume group
data "nutanix_volume_group_disks_v2" "vg_disks_example" {
volume_group_ext_id = resource.nutanix_volume_group_v2.volume_group_example.id
filter = "startswith(storageContainerId, 'value')"
limit = 2
}

# pull a specific disk in a volume group
data "nutanix_volume_group_disk_v2" "vg_disk_example" {
ext_id = var.volume_group_disk_ext_id
volume_group_ext_id = var.volume_group_ext_id
}
5 changes: 5 additions & 0 deletions examples/volume_disk_2/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -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
53 changes: 53 additions & 0 deletions examples/volume_disk_2/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#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
}

variable "volume_group_name" {
type = string
}

variable "volume_group_ext_id" {
type = string
}

variable "volume_group_disk_ext_id" {
type = string
}

variable "volume_group_sharing_status" {
type = string
}

variable "volume_group_target_secret" {
type = string
}

variable "disk_data_source_reference_ext_id" {
type = string
}

variable "vg_iscsi_ext_id" {
type = string
}

variable "vg_iscsi_initiator_name" {
type = string
}

variable "vg_vm_ext_id" {
type = string
}

variable "volume_iscsi_client_ext_id" {
type = string
}
110 changes: 110 additions & 0 deletions examples/volume_group_2/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#############################################################################
# Example main.tf for Nutanix + Terraform
#
# Author: [email protected]
#
# This script is a quick demo of how to use the following provider objects:
# - providers
# - terraform-provider-nutanix
# - resources
# - nutanix_volume_group_v2
# - data sources
# - nutanix_volume_groups_v2
# - nutanix_volume_group_v2
# - script Variables
# - clusterid's for targeting clusters within prism central
#
# Feel free to reuse, comment, and contribute, so that others may learn.
#
#############################################################################
### Define Provider Info for terraform-provider-nutanix
### This is where you define the credentials for ** Prism Central **
###
### NOTE:
### While it may be possible to use Prism Element directly, Nutanix's
### provider is not structured or tested for this. Using Prism Central will
### give the broadest capabilities across the board


terraform {
required_providers {
nutanix = {
source = "nutanix/nutanix"
version = "1.7.0"
}
}
}

#definig nutanix configuration
provider "nutanix" {
username = var.nutanix_username
password = var.nutanix_password
endpoint = var.nutanix_endpoint
port = 9440
insecure = true
}


#pull cluster data
data "nutanix_clusters" "clusters" {
}

#pull desired cluster data from setup
locals {
cluster1 = [
for cluster in data.nutanix_clusters.clusters.entities :
cluster.metadata.uuid if cluster.service_list[0] != "PRISM_CENTRAL"
][0]
}

##########################
### Resources
##########################


# create a voume group
resource "nutanix_volume_group_v2" "volume_group_example" {
name = var.volume_group_name
description = "Test Create Volume group with spec"
should_load_balance_vm_attachments = false
sharing_status = var.volume_group_sharing_status
target_name = "volumegroup-test-001234"
created_by = "example"
cluster_reference = local.cluster1
iscsi_features {
enabled_authentications = "CHAP"
target_secret = var.volume_group_target_secret
}

storage_features {
flash_mode {
is_enabled = true
}
}
usage_type = "USER"
is_hidden = false

# ignore changes to target_secret, target secert will not be returned in terraform plan output
lifecycle {
ignore_changes = [
iscsi_features[0].target_secret
]
}
}


##########################
### Data Sources
##########################

# pull all volume groups
data "nutanix_volume_groups_v2" "vgs_example" {
filter = "startswith(name, 'value')"
limit = 2
page = 0
}

# pull a specific volume group
data "nutanix_volume_group_v2" "vg_example" {
ext_id = resource.nutanix_volume_group_v2.volume_group_example.id
}
5 changes: 5 additions & 0 deletions examples/volume_group_2/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -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
53 changes: 53 additions & 0 deletions examples/volume_group_2/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#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
}

variable "volume_group_name" {
type = string
}

variable "volume_group_ext_id" {
type = string
}

variable "volume_group_disk_ext_id" {
type = string
}

variable "volume_group_sharing_status" {
type = string
}

variable "volume_group_target_secret" {
type = string
}

variable "disk_data_source_reference_ext_id" {
type = string
}

variable "vg_iscsi_ext_id" {
type = string
}

variable "vg_iscsi_initiator_name" {
type = string
}

variable "vg_vm_ext_id" {
type = string
}

variable "volume_iscsi_client_ext_id" {
type = string
}
Loading

0 comments on commit 581dcf0

Please sign in to comment.