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 in-cluster datastores in d/datastore_stats #2273

Merged

Conversation

nikfot
Copy link
Contributor

@nikfot nikfot commented Oct 3, 2024

Description

With the previous introduction of d/datastore_stats only local datastores were included in the output. Now, all datastores are fetched, even those under clusters, by accessing every storage pod object and retrieving all datastores that are set as childs to it.

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=TestAccDataSourceVSphereDatastoreStats_basic"                                                
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run=TestAccDataSourceVSphereDatastoreStats_basic -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/datastore       [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/folder  [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/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/ovfdeploy       [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/resourcepool    [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/storagepod      [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/virtualmachine  [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/vsansystem      [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/vsanclient      [no test files]
?       github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/vmworkflow     [no test files]
=== RUN   TestAccDataSourceVSphereDatastoreStats_basic
--- PASS: TestAccDataSourceVSphereDatastoreStats_basic (45.03s)
PASS
ok      github.com/hashicorp/terraform-provider-vsphere/vsphere 30.142s
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

data/vsphere_datastore_stats: Added the ability to return all data stores, both local and under a datastore cluster, in the datastore list.

Example Usage

main.tf:

data "vsphere_datacenter" "dc" {
  name = var.vsphere_dc
}

data "vsphere_datastore_stats" "datastore_stats" {
  datacenter_id = data.vsphere_datacenter.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 "max_free_space_name" {
  value = local.max_free_space_name
}

output "max_free_space" {
  value = local.max_free_space
}

variables.tf:

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

Close #2159

@nikfot nikfot requested a review from a team as a code owner October 3, 2024 11:00
@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 fix-datastores-fetch-within-datastore branch 3 times, most recently from e1fcf80 to 3de22fc Compare October 4, 2024 11:44
@nikfot nikfot changed the title Add in-cluster datastores in d/datastore_stats feat: add in-cluster datastores in d/datastore_stats Oct 4, 2024
@tenthirtyam tenthirtyam added this to the v2.10.0 milestone Oct 8, 2024
@tenthirtyam tenthirtyam changed the title feat: add in-cluster datastores in d/datastore_stats feat: add in-cluster datastores in d/datastore_stats Oct 8, 2024
@tenthirtyam tenthirtyam self-requested a review October 8, 2024 19:40
@tenthirtyam tenthirtyam force-pushed the fix-datastores-fetch-within-datastore branch from 3de22fc to c6926d9 Compare October 8, 2024 19:43
@tenthirtyam tenthirtyam added enhancement Type: Enhancement area/storage Area: Storage area/clustering Area: Clustering labels Oct 8, 2024
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

@nikfot nikfot force-pushed the fix-datastores-fetch-within-datastore branch from c6926d9 to a87f23f Compare October 11, 2024 10:54
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
* A full list of all datastores is fetched including
datastores in datastore clusters
* All datastores are displayed under the same capacity
and free capacity lists

Signed-off-by: nikfot <[email protected]>
@tenthirtyam tenthirtyam force-pushed the fix-datastores-fetch-within-datastore branch from a87f23f to 55b667b Compare October 16, 2024 17:28
@github-actions github-actions bot added the needs-review Status: Pull Request Needs Review label Oct 16, 2024
@tenthirtyam tenthirtyam merged commit 6ed3963 into hashicorp:main Oct 16, 2024
5 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!

Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/clustering Area: Clustering area/storage Area: Storage enhancement Type: Enhancement provider Type: Provider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support to fetch datastores within a datastore cluster in d/datastore_stats
3 participants