provider/openstack Add Acceptance Test for No Port IP
This commit is contained in:
parent
17e6e5d118
commit
b488541ee9
|
@ -63,6 +63,53 @@ func TestAccNetworkingV2Port_basic(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAccNetworkingV2Port_noip(t *testing.T) {
|
||||||
|
region := os.Getenv(OS_REGION_NAME)
|
||||||
|
|
||||||
|
var network networks.Network
|
||||||
|
var port ports.Port
|
||||||
|
var subnet subnets.Subnet
|
||||||
|
|
||||||
|
var testAccNetworkingV2Port_noip = fmt.Sprintf(`
|
||||||
|
resource "openstack_networking_network_v2" "foo" {
|
||||||
|
region = "%s"
|
||||||
|
name = "network_1"
|
||||||
|
admin_state_up = "true"
|
||||||
|
}
|
||||||
|
resource "openstack_networking_subnet_v2" "foo" {
|
||||||
|
region = "%s"
|
||||||
|
name = "subnet_1"
|
||||||
|
network_id = "${openstack_networking_network_v2.foo.id}"
|
||||||
|
cidr = "192.168.199.0/24"
|
||||||
|
ip_version = 4
|
||||||
|
}
|
||||||
|
resource "openstack_networking_port_v2" "foo" {
|
||||||
|
region = "%s"
|
||||||
|
name = "port_1"
|
||||||
|
network_id = "${openstack_networking_network_v2.foo.id}"
|
||||||
|
admin_state_up = "true"
|
||||||
|
fixed_ip {
|
||||||
|
subnet_id = "${openstack_networking_subnet_v2.foo.id}"
|
||||||
|
}
|
||||||
|
}`, region, region, region)
|
||||||
|
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccCheckNetworkingV2PortDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
resource.TestStep{
|
||||||
|
Config: testAccNetworkingV2Port_noip,
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.foo", &subnet),
|
||||||
|
testAccCheckNetworkingV2NetworkExists(t, "openstack_networking_network_v2.foo", &network),
|
||||||
|
testAccCheckNetworkingV2PortExists(t, "openstack_networking_port_v2.foo", &port),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func testAccCheckNetworkingV2PortDestroy(s *terraform.State) error {
|
func testAccCheckNetworkingV2PortDestroy(s *terraform.State) error {
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||||
|
|
|
@ -69,9 +69,9 @@ The `fixed_ip` block supports:
|
||||||
* `subnet_id` - (Required) Subnet in which to allocate IP address for
|
* `subnet_id` - (Required) Subnet in which to allocate IP address for
|
||||||
this port.
|
this port.
|
||||||
|
|
||||||
* `ip_address` - (Optional) IP address desired in the subnet for this
|
* `ip_address` - (Optional) IP address desired in the subnet for this port. If
|
||||||
port. If you don't specify `ip_address`, OpenStack will be allocated an available
|
you don't specify `ip_address`, an available IP address from the specified
|
||||||
IP address to this port.
|
subnet will be allocated to this port.
|
||||||
|
|
||||||
## Attributes Reference
|
## Attributes Reference
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue