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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

vsphere_datastore_stats does not fetch the datastores under a datastore cluster #2159

Open
4 tasks done
mrdevops100 opened this issue Mar 27, 2024 · 1 comment
Open
4 tasks done
Labels
bug Type: Bug
Milestone

Comments

@mrdevops100
Copy link

Community Guidelines

  • I have read and agree to the HashiCorp Community Guidelines .
  • Vote on this issue by adding a 馃憤 reaction to the original issue initial description to help the maintainers prioritize.
  • Do not leave "+1" or other comments that do not add relevant information or questions.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Terraform

v1.7.5

Terraform Provider

v2.7.0

VMware vSphere

v7.0

Description

When I use the "vsphere_datastore_stats" datasource it only fetches the top level datastores in a DC. It doesn't list the datastores under a datastore cluster.

Affected Resources or Data Sources

data "vsphere_datastore_stats" "datastore_stats" {
datacenter_id = data.vsphere_datacenter.datacenter.id
}

Terraform Configuration

data "vsphere_datacenter" "datacenter" {
name = "dc-01"
}

data "vsphere_datastore_stats" "datastore_stats" {
datacenter_id = data.vsphere_datacenter.datacenter.id
}

locals {
free_space_values = { for k, v in data.vsphere_datastore_stats.datastore_stats.free_space : k => tonumber(v) }
filtered_values = { for k, v in local.free_space_values : k => tonumber(v) if v != null }
numeric_values = [for v in values(local.filtered_values) : tonumber(v)]
max_free_space = max(local.numeric_values...)
max_free_space_name = [for k, v in local.filtered_values : k if v == local.max_free_space][0]
}

output "max_free_space_name" {
value = local.max_free_space_name
}

output "max_free_space" {
value = local.max_free_space
}

Debug Output

Not available

Panic Output

Not available

Expected Behavior

Show all the datastores including the ones under datastore cluster

Actual Behavior

Datasource only fetches the top level datastores in a DC

Steps to Reproduce

data "vsphere_datacenter" "datacenter" {
name = "dc-01"
}

data "vsphere_datastore_stats" "datastore_stats" {
datacenter_id = data.vsphere_datacenter.datacenter.id
}

locals {
free_space_values = { for k, v in data.vsphere_datastore_stats.datastore_stats.free_space : k => tonumber(v) }
filtered_values = { for k, v in local.free_space_values : k => tonumber(v) if v != null }
numeric_values = [for v in values(local.filtered_values) : tonumber(v)]
max_free_space = max(local.numeric_values...)
max_free_space_name = [for k, v in local.filtered_values : k if v == local.max_free_space][0]
}

output "max_free_space_name" {
value = local.max_free_space_name
}

output "max_free_space" {
value = local.max_free_space
}

Environment Details

No response

Screenshots

n/a

References

n/a

@mrdevops100 mrdevops100 added bug Type: Bug needs-triage Status: Issue Needs Triage labels Mar 27, 2024
Copy link

Hello, mrdevops100! 馃枑

Thank you for submitting an issue for this provider. The issue will now enter into the issue lifecycle.

If you want to contribute to this project, please review the contributing guidelines and information on submitting pull requests.

@mrdevops100 mrdevops100 changed the title vsphere_datastore_stats does not consider the datastore under datastore cluster vsphere_datastore_stats does not fetch the datastores under a datastore cluster Mar 27, 2024
@tenthirtyam tenthirtyam removed the needs-triage Status: Issue Needs Triage label Mar 27, 2024
@tenthirtyam tenthirtyam added this to the Backlog milestone Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Type: Bug
Projects
None yet
Development

No branches or pull requests

2 participants