mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-20 11:48:24 -06:00
provider/openstack: Change Port fixed_ip to a Set (#12613)
This commit changes the openstack_networking_port_v2 fixed_ip parameter from a List to a Set. This is because OpenStack does not preserve the original ordering of the fixed IPs.
This commit is contained in:
parent
f4e74650f0
commit
20c88bcdf4
@ -80,7 +80,7 @@ func resourceNetworkingPortV2() *schema.Resource {
|
||||
Computed: true,
|
||||
},
|
||||
"fixed_ip": &schema.Schema{
|
||||
Type: schema.TypeList,
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
ForceNew: false,
|
||||
Computed: true,
|
||||
@ -304,7 +304,7 @@ func resourcePortSecurityGroupsV2(d *schema.ResourceData) []string {
|
||||
}
|
||||
|
||||
func resourcePortFixedIpsV2(d *schema.ResourceData) interface{} {
|
||||
rawIP := d.Get("fixed_ip").([]interface{})
|
||||
rawIP := d.Get("fixed_ip").(*schema.Set).List()
|
||||
|
||||
if len(rawIP) == 0 {
|
||||
return nil
|
||||
|
@ -80,6 +80,28 @@ func TestAccNetworkingV2Port_allowedAddressPairs(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccNetworkingV2Port_multipleFixedIPs(t *testing.T) {
|
||||
var network networks.Network
|
||||
var port ports.Port
|
||||
var subnet subnets.Subnet
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckNetworkingV2PortDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccNetworkingV2Port_multipleFixedIPs,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckNetworkingV2SubnetExists("openstack_networking_subnet_v2.subnet_1", &subnet),
|
||||
testAccCheckNetworkingV2NetworkExists("openstack_networking_network_v2.network_1", &network),
|
||||
testAccCheckNetworkingV2PortExists("openstack_networking_port_v2.port_1", &port),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccCheckNetworkingV2PortDestroy(s *terraform.State) error {
|
||||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
@ -247,3 +269,38 @@ resource "openstack_networking_port_v2" "instance_port" {
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
const testAccNetworkingV2Port_multipleFixedIPs = `
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "network_1"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
name = "subnet_1"
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_networking_port_v2" "port_1" {
|
||||
name = "port_1"
|
||||
admin_state_up = "true"
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
|
||||
fixed_ip {
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
ip_address = "192.168.199.23"
|
||||
}
|
||||
|
||||
fixed_ip {
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
ip_address = "192.168.199.20"
|
||||
}
|
||||
|
||||
fixed_ip {
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
ip_address = "192.168.199.40"
|
||||
}
|
||||
}
|
||||
`
|
||||
|
Loading…
Reference in New Issue
Block a user