Skip to content

Commit

Permalink
VNF-3111 add initial config (#130)
Browse files Browse the repository at this point in the history
* feat: VNF-3111 add initial_config to resrouce_ecl_vna_appliance_v1

* style: VNF-3111 change indentation from spaces to tabs in resource_ecl_vna_appliance test file

* fix: VNF-3111 add initial_config.format validation(enum:set, text)

* build: VNF-3111 update eclcloud version for initial_config (v3.1.0->v3.2.0)
  • Loading branch information
guy555 authored Nov 29, 2024
1 parent 2ad7ec6 commit db6c316
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 93 deletions.
26 changes: 26 additions & 0 deletions ecl/resource_ecl_vna_appliance_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,29 @@ func interfaceInfoSchema() *schema.Schema {
}
}

func initialConfigSchema() *schema.Schema {
return &schema.Schema{
Type: schema.TypeMap,
Optional: true,

Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"format": &schema.Schema{
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice(
[]string{"set", "text"}, false,
),
},
"data": &schema.Schema{
Type: schema.TypeString,
Required: true,
},
},
},
}
}

func resourceVNAApplianceV1() *schema.Resource {
var result *schema.Resource

Expand Down Expand Up @@ -211,6 +234,8 @@ func resourceVNAApplianceV1() *schema.Resource {
result.Schema[fmt.Sprintf("interface_%d_no_allowed_address_pairs", i)] = noAllowedAddressPairsSchema(i)
}

result.Schema["initial_config"] = initialConfigSchema()

return result
}

Expand All @@ -231,6 +256,7 @@ func resourceVNAApplianceV1Create(d *schema.ResourceData, meta interface{}) erro
TenantID: d.Get("tenant_id").(string),
Tags: resourceTags(d),
Interfaces: getInterfaceCreateOpts(d),
InitialConfig: getInitialConfigCreateOpts(d),
},
}

Expand Down
107 changes: 67 additions & 40 deletions ecl/resource_ecl_vna_appliance_v1_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ func TestMockedAccVNAV1Appliance_basic(t *testing.T) {
resource.TestCheckResourceAttr("ecl_vna_appliance_v1.appliance_1", "interface_1_info.0.description", "interface_1_description"),
resource.TestCheckResourceAttr("ecl_vna_appliance_v1.appliance_1", "interface_1_info.0.network_id", "dummyNetworkID"),
resource.TestCheckResourceAttr("ecl_vna_appliance_v1.appliance_1", "interface_1_fixed_ips.0.ip_address", "192.168.1.50"),
resource.TestCheckResourceAttr("ecl_vna_appliance_v1.appliance_1", "initial_config.format", "set"),
resource.TestCheckResourceAttr("ecl_vna_appliance_v1.appliance_1", "initial_config.data", "c2V0IGludGVyZmFjZXMgZ2UtMC8wLzAgZGVzY3JpcHRpb24gc2FtcGxl"),
),
},
},
Expand Down Expand Up @@ -417,19 +419,26 @@ resource "ecl_vna_appliance_v1" "appliance_1" {
availability_zone = "%s"
virtual_network_appliance_plan_id = "%s"
interface_1_info {
interface_1_info {
name = "interface_1"
description = "interface_1_description"
network_id = "dummyNetworkID"
network_id = "dummyNetworkID"
}
interface_1_fixed_ips {
ip_address = "192.168.1.50"
}
initial_config = {
format = "set"
data = "c2V0IGludGVyZmFjZXMgZ2UtMC8wLzAgZGVzY3JpcHRpb24gc2FtcGxl"
}
lifecycle {
ignore_changes = [
"default_gateway",
"username",
"password",
]
}
}`,
Expand All @@ -445,20 +454,20 @@ resource "ecl_vna_appliance_v1" "appliance_1" {
availability_zone = "%s"
virtual_network_appliance_plan_id = "%s"
interface_3_info {
interface_3_info {
name = "interface_3"
description = "interface_3_description"
network_id = "dummyNetworkID"
network_id = "dummyNetworkID"
}
interface_3_fixed_ips {
ip_address = "192.168.1.53"
}
interface_8_info {
interface_8_info {
name = "interface_8"
description = "interface_8_description"
network_id = "dummyNetworkID"
network_id = "dummyNetworkID"
}
interface_8_fixed_ips {
Expand All @@ -467,6 +476,8 @@ resource "ecl_vna_appliance_v1" "appliance_1" {
lifecycle {
ignore_changes = [
"default_gateway",
"username",
"password",
]
}
}`,
Expand All @@ -485,6 +496,8 @@ resource "ecl_vna_appliance_v1" "appliance_1" {
lifecycle {
ignore_changes = [
"default_gateway",
"username",
"password",
]
}
}`,
Expand All @@ -500,17 +513,19 @@ resource "ecl_vna_appliance_v1" "appliance_1" {
availability_zone = "%s"
virtual_network_appliance_plan_id = "%s"
interface_1_info {
interface_1_info {
name = "interface_1"
description = "interface_1_description"
network_id = "dummyNetworkID"
network_id = "dummyNetworkID"
}
interface_1_no_fixed_ips = "true"
interface_1_no_fixed_ips = "true"
lifecycle {
lifecycle {
ignore_changes = [
"default_gateway",
"username",
"password",
]
}
}`,
Expand All @@ -526,15 +541,17 @@ resource "ecl_vna_appliance_v1" "appliance_1" {
availability_zone = "%s"
virtual_network_appliance_plan_id = "%s"
interface_1_info {
interface_1_info {
name = "interface_1"
description = "interface_1_description"
network_id = "dummyNetworkID"
network_id = "dummyNetworkID"
}
lifecycle {
lifecycle {
ignore_changes = [
"default_gateway",
"username",
"password",
]
}
}`,
Expand All @@ -550,10 +567,10 @@ resource "ecl_vna_appliance_v1" "appliance_1" {
availability_zone = "%s"
virtual_network_appliance_plan_id = "%s"
interface_1_info {
interface_1_info {
name = "interface_1"
description = "interface_1_description"
network_id = "dummyNetworkID"
network_id = "dummyNetworkID"
}
interface_1_fixed_ips {
Expand All @@ -574,9 +591,11 @@ resource "ecl_vna_appliance_v1" "appliance_1" {
vrid = "null"
}
lifecycle {
lifecycle {
ignore_changes = [
"default_gateway",
"username",
"password",
]
}
}`,
Expand All @@ -592,19 +611,19 @@ resource "ecl_vna_appliance_v1" "appliance_1" {
availability_zone = "%s"
virtual_network_appliance_plan_id = "%s"
tags = {
k1 = "v1"
k2 = "v2"
}
tags = {
k1 = "v1"
k2 = "v2"
}
interface_1_info {
interface_1_info {
name = "interface_1-update"
description = "interface_1_description-update"
network_id = "dummyNetworkID"
tags = {
interfaceK1 = "interfaceV1"
interfaceK2 = "interfaceV2"
}
network_id = "dummyNetworkID"
tags = {
interfaceK1 = "interfaceV1"
interfaceK2 = "interfaceV2"
}
}
interface_1_fixed_ips {
Expand All @@ -614,6 +633,8 @@ resource "ecl_vna_appliance_v1" "appliance_1" {
lifecycle {
ignore_changes = [
"default_gateway",
"username",
"password",
]
}
}`,
Expand All @@ -629,10 +650,10 @@ resource "ecl_vna_appliance_v1" "appliance_1" {
availability_zone = "%s"
virtual_network_appliance_plan_id = "%s"
interface_1_info {
interface_1_info {
name = "interface_1-update"
description = "interface_1_description-update"
network_id = "dummyNetworkID"
network_id = "dummyNetworkID"
}
interface_1_fixed_ips {
Expand All @@ -642,6 +663,8 @@ resource "ecl_vna_appliance_v1" "appliance_1" {
lifecycle {
ignore_changes = [
"default_gateway",
"username",
"password",
]
}
}`,
Expand All @@ -657,41 +680,43 @@ resource "ecl_vna_appliance_v1" "appliance_1" {
availability_zone = "%s"
virtual_network_appliance_plan_id = "%s"
interface_1_info {
interface_1_info {
name = "interface_1"
description = "interface_1_description"
network_id = "dummyNetworkID"
network_id = "dummyNetworkID"
}
interface_1_fixed_ips {
ip_address = "192.168.1.50"
}
interface_2_info {
network_id = "dummyNetworkID2"
interface_2_info {
network_id = "dummyNetworkID2"
}
interface_3_info {
network_id = "dummyNetworkID3"
interface_3_info {
network_id = "dummyNetworkID3"
}
interface_3_fixed_ips {
interface_3_fixed_ips {
ip_address = "192.168.3.50"
}
interface_3_fixed_ips {
interface_3_fixed_ips {
ip_address = "192.168.3.60"
}
interface_4_info {
network_id = "dummyNetworkID4"
interface_4_info {
network_id = "dummyNetworkID4"
}
interface_4_no_fixed_ips = "true"
interface_4_no_fixed_ips = "true"
lifecycle {
lifecycle {
ignore_changes = [
"default_gateway",
"username",
"password",
]
}
}`,
Expand Down Expand Up @@ -2587,6 +2612,8 @@ resource "ecl_vna_appliance_v1" "appliance_1" {
lifecycle {
ignore_changes = [
"default_gateway",
"username",
"password",
]
}
}`,
Expand Down
Loading

0 comments on commit db6c316

Please sign in to comment.