-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
V4 storage containers on v4 temp design 2.0 (#18)
* Feat/1.9.3 (#633) Co-authored-by: Abhishekism9450 <[email protected]> Co-authored-by: Deepak Muley <[email protected]> Co-authored-by: Abhishek <[email protected]> * Feat/1.9.4 (#645) Co-authored-by: Frederic M <[email protected]> Co-authored-by: ArtemProt <[email protected]> Co-authored-by: Abhishekism9450 <[email protected]> * new tf design * import changes * package name change for fc * package name for fc is foundationCentral * package name to foundationcentral * fixes around acctest * examples folder * v4 design * some fixes after merging * datasource for subnets,vpcs, fips * datasource for pbrs * lint fixes. go error (gomnd, gosimple, golint) * go checks, magic numbers(gomnd) * fix config testcase as base client will differ in sdks * datadource for clusters * lint fixes * resource for subnets * adding go mod for public repo * lint fixes * lint fix * lint fix for client name * test config as client will be different for sdks * adding crud for fips * 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 * create Ops * CUD ops done * Get VMs * VMs * CRUD for vm disks * CRUD/ds serial ports * cdrom CRUD * insert/eject cdrom * vm actions power * vm shutdown actions * CRUD gpus * missing return in vms * vm clone resource * tcs for vm resource * tcs for vms * acc for images * adding more tcs * Vms disk Tcs * tcs for serial port * resource tcs for cdrom * TCs for cdroms * vm clone example and docs * tcs for vm power state * power state testcase * shutdown Tcs * Adding TCs for Gpus * vm clone testcases * fic for argument naming * resource and tests for update guest customization for next boot * guest customization update doc and example * cluster v4 resource * fix for b2 version * data source for storage containers and storage container modules * implement storage containers resources, Create Operation done * fix create operation for storage containers, implement Delete Operation * implement Update Operation for storage containers * acc tests for storage containers * storage container docs for resource and data source * test_config_v4 file for acc tests * extract storage containers into separate package, use new prism sdk instead of internal sdk * implement data source for storage stats info * set the default values for sampling interval and stat type attributes, convert timestamp to string in the flattenValueTimestamp method * Revert "set the default values for sampling interval and stat type attributes, convert timestamp to string in the flattenValueTimestamp method" This reverts commit 2abc8b3b2dc11c453aaa775a0f84ffeaf677246a. * set the default values for sampling interval and stat type attributes, convert timestamp to string in the flattenValueTimestamp method * acc test for storage stat info * rename from storage stats to storage container stat * add test case to validate required args * docs for storage container stats info * use internal prism sdk * use internal prism sdk * set the default values for sampling interval and stat type attributes, convert timestamp to string in the flattenValueTimestamp method * exclude vendor * remove all other modules and sdk, update provider resource/data maps, change the name from v4 to v2 * remove all other modules and sdk, update provider resource/data maps, change the name from v4 to v2 * change the storage container stats info from v4 to v2, add examples * change the test_config_v4 from v4 to v2 * Revert "exclude vendor" This reverts commit 5728f1196ec8c29ed0382b757d22342fe64fe89e. --------- Co-authored-by: Abhishek Chaudhary <[email protected]> Co-authored-by: Abhishekism9450 <[email protected]> Co-authored-by: Deepak Muley <[email protected]> Co-authored-by: Abhishek <[email protected]> Co-authored-by: Frederic M <[email protected]> Co-authored-by: ArtemProt <[email protected]> Co-authored-by: Gevorg <[email protected]>
- Loading branch information
1 parent
81820b5
commit 9e9725c
Showing
26 changed files
with
3,054 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
terraform{ | ||
required_providers { | ||
nutanix = { | ||
source = "nutanix/nutanix" | ||
version = "1.3.0" | ||
} | ||
} | ||
} | ||
|
||
#definig nutanix configuration | ||
provider "nutanix"{ | ||
username = var.nutanix_username | ||
password = var.nutanix_password | ||
endpoint = var.nutanix_endpoint | ||
port = 9440 | ||
insecure = true | ||
} | ||
|
||
#pull all clusters data | ||
data "nutanix_clusters" "clusters"{} | ||
|
||
#create local variable pointing to desired cluster | ||
locals { | ||
cluster1 = [ | ||
for cluster in data.nutanix_clusters.clusters.entities : | ||
cluster.metadata.uuid if cluster.service_list[0] != "PRISM_CENTRAL" | ||
][0] | ||
} | ||
|
||
#pull the storage container stats data | ||
data "nutanix_storage_container_stats_info_v2" "test" { | ||
ext_id = "<storage_container_ext_id>" | ||
start_time = "<start_time>" | ||
end_time = "<end_time>" | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "Nutanix/123456" | ||
nutanix_endpoint = "10.xx.xx.xx" | ||
nutanix_port = 9440 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
terraform{ | ||
required_providers { | ||
nutanix = { | ||
source = "nutanix/nutanix" | ||
version = "1.3.0" | ||
} | ||
} | ||
} | ||
|
||
#definig nutanix configuration | ||
provider "nutanix"{ | ||
username = var.nutanix_username | ||
password = var.nutanix_password | ||
endpoint = var.nutanix_endpoint | ||
port = 9440 | ||
insecure = true | ||
} | ||
|
||
#pull all clusters data | ||
data "nutanix_clusters" "clusters"{} | ||
|
||
#create local variable pointing to desired cluster | ||
locals { | ||
cluster1 = [ | ||
for cluster in data.nutanix_clusters.clusters.entities : | ||
cluster.metadata.uuid if cluster.service_list[0] != "PRISM_CENTRAL" | ||
][0] | ||
} | ||
|
||
#creating storage container | ||
resource "nutanix_storage_containers_v2" "example" { | ||
name = "<storage_container_name>" | ||
cluster_ext_id = local.cluster1 | ||
logical_advertised_capacity_bytes = <logical_advertised_capacity_bytes> | ||
logical_explicit_reserved_capacity_bytes = <logical_explicit_reserved_capacity_bytes> | ||
replication_factor = <replication_factor> | ||
nfs_whitelist_addresses { | ||
ipv4 { | ||
value = "<nfs_whitelist_addresses>" | ||
prefix_length ="<prefix_length>" | ||
} | ||
} | ||
erasure_code = "OFF" | ||
is_inline_ec_enabled = false | ||
has_higher_ec_fault_domain_preference = false | ||
cache_deduplication = "OFF" | ||
on_disk_dedup = "OFF" | ||
is_compression_enabled = true | ||
is_internal = false | ||
is_software_encryption_enabled = false | ||
} | ||
|
||
#output the storage container info | ||
output "subnet" { | ||
value = nutanix_storage_containers_v2.example | ||
} | ||
|
||
|
||
#pull all storage containers data in the system | ||
data "nutanix_storage_containers_v2" "example"{} | ||
|
||
|
||
#pull a storage containers data by ext id | ||
data "nutanix_storage_container_v2" "example"{ | ||
cluster_ext_id = local.cluster1 | ||
storage_container_ext_id = nutanix_storage_containers_v2.example.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "Nutanix/123456" | ||
nutanix_endpoint = "10.xx.xx.xx" | ||
nutanix_port = 9440 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package clusters | ||
|
||
import ( | ||
"github.com/nutanix-core/ntnx-api-golang-sdk-internal/clustermgmt-go-client/v16/api" | ||
network "github.com/nutanix-core/ntnx-api-golang-sdk-internal/clustermgmt-go-client/v16/client" | ||
|
||
"github.com/terraform-providers/terraform-provider-nutanix/nutanix/client" | ||
) | ||
|
||
type Client struct { | ||
ClusterEntityAPI *api.ClustersApi | ||
StorageContainersAPI *api.StorageContainersApi | ||
} | ||
|
||
func NewClustersClient(credentials client.Credentials) (*Client, error) { | ||
var baseClient *network.ApiClient | ||
|
||
// check if all required fields are present. Else create an empty client | ||
if credentials.Username != "" && credentials.Password != "" && credentials.Endpoint != "" { | ||
pcClient := network.NewApiClient() | ||
|
||
pcClient.Host = credentials.Endpoint | ||
pcClient.Password = credentials.Password | ||
pcClient.Username = credentials.Username | ||
pcClient.Port = 9440 | ||
pcClient.VerifySSL = false | ||
|
||
baseClient = pcClient | ||
} | ||
|
||
f := &Client{ | ||
ClusterEntityAPI: api.NewClustersApi(baseClient), | ||
StorageContainersAPI: api.NewStorageContainersApi(baseClient), | ||
} | ||
|
||
return f, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.