vsphere.getDatastoreStats
Explore with Pulumi AI
The vsphere.getDatastoreStats
data source can be used to retrieve the usage
stats of all vSphere datastore objects in a datacenter. This can then be used as
a standalone data source to get information required as input to other data
sources.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as vsphere from "@pulumi/vsphere";
const datacenter = vsphere.getDatacenter({
name: "dc-01",
});
const datastoreStats = datacenter.then(datacenter => vsphere.getDatastoreStats({
datacenterId: datacenter.id,
}));
import pulumi
import pulumi_vsphere as vsphere
datacenter = vsphere.get_datacenter(name="dc-01")
datastore_stats = vsphere.get_datastore_stats(datacenter_id=datacenter.id)
package main
import (
"github.com/pulumi/pulumi-vsphere/sdk/v4/go/vsphere"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
datacenter, err := vsphere.LookupDatacenter(ctx, &vsphere.LookupDatacenterArgs{
Name: pulumi.StringRef("dc-01"),
}, nil)
if err != nil {
return err
}
_, err = vsphere.GetDatastoreStats(ctx, &vsphere.GetDatastoreStatsArgs{
DatacenterId: datacenter.Id,
}, nil)
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using VSphere = Pulumi.VSphere;
return await Deployment.RunAsync(() =>
{
var datacenter = VSphere.GetDatacenter.Invoke(new()
{
Name = "dc-01",
});
var datastoreStats = VSphere.GetDatastoreStats.Invoke(new()
{
DatacenterId = datacenter.Apply(getDatacenterResult => getDatacenterResult.Id),
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.vsphere.VsphereFunctions;
import com.pulumi.vsphere.inputs.GetDatacenterArgs;
import com.pulumi.vsphere.inputs.GetDatastoreStatsArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var datacenter = VsphereFunctions.getDatacenter(GetDatacenterArgs.builder()
.name("dc-01")
.build());
final var datastoreStats = VsphereFunctions.getDatastoreStats(GetDatastoreStatsArgs.builder()
.datacenterId(datacenter.applyValue(getDatacenterResult -> getDatacenterResult.id()))
.build());
}
}
variables:
datacenter:
fn::invoke:
Function: vsphere:getDatacenter
Arguments:
name: dc-01
datastoreStats:
fn::invoke:
Function: vsphere:getDatastoreStats
Arguments:
datacenterId: ${datacenter.id}
A useful example of this data source would be to determine the datastore with the most free space. For example, in addition to the above:
Create an outputs.tf
like that:
import * as pulumi from "@pulumi/pulumi";
export const maxFreeSpaceName = theirMaxFreeSpaceName;
export const maxFreeSpace = theirMaxFreeSpace;
import pulumi
pulumi.export("maxFreeSpaceName", their_max_free_space_name)
pulumi.export("maxFreeSpace", their_max_free_space)
package main
import (
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
ctx.Export("maxFreeSpaceName", theirMaxFreeSpaceName)
ctx.Export("maxFreeSpace", theirMaxFreeSpace)
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
return await Deployment.RunAsync(() =>
{
return new Dictionary<string, object?>
{
["maxFreeSpaceName"] = theirMaxFreeSpaceName,
["maxFreeSpace"] = theirMaxFreeSpace,
};
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
ctx.export("maxFreeSpaceName", theirMaxFreeSpaceName);
ctx.export("maxFreeSpace", theirMaxFreeSpace);
}
}
outputs:
maxFreeSpaceName: ${theirMaxFreeSpaceName}
maxFreeSpace: ${theirMaxFreeSpace}
and a locals.tf
like that:
Using getDatastoreStats
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getDatastoreStats(args: GetDatastoreStatsArgs, opts?: InvokeOptions): Promise<GetDatastoreStatsResult>
function getDatastoreStatsOutput(args: GetDatastoreStatsOutputArgs, opts?: InvokeOptions): Output<GetDatastoreStatsResult>
def get_datastore_stats(capacity: Optional[Mapping[str, str]] = None,
datacenter_id: Optional[str] = None,
free_space: Optional[Mapping[str, str]] = None,
opts: Optional[InvokeOptions] = None) -> GetDatastoreStatsResult
def get_datastore_stats_output(capacity: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
datacenter_id: Optional[pulumi.Input[str]] = None,
free_space: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetDatastoreStatsResult]
func GetDatastoreStats(ctx *Context, args *GetDatastoreStatsArgs, opts ...InvokeOption) (*GetDatastoreStatsResult, error)
func GetDatastoreStatsOutput(ctx *Context, args *GetDatastoreStatsOutputArgs, opts ...InvokeOption) GetDatastoreStatsResultOutput
> Note: This function is named GetDatastoreStats
in the Go SDK.
public static class GetDatastoreStats
{
public static Task<GetDatastoreStatsResult> InvokeAsync(GetDatastoreStatsArgs args, InvokeOptions? opts = null)
public static Output<GetDatastoreStatsResult> Invoke(GetDatastoreStatsInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetDatastoreStatsResult> getDatastoreStats(GetDatastoreStatsArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: vsphere:index/getDatastoreStats:getDatastoreStats
arguments:
# arguments dictionary
The following arguments are supported:
- Datacenter
Id string - The
managed object reference ID of the datacenter the
datastores are located in. For default datacenters, use the
id
attribute from an emptyvsphere.Datacenter
data source. - Capacity Dictionary<string, string>
- A mapping of the capacity for all datastore in the datacenter, where the name of the datastore is used as key and the capacity as value.
- Free
Space Dictionary<string, string> - A mapping of the free space for each datastore in the datacenter, where the name of the datastore is used as key and the free space as value.
- Datacenter
Id string - The
managed object reference ID of the datacenter the
datastores are located in. For default datacenters, use the
id
attribute from an emptyvsphere.Datacenter
data source. - Capacity map[string]string
- A mapping of the capacity for all datastore in the datacenter, where the name of the datastore is used as key and the capacity as value.
- Free
Space map[string]string - A mapping of the free space for each datastore in the datacenter, where the name of the datastore is used as key and the free space as value.
- datacenter
Id String - The
managed object reference ID of the datacenter the
datastores are located in. For default datacenters, use the
id
attribute from an emptyvsphere.Datacenter
data source. - capacity Map<String,String>
- A mapping of the capacity for all datastore in the datacenter, where the name of the datastore is used as key and the capacity as value.
- free
Space Map<String,String> - A mapping of the free space for each datastore in the datacenter, where the name of the datastore is used as key and the free space as value.
- datacenter
Id string - The
managed object reference ID of the datacenter the
datastores are located in. For default datacenters, use the
id
attribute from an emptyvsphere.Datacenter
data source. - capacity {[key: string]: string}
- A mapping of the capacity for all datastore in the datacenter, where the name of the datastore is used as key and the capacity as value.
- free
Space {[key: string]: string} - A mapping of the free space for each datastore in the datacenter, where the name of the datastore is used as key and the free space as value.
- datacenter_
id str - The
managed object reference ID of the datacenter the
datastores are located in. For default datacenters, use the
id
attribute from an emptyvsphere.Datacenter
data source. - capacity Mapping[str, str]
- A mapping of the capacity for all datastore in the datacenter, where the name of the datastore is used as key and the capacity as value.
- free_
space Mapping[str, str] - A mapping of the free space for each datastore in the datacenter, where the name of the datastore is used as key and the free space as value.
- datacenter
Id String - The
managed object reference ID of the datacenter the
datastores are located in. For default datacenters, use the
id
attribute from an emptyvsphere.Datacenter
data source. - capacity Map<String>
- A mapping of the capacity for all datastore in the datacenter, where the name of the datastore is used as key and the capacity as value.
- free
Space Map<String> - A mapping of the free space for each datastore in the datacenter, where the name of the datastore is used as key and the free space as value.
getDatastoreStats Result
The following output properties are available:
- Datacenter
Id string - The [managed object reference ID][docs-about-morefs] of the datacenter the datastores are located in.
- Id string
- The provider-assigned unique ID for this managed resource.
- Capacity Dictionary<string, string>
- A mapping of the capacity for all datastore in the datacenter, where the name of the datastore is used as key and the capacity as value.
- Free
Space Dictionary<string, string> - A mapping of the free space for each datastore in the datacenter, where the name of the datastore is used as key and the free space as value.
- Datacenter
Id string - The [managed object reference ID][docs-about-morefs] of the datacenter the datastores are located in.
- Id string
- The provider-assigned unique ID for this managed resource.
- Capacity map[string]string
- A mapping of the capacity for all datastore in the datacenter, where the name of the datastore is used as key and the capacity as value.
- Free
Space map[string]string - A mapping of the free space for each datastore in the datacenter, where the name of the datastore is used as key and the free space as value.
- datacenter
Id String - The [managed object reference ID][docs-about-morefs] of the datacenter the datastores are located in.
- id String
- The provider-assigned unique ID for this managed resource.
- capacity Map<String,String>
- A mapping of the capacity for all datastore in the datacenter, where the name of the datastore is used as key and the capacity as value.
- free
Space Map<String,String> - A mapping of the free space for each datastore in the datacenter, where the name of the datastore is used as key and the free space as value.
- datacenter
Id string - The [managed object reference ID][docs-about-morefs] of the datacenter the datastores are located in.
- id string
- The provider-assigned unique ID for this managed resource.
- capacity {[key: string]: string}
- A mapping of the capacity for all datastore in the datacenter, where the name of the datastore is used as key and the capacity as value.
- free
Space {[key: string]: string} - A mapping of the free space for each datastore in the datacenter, where the name of the datastore is used as key and the free space as value.
- datacenter_
id str - The [managed object reference ID][docs-about-morefs] of the datacenter the datastores are located in.
- id str
- The provider-assigned unique ID for this managed resource.
- capacity Mapping[str, str]
- A mapping of the capacity for all datastore in the datacenter, where the name of the datastore is used as key and the capacity as value.
- free_
space Mapping[str, str] - A mapping of the free space for each datastore in the datacenter, where the name of the datastore is used as key and the free space as value.
- datacenter
Id String - The [managed object reference ID][docs-about-morefs] of the datacenter the datastores are located in.
- id String
- The provider-assigned unique ID for this managed resource.
- capacity Map<String>
- A mapping of the capacity for all datastore in the datacenter, where the name of the datastore is used as key and the capacity as value.
- free
Space Map<String> - A mapping of the free space for each datastore in the datacenter, where the name of the datastore is used as key and the free space as value.
Package Details
- Repository
- vSphere pulumi/pulumi-vsphere
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
vsphere
Terraform Provider.