provider/openstack: docs and tests for allowed_address_pairs

This commit is contained in:
Joe Topjian 2016-08-23 02:13:37 +00:00
parent 51d669be44
commit a41ae4b9ac
2 changed files with 80 additions and 0 deletions

View File

@ -56,6 +56,29 @@ func TestAccNetworkingV2Port_noip(t *testing.T) {
})
}
func TestAccNetworkingV2Port_allowedAddressPairs(t *testing.T) {
var network networks.Network
var subnet subnets.Subnet
var vrrp_port, instance_port ports.Port
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckNetworkingV2PortDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccNetworkingV2Port_allowedAddressPairs,
Check: resource.ComposeTestCheckFunc(
testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.vrrp_subnet", &subnet),
testAccCheckNetworkingV2NetworkExists(t, "openstack_networking_network_v2.vrrp_network", &network),
testAccCheckNetworkingV2PortExists(t, "openstack_networking_port_v2.vrrp_port", &vrrp_port),
testAccCheckNetworkingV2PortExists(t, "openstack_networking_port_v2.instance_port", &instance_port),
),
},
},
})
}
func testAccCheckNetworkingV2PortDestroy(s *terraform.State) error {
config := testAccProvider.Meta().(*Config)
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
@ -151,3 +174,51 @@ var testAccNetworkingV2Port_noip = fmt.Sprintf(`
subnet_id = "${openstack_networking_subnet_v2.foo.id}"
}
}`)
var testAccNetworkingV2Port_allowedAddressPairs = fmt.Sprintf(`
resource "openstack_networking_network_v2" "vrrp_network" {
name = "vrrp_network"
admin_state_up = "true"
}
resource "openstack_networking_subnet_v2" "vrrp_subnet" {
name = "vrrp_subnet"
network_id = "${openstack_networking_network_v2.vrrp_network.id}"
cidr = "10.0.0.0/24"
ip_version = 4
allocation_pools {
start = "10.0.0.2"
end = "10.0.0.200"
}
}
resource "openstack_networking_router_v2" "vrrp_router" {
name = "vrrp_router"
}
resource "openstack_networking_router_interface_v2" "vrrp_interface" {
router_id = "${openstack_networking_router_v2.vrrp_router.id}"
subnet_id = "${openstack_networking_subnet_v2.vrrp_subnet.id}"
}
resource "openstack_networking_port_v2" "vrrp_port" {
name = "vrrp_port"
network_id = "${openstack_networking_network_v2.vrrp_network.id}"
admin_state_up = "true"
fixed_ip {
subnet_id = "${openstack_networking_subnet_v2.vrrp_subnet.id}"
ip_address = "10.0.0.201"
}
}
resource "openstack_networking_port_v2" "instance_port" {
name = "instance_port"
network_id = "${openstack_networking_network_v2.vrrp_network.id}"
admin_state_up = "true"
allowed_address_pairs {
ip_address = "${openstack_networking_port_v2.vrrp_port.fixed_ip.0.ip_address}"
mac_address = "${openstack_networking_port_v2.vrrp_port.mac_address}"
}
}`)

View File

@ -63,6 +63,9 @@ The following arguments are supported:
* `fixed_ip` - (Optional) An array of desired IPs for this port. The structure is
described below.
* `allowed_address_pairs` - (Optional) An IP/MAC Address pair of additional IP
addresses that can be active on this port. The structure is described
below.
The `fixed_ip` block supports:
@ -73,6 +76,12 @@ this port.
you don't specify `ip_address`, an available IP address from the specified
subnet will be allocated to this port.
The `allowed_address_pairs` block supports:
* `ip_address` - (Required) The additional IP address.
* `mac_address` - (Optional) The additional MAC address.
## Attributes Reference
The following attributes are exported: