Skip to content

Commit 692cfca

Browse files
committed
Adding license header to files. Fixed an issue with setting zone ids to null, moved storage_tags field to nested block disk_offering
1 parent 0ef7e49 commit 692cfca

9 files changed

+188
-70
lines changed

cloudstack/service_offering_constrained_resource.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
//
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
//
19+
120
package cloudstack
221

322
import (

cloudstack/service_offering_constrained_resource_test.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ func TestAccServiceOfferingConstrained(t *testing.T) {
7777
}
7878

7979
const testAccServiceOfferingCustomConstrained1 = `
80+
resource "cloudstack_zone" "test" {
81+
name = "acctest"
82+
dns1 = "8.8.8.8"
83+
internal_dns1 = "8.8.4.4"
84+
network_type = "Advanced"
85+
}
86+
8087
resource "cloudstack_service_offering_constrained" "constrained1" {
8188
display_text = "constrained1"
8289
name = "constrained1"
@@ -91,17 +98,16 @@ resource "cloudstack_service_offering_constrained" "constrained1" {
9198
min_memory = 1024
9299
93100
// other
94-
storage_tags = "foo"
95101
host_tags = "test0101,test0202"
96102
network_rate = 1024
97103
deployment_planner = "UserDispersingPlanner"
98104
99-
//Feature flags
105+
// Feature flags
100106
dynamic_scaling_enabled = false
101107
is_volatile = false
102108
limit_cpu_use = false
103109
offer_ha = false
104-
zone_ids = []
110+
zone_ids = [cloudstack_zone.test.id]
105111
106112
}
107113
`
@@ -121,7 +127,6 @@ resource "cloudstack_service_offering_constrained" "constrained1" {
121127
min_memory = 1024
122128
123129
// other
124-
storage_tags = "foo1"
125130
host_tags = "test0101,test0202"
126131
network_rate = 1024
127132
deployment_planner = "UserDispersingPlanner"
@@ -215,10 +220,11 @@ resource "cloudstack_service_offering_constrained" "constrained1" {
215220
216221
disk_offering = {
217222
storage_type = "local"
223+
sdfjklsdf = "sdfjks"
218224
provisioning_type = "thin"
219225
cache_mode = "none"
220226
root_disk_size = "5"
221-
tags = "FOO"
227+
storage_tags = "FOO"
222228
disk_offering_strictness = false
223229
}
224230
}
@@ -254,7 +260,7 @@ resource "cloudstack_service_offering_constrained" "disk_hypervisor" {
254260
provisioning_type = "thin"
255261
cache_mode = "none"
256262
root_disk_size = "5"
257-
tags = "FOO"
263+
storage_tags = "FOO"
258264
disk_offering_strictness = false
259265
}
260266
disk_hypervisor = {
@@ -298,7 +304,7 @@ resource "cloudstack_service_offering_constrained" "disk_storage" {
298304
provisioning_type = "thin"
299305
cache_mode = "none"
300306
root_disk_size = "5"
301-
tags = "FOO"
307+
storage_tags = "FOO"
302308
disk_offering_strictness = false
303309
}
304310
disk_hypervisor = {

cloudstack/service_offering_fixed_resource.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
//
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
//
19+
120
package cloudstack
221

322
import (

cloudstack/service_offering_fixed_resource_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ resource "cloudstack_service_offering_fixed" "disk" {
158158
provisioning_type = "thin"
159159
cache_mode = "none"
160160
root_disk_size = "5"
161-
tags = "FOO"
161+
storage_tags = "test0101,test0202"
162162
disk_offering_strictness = false
163163
}
164164
}
@@ -189,7 +189,7 @@ resource "cloudstack_service_offering_fixed" "disk_hypervisor" {
189189
provisioning_type = "thin"
190190
cache_mode = "none"
191191
root_disk_size = "5"
192-
tags = "FOO"
192+
storage_tags = "test0101,test0202"
193193
disk_offering_strictness = false
194194
}
195195
disk_hypervisor = {
@@ -228,7 +228,7 @@ resource "cloudstack_service_offering_fixed" "disk_storage" {
228228
provisioning_type = "thin"
229229
cache_mode = "none"
230230
root_disk_size = "5"
231-
tags = "FOO"
231+
storage_tags = "test0101,test0202"
232232
disk_offering_strictness = false
233233
}
234234
disk_storage = {

cloudstack/service_offering_models.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
//
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
//
19+
120
package cloudstack
221

322
import "github.com/hashicorp/terraform-plugin-framework/types"
@@ -35,7 +54,6 @@ type serviceOfferingCommonResourceModel struct {
3554
Name types.String `tfsdk:"name"`
3655
NetworkRate types.Int32 `tfsdk:"network_rate"`
3756
OfferHa types.Bool `tfsdk:"offer_ha"`
38-
StorageTags types.String `tfsdk:"storage_tags"`
3957
ZoneIds types.Set `tfsdk:"zone_ids"`
4058
ServiceOfferingDiskQosHypervisor types.Object `tfsdk:"disk_hypervisor"`
4159
ServiceOfferingDiskOffering types.Object `tfsdk:"disk_offering"`
@@ -57,6 +75,7 @@ type ServiceOfferingDiskOffering struct {
5775
ProvisionType types.String `tfsdk:"provisioning_type"`
5876
RootDiskSize types.Int64 `tfsdk:"root_disk_size"`
5977
StorageType types.String `tfsdk:"storage_type"`
78+
StorageTags types.String `tfsdk:"storage_tags"`
6079
}
6180

6281
type ServiceOfferingDiskQosStorage struct {

cloudstack/service_offering_schema.go

Lines changed: 67 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
//
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
//
19+
20+
// Nested schema attributes arent validated
21+
// disk_offering, disk_hypervisor, disk_storage
22+
// ref: https://github.com/hashicorp/terraform-plugin-framework/issues/805
23+
124
package cloudstack
225

326
import (
@@ -85,15 +108,55 @@ func serviceOfferingMergeCommonSchema(s1 map[string]schema.Attribute) map[string
85108
},
86109
Default: booldefault.StaticBool(false),
87110
},
88-
"storage_tags": schema.StringAttribute{
89-
Description: "the tags for the service offering",
90-
Optional: true,
91-
},
92111
"zone_ids": schema.SetAttribute{
93112
Description: "The ID of the zone(s)",
94113
Optional: true,
95114
ElementType: types.StringType,
96115
},
116+
"disk_offering": schema.SingleNestedAttribute{
117+
Optional: true,
118+
Attributes: map[string]schema.Attribute{
119+
"cache_mode": schema.StringAttribute{
120+
Description: "the cache mode to use for this disk offering. none, writeback or writethrough",
121+
Required: true,
122+
PlanModifiers: []planmodifier.String{
123+
stringplanmodifier.RequiresReplace(),
124+
},
125+
},
126+
"disk_offering_strictness": schema.BoolAttribute{
127+
Description: "True/False to indicate the strictness of the disk offering association with the compute offering. When set to true, override of disk offering is not allowed when VM is deployed and change disk offering is not allowed for the ROOT disk after the VM is deployed",
128+
Required: true,
129+
PlanModifiers: []planmodifier.Bool{
130+
boolplanmodifier.RequiresReplace(),
131+
},
132+
},
133+
"provisioning_type": schema.StringAttribute{
134+
Description: "provisioning type used to create volumes. Valid values are thin, sparse, fat.",
135+
Required: true,
136+
PlanModifiers: []planmodifier.String{
137+
stringplanmodifier.RequiresReplace(),
138+
},
139+
},
140+
"root_disk_size": schema.Int64Attribute{
141+
Description: "the Root disk size in GB.",
142+
Required: true,
143+
PlanModifiers: []planmodifier.Int64{
144+
int64planmodifier.RequiresReplace(),
145+
},
146+
},
147+
"storage_type": schema.StringAttribute{
148+
Description: "the storage type of the service offering. Values are local and shared.",
149+
Required: true,
150+
PlanModifiers: []planmodifier.String{
151+
stringplanmodifier.RequiresReplace(),
152+
},
153+
},
154+
"storage_tags": schema.StringAttribute{
155+
Description: "the tags for the service offering",
156+
Optional: true,
157+
},
158+
},
159+
},
97160
"disk_hypervisor": schema.SingleNestedAttribute{
98161
Optional: true,
99162
Attributes: map[string]schema.Attribute{
@@ -141,46 +204,6 @@ func serviceOfferingMergeCommonSchema(s1 map[string]schema.Attribute) map[string
141204
},
142205
},
143206
},
144-
"disk_offering": schema.SingleNestedAttribute{
145-
Optional: true,
146-
Attributes: map[string]schema.Attribute{
147-
"cache_mode": schema.StringAttribute{
148-
Description: "the cache mode to use for this disk offering. none, writeback or writethrough",
149-
Required: true,
150-
PlanModifiers: []planmodifier.String{
151-
stringplanmodifier.RequiresReplace(),
152-
},
153-
},
154-
"disk_offering_strictness": schema.BoolAttribute{
155-
Description: "True/False to indicate the strictness of the disk offering association with the compute offering. When set to true, override of disk offering is not allowed when VM is deployed and change disk offering is not allowed for the ROOT disk after the VM is deployed",
156-
Required: true,
157-
PlanModifiers: []planmodifier.Bool{
158-
boolplanmodifier.RequiresReplace(),
159-
},
160-
},
161-
"provisioning_type": schema.StringAttribute{
162-
Description: "provisioning type used to create volumes. Valid values are thin, sparse, fat.",
163-
Required: true,
164-
PlanModifiers: []planmodifier.String{
165-
stringplanmodifier.RequiresReplace(),
166-
},
167-
},
168-
"root_disk_size": schema.Int64Attribute{
169-
Description: "the Root disk size in GB.",
170-
Required: true,
171-
PlanModifiers: []planmodifier.Int64{
172-
int64planmodifier.RequiresReplace(),
173-
},
174-
},
175-
"storage_type": schema.StringAttribute{
176-
Description: "the storage type of the service offering. Values are local and shared.",
177-
Required: true,
178-
PlanModifiers: []planmodifier.String{
179-
stringplanmodifier.RequiresReplace(),
180-
},
181-
},
182-
},
183-
},
184207
"disk_storage": schema.SingleNestedAttribute{
185208
Optional: true,
186209
Attributes: map[string]schema.Attribute{

cloudstack/service_offering_unconstrained_resource.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
//
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
//
19+
120
package cloudstack
221

322
import (

cloudstack/service_offering_unconstrained_resource_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ resource "cloudstack_service_offering_unconstrained" "disk" {
137137
provisioning_type = "thin"
138138
cache_mode = "none"
139139
root_disk_size = "5"
140-
tags = "FOO"
140+
storage_tags = "test0101,test0202"
141141
disk_offering_strictness = false
142142
}
143143
}
@@ -162,7 +162,7 @@ resource "cloudstack_service_offering_unconstrained" "disk_hypervisor" {
162162
provisioning_type = "thin"
163163
cache_mode = "none"
164164
root_disk_size = "5"
165-
tags = "FOO"
165+
storage_tags = "test0101,test0202"
166166
disk_offering_strictness = false
167167
}
168168
disk_hypervisor = {
@@ -196,7 +196,7 @@ resource "cloudstack_service_offering_unconstrained" "disk_storage" {
196196
provisioning_type = "thin"
197197
cache_mode = "none"
198198
root_disk_size = "5"
199-
tags = "FOO"
199+
storage_tags = "test0101,test0202"
200200
disk_offering_strictness = false
201201
}
202202
disk_storage = {

0 commit comments

Comments
 (0)