From a41ae4b9acee9d56b49446cb56c8fc89e04f4d52 Mon Sep 17 00:00:00 2001 From: Joe Topjian Date: Tue, 23 Aug 2016 02:13:37 +0000 Subject: [PATCH] provider/openstack: docs and tests for allowed_address_pairs --- ...ource_openstack_networking_port_v2_test.go | 71 +++++++++++++++++++ .../r/networking_port_v2.html.markdown | 9 +++ 2 files changed, 80 insertions(+) diff --git a/builtin/providers/openstack/resource_openstack_networking_port_v2_test.go b/builtin/providers/openstack/resource_openstack_networking_port_v2_test.go index 1bb79e7f4..9b871ff74 100644 --- a/builtin/providers/openstack/resource_openstack_networking_port_v2_test.go +++ b/builtin/providers/openstack/resource_openstack_networking_port_v2_test.go @@ -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}" + } + }`) diff --git a/website/source/docs/providers/openstack/r/networking_port_v2.html.markdown b/website/source/docs/providers/openstack/r/networking_port_v2.html.markdown index 0a4c21e4a..14e9998e5 100644 --- a/website/source/docs/providers/openstack/r/networking_port_v2.html.markdown +++ b/website/source/docs/providers/openstack/r/networking_port_v2.html.markdown @@ -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: