@@ -23,29 +23,18 @@ type vdcDataSource struct {
23
23
}
24
24
25
25
type vdcDataSourceModel struct {
26
- ID types.String `tfsdk:"id"`
27
- VdcGroup types.String `tfsdk:"vdc_group"`
28
- Name types.String `tfsdk:"name"`
29
- Vdc * vdcDetail `tfsdk:"vdc"`
30
- }
31
-
32
- type vdcDetail struct {
33
- Name types.String `tfsdk:"name"`
34
- Description types.String `tfsdk:"description"`
35
- VdcServiceClass types.String `tfsdk:"vdc_service_class"`
36
- VdcDisponibilityClass types.String `tfsdk:"vdc_disponibility_class"`
37
- VdcBillingModel types.String `tfsdk:"vdc_billing_model"`
38
- VcpuInMhz2 types.Float64 `tfsdk:"vcpu_in_mhz2"`
39
- CPUAllocated types.Float64 `tfsdk:"cpu_allocated"`
40
- MemoryAllocated types.Float64 `tfsdk:"memory_allocated"`
41
- VdcStorageBillingModel types.String `tfsdk:"vdc_storage_billing_model"`
42
- VdcStorageProfiles []vdcStorageProfiles `tfsdk:"vdc_storage_profiles"`
43
- }
44
-
45
- type vdcStorageProfiles struct {
46
- Class types.String `tfsdk:"class"`
47
- Limit types.Int64 `tfsdk:"limit"`
48
- Default types.Bool `tfsdk:"default"`
26
+ ID types.String `tfsdk:"id"`
27
+ Name types.String `tfsdk:"name"`
28
+ Description types.String `tfsdk:"description"`
29
+ VdcServiceClass types.String `tfsdk:"service_class"`
30
+ VdcDisponibilityClass types.String `tfsdk:"disponibility_class"`
31
+ VdcBillingModel types.String `tfsdk:"billing_model"`
32
+ VcpuInMhz2 types.Float64 `tfsdk:"cpu_speed_in_mhz"`
33
+ CPUAllocated types.Float64 `tfsdk:"cpu_allocated"`
34
+ MemoryAllocated types.Float64 `tfsdk:"memory_allocated"`
35
+ VdcStorageBillingModel types.String `tfsdk:"storage_billing_model"`
36
+ VdcStorageProfiles []vdcStorageProfileModel `tfsdk:"storage_profile"`
37
+ VdcGroup types.String `tfsdk:"vdc_group"`
49
38
}
50
39
51
40
func (d * vdcDataSource ) Metadata (ctx context.Context , req datasource.MetadataRequest , resp * datasource.MetadataResponse ) {
@@ -54,77 +43,76 @@ func (d *vdcDataSource) Metadata(ctx context.Context, req datasource.MetadataReq
54
43
55
44
func (d * vdcDataSource ) Schema (ctx context.Context , req datasource.SchemaRequest , resp * datasource.SchemaResponse ) {
56
45
resp .Schema = schema.Schema {
57
- MarkdownDescription : "Show the vDC details." ,
58
-
46
+ MarkdownDescription : "Provides a Cloud Avenue Organization VDC data source. An Organization VDC can be used to reference a VDC and use its data within other resources or data sources." ,
59
47
Attributes : map [string ]schema.Attribute {
60
48
"id" : schema.StringAttribute {
61
- Computed : true ,
49
+ Computed : true ,
50
+ MarkdownDescription : "ID is the Name of the VCD." ,
62
51
},
63
52
"name" : schema.StringAttribute {
64
- MarkdownDescription : "VDC name." ,
65
- Required : true ,
53
+ Required : true ,
54
+ MarkdownDescription : "The name of the org VDC. It must be unique in the organization.\n " +
55
+ "The length must be between 2 and 27 characters." ,
56
+ },
57
+ "description" : schema.StringAttribute {
58
+ Computed : true ,
59
+ MarkdownDescription : "The description of the org VDC." ,
60
+ },
61
+ "cpu_speed_in_mhz" : schema.Float64Attribute {
62
+ Computed : true ,
63
+ MarkdownDescription : "Specifies the clock frequency, in Mhz, for any virtual CPU that is allocated to a VM.\n " +
64
+ "It must be at least 1200." ,
65
+ },
66
+ "cpu_allocated" : schema.Float64Attribute {
67
+ Computed : true ,
68
+ MarkdownDescription : "CPU capacity in *MHz* that is committed to be available or used as a limit in PAYG mode.\n " +
69
+ "It must be at least 5 * `cpu_speed_in_mhz` and at most 200 * `cpu_speed_in_mhz`.\n " +
70
+ " *Note:* Reserved capacity is automatically set according to the service class." ,
71
+ },
72
+ "memory_allocated" : schema.Float64Attribute {
73
+ Computed : true ,
74
+ MarkdownDescription : "Memory capacity in Gb that is committed to be available or used as a limit in PAYG mode.\n " +
75
+ "It must be between 1 and 5000." ,
66
76
},
67
77
"vdc_group" : schema.StringAttribute {
68
78
Computed : true ,
79
+ MarkdownDescription : "Name of an existing VDC group or a new one. This allows you to isolate your VDC.\n " +
80
+ "VMs of VDCs which belong to the same VDC group can communicate together." ,
69
81
},
70
- "vdc" : schema.SingleNestedAttribute {
71
- MarkdownDescription : "VDC details." ,
82
+ "service_class" : schema.StringAttribute {
72
83
Computed : true ,
73
- Attributes : map [string ]schema.Attribute {
74
- "name" : schema.StringAttribute {
75
- MarkdownDescription : "VDC name." ,
76
- Computed : true ,
77
- },
78
- "description" : schema.StringAttribute {
79
- MarkdownDescription : "VDC UUID." ,
80
- Computed : true ,
81
- },
82
- "vdc_service_class" : schema.StringAttribute {
83
- MarkdownDescription : "VDC service class." ,
84
- Computed : true ,
85
- },
86
- "vdc_disponibility_class" : schema.StringAttribute {
87
- MarkdownDescription : "VDC disponibility class." ,
88
- Computed : true ,
89
- },
90
- "vdc_billing_model" : schema.StringAttribute {
91
- MarkdownDescription : "VDC billing model." ,
92
- Computed : true ,
93
- },
94
- "vcpu_in_mhz2" : schema.NumberAttribute {
95
- MarkdownDescription : "VDC CPU in Mhz2." ,
96
- Computed : true ,
97
- },
98
- "cpu_allocated" : schema.NumberAttribute {
99
- MarkdownDescription : "VDC CPU allocated." ,
100
- Computed : true ,
101
- },
102
- "memory_allocated" : schema.NumberAttribute {
103
- MarkdownDescription : "VDC memory allocated." ,
104
- Computed : true ,
105
- },
106
- "vdc_storage_billing_model" : schema.StringAttribute {
107
- MarkdownDescription : "VDC storage billing model." ,
108
- Computed : true ,
109
- },
110
- "vdc_storage_profiles" : schema.ListNestedAttribute {
111
- MarkdownDescription : "VDC storage profiles." ,
112
- Computed : true ,
113
- NestedObject : schema.NestedAttributeObject {
114
- Attributes : map [string ]schema.Attribute {
115
- "class" : schema.StringAttribute {
116
- MarkdownDescription : "VDC storage profile class." ,
117
- Computed : true ,
118
- },
119
- "limit" : schema.NumberAttribute {
120
- MarkdownDescription : "VDC storage profile limit." ,
121
- Computed : true ,
122
- },
123
- "default" : schema.BoolAttribute {
124
- MarkdownDescription : "VDC storage profile default." ,
125
- Computed : true ,
126
- },
127
- },
84
+ MarkdownDescription : "The service class of the org VDC. It can be `ECO`, `STD`, `HP` or `VOIP`." ,
85
+ },
86
+ "disponibility_class" : schema.StringAttribute {
87
+ Computed : true ,
88
+ MarkdownDescription : "The disponibility class of the org VDC. It can be `ONE-ROOM`, `DUAL-ROOM` or `HA-DUAL-ROOM`." ,
89
+ },
90
+ "billing_model" : schema.StringAttribute {
91
+ Computed : true ,
92
+ MarkdownDescription : "Choose Billing model of compute resources. It can be `PAYG`, `DRAAS` or `RESERVED`." ,
93
+ },
94
+ "storage_billing_model" : schema.StringAttribute {
95
+ Computed : true ,
96
+ MarkdownDescription : "Choose Billing model of storage resources. It can be `PAYG` or `RESERVED`." ,
97
+ },
98
+ },
99
+ Blocks : map [string ]schema.Block {
100
+ "storage_profile" : schema.ListNestedBlock {
101
+ MarkdownDescription : "List of storage profiles for this VDC." ,
102
+ NestedObject : schema.NestedBlockObject {
103
+ Attributes : map [string ]schema.Attribute {
104
+ "class" : schema.StringAttribute {
105
+ Computed : true ,
106
+ MarkdownDescription : "The storage class of the storage profile.\n " +
107
+ "It can be `silver`, `silver_r1`, `silver_r2`, `gold`, `gold_r1`, `gold_r2`, `gold_hm`, `platinum3k`, `platinum3k_r1`, `platinum3k_r2`, `platinum3k_hm`, `platinum7k`, `platinum7k_r1`, `platinum7k_r2`, `platinum7k_hm`." ,
108
+ },
109
+ "limit" : schema.Int64Attribute {
110
+ Computed : true ,
111
+ MarkdownDescription : "Max number of units allocated for this storage profile. In Gb. It must be between 500 and 10000." ,
112
+ },
113
+ "default" : schema.BoolAttribute {
114
+ Computed : true ,
115
+ MarkdownDescription : "Set this storage profile as default for this VDC. Only one storage profile can be default per VDC." ,
128
116
},
129
117
},
130
118
},
@@ -169,9 +157,9 @@ func (d *vdcDataSource) Read(ctx context.Context, req datasource.ReadRequest, re
169
157
return
170
158
}
171
159
172
- var profiles []vdcStorageProfiles
160
+ var profiles []vdcStorageProfileModel
173
161
for _ , profile := range vdcs .Vdc .VdcStorageProfiles {
174
- p := vdcStorageProfiles {
162
+ p := vdcStorageProfileModel {
175
163
Class : types .StringValue (profile .Class ),
176
164
Limit : types .Int64Value (int64 (profile .Limit )),
177
165
Default : types .BoolValue (profile .Default_ ),
@@ -180,24 +168,20 @@ func (d *vdcDataSource) Read(ctx context.Context, req datasource.ReadRequest, re
180
168
}
181
169
182
170
data = vdcDataSourceModel {
183
- VdcGroup : types .StringValue (vdcs .VdcGroup ),
184
- Name : types .StringValue (vdcs .Vdc .Name ),
185
- Vdc : & vdcDetail {
186
- Name : types .StringValue (vdcs .Vdc .Name ),
187
- Description : types .StringValue (vdcs .Vdc .Description ),
188
- VdcServiceClass : types .StringValue (vdcs .Vdc .VdcServiceClass ),
189
- VdcDisponibilityClass : types .StringValue (vdcs .Vdc .VdcDisponibilityClass ),
190
- VdcBillingModel : types .StringValue (vdcs .Vdc .VdcBillingModel ),
191
- VcpuInMhz2 : types .Float64Value (vdcs .Vdc .VcpuInMhz2 ),
192
- CPUAllocated : types .Float64Value (vdcs .Vdc .CpuAllocated ),
193
- MemoryAllocated : types .Float64Value (vdcs .Vdc .MemoryAllocated ),
194
- VdcStorageBillingModel : types .StringValue (vdcs .Vdc .VdcStorageBillingModel ),
195
- VdcStorageProfiles : profiles ,
196
- },
171
+ ID : types .StringValue (vdcs .Vdc .Name ),
172
+ VdcGroup : types .StringValue (vdcs .VdcGroup ),
173
+ Name : types .StringValue (vdcs .Vdc .Name ),
174
+ Description : types .StringValue (vdcs .Vdc .Description ),
175
+ VdcServiceClass : types .StringValue (vdcs .Vdc .VdcServiceClass ),
176
+ VdcDisponibilityClass : types .StringValue (vdcs .Vdc .VdcDisponibilityClass ),
177
+ VdcBillingModel : types .StringValue (vdcs .Vdc .VdcBillingModel ),
178
+ VcpuInMhz2 : types .Float64Value (vdcs .Vdc .VcpuInMhz2 ),
179
+ CPUAllocated : types .Float64Value (vdcs .Vdc .CpuAllocated ),
180
+ MemoryAllocated : types .Float64Value (vdcs .Vdc .MemoryAllocated ),
181
+ VdcStorageBillingModel : types .StringValue (vdcs .Vdc .VdcStorageBillingModel ),
182
+ VdcStorageProfiles : profiles ,
197
183
}
198
184
199
- data .ID = types .StringValue ("frangipane" )
200
-
201
185
// Save data into Terraform state
202
186
resp .Diagnostics .Append (resp .State .Set (ctx , & data )... )
203
187
if resp .Diagnostics .HasError () {
0 commit comments