/
datastoreClusterVmAntiAffinityRule.go
163 lines (149 loc) · 7.3 KB
/
datastoreClusterVmAntiAffinityRule.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
// nolint: lll
package vsphere
import (
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/go/pulumi"
)
// The `.DatastoreClusterVmAntiAffinityRule` resource can be used to
// manage VM anti-affinity rules in a datastore cluster, either created by the
// [`.DatastoreCluster`][tf-vsphere-datastore-cluster-resource] resource or looked up
// by the [`.DatastoreCluster`][tf-vsphere-datastore-cluster-data-source] data source.
//
// [tf-vsphere-datastore-cluster-resource]: /docs/providers/vsphere/r/datastore_cluster.html
// [tf-vsphere-datastore-cluster-data-source]: /docs/providers/vsphere/d/datastore_cluster.html
//
// This rule can be used to tell a set to virtual machines to run on different
// datastores within a cluster, useful for preventing single points of failure in
// application cluster scenarios. When configured, Storage DRS will make a best effort to
// ensure that the virtual machines run on different datastores, or prevent any
// operation that would keep that from happening, depending on the value of the
// `mandatory` flag.
//
// > **NOTE:** This resource requires vCenter and is not available on direct ESXi
// connections.
//
// > **NOTE:** Storage DRS requires a vSphere Enterprise Plus license.
//
// > This content is derived from https://github.com/terraform-providers/terraform-provider-vsphere/blob/master/website/docs/r/datastore_cluster_vm_anti_affinity_rule.html.markdown.
type DatastoreClusterVmAntiAffinityRule struct {
pulumi.CustomResourceState
// The [managed object reference
// ID][docs-about-morefs] of the datastore cluster to put the group in. Forces
// a new resource if changed.
DatastoreClusterId pulumi.StringOutput `pulumi:"datastoreClusterId"`
// Enable this rule in the cluster. Default: `true`.
Enabled pulumi.BoolPtrOutput `pulumi:"enabled"`
// When this value is `true`, prevents any virtual
// machine operations that may violate this rule. Default: `false`.
Mandatory pulumi.BoolPtrOutput `pulumi:"mandatory"`
// The name of the rule. This must be unique in the cluster.
Name pulumi.StringOutput `pulumi:"name"`
// The UUIDs of the virtual machines to run
// on different datastores from each other.
VirtualMachineIds pulumi.StringArrayOutput `pulumi:"virtualMachineIds"`
}
// NewDatastoreClusterVmAntiAffinityRule registers a new resource with the given unique name, arguments, and options.
func NewDatastoreClusterVmAntiAffinityRule(ctx *pulumi.Context,
name string, args *DatastoreClusterVmAntiAffinityRuleArgs, opts ...pulumi.ResourceOption) (*DatastoreClusterVmAntiAffinityRule, error) {
if args == nil || args.DatastoreClusterId == nil {
return nil, errors.New("missing required argument 'DatastoreClusterId'")
}
if args == nil || args.VirtualMachineIds == nil {
return nil, errors.New("missing required argument 'VirtualMachineIds'")
}
if args == nil {
args = &DatastoreClusterVmAntiAffinityRuleArgs{}
}
var resource DatastoreClusterVmAntiAffinityRule
err := ctx.RegisterResource("vsphere:index/datastoreClusterVmAntiAffinityRule:DatastoreClusterVmAntiAffinityRule", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetDatastoreClusterVmAntiAffinityRule gets an existing DatastoreClusterVmAntiAffinityRule resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetDatastoreClusterVmAntiAffinityRule(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *DatastoreClusterVmAntiAffinityRuleState, opts ...pulumi.ResourceOption) (*DatastoreClusterVmAntiAffinityRule, error) {
var resource DatastoreClusterVmAntiAffinityRule
err := ctx.ReadResource("vsphere:index/datastoreClusterVmAntiAffinityRule:DatastoreClusterVmAntiAffinityRule", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering DatastoreClusterVmAntiAffinityRule resources.
type datastoreClusterVmAntiAffinityRuleState struct {
// The [managed object reference
// ID][docs-about-morefs] of the datastore cluster to put the group in. Forces
// a new resource if changed.
DatastoreClusterId *string `pulumi:"datastoreClusterId"`
// Enable this rule in the cluster. Default: `true`.
Enabled *bool `pulumi:"enabled"`
// When this value is `true`, prevents any virtual
// machine operations that may violate this rule. Default: `false`.
Mandatory *bool `pulumi:"mandatory"`
// The name of the rule. This must be unique in the cluster.
Name *string `pulumi:"name"`
// The UUIDs of the virtual machines to run
// on different datastores from each other.
VirtualMachineIds []string `pulumi:"virtualMachineIds"`
}
type DatastoreClusterVmAntiAffinityRuleState struct {
// The [managed object reference
// ID][docs-about-morefs] of the datastore cluster to put the group in. Forces
// a new resource if changed.
DatastoreClusterId pulumi.StringPtrInput
// Enable this rule in the cluster. Default: `true`.
Enabled pulumi.BoolPtrInput
// When this value is `true`, prevents any virtual
// machine operations that may violate this rule. Default: `false`.
Mandatory pulumi.BoolPtrInput
// The name of the rule. This must be unique in the cluster.
Name pulumi.StringPtrInput
// The UUIDs of the virtual machines to run
// on different datastores from each other.
VirtualMachineIds pulumi.StringArrayInput
}
func (DatastoreClusterVmAntiAffinityRuleState) ElementType() reflect.Type {
return reflect.TypeOf((*datastoreClusterVmAntiAffinityRuleState)(nil)).Elem()
}
type datastoreClusterVmAntiAffinityRuleArgs struct {
// The [managed object reference
// ID][docs-about-morefs] of the datastore cluster to put the group in. Forces
// a new resource if changed.
DatastoreClusterId string `pulumi:"datastoreClusterId"`
// Enable this rule in the cluster. Default: `true`.
Enabled *bool `pulumi:"enabled"`
// When this value is `true`, prevents any virtual
// machine operations that may violate this rule. Default: `false`.
Mandatory *bool `pulumi:"mandatory"`
// The name of the rule. This must be unique in the cluster.
Name *string `pulumi:"name"`
// The UUIDs of the virtual machines to run
// on different datastores from each other.
VirtualMachineIds []string `pulumi:"virtualMachineIds"`
}
// The set of arguments for constructing a DatastoreClusterVmAntiAffinityRule resource.
type DatastoreClusterVmAntiAffinityRuleArgs struct {
// The [managed object reference
// ID][docs-about-morefs] of the datastore cluster to put the group in. Forces
// a new resource if changed.
DatastoreClusterId pulumi.StringInput
// Enable this rule in the cluster. Default: `true`.
Enabled pulumi.BoolPtrInput
// When this value is `true`, prevents any virtual
// machine operations that may violate this rule. Default: `false`.
Mandatory pulumi.BoolPtrInput
// The name of the rule. This must be unique in the cluster.
Name pulumi.StringPtrInput
// The UUIDs of the virtual machines to run
// on different datastores from each other.
VirtualMachineIds pulumi.StringArrayInput
}
func (DatastoreClusterVmAntiAffinityRuleArgs) ElementType() reflect.Type {
return reflect.TypeOf((*datastoreClusterVmAntiAffinityRuleArgs)(nil)).Elem()
}