VmStoragePolicy
The vsphere.VmStoragePolicy
resource can be used to create and manage storage
policies. Using this storage policy, tag based placement rules can be created to
place a VM on a particular tagged datastore.
Example Usage
using Pulumi;
using VSphere = Pulumi.VSphere;
class MyStack : Stack
{
public MyStack()
{
var dc = Output.Create(VSphere.GetDatacenter.InvokeAsync(new VSphere.GetDatacenterArgs
{
Name = "DC",
}));
var tagCategory = Output.Create(VSphere.GetTagCategory.InvokeAsync(new VSphere.GetTagCategoryArgs
{
Name = "cat1",
}));
var tag1 = tagCategory.Apply(tagCategory => Output.Create(VSphere.GetTag.InvokeAsync(new VSphere.GetTagArgs
{
Name = "tag1",
CategoryId = tagCategory.Id,
})));
var tag2 = tagCategory.Apply(tagCategory => Output.Create(VSphere.GetTag.InvokeAsync(new VSphere.GetTagArgs
{
Name = "tag2",
CategoryId = tagCategory.Id,
})));
var policyTagBasedPlacement = new VSphere.VmStoragePolicy("policyTagBasedPlacement", new VSphere.VmStoragePolicyArgs
{
Description = "description",
TagRules =
{
new VSphere.Inputs.VmStoragePolicyTagRuleArgs
{
TagCategory = tagCategory.Apply(tagCategory => tagCategory.Name),
Tags =
{
tag1.Apply(tag1 => tag1.Name),
tag2.Apply(tag2 => tag2.Name),
},
IncludeDatastoresWithTags = true,
},
},
});
}
}
package main
import (
"github.com/pulumi/pulumi-vsphere/sdk/v2/go/vsphere"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
opt0 := "DC"
_, err := vsphere.LookupDatacenter(ctx, &vsphere.LookupDatacenterArgs{
Name: &opt0,
}, nil)
if err != nil {
return err
}
tagCategory, err := vsphere.LookupTagCategory(ctx, &vsphere.LookupTagCategoryArgs{
Name: "cat1",
}, nil)
if err != nil {
return err
}
tag1, err := vsphere.LookupTag(ctx, &vsphere.LookupTagArgs{
Name: "tag1",
CategoryId: tagCategory.Id,
}, nil)
if err != nil {
return err
}
tag2, err := vsphere.LookupTag(ctx, &vsphere.LookupTagArgs{
Name: "tag2",
CategoryId: tagCategory.Id,
}, nil)
if err != nil {
return err
}
_, err = vsphere.NewVmStoragePolicy(ctx, "policyTagBasedPlacement", &vsphere.VmStoragePolicyArgs{
Description: pulumi.String("description"),
TagRules: vsphere.VmStoragePolicyTagRuleArray{
&vsphere.VmStoragePolicyTagRuleArgs{
TagCategory: pulumi.String(tagCategory.Name),
Tags: pulumi.StringArray{
pulumi.String(tag1.Name),
pulumi.String(tag2.Name),
},
IncludeDatastoresWithTags: pulumi.Bool(true),
},
},
})
if err != nil {
return err
}
return nil
})
}
import pulumi
import pulumi_vsphere as vsphere
dc = vsphere.get_datacenter(name="DC")
tag_category = vsphere.get_tag_category(name="cat1")
tag1 = vsphere.get_tag(name="tag1",
category_id=tag_category.id)
tag2 = vsphere.get_tag(name="tag2",
category_id=tag_category.id)
policy_tag_based_placement = vsphere.VmStoragePolicy("policyTagBasedPlacement",
description="description",
tag_rules=[vsphere.VmStoragePolicyTagRuleArgs(
tag_category=tag_category.name,
tags=[
tag1.name,
tag2.name,
],
include_datastores_with_tags=True,
)])
import * as pulumi from "@pulumi/pulumi";
import * as vsphere from "@pulumi/vsphere";
const dc = vsphere.getDatacenter({
name: "DC",
});
const tagCategory = vsphere.getTagCategory({
name: "cat1",
});
const tag1 = tagCategory.then(tagCategory => vsphere.getTag({
name: "tag1",
categoryId: tagCategory.id,
}));
const tag2 = tagCategory.then(tagCategory => vsphere.getTag({
name: "tag2",
categoryId: tagCategory.id,
}));
const policyTagBasedPlacement = new vsphere.VmStoragePolicy("policyTagBasedPlacement", {
description: "description",
tagRules: [{
tagCategory: tagCategory.then(tagCategory => tagCategory.name),
tags: [
tag1.then(tag1 => tag1.name),
tag2.then(tag2 => tag2.name),
],
includeDatastoresWithTags: true,
}],
});
Create a VmStoragePolicy Resource
new VmStoragePolicy(name: string, args: VmStoragePolicyArgs, opts?: CustomResourceOptions);
def VmStoragePolicy(resource_name: str, opts: Optional[ResourceOptions] = None, description: Optional[str] = None, name: Optional[str] = None, tag_rules: Optional[Sequence[VmStoragePolicyTagRuleArgs]] = None)
func NewVmStoragePolicy(ctx *Context, name string, args VmStoragePolicyArgs, opts ...ResourceOption) (*VmStoragePolicy, error)
public VmStoragePolicy(string name, VmStoragePolicyArgs args, CustomResourceOptions? opts = null)
- name string
- The unique name of the resource.
- args VmStoragePolicyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- opts ResourceOptions
- A bag of options that control this resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args VmStoragePolicyArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args VmStoragePolicyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
VmStoragePolicy Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The VmStoragePolicy resource accepts the following input properties:
- Tag
Rules List<Pulumi.VSphere. Inputs. Vm Storage Policy Tag Rule Args> List of tag rules. The tag category and tags to be associated to this storage policy.
- Description string
Description of the storage policy.
- Name string
The name of the storage policy.
- Tag
Rules []VmStorage Policy Tag Rule List of tag rules. The tag category and tags to be associated to this storage policy.
- Description string
Description of the storage policy.
- Name string
The name of the storage policy.
- tag
Rules VmStorage Policy Tag Rule[] List of tag rules. The tag category and tags to be associated to this storage policy.
- description string
Description of the storage policy.
- name string
The name of the storage policy.
- tag_
rules Sequence[VmStorage Policy Tag Rule Args] List of tag rules. The tag category and tags to be associated to this storage policy.
- description str
Description of the storage policy.
- name str
The name of the storage policy.
Outputs
All input properties are implicitly available as output properties. Additionally, the VmStoragePolicy resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
Look up an Existing VmStoragePolicy Resource
Get an existing VmStoragePolicy resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: VmStoragePolicyState, opts?: CustomResourceOptions): VmStoragePolicy
@staticmethod
def get(resource_name: str, id: str, opts: Optional[ResourceOptions] = None, description: Optional[str] = None, name: Optional[str] = None, tag_rules: Optional[Sequence[VmStoragePolicyTagRuleArgs]] = None) -> VmStoragePolicy
func GetVmStoragePolicy(ctx *Context, name string, id IDInput, state *VmStoragePolicyState, opts ...ResourceOption) (*VmStoragePolicy, error)
public static VmStoragePolicy Get(string name, Input<string> id, VmStoragePolicyState? state, CustomResourceOptions? opts = null)
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
The following state arguments are supported:
- Description string
Description of the storage policy.
- Name string
The name of the storage policy.
- Tag
Rules List<Pulumi.VSphere. Inputs. Vm Storage Policy Tag Rule Args> List of tag rules. The tag category and tags to be associated to this storage policy.
- Description string
Description of the storage policy.
- Name string
The name of the storage policy.
- Tag
Rules []VmStorage Policy Tag Rule List of tag rules. The tag category and tags to be associated to this storage policy.
- description string
Description of the storage policy.
- name string
The name of the storage policy.
- tag
Rules VmStorage Policy Tag Rule[] List of tag rules. The tag category and tags to be associated to this storage policy.
- description str
Description of the storage policy.
- name str
The name of the storage policy.
- tag_
rules Sequence[VmStorage Policy Tag Rule Args] List of tag rules. The tag category and tags to be associated to this storage policy.
Supporting Types
VmStoragePolicyTagRule
- Tag
Category string Name of the tag category.
- List<string>
List of Name of tags to select from the given category.
- bool
Whether to include datastores with the given tags or exclude. Default value is true i.e. include datastores with the given tags.
- Tag
Category string Name of the tag category.
- []string
List of Name of tags to select from the given category.
- bool
Whether to include datastores with the given tags or exclude. Default value is true i.e. include datastores with the given tags.
- tag
Category string Name of the tag category.
- string[]
List of Name of tags to select from the given category.
- boolean
Whether to include datastores with the given tags or exclude. Default value is true i.e. include datastores with the given tags.
- tag_
category str Name of the tag category.
- Sequence[str]
List of Name of tags to select from the given category.
- bool
Whether to include datastores with the given tags or exclude. Default value is true i.e. include datastores with the given tags.
Package Details
- Repository
- https://github.com/pulumi/pulumi-vsphere
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
vsphere
Terraform Provider.