@@ -2,6 +2,7 @@ package fmc
2
2
3
3
import (
4
4
"context"
5
+ "strconv"
5
6
6
7
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
7
8
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -73,10 +74,10 @@ func resourceFmcSubInterface() *schema.Resource {
73
74
Computed : true ,
74
75
Description : "The type of this resource" ,
75
76
},
76
- "mode" : {
77
+ "mode" : {
77
78
Type : schema .TypeString ,
78
79
Optional : true ,
79
- Default : "NONE" ,
80
+ Default : "NONE" ,
80
81
Description : "The mode of this resource" ,
81
82
},
82
83
"name" : {
@@ -93,7 +94,7 @@ func resourceFmcSubInterface() *schema.Resource {
93
94
"priority" : {
94
95
Type : schema .TypeInt ,
95
96
Optional : true ,
96
- Default : 0 ,
97
+ Default : 0 ,
97
98
Description : "The type of this resource" ,
98
99
},
99
100
"security_zone_id" : {
@@ -193,14 +194,13 @@ func resourceFmcSubInterfaceCreate(ctx context.Context, d *schema.ResourceData,
193
194
194
195
var diags diag.Diagnostics
195
196
196
-
197
197
ipv4StaticAddress := d .Get ("ipv4_static_address" ).(string )
198
198
ipv4StaticNetmask := d .Get ("ipv4_static_netmask" ).(int )
199
199
ipv4DhcpEnabled := d .Get ("ipv4_dhcp_enabled" ).(bool )
200
200
ipv4DhcpRouteMetric := d .Get ("ipv4_dhcp_route_metric" ).(int )
201
-
201
+
202
202
securityZoneId := d .Get ("security_zone_id" ).(string )
203
-
203
+
204
204
ipv6Address := d .Get ("ipv6_address" ).(string )
205
205
ipv6Prefix := d .Get ("ipv6_prefix" ).(int )
206
206
ipv6EnforceEUI := d .Get ("ipv6_enforce_eui" ).(bool )
@@ -215,15 +215,15 @@ func resourceFmcSubInterfaceCreate(ctx context.Context, d *schema.ResourceData,
215
215
})
216
216
}
217
217
218
- var IPv6 = IPv6 {EnableIPv6 :enable_ipv6 , Addresses : IPv6Add }
218
+ var IPv6 = IPv6 {EnableIPv6 : enable_ipv6 , Addresses : IPv6Add }
219
219
220
220
var SubInterfaceSecurityZone = PhysicalInterfaceSecurityZone {
221
221
ID : securityZoneId ,
222
222
Type : "SecurityZone" ,
223
223
}
224
224
var IPv4Static = IPv4Static {
225
225
Address : ipv4StaticAddress ,
226
- Netmask : ipv4StaticNetmask ,
226
+ Netmask : strconv . Itoa ( ipv4StaticNetmask ) ,
227
227
}
228
228
var IPv4DHCP = IPv4DHCP {
229
229
Enable : ipv4DhcpEnabled ,
@@ -242,14 +242,14 @@ func resourceFmcSubInterfaceCreate(ctx context.Context, d *schema.ResourceData,
242
242
Mode : d .Get ("mode" ).(string ),
243
243
Name : d .Get ("name" ).(string ),
244
244
IPv4 : IPv4 ,
245
- VlanID : d .Get ("vlan_id" ).(int ),
245
+ VlanID : d .Get ("vlan_id" ).(int ),
246
246
SubInterfaceID : d .Get ("subinterface_id" ).(int ),
247
247
Enabled : d .Get ("enabled" ).(bool ),
248
248
SecurityZone : SubInterfaceSecurityZone ,
249
249
MgmntOnly : d .Get ("management_only" ).(bool ),
250
250
Priority : d .Get ("priority" ).(int ),
251
251
MTU : d .Get ("mtu" ).(int ),
252
- IPv6 : IPv6 ,
252
+ IPv6 : IPv6 ,
253
253
})
254
254
if err != nil {
255
255
diags = append (diags , diag.Diagnostic {
@@ -268,7 +268,7 @@ func resourceFmcSubInterfaceUpdate(ctx context.Context, d *schema.ResourceData,
268
268
269
269
var diags diag.Diagnostics
270
270
id := d .Id ()
271
- if d .HasChanges ("ipv6_enforce_eui" ,"ipv6_prefix" ,"ipv6_address" ,"vlan_id" ,"management_only" ,"ifname" ,"name" , "mode" , "ipv4_static_address" , "security_zone_id" , "ipv4_dhcp_enabled" ,"ipv4_dhcp_route_metric" , "priority" , "enabled" ) {
271
+ if d .HasChanges ("ipv6_enforce_eui" , "ipv6_prefix" , "ipv6_address" , "vlan_id" , "management_only" , "ifname" , "name" , "mode" , "ipv4_static_address" , "ipv4_static_netmask" , " security_zone_id" , "ipv4_dhcp_enabled" , "ipv4_dhcp_route_metric" , "priority" , "enabled" ) {
272
272
273
273
ipv4StaticAddress := d .Get ("ipv4_static_address" ).(string )
274
274
ipv4StaticNetmask := d .Get ("ipv4_static_netmask" ).(int )
@@ -283,7 +283,7 @@ func resourceFmcSubInterfaceUpdate(ctx context.Context, d *schema.ResourceData,
283
283
}
284
284
var IPv4Static = IPv4Static {
285
285
Address : ipv4StaticAddress ,
286
- Netmask : ipv4StaticNetmask ,
286
+ Netmask : strconv . Itoa ( ipv4StaticNetmask ) ,
287
287
}
288
288
var IPv4DHCP = IPv4DHCP {
289
289
Enable : ipv4DhcpEnabled ,
@@ -311,22 +311,22 @@ func resourceFmcSubInterfaceUpdate(ctx context.Context, d *schema.ResourceData,
311
311
})
312
312
}
313
313
314
- var IPv6 = IPv6 {EnableIPv6 :enable_ipv6 , Addresses : IPv6Add }
314
+ var IPv6 = IPv6 {EnableIPv6 : enable_ipv6 , Addresses : IPv6Add }
315
315
316
316
_ , err := c .UpdateFmcSubInterface (ctx , d .Get ("device_id" ).(string ), id , & SubInterface {
317
317
ID : id ,
318
318
Ifname : d .Get ("ifname" ).(string ),
319
319
Mode : d .Get ("mode" ).(string ),
320
320
Name : d .Get ("name" ).(string ),
321
321
IPv4 : IPv4 ,
322
- VlanID : d .Get ("vlan_id" ).(int ),
322
+ VlanID : d .Get ("vlan_id" ).(int ),
323
323
Enabled : d .Get ("enabled" ).(bool ),
324
324
SecurityZone : SubInterfaceSecurityZone ,
325
325
SubInterfaceID : d .Get ("subinterface_id" ).(int ),
326
326
MgmntOnly : d .Get ("management_only" ).(bool ),
327
327
Priority : d .Get ("priority" ).(int ),
328
328
MTU : d .Get ("mtu" ).(int ),
329
- IPv6 : IPv6 ,
329
+ IPv6 : IPv6 ,
330
330
})
331
331
if err != nil {
332
332
diags = append (diags , diag.Diagnostic {
@@ -348,7 +348,7 @@ func resourceFmcSubInterfaceDelete(ctx context.Context, d *schema.ResourceData,
348
348
349
349
id := d .Id ()
350
350
351
- err := c .DeleteFmcSubInterface (ctx , d .Get ("device_id" ).(string ) , id )
351
+ err := c .DeleteFmcSubInterface (ctx , d .Get ("device_id" ).(string ), id )
352
352
if err != nil {
353
353
diags = append (diags , diag.Diagnostic {
354
354
Severity : diag .Error ,
0 commit comments