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

feat: add datastore information under datastore cluster #2274

Conversation

nikfot
Copy link
Contributor

@nikfot nikfot commented Oct 3, 2024

Description

Currently the datastore cluster object only returns the id of the cluster. There is need to access the children of the cluster ( like supported in the gui under the tab datastores). With this PR we will enable the filtering of datastores based on the cluster object

Acceptance tests

  • Have you added an acceptance test for the functionality being added?
  • Have you run the acceptance tests on this branch?

Output from acceptance testing:

$ make testacc TESTARGS="-run=TestAccDataSourceVSphereDatastoreCluster_getDatastores"                                                                    
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run=TestAccDataSourceVSphereDatastoreCluster_getDatastores -timeout 360m
?       github.com/hashicorp/terraform-provider-vsphere [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/administrationroles    [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/clustercomputeresource  [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/computeresource [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/contentlibrary  [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/customattribute [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/datacenter      [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/dvportgroup     [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/envbrowse       [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/datastore       [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/guestoscustomizations   [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/folder  [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/hostsystem      [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/network [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/nsx     [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/provider        [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/ovfdeploy       [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/storagepod      [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/resourcepool    [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/structure       [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/testhelper      [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/utils   [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/vappcontainer   [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/spbm    [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/virtualmachine  [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/vsanclient      [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/vsansystem      [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/vmworkflow     [no test files]
=== RUN   TestAccDataSourceVSphereDatastoreCluster_getDatastores
--- PASS: TestAccDataSourceVSphereDatastoreCluster_getDatastores (18.62s)
PASS
ok      github.com/hashicorp/terraform-provider-vsphere/vsphere 18.647s
testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/viapi   (cached) [no tests to run]
testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/virtualdisk     (cached) [no tests to run]
testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/virtualdevice  (cached) [no tests to run]

...

Release Note

Release note for CHANGELOG:

data/datasource_cluster: Return datastore names under from a datasource cluster.

Example Usage

main.tf:

data "vsphere_datastore_cluster" "datastore_cluster_data" {
  name          = var.vsphere_cluster_name
  datacenter_id = var.vsphere_dc_id
}

providers.tf:

provider "vsphere" {
  user                 = var.vcenter_name
  password             = var.vcenter_password
  vsphere_server       = var.vsphere_server
  allow_unverified_ssl = var.allow_unverified_ssl
}

terraform {
  required_providers {
    vsphere = {
      source  = "localhost/test/vsphere"
      version = "1.0.0"
    }
  }
}

outputs.tf:

output "all_ds" {
  value = data.vsphere_datastore_cluster.datastore_cluster_data.datastores
}

variables.tf:

variable "vsphere_cluster_name" {
  description = "Name of the vSpher cluster."
  type        = string
}

variable "vsphere_dc" {
  description = "Name of the vSpher datacenter you want to deploy the VM to."
  type        = string
}

variable "vsphere_dc_id" {
  description = "ID of the vSpher datacenter you want to deploy the VM to."
  type        = string
}

variable "vcenter_name" {
  description = "vSphere username"
  type        = string
}

variable "vcenter_password" {
  description = "Password for vCenter"
  type        = string
  sensitive   = true
}

variable "allow_unverified_ssl" {
  description = "Allow unverified ssl(true or false)"
  type        = bool
  default     = true
}

References

Closes #2284

@nikfot nikfot requested a review from a team as a code owner October 3, 2024 13:36
@github-actions github-actions bot added provider Type: Provider needs-review Status: Pull Request Needs Review labels Oct 3, 2024
@nikfot nikfot force-pushed the add-datastore-information-under-datastore-cluster branch from 812b239 to 284bfcd Compare October 3, 2024 13:40
@github-actions github-actions bot added the documentation Type: Documentation label Oct 3, 2024
@nikfot nikfot force-pushed the add-datastore-information-under-datastore-cluster branch from 284bfcd to 28583f5 Compare October 4, 2024 11:43
@nikfot nikfot changed the title Add datastore information under datastore cluster feat: add datastore information under datastore cluster Oct 4, 2024
@tenthirtyam tenthirtyam added this to the v2.10.0 milestone Oct 8, 2024
@tenthirtyam tenthirtyam self-requested a review October 8, 2024 19:49
@tenthirtyam tenthirtyam force-pushed the add-datastore-information-under-datastore-cluster branch from 28583f5 to d523087 Compare October 8, 2024 19:51
Copy link
Collaborator

@tenthirtyam tenthirtyam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple minor comments provided.

Also, please open an enhancement issue and attach the issue to this pull request using the Closes #xxxx syntax in the Reference.

@tenthirtyam tenthirtyam added enhancement Type: Enhancement area/storage Area: Storage area/clustering Area: Clustering labels Oct 8, 2024
@nikfot nikfot force-pushed the add-datastore-information-under-datastore-cluster branch from d523087 to d46398a Compare October 11, 2024 14:35
@nikfot
Copy link
Contributor Author

nikfot commented Oct 11, 2024

Closes #2284

Copy link
Collaborator

@tenthirtyam tenthirtyam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🎉

@tenthirtyam tenthirtyam removed the needs-review Status: Pull Request Needs Review label Oct 11, 2024
* Enhance d/datastore_cluster to return a list with the names of data
stores under the specific cluster
* Add the attribute datastores under the datastore_cluster

Signed-off-by: nikfot <nik_fot@hotmail.gr>
@tenthirtyam tenthirtyam force-pushed the add-datastore-information-under-datastore-cluster branch from d46398a to 358ea9c Compare October 16, 2024 17:27
@github-actions github-actions bot added the needs-review Status: Pull Request Needs Review label Oct 16, 2024
@tenthirtyam tenthirtyam merged commit d135500 into hashicorp:main Oct 16, 2024
4 checks passed
@tenthirtyam tenthirtyam removed the needs-review Status: Pull Request Needs Review label Oct 16, 2024
Copy link

This functionality has been released in v2.10.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/clustering Area: Clustering area/storage Area: Storage documentation Type: Documentation enhancement Type: Enhancement provider Type: Provider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add children datastore information under datastore cluster
3 participants