provider/openstack: Network and Object Storage Acceptance Test Cleanup (#10967)
* provider/openstack: Updating Networking acceptance tests * provider/openstack: Updating Object Storage acceptance tests
This commit is contained in:
parent
5de3a39f3e
commit
af5baf7b13
|
@ -58,8 +58,8 @@ func TestAccLBV1Pool_fullstack(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccLBV1Pool_fullstack_1,
|
Config: testAccLBV1Pool_fullstack_1,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2NetworkExists(t, "openstack_networking_network_v2.network_1", &network),
|
testAccCheckNetworkingV2NetworkExists("openstack_networking_network_v2.network_1", &network),
|
||||||
testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.subnet_1", &subnet),
|
testAccCheckNetworkingV2SubnetExists("openstack_networking_subnet_v2.subnet_1", &subnet),
|
||||||
testAccCheckComputeV2SecGroupExists("openstack_compute_secgroup_v2.secgroup_1", &secgroup),
|
testAccCheckComputeV2SecGroupExists("openstack_compute_secgroup_v2.secgroup_1", &secgroup),
|
||||||
testAccCheckComputeV2InstanceExists("openstack_compute_instance_v2.instance_1", &instance1),
|
testAccCheckComputeV2InstanceExists("openstack_compute_instance_v2.instance_1", &instance1),
|
||||||
testAccCheckComputeV2InstanceExists("openstack_compute_instance_v2.instance_2", &instance2),
|
testAccCheckComputeV2InstanceExists("openstack_compute_instance_v2.instance_2", &instance2),
|
||||||
|
@ -71,8 +71,8 @@ func TestAccLBV1Pool_fullstack(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccLBV1Pool_fullstack_2,
|
Config: testAccLBV1Pool_fullstack_2,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2NetworkExists(t, "openstack_networking_network_v2.network_1", &network),
|
testAccCheckNetworkingV2NetworkExists("openstack_networking_network_v2.network_1", &network),
|
||||||
testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.subnet_1", &subnet),
|
testAccCheckNetworkingV2SubnetExists("openstack_networking_subnet_v2.subnet_1", &subnet),
|
||||||
testAccCheckComputeV2SecGroupExists("openstack_compute_secgroup_v2.secgroup_1", &secgroup),
|
testAccCheckComputeV2SecGroupExists("openstack_compute_secgroup_v2.secgroup_1", &secgroup),
|
||||||
testAccCheckComputeV2InstanceExists("openstack_compute_instance_v2.instance_1", &instance1),
|
testAccCheckComputeV2InstanceExists("openstack_compute_instance_v2.instance_1", &instance1),
|
||||||
testAccCheckComputeV2InstanceExists("openstack_compute_instance_v2.instance_2", &instance2),
|
testAccCheckComputeV2InstanceExists("openstack_compute_instance_v2.instance_2", &instance2),
|
||||||
|
|
|
@ -2,7 +2,6 @@ package openstack
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
|
@ -13,7 +12,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAccNetworkingV2FloatingIP_basic(t *testing.T) {
|
func TestAccNetworkingV2FloatingIP_basic(t *testing.T) {
|
||||||
var floatingIP floatingips.FloatingIP
|
var fip floatingips.FloatingIP
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
@ -23,7 +22,7 @@ func TestAccNetworkingV2FloatingIP_basic(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2FloatingIP_basic,
|
Config: testAccNetworkingV2FloatingIP_basic,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2FloatingIPExists(t, "openstack_networking_floatingip_v2.foo", &floatingIP),
|
testAccCheckNetworkingV2FloatingIPExists("openstack_networking_floatingip_v2.fip_1", &fip),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -33,20 +32,6 @@ func TestAccNetworkingV2FloatingIP_basic(t *testing.T) {
|
||||||
func TestAccNetworkingV2FloatingIP_attach(t *testing.T) {
|
func TestAccNetworkingV2FloatingIP_attach(t *testing.T) {
|
||||||
var instance servers.Server
|
var instance servers.Server
|
||||||
var fip floatingips.FloatingIP
|
var fip floatingips.FloatingIP
|
||||||
var testAccNetworkV2FloatingIP_attach = fmt.Sprintf(`
|
|
||||||
resource "openstack_networking_floatingip_v2" "myip" {
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "openstack_compute_instance_v2" "foo" {
|
|
||||||
name = "terraform-test"
|
|
||||||
security_groups = ["default"]
|
|
||||||
floating_ip = "${openstack_networking_floatingip_v2.myip.address}"
|
|
||||||
|
|
||||||
network {
|
|
||||||
uuid = "%s"
|
|
||||||
}
|
|
||||||
}`,
|
|
||||||
os.Getenv("OS_NETWORK_ID"))
|
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
@ -56,8 +41,8 @@ func TestAccNetworkingV2FloatingIP_attach(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkV2FloatingIP_attach,
|
Config: testAccNetworkV2FloatingIP_attach,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2FloatingIPExists(t, "openstack_networking_floatingip_v2.myip", &fip),
|
testAccCheckNetworkingV2FloatingIPExists("openstack_networking_floatingip_v2.fip_1", &fip),
|
||||||
testAccCheckComputeV2InstanceExists("openstack_compute_instance_v2.foo", &instance),
|
testAccCheckComputeV2InstanceExists("openstack_compute_instance_v2.instance_1", &instance),
|
||||||
testAccCheckNetworkingV2InstanceFloatingIPAttach(&instance, &fip),
|
testAccCheckNetworkingV2InstanceFloatingIPAttach(&instance, &fip),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
@ -67,48 +52,6 @@ func TestAccNetworkingV2FloatingIP_attach(t *testing.T) {
|
||||||
|
|
||||||
func TestAccNetworkingV2FloatingIP_fixedip_bind(t *testing.T) {
|
func TestAccNetworkingV2FloatingIP_fixedip_bind(t *testing.T) {
|
||||||
var fip floatingips.FloatingIP
|
var fip floatingips.FloatingIP
|
||||||
var testAccNetworkingV2FloatingIP_fixedip_bind = fmt.Sprintf(`
|
|
||||||
resource "openstack_networking_network_v2" "network_1" {
|
|
||||||
name = "network_1"
|
|
||||||
admin_state_up = "true"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
|
||||||
name = "subnet_1"
|
|
||||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
|
||||||
cidr = "192.168.199.0/24"
|
|
||||||
ip_version = 4
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "openstack_networking_router_interface_v2" "router_interface_1" {
|
|
||||||
router_id = "${openstack_networking_router_v2.router_1.id}"
|
|
||||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "openstack_networking_router_v2" "router_1" {
|
|
||||||
name = "router_1"
|
|
||||||
external_gateway = "%s"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "openstack_networking_port_v2" "port_1" {
|
|
||||||
network_id = "${openstack_networking_subnet_v2.subnet_1.network_id}"
|
|
||||||
admin_state_up = "true"
|
|
||||||
fixed_ip {
|
|
||||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
|
||||||
ip_address = "192.168.199.10"
|
|
||||||
}
|
|
||||||
fixed_ip {
|
|
||||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
|
||||||
ip_address = "192.168.199.20"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "openstack_networking_floatingip_v2" "ip_1" {
|
|
||||||
pool = "%s"
|
|
||||||
port_id = "${openstack_networking_port_v2.port_1.id}"
|
|
||||||
fixed_ip = "${openstack_networking_port_v2.port_1.fixed_ip.1.ip_address}"
|
|
||||||
}`,
|
|
||||||
os.Getenv("OS_EXTGW_ID"), os.Getenv("OS_POOL_NAME"))
|
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
@ -118,8 +61,8 @@ func TestAccNetworkingV2FloatingIP_fixedip_bind(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2FloatingIP_fixedip_bind,
|
Config: testAccNetworkingV2FloatingIP_fixedip_bind,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2FloatingIPExists(t, "openstack_networking_floatingip_v2.ip_1", &fip),
|
testAccCheckNetworkingV2FloatingIPExists("openstack_networking_floatingip_v2.fip_1", &fip),
|
||||||
testAccCheckNetworkingV2FloatingIPBoundToCorrectIP(t, &fip, "192.168.199.20"),
|
testAccCheckNetworkingV2FloatingIPBoundToCorrectIP(&fip, "192.168.199.20"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -130,7 +73,7 @@ func testAccCheckNetworkingV2FloatingIPDestroy(s *terraform.State) error {
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
networkClient, err := config.networkingV2Client(OS_REGION_NAME)
|
networkClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("(testAccCheckNetworkingV2FloatingIPDestroy) Error creating OpenStack floating IP: %s", err)
|
return fmt.Errorf("Error creating OpenStack floating IP: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, rs := range s.RootModule().Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
|
@ -147,7 +90,7 @@ func testAccCheckNetworkingV2FloatingIPDestroy(s *terraform.State) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckNetworkingV2FloatingIPExists(t *testing.T, n string, kp *floatingips.FloatingIP) resource.TestCheckFunc {
|
func testAccCheckNetworkingV2FloatingIPExists(n string, kp *floatingips.FloatingIP) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
rs, ok := s.RootModule().Resources[n]
|
rs, ok := s.RootModule().Resources[n]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -161,7 +104,7 @@ func testAccCheckNetworkingV2FloatingIPExists(t *testing.T, n string, kp *floati
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
networkClient, err := config.networkingV2Client(OS_REGION_NAME)
|
networkClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("(testAccCheckNetworkingV2FloatingIPExists) Error creating OpenStack networking client: %s", err)
|
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
found, err := floatingips.Get(networkClient, rs.Primary.ID).Extract()
|
found, err := floatingips.Get(networkClient, rs.Primary.ID).Extract()
|
||||||
|
@ -179,7 +122,7 @@ func testAccCheckNetworkingV2FloatingIPExists(t *testing.T, n string, kp *floati
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckNetworkingV2FloatingIPBoundToCorrectIP(t *testing.T, fip *floatingips.FloatingIP, fixed_ip string) resource.TestCheckFunc {
|
func testAccCheckNetworkingV2FloatingIPBoundToCorrectIP(fip *floatingips.FloatingIP, fixed_ip string) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
if fip.FixedIP != fixed_ip {
|
if fip.FixedIP != fixed_ip {
|
||||||
return fmt.Errorf("Floating ip associated with wrong fixed ip")
|
return fmt.Errorf("Floating ip associated with wrong fixed ip")
|
||||||
|
@ -211,6 +154,67 @@ func testAccCheckNetworkingV2InstanceFloatingIPAttach(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var testAccNetworkingV2FloatingIP_basic = `
|
const testAccNetworkingV2FloatingIP_basic = `
|
||||||
resource "openstack_networking_floatingip_v2" "foo" {
|
resource "openstack_networking_floatingip_v2" "fip_1" {
|
||||||
}`
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
var testAccNetworkV2FloatingIP_attach = fmt.Sprintf(`
|
||||||
|
resource "openstack_networking_floatingip_v2" "fip_1" {
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "openstack_compute_instance_v2" "instance_1" {
|
||||||
|
name = "instance_1"
|
||||||
|
security_groups = ["default"]
|
||||||
|
floating_ip = "${openstack_networking_floatingip_v2.fip_1.address}"
|
||||||
|
|
||||||
|
network {
|
||||||
|
uuid = "%s"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`, OS_NETWORK_ID)
|
||||||
|
|
||||||
|
var testAccNetworkingV2FloatingIP_fixedip_bind = fmt.Sprintf(`
|
||||||
|
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_router_interface_v2" "router_interface_1" {
|
||||||
|
router_id = "${openstack_networking_router_v2.router_1.id}"
|
||||||
|
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "openstack_networking_router_v2" "router_1" {
|
||||||
|
name = "router_1"
|
||||||
|
external_gateway = "%s"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "openstack_networking_port_v2" "port_1" {
|
||||||
|
admin_state_up = "true"
|
||||||
|
network_id = "${openstack_networking_subnet_v2.subnet_1.network_id}"
|
||||||
|
|
||||||
|
fixed_ip {
|
||||||
|
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||||
|
ip_address = "192.168.199.10"
|
||||||
|
}
|
||||||
|
|
||||||
|
fixed_ip {
|
||||||
|
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||||
|
ip_address = "192.168.199.20"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "openstack_networking_floatingip_v2" "fip_1" {
|
||||||
|
pool = "%s"
|
||||||
|
port_id = "${openstack_networking_port_v2.port_1.id}"
|
||||||
|
fixed_ip = "${openstack_networking_port_v2.port_1.fixed_ip.1.ip_address}"
|
||||||
|
}
|
||||||
|
`, OS_EXTGW_ID, OS_POOL_NAME)
|
||||||
|
|
|
@ -26,13 +26,14 @@ func TestAccNetworkingV2Network_basic(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2Network_basic,
|
Config: testAccNetworkingV2Network_basic,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2NetworkExists(t, "openstack_networking_network_v2.foo", &network),
|
testAccCheckNetworkingV2NetworkExists("openstack_networking_network_v2.network_1", &network),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2Network_update,
|
Config: testAccNetworkingV2Network_update,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
resource.TestCheckResourceAttr("openstack_networking_network_v2.foo", "name", "network_2"),
|
resource.TestCheckResourceAttr(
|
||||||
|
"openstack_networking_network_v2.network_1", "name", "network_2"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -44,28 +45,6 @@ func TestAccNetworkingV2Network_netstack(t *testing.T) {
|
||||||
var subnet subnets.Subnet
|
var subnet subnets.Subnet
|
||||||
var router routers.Router
|
var router routers.Router
|
||||||
|
|
||||||
var testAccNetworkingV2Network_netstack = fmt.Sprintf(`
|
|
||||||
resource "openstack_networking_network_v2" "foo" {
|
|
||||||
name = "network_1"
|
|
||||||
admin_state_up = "true"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "openstack_networking_subnet_v2" "foo" {
|
|
||||||
name = "subnet_1"
|
|
||||||
network_id = "${openstack_networking_network_v2.foo.id}"
|
|
||||||
cidr = "192.168.10.0/24"
|
|
||||||
ip_version = 4
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "openstack_networking_router_v2" "foo" {
|
|
||||||
name = "router_1"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "openstack_networking_router_interface_v2" "foo" {
|
|
||||||
router_id = "${openstack_networking_router_v2.foo.id}"
|
|
||||||
subnet_id = "${openstack_networking_subnet_v2.foo.id}"
|
|
||||||
}`)
|
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
|
@ -74,10 +53,11 @@ func TestAccNetworkingV2Network_netstack(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2Network_netstack,
|
Config: testAccNetworkingV2Network_netstack,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2NetworkExists(t, "openstack_networking_network_v2.foo", &network),
|
testAccCheckNetworkingV2NetworkExists("openstack_networking_network_v2.network_1", &network),
|
||||||
testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.foo", &subnet),
|
testAccCheckNetworkingV2SubnetExists("openstack_networking_subnet_v2.subnet_1", &subnet),
|
||||||
testAccCheckNetworkingV2RouterExists(t, "openstack_networking_router_v2.foo", &router),
|
testAccCheckNetworkingV2RouterExists("openstack_networking_router_v2.router_1", &router),
|
||||||
testAccCheckNetworkingV2RouterInterfaceExists(t, "openstack_networking_router_interface_v2.foo"),
|
testAccCheckNetworkingV2RouterInterfaceExists(
|
||||||
|
"openstack_networking_router_interface_v2.ri_1"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -91,50 +71,6 @@ func TestAccNetworkingV2Network_fullstack(t *testing.T) {
|
||||||
var secgroup secgroups.SecurityGroup
|
var secgroup secgroups.SecurityGroup
|
||||||
var subnet subnets.Subnet
|
var subnet subnets.Subnet
|
||||||
|
|
||||||
var testAccNetworkingV2Network_fullstack = fmt.Sprintf(`
|
|
||||||
resource "openstack_networking_network_v2" "foo" {
|
|
||||||
name = "network_1"
|
|
||||||
admin_state_up = "true"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "openstack_networking_subnet_v2" "foo" {
|
|
||||||
name = "subnet_1"
|
|
||||||
network_id = "${openstack_networking_network_v2.foo.id}"
|
|
||||||
cidr = "192.168.199.0/24"
|
|
||||||
ip_version = 4
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "openstack_compute_secgroup_v2" "foo" {
|
|
||||||
name = "secgroup_1"
|
|
||||||
description = "a security group"
|
|
||||||
rule {
|
|
||||||
from_port = 22
|
|
||||||
to_port = 22
|
|
||||||
ip_protocol = "tcp"
|
|
||||||
cidr = "0.0.0.0/0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "openstack_networking_port_v2" "foo" {
|
|
||||||
name = "port_1"
|
|
||||||
network_id = "${openstack_networking_network_v2.foo.id}"
|
|
||||||
admin_state_up = "true"
|
|
||||||
security_group_ids = ["${openstack_compute_secgroup_v2.foo.id}"]
|
|
||||||
fixed_ip {
|
|
||||||
"subnet_id" = "${openstack_networking_subnet_v2.foo.id}"
|
|
||||||
"ip_address" = "192.168.199.23"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "openstack_compute_instance_v2" "foo" {
|
|
||||||
name = "terraform-test"
|
|
||||||
security_groups = ["${openstack_compute_secgroup_v2.foo.name}"]
|
|
||||||
|
|
||||||
network {
|
|
||||||
port = "${openstack_networking_port_v2.foo.id}"
|
|
||||||
}
|
|
||||||
}`)
|
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
|
@ -143,11 +79,11 @@ func TestAccNetworkingV2Network_fullstack(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2Network_fullstack,
|
Config: testAccNetworkingV2Network_fullstack,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2NetworkExists(t, "openstack_networking_network_v2.foo", &network),
|
testAccCheckNetworkingV2NetworkExists("openstack_networking_network_v2.network_1", &network),
|
||||||
testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.foo", &subnet),
|
testAccCheckNetworkingV2SubnetExists("openstack_networking_subnet_v2.subnet_1", &subnet),
|
||||||
testAccCheckComputeV2SecGroupExists("openstack_compute_secgroup_v2.foo", &secgroup),
|
testAccCheckComputeV2SecGroupExists("openstack_compute_secgroup_v2.secgroup_1", &secgroup),
|
||||||
testAccCheckNetworkingV2PortExists(t, "openstack_networking_port_v2.foo", &port),
|
testAccCheckNetworkingV2PortExists("openstack_networking_port_v2.port_1", &port),
|
||||||
testAccCheckComputeV2InstanceExists("openstack_compute_instance_v2.foo", &instance),
|
testAccCheckComputeV2InstanceExists("openstack_compute_instance_v2.instance_1", &instance),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -158,7 +94,7 @@ func testAccCheckNetworkingV2NetworkDestroy(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)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("(testAccCheckNetworkingV2NetworkDestroy) Error creating OpenStack networking client: %s", err)
|
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, rs := range s.RootModule().Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
|
@ -175,7 +111,7 @@ func testAccCheckNetworkingV2NetworkDestroy(s *terraform.State) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckNetworkingV2NetworkExists(t *testing.T, n string, network *networks.Network) resource.TestCheckFunc {
|
func testAccCheckNetworkingV2NetworkExists(n string, network *networks.Network) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
rs, ok := s.RootModule().Resources[n]
|
rs, ok := s.RootModule().Resources[n]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -189,7 +125,7 @@ func testAccCheckNetworkingV2NetworkExists(t *testing.T, n string, network *netw
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("(testAccCheckNetworkingV2NetworkExists) Error creating OpenStack networking client: %s", err)
|
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
found, err := networks.Get(networkingClient, rs.Primary.ID).Extract()
|
found, err := networks.Get(networkingClient, rs.Primary.ID).Extract()
|
||||||
|
@ -207,14 +143,85 @@ func testAccCheckNetworkingV2NetworkExists(t *testing.T, n string, network *netw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var testAccNetworkingV2Network_basic = fmt.Sprintf(`
|
const testAccNetworkingV2Network_basic = `
|
||||||
resource "openstack_networking_network_v2" "foo" {
|
resource "openstack_networking_network_v2" "network_1" {
|
||||||
name = "network_1"
|
name = "network_1"
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
}`)
|
}
|
||||||
|
`
|
||||||
|
|
||||||
var testAccNetworkingV2Network_update = fmt.Sprintf(`
|
const testAccNetworkingV2Network_update = `
|
||||||
resource "openstack_networking_network_v2" "foo" {
|
resource "openstack_networking_network_v2" "network_1" {
|
||||||
name = "network_2"
|
name = "network_2"
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
}`)
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
const testAccNetworkingV2Network_netstack = `
|
||||||
|
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.10.0/24"
|
||||||
|
ip_version = 4
|
||||||
|
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "openstack_networking_router_v2" "router_1" {
|
||||||
|
name = "router_1"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "openstack_networking_router_interface_v2" "ri_1" {
|
||||||
|
router_id = "${openstack_networking_router_v2.router_1.id}"
|
||||||
|
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
const testAccNetworkingV2Network_fullstack = `
|
||||||
|
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_compute_secgroup_v2" "secgroup_1" {
|
||||||
|
name = "secgroup_1"
|
||||||
|
description = "a security group"
|
||||||
|
rule {
|
||||||
|
from_port = 22
|
||||||
|
to_port = 22
|
||||||
|
ip_protocol = "tcp"
|
||||||
|
cidr = "0.0.0.0/0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "openstack_networking_port_v2" "port_1" {
|
||||||
|
name = "port_1"
|
||||||
|
admin_state_up = "true"
|
||||||
|
security_group_ids = ["${openstack_compute_secgroup_v2.secgroup_1.id}"]
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "openstack_compute_instance_v2" "instance_1" {
|
||||||
|
name = "instance_1"
|
||||||
|
security_groups = ["${openstack_compute_secgroup_v2.secgroup_1.name}"]
|
||||||
|
|
||||||
|
network {
|
||||||
|
port = "${openstack_networking_port_v2.port_1.id}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
|
@ -25,9 +25,9 @@ func TestAccNetworkingV2Port_basic(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2Port_basic,
|
Config: testAccNetworkingV2Port_basic,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.foo", &subnet),
|
testAccCheckNetworkingV2SubnetExists("openstack_networking_subnet_v2.subnet_1", &subnet),
|
||||||
testAccCheckNetworkingV2NetworkExists(t, "openstack_networking_network_v2.foo", &network),
|
testAccCheckNetworkingV2NetworkExists("openstack_networking_network_v2.network_1", &network),
|
||||||
testAccCheckNetworkingV2PortExists(t, "openstack_networking_port_v2.foo", &port),
|
testAccCheckNetworkingV2PortExists("openstack_networking_port_v2.port_1", &port),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -47,9 +47,9 @@ func TestAccNetworkingV2Port_noip(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2Port_noip,
|
Config: testAccNetworkingV2Port_noip,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.foo", &subnet),
|
testAccCheckNetworkingV2SubnetExists("openstack_networking_subnet_v2.subnet_1", &subnet),
|
||||||
testAccCheckNetworkingV2NetworkExists(t, "openstack_networking_network_v2.foo", &network),
|
testAccCheckNetworkingV2NetworkExists("openstack_networking_network_v2.network_1", &network),
|
||||||
testAccCheckNetworkingV2PortExists(t, "openstack_networking_port_v2.foo", &port),
|
testAccCheckNetworkingV2PortExists("openstack_networking_port_v2.port_1", &port),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -69,11 +69,11 @@ func TestAccNetworkingV2Port_allowedAddressPairs(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2Port_allowedAddressPairs,
|
Config: testAccNetworkingV2Port_allowedAddressPairs,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.vrrp_subnet", &subnet),
|
testAccCheckNetworkingV2SubnetExists("openstack_networking_subnet_v2.vrrp_subnet", &subnet),
|
||||||
testAccCheckNetworkingV2NetworkExists(t, "openstack_networking_network_v2.vrrp_network", &network),
|
testAccCheckNetworkingV2NetworkExists("openstack_networking_network_v2.vrrp_network", &network),
|
||||||
testAccCheckNetworkingV2PortExists(t, "openstack_networking_port_v2.vrrp_port_1", &vrrp_port_1),
|
testAccCheckNetworkingV2PortExists("openstack_networking_port_v2.vrrp_port_1", &vrrp_port_1),
|
||||||
testAccCheckNetworkingV2PortExists(t, "openstack_networking_port_v2.vrrp_port_2", &vrrp_port_2),
|
testAccCheckNetworkingV2PortExists("openstack_networking_port_v2.vrrp_port_2", &vrrp_port_2),
|
||||||
testAccCheckNetworkingV2PortExists(t, "openstack_networking_port_v2.instance_port", &instance_port),
|
testAccCheckNetworkingV2PortExists("openstack_networking_port_v2.instance_port", &instance_port),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -84,7 +84,7 @@ 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)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("(testAccCheckNetworkingV2PortDestroy) Error creating OpenStack networking client: %s", err)
|
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, rs := range s.RootModule().Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
|
@ -101,7 +101,7 @@ func testAccCheckNetworkingV2PortDestroy(s *terraform.State) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckNetworkingV2PortExists(t *testing.T, n string, port *ports.Port) resource.TestCheckFunc {
|
func testAccCheckNetworkingV2PortExists(n string, port *ports.Port) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
rs, ok := s.RootModule().Resources[n]
|
rs, ok := s.RootModule().Resources[n]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -115,7 +115,7 @@ func testAccCheckNetworkingV2PortExists(t *testing.T, n string, port *ports.Port
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("(testAccCheckNetworkingV2PortExists) Error creating OpenStack networking client: %s", err)
|
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
found, err := ports.Get(networkingClient, rs.Primary.ID).Extract()
|
found, err := ports.Get(networkingClient, rs.Primary.ID).Extract()
|
||||||
|
@ -133,50 +133,56 @@ func testAccCheckNetworkingV2PortExists(t *testing.T, n string, port *ports.Port
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var testAccNetworkingV2Port_basic = fmt.Sprintf(`
|
const testAccNetworkingV2Port_basic = `
|
||||||
resource "openstack_networking_network_v2" "foo" {
|
resource "openstack_networking_network_v2" "network_1" {
|
||||||
name = "network_1"
|
name = "network_1"
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_subnet_v2" "foo" {
|
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||||
name = "subnet_1"
|
name = "subnet_1"
|
||||||
network_id = "${openstack_networking_network_v2.foo.id}"
|
|
||||||
cidr = "192.168.199.0/24"
|
cidr = "192.168.199.0/24"
|
||||||
ip_version = 4
|
ip_version = 4
|
||||||
|
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_port_v2" "foo" {
|
resource "openstack_networking_port_v2" "port_1" {
|
||||||
name = "port_1"
|
name = "port_1"
|
||||||
network_id = "${openstack_networking_network_v2.foo.id}"
|
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
|
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||||
|
|
||||||
fixed_ip {
|
fixed_ip {
|
||||||
subnet_id = "${openstack_networking_subnet_v2.foo.id}"
|
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||||
ip_address = "192.168.199.23"
|
ip_address = "192.168.199.23"
|
||||||
}
|
}
|
||||||
}`)
|
}
|
||||||
|
`
|
||||||
|
|
||||||
var testAccNetworkingV2Port_noip = fmt.Sprintf(`
|
const testAccNetworkingV2Port_noip = `
|
||||||
resource "openstack_networking_network_v2" "foo" {
|
resource "openstack_networking_network_v2" "network_1" {
|
||||||
name = "network_1"
|
name = "network_1"
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
}
|
}
|
||||||
resource "openstack_networking_subnet_v2" "foo" {
|
|
||||||
|
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||||
name = "subnet_1"
|
name = "subnet_1"
|
||||||
network_id = "${openstack_networking_network_v2.foo.id}"
|
|
||||||
cidr = "192.168.199.0/24"
|
cidr = "192.168.199.0/24"
|
||||||
ip_version = 4
|
ip_version = 4
|
||||||
|
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||||
}
|
}
|
||||||
resource "openstack_networking_port_v2" "foo" {
|
|
||||||
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}"
|
|
||||||
}
|
|
||||||
}`)
|
|
||||||
|
|
||||||
var testAccNetworkingV2Port_allowedAddressPairs = fmt.Sprintf(`
|
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}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
const testAccNetworkingV2Port_allowedAddressPairs = `
|
||||||
resource "openstack_networking_network_v2" "vrrp_network" {
|
resource "openstack_networking_network_v2" "vrrp_network" {
|
||||||
name = "vrrp_network"
|
name = "vrrp_network"
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
|
@ -184,9 +190,9 @@ var testAccNetworkingV2Port_allowedAddressPairs = fmt.Sprintf(`
|
||||||
|
|
||||||
resource "openstack_networking_subnet_v2" "vrrp_subnet" {
|
resource "openstack_networking_subnet_v2" "vrrp_subnet" {
|
||||||
name = "vrrp_subnet"
|
name = "vrrp_subnet"
|
||||||
network_id = "${openstack_networking_network_v2.vrrp_network.id}"
|
|
||||||
cidr = "10.0.0.0/24"
|
cidr = "10.0.0.0/24"
|
||||||
ip_version = 4
|
ip_version = 4
|
||||||
|
network_id = "${openstack_networking_network_v2.vrrp_network.id}"
|
||||||
|
|
||||||
allocation_pools {
|
allocation_pools {
|
||||||
start = "10.0.0.2"
|
start = "10.0.0.2"
|
||||||
|
@ -205,8 +211,9 @@ var testAccNetworkingV2Port_allowedAddressPairs = fmt.Sprintf(`
|
||||||
|
|
||||||
resource "openstack_networking_port_v2" "vrrp_port_1" {
|
resource "openstack_networking_port_v2" "vrrp_port_1" {
|
||||||
name = "vrrp_port_1"
|
name = "vrrp_port_1"
|
||||||
network_id = "${openstack_networking_network_v2.vrrp_network.id}"
|
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
|
network_id = "${openstack_networking_network_v2.vrrp_network.id}"
|
||||||
|
|
||||||
fixed_ip {
|
fixed_ip {
|
||||||
subnet_id = "${openstack_networking_subnet_v2.vrrp_subnet.id}"
|
subnet_id = "${openstack_networking_subnet_v2.vrrp_subnet.id}"
|
||||||
ip_address = "10.0.0.202"
|
ip_address = "10.0.0.202"
|
||||||
|
@ -215,8 +222,9 @@ var testAccNetworkingV2Port_allowedAddressPairs = fmt.Sprintf(`
|
||||||
|
|
||||||
resource "openstack_networking_port_v2" "vrrp_port_2" {
|
resource "openstack_networking_port_v2" "vrrp_port_2" {
|
||||||
name = "vrrp_port_2"
|
name = "vrrp_port_2"
|
||||||
network_id = "${openstack_networking_network_v2.vrrp_network.id}"
|
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
|
network_id = "${openstack_networking_network_v2.vrrp_network.id}"
|
||||||
|
|
||||||
fixed_ip {
|
fixed_ip {
|
||||||
subnet_id = "${openstack_networking_subnet_v2.vrrp_subnet.id}"
|
subnet_id = "${openstack_networking_subnet_v2.vrrp_subnet.id}"
|
||||||
ip_address = "10.0.0.201"
|
ip_address = "10.0.0.201"
|
||||||
|
@ -225,8 +233,8 @@ var testAccNetworkingV2Port_allowedAddressPairs = fmt.Sprintf(`
|
||||||
|
|
||||||
resource "openstack_networking_port_v2" "instance_port" {
|
resource "openstack_networking_port_v2" "instance_port" {
|
||||||
name = "instance_port"
|
name = "instance_port"
|
||||||
network_id = "${openstack_networking_network_v2.vrrp_network.id}"
|
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
|
network_id = "${openstack_networking_network_v2.vrrp_network.id}"
|
||||||
|
|
||||||
allowed_address_pairs {
|
allowed_address_pairs {
|
||||||
ip_address = "${openstack_networking_port_v2.vrrp_port_1.fixed_ip.0.ip_address}"
|
ip_address = "${openstack_networking_port_v2.vrrp_port_1.fixed_ip.0.ip_address}"
|
||||||
|
@ -237,4 +245,5 @@ var testAccNetworkingV2Port_allowedAddressPairs = fmt.Sprintf(`
|
||||||
ip_address = "${openstack_networking_port_v2.vrrp_port_2.fixed_ip.0.ip_address}"
|
ip_address = "${openstack_networking_port_v2.vrrp_port_2.fixed_ip.0.ip_address}"
|
||||||
mac_address = "${openstack_networking_port_v2.vrrp_port_2.mac_address}"
|
mac_address = "${openstack_networking_port_v2.vrrp_port_2.mac_address}"
|
||||||
}
|
}
|
||||||
}`)
|
}
|
||||||
|
`
|
||||||
|
|
|
@ -26,10 +26,10 @@ func TestAccNetworkingV2RouterInterface_basic_subnet(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2RouterInterface_basic_subnet,
|
Config: testAccNetworkingV2RouterInterface_basic_subnet,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2NetworkExists(t, "openstack_networking_network_v2.network_1", &network),
|
testAccCheckNetworkingV2NetworkExists("openstack_networking_network_v2.network_1", &network),
|
||||||
testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.subnet_1", &subnet),
|
testAccCheckNetworkingV2SubnetExists("openstack_networking_subnet_v2.subnet_1", &subnet),
|
||||||
testAccCheckNetworkingV2RouterExists(t, "openstack_networking_router_v2.router_1", &router),
|
testAccCheckNetworkingV2RouterExists("openstack_networking_router_v2.router_1", &router),
|
||||||
testAccCheckNetworkingV2RouterInterfaceExists(t, "openstack_networking_router_interface_v2.int_1"),
|
testAccCheckNetworkingV2RouterInterfaceExists("openstack_networking_router_interface_v2.int_1"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -50,11 +50,11 @@ func TestAccNetworkingV2RouterInterface_basic_port(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2RouterInterface_basic_port,
|
Config: testAccNetworkingV2RouterInterface_basic_port,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2NetworkExists(t, "openstack_networking_network_v2.network_1", &network),
|
testAccCheckNetworkingV2NetworkExists("openstack_networking_network_v2.network_1", &network),
|
||||||
testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.subnet_1", &subnet),
|
testAccCheckNetworkingV2SubnetExists("openstack_networking_subnet_v2.subnet_1", &subnet),
|
||||||
testAccCheckNetworkingV2RouterExists(t, "openstack_networking_router_v2.router_1", &router),
|
testAccCheckNetworkingV2RouterExists("openstack_networking_router_v2.router_1", &router),
|
||||||
testAccCheckNetworkingV2PortExists(t, "openstack_networking_port_v2.port_1", &port),
|
testAccCheckNetworkingV2PortExists("openstack_networking_port_v2.port_1", &port),
|
||||||
testAccCheckNetworkingV2RouterInterfaceExists(t, "openstack_networking_router_interface_v2.int_1"),
|
testAccCheckNetworkingV2RouterInterfaceExists("openstack_networking_router_interface_v2.int_1"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -65,7 +65,7 @@ func testAccCheckNetworkingV2RouterInterfaceDestroy(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)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("(testAccCheckNetworkingV2RouterInterfaceDestroy) Error creating OpenStack networking client: %s", err)
|
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, rs := range s.RootModule().Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
|
@ -82,7 +82,7 @@ func testAccCheckNetworkingV2RouterInterfaceDestroy(s *terraform.State) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckNetworkingV2RouterInterfaceExists(t *testing.T, n string) resource.TestCheckFunc {
|
func testAccCheckNetworkingV2RouterInterfaceExists(n string) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
rs, ok := s.RootModule().Resources[n]
|
rs, ok := s.RootModule().Resources[n]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -96,7 +96,7 @@ func testAccCheckNetworkingV2RouterInterfaceExists(t *testing.T, n string) resou
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("(testAccCheckNetworkingV2RouterInterfaceExists) Error creating OpenStack networking client: %s", err)
|
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
found, err := ports.Get(networkingClient, rs.Primary.ID).Extract()
|
found, err := ports.Get(networkingClient, rs.Primary.ID).Extract()
|
||||||
|
@ -112,7 +112,7 @@ func testAccCheckNetworkingV2RouterInterfaceExists(t *testing.T, n string) resou
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var testAccNetworkingV2RouterInterface_basic_subnet = fmt.Sprintf(`
|
const testAccNetworkingV2RouterInterface_basic_subnet = `
|
||||||
resource "openstack_networking_router_v2" "router_1" {
|
resource "openstack_networking_router_v2" "router_1" {
|
||||||
name = "router_1"
|
name = "router_1"
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
|
@ -129,12 +129,13 @@ var testAccNetworkingV2RouterInterface_basic_subnet = fmt.Sprintf(`
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
|
||||||
cidr = "192.168.199.0/24"
|
cidr = "192.168.199.0/24"
|
||||||
ip_version = 4
|
ip_version = 4
|
||||||
}`)
|
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
var testAccNetworkingV2RouterInterface_basic_port = fmt.Sprintf(`
|
const testAccNetworkingV2RouterInterface_basic_port = `
|
||||||
resource "openstack_networking_router_v2" "router_1" {
|
resource "openstack_networking_router_v2" "router_1" {
|
||||||
name = "router_1"
|
name = "router_1"
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
|
@ -151,17 +152,19 @@ var testAccNetworkingV2RouterInterface_basic_port = fmt.Sprintf(`
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
|
||||||
cidr = "192.168.199.0/24"
|
cidr = "192.168.199.0/24"
|
||||||
ip_version = 4
|
ip_version = 4
|
||||||
|
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_port_v2" "port_1" {
|
resource "openstack_networking_port_v2" "port_1" {
|
||||||
name = "port_1"
|
name = "port_1"
|
||||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
|
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||||
|
|
||||||
fixed_ip {
|
fixed_ip {
|
||||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||||
ip_address = "192.168.199.1"
|
ip_address = "192.168.199.1"
|
||||||
}
|
}
|
||||||
}`)
|
}
|
||||||
|
`
|
||||||
|
|
|
@ -24,34 +24,43 @@ func TestAccNetworkingV2RouterRoute_basic(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2RouterRoute_create,
|
Config: testAccNetworkingV2RouterRoute_create,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2RouterExists(t, "openstack_networking_router_v2.router_1", &router),
|
testAccCheckNetworkingV2RouterExists("openstack_networking_router_v2.router_1", &router),
|
||||||
testAccCheckNetworkingV2NetworkExists(t, "openstack_networking_network_v2.network_1", &network[0]),
|
testAccCheckNetworkingV2NetworkExists(
|
||||||
testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.subnet_1", &subnet[0]),
|
"openstack_networking_network_v2.network_1", &network[0]),
|
||||||
testAccCheckNetworkingV2NetworkExists(t, "openstack_networking_network_v2.network_1", &network[1]),
|
testAccCheckNetworkingV2SubnetExists(
|
||||||
testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.subnet_1", &subnet[1]),
|
"openstack_networking_subnet_v2.subnet_1", &subnet[0]),
|
||||||
testAccCheckNetworkingV2RouterInterfaceExists(t, "openstack_networking_router_interface_v2.int_1"),
|
testAccCheckNetworkingV2NetworkExists(
|
||||||
testAccCheckNetworkingV2RouterInterfaceExists(t, "openstack_networking_router_interface_v2.int_2"),
|
"openstack_networking_network_v2.network_1", &network[1]),
|
||||||
testAccCheckNetworkingV2RouterRouteExists(t, "openstack_networking_router_route_v2.router_route_1"),
|
testAccCheckNetworkingV2SubnetExists(
|
||||||
|
"openstack_networking_subnet_v2.subnet_1", &subnet[1]),
|
||||||
|
testAccCheckNetworkingV2RouterInterfaceExists(
|
||||||
|
"openstack_networking_router_interface_v2.int_1"),
|
||||||
|
testAccCheckNetworkingV2RouterInterfaceExists(
|
||||||
|
"openstack_networking_router_interface_v2.int_2"),
|
||||||
|
testAccCheckNetworkingV2RouterRouteExists(
|
||||||
|
"openstack_networking_router_route_v2.router_route_1"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2RouterRoute_update,
|
Config: testAccNetworkingV2RouterRoute_update,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2RouterRouteExists(t, "openstack_networking_router_route_v2.router_route_1"),
|
testAccCheckNetworkingV2RouterRouteExists(
|
||||||
testAccCheckNetworkingV2RouterRouteExists(t, "openstack_networking_router_route_v2.router_route_2"),
|
"openstack_networking_router_route_v2.router_route_1"),
|
||||||
|
testAccCheckNetworkingV2RouterRouteExists(
|
||||||
|
"openstack_networking_router_route_v2.router_route_2"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2RouterRoute_destroy,
|
Config: testAccNetworkingV2RouterRoute_destroy,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2RouterRouteEmpty(t, "openstack_networking_router_v2.router_1"),
|
testAccCheckNetworkingV2RouterRouteEmpty("openstack_networking_router_v2.router_1"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckNetworkingV2RouterRouteEmpty(t *testing.T, n string) resource.TestCheckFunc {
|
func testAccCheckNetworkingV2RouterRouteEmpty(n string) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
rs, ok := s.RootModule().Resources[n]
|
rs, ok := s.RootModule().Resources[n]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -65,7 +74,7 @@ func testAccCheckNetworkingV2RouterRouteEmpty(t *testing.T, n string) resource.T
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("(testAccCheckNetworkingV2RouterRouteExists) Error creating OpenStack networking client: %s", err)
|
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
router, err := routers.Get(networkingClient, rs.Primary.ID).Extract()
|
router, err := routers.Get(networkingClient, rs.Primary.ID).Extract()
|
||||||
|
@ -85,7 +94,7 @@ func testAccCheckNetworkingV2RouterRouteEmpty(t *testing.T, n string) resource.T
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckNetworkingV2RouterRouteExists(t *testing.T, n string) resource.TestCheckFunc {
|
func testAccCheckNetworkingV2RouterRouteExists(n string) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
rs, ok := s.RootModule().Resources[n]
|
rs, ok := s.RootModule().Resources[n]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -99,7 +108,7 @@ func testAccCheckNetworkingV2RouterRouteExists(t *testing.T, n string) resource.
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("(testAccCheckNetworkingV2RouterRouteExists) Error creating OpenStack networking client: %s", err)
|
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
router, err := routers.Get(networkingClient, rs.Primary.Attributes["router_id"]).Extract()
|
router, err := routers.Get(networkingClient, rs.Primary.Attributes["router_id"]).Extract()
|
||||||
|
@ -125,7 +134,7 @@ func testAccCheckNetworkingV2RouterRouteExists(t *testing.T, n string) resource.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var testAccNetworkingV2RouterRoute_create = fmt.Sprintf(`
|
const testAccNetworkingV2RouterRoute_create = `
|
||||||
resource "openstack_networking_router_v2" "router_1" {
|
resource "openstack_networking_router_v2" "router_1" {
|
||||||
name = "router_1"
|
name = "router_1"
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
|
@ -137,15 +146,16 @@ var testAccNetworkingV2RouterRoute_create = fmt.Sprintf(`
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
|
||||||
cidr = "192.168.199.0/24"
|
cidr = "192.168.199.0/24"
|
||||||
ip_version = 4
|
ip_version = 4
|
||||||
|
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_port_v2" "port_1" {
|
resource "openstack_networking_port_v2" "port_1" {
|
||||||
name = "port_1"
|
name = "port_1"
|
||||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
|
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||||
|
|
||||||
fixed_ip {
|
fixed_ip {
|
||||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||||
ip_address = "192.168.199.1"
|
ip_address = "192.168.199.1"
|
||||||
|
@ -163,15 +173,16 @@ var testAccNetworkingV2RouterRoute_create = fmt.Sprintf(`
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_subnet_v2" "subnet_2" {
|
resource "openstack_networking_subnet_v2" "subnet_2" {
|
||||||
network_id = "${openstack_networking_network_v2.network_2.id}"
|
|
||||||
cidr = "192.168.200.0/24"
|
cidr = "192.168.200.0/24"
|
||||||
ip_version = 4
|
ip_version = 4
|
||||||
|
network_id = "${openstack_networking_network_v2.network_2.id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_port_v2" "port_2" {
|
resource "openstack_networking_port_v2" "port_2" {
|
||||||
name = "port_2"
|
name = "port_2"
|
||||||
network_id = "${openstack_networking_network_v2.network_2.id}"
|
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
|
network_id = "${openstack_networking_network_v2.network_2.id}"
|
||||||
|
|
||||||
fixed_ip {
|
fixed_ip {
|
||||||
subnet_id = "${openstack_networking_subnet_v2.subnet_2.id}"
|
subnet_id = "${openstack_networking_subnet_v2.subnet_2.id}"
|
||||||
ip_address = "192.168.200.1"
|
ip_address = "192.168.200.1"
|
||||||
|
@ -184,14 +195,15 @@ var testAccNetworkingV2RouterRoute_create = fmt.Sprintf(`
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_router_route_v2" "router_route_1" {
|
resource "openstack_networking_router_route_v2" "router_route_1" {
|
||||||
depends_on = ["openstack_networking_router_interface_v2.int_1"]
|
|
||||||
router_id = "${openstack_networking_router_v2.router_1.id}"
|
|
||||||
|
|
||||||
destination_cidr = "10.0.1.0/24"
|
destination_cidr = "10.0.1.0/24"
|
||||||
next_hop = "192.168.199.254"
|
next_hop = "192.168.199.254"
|
||||||
}`)
|
|
||||||
|
|
||||||
var testAccNetworkingV2RouterRoute_update = fmt.Sprintf(`
|
depends_on = ["openstack_networking_router_interface_v2.int_1"]
|
||||||
|
router_id = "${openstack_networking_router_v2.router_1.id}"
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
const testAccNetworkingV2RouterRoute_update = `
|
||||||
resource "openstack_networking_router_v2" "router_1" {
|
resource "openstack_networking_router_v2" "router_1" {
|
||||||
name = "router_1"
|
name = "router_1"
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
|
@ -203,15 +215,16 @@ var testAccNetworkingV2RouterRoute_update = fmt.Sprintf(`
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
|
||||||
cidr = "192.168.199.0/24"
|
cidr = "192.168.199.0/24"
|
||||||
ip_version = 4
|
ip_version = 4
|
||||||
|
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_port_v2" "port_1" {
|
resource "openstack_networking_port_v2" "port_1" {
|
||||||
name = "port_1"
|
name = "port_1"
|
||||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
|
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||||
|
|
||||||
fixed_ip {
|
fixed_ip {
|
||||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||||
ip_address = "192.168.199.1"
|
ip_address = "192.168.199.1"
|
||||||
|
@ -229,15 +242,16 @@ var testAccNetworkingV2RouterRoute_update = fmt.Sprintf(`
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_subnet_v2" "subnet_2" {
|
resource "openstack_networking_subnet_v2" "subnet_2" {
|
||||||
network_id = "${openstack_networking_network_v2.network_2.id}"
|
|
||||||
cidr = "192.168.200.0/24"
|
cidr = "192.168.200.0/24"
|
||||||
ip_version = 4
|
ip_version = 4
|
||||||
|
network_id = "${openstack_networking_network_v2.network_2.id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_port_v2" "port_2" {
|
resource "openstack_networking_port_v2" "port_2" {
|
||||||
name = "port_2"
|
name = "port_2"
|
||||||
network_id = "${openstack_networking_network_v2.network_2.id}"
|
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
|
network_id = "${openstack_networking_network_v2.network_2.id}"
|
||||||
|
|
||||||
fixed_ip {
|
fixed_ip {
|
||||||
subnet_id = "${openstack_networking_subnet_v2.subnet_2.id}"
|
subnet_id = "${openstack_networking_subnet_v2.subnet_2.id}"
|
||||||
ip_address = "192.168.200.1"
|
ip_address = "192.168.200.1"
|
||||||
|
@ -250,22 +264,23 @@ var testAccNetworkingV2RouterRoute_update = fmt.Sprintf(`
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_router_route_v2" "router_route_1" {
|
resource "openstack_networking_router_route_v2" "router_route_1" {
|
||||||
depends_on = ["openstack_networking_router_interface_v2.int_1"]
|
|
||||||
router_id = "${openstack_networking_router_v2.router_1.id}"
|
|
||||||
|
|
||||||
destination_cidr = "10.0.1.0/24"
|
destination_cidr = "10.0.1.0/24"
|
||||||
next_hop = "192.168.199.254"
|
next_hop = "192.168.199.254"
|
||||||
|
|
||||||
|
depends_on = ["openstack_networking_router_interface_v2.int_1"]
|
||||||
|
router_id = "${openstack_networking_router_v2.router_1.id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_router_route_v2" "router_route_2" {
|
resource "openstack_networking_router_route_v2" "router_route_2" {
|
||||||
depends_on = ["openstack_networking_router_interface_v2.int_2"]
|
|
||||||
router_id = "${openstack_networking_router_v2.router_1.id}"
|
|
||||||
|
|
||||||
destination_cidr = "10.0.2.0/24"
|
destination_cidr = "10.0.2.0/24"
|
||||||
next_hop = "192.168.200.254"
|
next_hop = "192.168.200.254"
|
||||||
}`)
|
|
||||||
|
|
||||||
var testAccNetworkingV2RouterRoute_destroy = fmt.Sprintf(`
|
depends_on = ["openstack_networking_router_interface_v2.int_2"]
|
||||||
|
router_id = "${openstack_networking_router_v2.router_1.id}"
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
const testAccNetworkingV2RouterRoute_destroy = `
|
||||||
resource "openstack_networking_router_v2" "router_1" {
|
resource "openstack_networking_router_v2" "router_1" {
|
||||||
name = "router_1"
|
name = "router_1"
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
|
@ -277,15 +292,16 @@ var testAccNetworkingV2RouterRoute_destroy = fmt.Sprintf(`
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
|
||||||
cidr = "192.168.199.0/24"
|
cidr = "192.168.199.0/24"
|
||||||
ip_version = 4
|
ip_version = 4
|
||||||
|
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_port_v2" "port_1" {
|
resource "openstack_networking_port_v2" "port_1" {
|
||||||
name = "port_1"
|
name = "port_1"
|
||||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
|
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||||
|
|
||||||
fixed_ip {
|
fixed_ip {
|
||||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||||
ip_address = "192.168.199.1"
|
ip_address = "192.168.199.1"
|
||||||
|
@ -303,15 +319,16 @@ var testAccNetworkingV2RouterRoute_destroy = fmt.Sprintf(`
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_subnet_v2" "subnet_2" {
|
resource "openstack_networking_subnet_v2" "subnet_2" {
|
||||||
network_id = "${openstack_networking_network_v2.network_2.id}"
|
|
||||||
cidr = "192.168.200.0/24"
|
|
||||||
ip_version = 4
|
ip_version = 4
|
||||||
|
cidr = "192.168.200.0/24"
|
||||||
|
network_id = "${openstack_networking_network_v2.network_2.id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_port_v2" "port_2" {
|
resource "openstack_networking_port_v2" "port_2" {
|
||||||
name = "port_2"
|
name = "port_2"
|
||||||
network_id = "${openstack_networking_network_v2.network_2.id}"
|
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
|
network_id = "${openstack_networking_network_v2.network_2.id}"
|
||||||
|
|
||||||
fixed_ip {
|
fixed_ip {
|
||||||
subnet_id = "${openstack_networking_subnet_v2.subnet_2.id}"
|
subnet_id = "${openstack_networking_subnet_v2.subnet_2.id}"
|
||||||
ip_address = "192.168.200.1"
|
ip_address = "192.168.200.1"
|
||||||
|
@ -321,4 +338,5 @@ var testAccNetworkingV2RouterRoute_destroy = fmt.Sprintf(`
|
||||||
resource "openstack_networking_router_interface_v2" "int_2" {
|
resource "openstack_networking_router_interface_v2" "int_2" {
|
||||||
router_id = "${openstack_networking_router_v2.router_1.id}"
|
router_id = "${openstack_networking_router_v2.router_1.id}"
|
||||||
port_id = "${openstack_networking_port_v2.port_2.id}"
|
port_id = "${openstack_networking_port_v2.port_2.id}"
|
||||||
}`)
|
}
|
||||||
|
`
|
||||||
|
|
|
@ -2,7 +2,6 @@ package openstack
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
|
@ -22,13 +21,14 @@ func TestAccNetworkingV2Router_basic(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2Router_basic,
|
Config: testAccNetworkingV2Router_basic,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2RouterExists(t, "openstack_networking_router_v2.foo", &router),
|
testAccCheckNetworkingV2RouterExists("openstack_networking_router_v2.router_1", &router),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2Router_update,
|
Config: testAccNetworkingV2Router_update,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
resource.TestCheckResourceAttr("openstack_networking_router_v2.foo", "name", "router_2"),
|
resource.TestCheckResourceAttr(
|
||||||
|
"openstack_networking_router_v2.router_1", "name", "router_2"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -37,22 +37,6 @@ func TestAccNetworkingV2Router_basic(t *testing.T) {
|
||||||
|
|
||||||
func TestAccNetworkingV2Router_update_external_gw(t *testing.T) {
|
func TestAccNetworkingV2Router_update_external_gw(t *testing.T) {
|
||||||
var router routers.Router
|
var router routers.Router
|
||||||
externalGateway := os.Getenv("OS_EXTGW_ID")
|
|
||||||
|
|
||||||
var testAccNetworkingV2Router_update_external_gw_1 = fmt.Sprintf(`
|
|
||||||
resource "openstack_networking_router_v2" "foo" {
|
|
||||||
name = "router"
|
|
||||||
admin_state_up = "true"
|
|
||||||
distributed = "false"
|
|
||||||
}`)
|
|
||||||
|
|
||||||
var testAccNetworkingV2Router_update_external_gw_2 = fmt.Sprintf(`
|
|
||||||
resource "openstack_networking_router_v2" "foo" {
|
|
||||||
name = "router"
|
|
||||||
admin_state_up = "true"
|
|
||||||
distributed = "false"
|
|
||||||
external_gateway = "%s"
|
|
||||||
}`, externalGateway)
|
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
@ -62,13 +46,14 @@ func TestAccNetworkingV2Router_update_external_gw(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2Router_update_external_gw_1,
|
Config: testAccNetworkingV2Router_update_external_gw_1,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2RouterExists(t, "openstack_networking_router_v2.foo", &router),
|
testAccCheckNetworkingV2RouterExists("openstack_networking_router_v2.router_1", &router),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2Router_update_external_gw_2,
|
Config: testAccNetworkingV2Router_update_external_gw_2,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
resource.TestCheckResourceAttr("openstack_networking_router_v2.foo", "external_gateway", externalGateway),
|
resource.TestCheckResourceAttr(
|
||||||
|
"openstack_networking_router_v2.router_1", "external_gateway", OS_EXTGW_ID),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -79,7 +64,7 @@ func testAccCheckNetworkingV2RouterDestroy(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)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("(testAccCheckNetworkingV2RouterDestroy) Error creating OpenStack networking client: %s", err)
|
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, rs := range s.RootModule().Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
|
@ -96,7 +81,7 @@ func testAccCheckNetworkingV2RouterDestroy(s *terraform.State) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckNetworkingV2RouterExists(t *testing.T, n string, router *routers.Router) resource.TestCheckFunc {
|
func testAccCheckNetworkingV2RouterExists(n string, router *routers.Router) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
rs, ok := s.RootModule().Resources[n]
|
rs, ok := s.RootModule().Resources[n]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -110,7 +95,7 @@ func testAccCheckNetworkingV2RouterExists(t *testing.T, n string, router *router
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("(testAccCheckNetworkingV2RouterExists) Error creating OpenStack networking client: %s", err)
|
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
found, err := routers.Get(networkingClient, rs.Primary.ID).Extract()
|
found, err := routers.Get(networkingClient, rs.Primary.ID).Extract()
|
||||||
|
@ -128,16 +113,35 @@ func testAccCheckNetworkingV2RouterExists(t *testing.T, n string, router *router
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var testAccNetworkingV2Router_basic = fmt.Sprintf(`
|
const testAccNetworkingV2Router_basic = `
|
||||||
resource "openstack_networking_router_v2" "foo" {
|
resource "openstack_networking_router_v2" "router_1" {
|
||||||
name = "router"
|
name = "router_1"
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
distributed = "false"
|
distributed = "false"
|
||||||
}`)
|
}
|
||||||
|
`
|
||||||
|
|
||||||
var testAccNetworkingV2Router_update = fmt.Sprintf(`
|
const testAccNetworkingV2Router_update = `
|
||||||
resource "openstack_networking_router_v2" "foo" {
|
resource "openstack_networking_router_v2" "router_1" {
|
||||||
name = "router_2"
|
name = "router_2"
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
distributed = "false"
|
distributed = "false"
|
||||||
}`)
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
const testAccNetworkingV2Router_update_external_gw_1 = `
|
||||||
|
resource "openstack_networking_router_v2" "router_1" {
|
||||||
|
name = "router"
|
||||||
|
admin_state_up = "true"
|
||||||
|
distributed = "false"
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
var testAccNetworkingV2Router_update_external_gw_2 = fmt.Sprintf(`
|
||||||
|
resource "openstack_networking_router_v2" "router_1" {
|
||||||
|
name = "router"
|
||||||
|
admin_state_up = "true"
|
||||||
|
distributed = "false"
|
||||||
|
external_gateway = "%s"
|
||||||
|
}
|
||||||
|
`, OS_EXTGW_ID)
|
||||||
|
|
|
@ -12,10 +12,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAccNetworkingV2SecGroupRule_basic(t *testing.T) {
|
func TestAccNetworkingV2SecGroupRule_basic(t *testing.T) {
|
||||||
var security_group_1 groups.SecGroup
|
var secgroup_1 groups.SecGroup
|
||||||
var security_group_2 groups.SecGroup
|
var secgroup_2 groups.SecGroup
|
||||||
var security_group_rule_1 rules.SecGroupRule
|
var secgroup_rule_1 rules.SecGroupRule
|
||||||
var security_group_rule_2 rules.SecGroupRule
|
var secgroup_rule_2 rules.SecGroupRule
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
@ -25,10 +25,14 @@ func TestAccNetworkingV2SecGroupRule_basic(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2SecGroupRule_basic,
|
Config: testAccNetworkingV2SecGroupRule_basic,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2SecGroupExists(t, "openstack_networking_secgroup_v2.sg_foo", &security_group_1),
|
testAccCheckNetworkingV2SecGroupExists(
|
||||||
testAccCheckNetworkingV2SecGroupExists(t, "openstack_networking_secgroup_v2.sg_bar", &security_group_2),
|
"openstack_networking_secgroup_v2.secgroup_1", &secgroup_1),
|
||||||
testAccCheckNetworkingV2SecGroupRuleExists(t, "openstack_networking_secgroup_rule_v2.sr_foo", &security_group_rule_1),
|
testAccCheckNetworkingV2SecGroupExists(
|
||||||
testAccCheckNetworkingV2SecGroupRuleExists(t, "openstack_networking_secgroup_rule_v2.sr_bar", &security_group_rule_2),
|
"openstack_networking_secgroup_v2.secgroup_2", &secgroup_2),
|
||||||
|
testAccCheckNetworkingV2SecGroupRuleExists(
|
||||||
|
"openstack_networking_secgroup_rule_v2.secgroup_rule_1", &secgroup_rule_1),
|
||||||
|
testAccCheckNetworkingV2SecGroupRuleExists(
|
||||||
|
"openstack_networking_secgroup_rule_v2.secgroup_rule_2", &secgroup_rule_2),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -36,8 +40,8 @@ func TestAccNetworkingV2SecGroupRule_basic(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccNetworkingV2SecGroupRule_lowerCaseCIDR(t *testing.T) {
|
func TestAccNetworkingV2SecGroupRule_lowerCaseCIDR(t *testing.T) {
|
||||||
var security_group_1 groups.SecGroup
|
var secgroup_1 groups.SecGroup
|
||||||
var security_group_rule_1 rules.SecGroupRule
|
var secgroup_rule_1 rules.SecGroupRule
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
@ -47,10 +51,12 @@ func TestAccNetworkingV2SecGroupRule_lowerCaseCIDR(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2SecGroupRule_lowerCaseCIDR,
|
Config: testAccNetworkingV2SecGroupRule_lowerCaseCIDR,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2SecGroupExists(t, "openstack_networking_secgroup_v2.sg_foo", &security_group_1),
|
testAccCheckNetworkingV2SecGroupExists(
|
||||||
testAccCheckNetworkingV2SecGroupRuleExists(t, "openstack_networking_secgroup_rule_v2.sr_foo", &security_group_rule_1),
|
"openstack_networking_secgroup_v2.secgroup_1", &secgroup_1),
|
||||||
|
testAccCheckNetworkingV2SecGroupRuleExists(
|
||||||
|
"openstack_networking_secgroup_rule_v2.secgroup_rule_1", &secgroup_rule_1),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"openstack_networking_secgroup_rule_v2.sr_foo", "remote_ip_prefix", "2001:558:fc00::/39"),
|
"openstack_networking_secgroup_rule_v2.secgroup_rule_1", "remote_ip_prefix", "2001:558:fc00::/39"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -61,7 +67,7 @@ func testAccCheckNetworkingV2SecGroupRuleDestroy(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)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("(testAccCheckNetworkingV2SecGroupRuleDestroy) Error creating OpenStack networking client: %s", err)
|
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, rs := range s.RootModule().Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
|
@ -78,7 +84,7 @@ func testAccCheckNetworkingV2SecGroupRuleDestroy(s *terraform.State) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckNetworkingV2SecGroupRuleExists(t *testing.T, n string, security_group_rule *rules.SecGroupRule) resource.TestCheckFunc {
|
func testAccCheckNetworkingV2SecGroupRuleExists(n string, security_group_rule *rules.SecGroupRule) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
rs, ok := s.RootModule().Resources[n]
|
rs, ok := s.RootModule().Resources[n]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -92,7 +98,7 @@ func testAccCheckNetworkingV2SecGroupRuleExists(t *testing.T, n string, security
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("(testAccCheckNetworkingV2SecGroupRuleExists) Error creating OpenStack networking client: %s", err)
|
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
found, err := rules.Get(networkingClient, rs.Primary.ID).Extract()
|
found, err := rules.Get(networkingClient, rs.Primary.ID).Extract()
|
||||||
|
@ -110,45 +116,51 @@ func testAccCheckNetworkingV2SecGroupRuleExists(t *testing.T, n string, security
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var testAccNetworkingV2SecGroupRule_basic = fmt.Sprintf(`
|
const testAccNetworkingV2SecGroupRule_basic = `
|
||||||
resource "openstack_networking_secgroup_v2" "sg_foo" {
|
resource "openstack_networking_secgroup_v2" "secgroup_1" {
|
||||||
name = "security_group_1"
|
name = "secgroup_1"
|
||||||
description = "terraform security group rule acceptance test"
|
description = "terraform security group rule acceptance test"
|
||||||
}
|
}
|
||||||
resource "openstack_networking_secgroup_v2" "sg_bar" {
|
|
||||||
name = "security_group_2"
|
resource "openstack_networking_secgroup_v2" "secgroup_2" {
|
||||||
|
name = "secgroup_2"
|
||||||
description = "terraform security group rule acceptance test"
|
description = "terraform security group rule acceptance test"
|
||||||
}
|
}
|
||||||
resource "openstack_networking_secgroup_rule_v2" "sr_foo" {
|
|
||||||
|
resource "openstack_networking_secgroup_rule_v2" "secgroup_rule_1" {
|
||||||
direction = "ingress"
|
direction = "ingress"
|
||||||
ethertype = "IPv4"
|
ethertype = "IPv4"
|
||||||
port_range_max = 22
|
port_range_max = 22
|
||||||
port_range_min = 22
|
port_range_min = 22
|
||||||
protocol = "tcp"
|
protocol = "tcp"
|
||||||
remote_ip_prefix = "0.0.0.0/0"
|
remote_ip_prefix = "0.0.0.0/0"
|
||||||
security_group_id = "${openstack_networking_secgroup_v2.sg_foo.id}"
|
security_group_id = "${openstack_networking_secgroup_v2.secgroup_1.id}"
|
||||||
}
|
}
|
||||||
resource "openstack_networking_secgroup_rule_v2" "sr_bar" {
|
|
||||||
|
resource "openstack_networking_secgroup_rule_v2" "secgroup_rule_2" {
|
||||||
direction = "ingress"
|
direction = "ingress"
|
||||||
ethertype = "IPv4"
|
ethertype = "IPv4"
|
||||||
port_range_max = 80
|
port_range_max = 80
|
||||||
port_range_min = 80
|
port_range_min = 80
|
||||||
protocol = "tcp"
|
protocol = "tcp"
|
||||||
remote_group_id = "${openstack_networking_secgroup_v2.sg_foo.id}"
|
remote_group_id = "${openstack_networking_secgroup_v2.secgroup_1.id}"
|
||||||
security_group_id = "${openstack_networking_secgroup_v2.sg_bar.id}"
|
security_group_id = "${openstack_networking_secgroup_v2.secgroup_2.id}"
|
||||||
}`)
|
}
|
||||||
|
`
|
||||||
|
|
||||||
var testAccNetworkingV2SecGroupRule_lowerCaseCIDR = fmt.Sprintf(`
|
const testAccNetworkingV2SecGroupRule_lowerCaseCIDR = `
|
||||||
resource "openstack_networking_secgroup_v2" "sg_foo" {
|
resource "openstack_networking_secgroup_v2" "secgroup_1" {
|
||||||
name = "security_group_1"
|
name = "secgroup_1"
|
||||||
description = "terraform security group rule acceptance test"
|
description = "terraform security group rule acceptance test"
|
||||||
}
|
}
|
||||||
resource "openstack_networking_secgroup_rule_v2" "sr_foo" {
|
|
||||||
|
resource "openstack_networking_secgroup_rule_v2" "secgroup_rule_1" {
|
||||||
direction = "ingress"
|
direction = "ingress"
|
||||||
ethertype = "IPv6"
|
ethertype = "IPv6"
|
||||||
port_range_max = 22
|
port_range_max = 22
|
||||||
port_range_min = 22
|
port_range_min = 22
|
||||||
protocol = "tcp"
|
protocol = "tcp"
|
||||||
remote_ip_prefix = "2001:558:FC00::/39"
|
remote_ip_prefix = "2001:558:FC00::/39"
|
||||||
security_group_id = "${openstack_networking_secgroup_v2.sg_foo.id}"
|
security_group_id = "${openstack_networking_secgroup_v2.secgroup_1.id}"
|
||||||
}`)
|
}
|
||||||
|
`
|
||||||
|
|
|
@ -21,13 +21,15 @@ func TestAccNetworkingV2SecGroup_basic(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2SecGroup_basic,
|
Config: testAccNetworkingV2SecGroup_basic,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2SecGroupExists(t, "openstack_networking_secgroup_v2.foo", &security_group),
|
testAccCheckNetworkingV2SecGroupExists(
|
||||||
|
"openstack_networking_secgroup_v2.secgroup_1", &security_group),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2SecGroup_update,
|
Config: testAccNetworkingV2SecGroup_update,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
resource.TestCheckResourceAttr("openstack_networking_secgroup_v2.foo", "name", "security_group_2"),
|
resource.TestCheckResourceAttr(
|
||||||
|
"openstack_networking_secgroup_v2.secgroup_1", "name", "security_group_2"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -38,7 +40,7 @@ func testAccCheckNetworkingV2SecGroupDestroy(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)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("(testAccCheckNetworkingV2SecGroupDestroy) Error creating OpenStack networking client: %s", err)
|
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, rs := range s.RootModule().Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
|
@ -55,7 +57,7 @@ func testAccCheckNetworkingV2SecGroupDestroy(s *terraform.State) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckNetworkingV2SecGroupExists(t *testing.T, n string, security_group *groups.SecGroup) resource.TestCheckFunc {
|
func testAccCheckNetworkingV2SecGroupExists(n string, security_group *groups.SecGroup) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
rs, ok := s.RootModule().Resources[n]
|
rs, ok := s.RootModule().Resources[n]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -69,7 +71,7 @@ func testAccCheckNetworkingV2SecGroupExists(t *testing.T, n string, security_gro
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("(testAccCheckNetworkingV2SecGroupExists) Error creating OpenStack networking client: %s", err)
|
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
found, err := groups.Get(networkingClient, rs.Primary.ID).Extract()
|
found, err := groups.Get(networkingClient, rs.Primary.ID).Extract()
|
||||||
|
@ -87,14 +89,16 @@ func testAccCheckNetworkingV2SecGroupExists(t *testing.T, n string, security_gro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var testAccNetworkingV2SecGroup_basic = fmt.Sprintf(`
|
const testAccNetworkingV2SecGroup_basic = `
|
||||||
resource "openstack_networking_secgroup_v2" "foo" {
|
resource "openstack_networking_secgroup_v2" "secgroup_1" {
|
||||||
name = "security_group"
|
name = "security_group"
|
||||||
description = "terraform security group acceptance test"
|
description = "terraform security group acceptance test"
|
||||||
}`)
|
}
|
||||||
|
`
|
||||||
|
|
||||||
var testAccNetworkingV2SecGroup_update = fmt.Sprintf(`
|
const testAccNetworkingV2SecGroup_update = `
|
||||||
resource "openstack_networking_secgroup_v2" "foo" {
|
resource "openstack_networking_secgroup_v2" "secgroup_1" {
|
||||||
name = "security_group_2"
|
name = "security_group_2"
|
||||||
description = "terraform security group acceptance test"
|
description = "terraform security group acceptance test"
|
||||||
}`)
|
}
|
||||||
|
`
|
||||||
|
|
|
@ -21,15 +21,18 @@ func TestAccNetworkingV2Subnet_basic(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2Subnet_basic,
|
Config: testAccNetworkingV2Subnet_basic,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.subnet_1", &subnet),
|
testAccCheckNetworkingV2SubnetExists("openstack_networking_subnet_v2.subnet_1", &subnet),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2Subnet_update,
|
Config: testAccNetworkingV2Subnet_update,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
resource.TestCheckResourceAttr("openstack_networking_subnet_v2.subnet_1", "name", "subnet_1"),
|
resource.TestCheckResourceAttr(
|
||||||
resource.TestCheckResourceAttr("openstack_networking_subnet_v2.subnet_1", "gateway_ip", "192.168.199.1"),
|
"openstack_networking_subnet_v2.subnet_1", "name", "subnet_1"),
|
||||||
resource.TestCheckResourceAttr("openstack_networking_subnet_v2.subnet_1", "enable_dhcp", "true"),
|
resource.TestCheckResourceAttr(
|
||||||
|
"openstack_networking_subnet_v2.subnet_1", "gateway_ip", "192.168.199.1"),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"openstack_networking_subnet_v2.subnet_1", "enable_dhcp", "true"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -47,8 +50,9 @@ func TestAccNetworkingV2Subnet_enableDHCP(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2Subnet_enableDHCP,
|
Config: testAccNetworkingV2Subnet_enableDHCP,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.subnet_1", &subnet),
|
testAccCheckNetworkingV2SubnetExists("openstack_networking_subnet_v2.subnet_1", &subnet),
|
||||||
resource.TestCheckResourceAttr("openstack_networking_subnet_v2.subnet_1", "enable_dhcp", "true"),
|
resource.TestCheckResourceAttr(
|
||||||
|
"openstack_networking_subnet_v2.subnet_1", "enable_dhcp", "true"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -66,8 +70,9 @@ func TestAccNetworkingV2Subnet_disableDHCP(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2Subnet_disableDHCP,
|
Config: testAccNetworkingV2Subnet_disableDHCP,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.subnet_1", &subnet),
|
testAccCheckNetworkingV2SubnetExists("openstack_networking_subnet_v2.subnet_1", &subnet),
|
||||||
resource.TestCheckResourceAttr("openstack_networking_subnet_v2.subnet_1", "enable_dhcp", "false"),
|
resource.TestCheckResourceAttr(
|
||||||
|
"openstack_networking_subnet_v2.subnet_1", "enable_dhcp", "false"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -85,8 +90,9 @@ func TestAccNetworkingV2Subnet_noGateway(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2Subnet_noGateway,
|
Config: testAccNetworkingV2Subnet_noGateway,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.subnet_1", &subnet),
|
testAccCheckNetworkingV2SubnetExists("openstack_networking_subnet_v2.subnet_1", &subnet),
|
||||||
resource.TestCheckResourceAttr("openstack_networking_subnet_v2.subnet_1", "gateway_ip", ""),
|
resource.TestCheckResourceAttr(
|
||||||
|
"openstack_networking_subnet_v2.subnet_1", "gateway_ip", ""),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -104,8 +110,9 @@ func TestAccNetworkingV2Subnet_impliedGateway(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccNetworkingV2Subnet_impliedGateway,
|
Config: testAccNetworkingV2Subnet_impliedGateway,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.subnet_1", &subnet),
|
testAccCheckNetworkingV2SubnetExists("openstack_networking_subnet_v2.subnet_1", &subnet),
|
||||||
resource.TestCheckResourceAttr("openstack_networking_subnet_v2.subnet_1", "gateway_ip", "192.168.199.1"),
|
resource.TestCheckResourceAttr(
|
||||||
|
"openstack_networking_subnet_v2.subnet_1", "gateway_ip", "192.168.199.1"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -116,7 +123,7 @@ func testAccCheckNetworkingV2SubnetDestroy(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)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("(testAccCheckNetworkingV2SubnetDestroy) Error creating OpenStack networking client: %s", err)
|
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, rs := range s.RootModule().Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
|
@ -133,7 +140,7 @@ func testAccCheckNetworkingV2SubnetDestroy(s *terraform.State) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckNetworkingV2SubnetExists(t *testing.T, n string, subnet *subnets.Subnet) resource.TestCheckFunc {
|
func testAccCheckNetworkingV2SubnetExists(n string, subnet *subnets.Subnet) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
rs, ok := s.RootModule().Resources[n]
|
rs, ok := s.RootModule().Resources[n]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -147,7 +154,7 @@ func testAccCheckNetworkingV2SubnetExists(t *testing.T, n string, subnet *subnet
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("(testAccCheckNetworkingV2SubnetExists) Error creating OpenStack networking client: %s", err)
|
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
found, err := subnets.Get(networkingClient, rs.Primary.ID).Extract()
|
found, err := subnets.Get(networkingClient, rs.Primary.ID).Extract()
|
||||||
|
@ -165,22 +172,24 @@ func testAccCheckNetworkingV2SubnetExists(t *testing.T, n string, subnet *subnet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var testAccNetworkingV2Subnet_basic = fmt.Sprintf(`
|
const testAccNetworkingV2Subnet_basic = `
|
||||||
resource "openstack_networking_network_v2" "network_1" {
|
resource "openstack_networking_network_v2" "network_1" {
|
||||||
name = "network_1"
|
name = "network_1"
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
|
||||||
cidr = "192.168.199.0/24"
|
cidr = "192.168.199.0/24"
|
||||||
|
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||||
|
|
||||||
allocation_pools {
|
allocation_pools {
|
||||||
start = "192.168.199.100"
|
start = "192.168.199.100"
|
||||||
end = "192.168.199.200"
|
end = "192.168.199.200"
|
||||||
}
|
}
|
||||||
}`)
|
}
|
||||||
|
`
|
||||||
|
|
||||||
var testAccNetworkingV2Subnet_update = fmt.Sprintf(`
|
const testAccNetworkingV2Subnet_update = `
|
||||||
resource "openstack_networking_network_v2" "network_1" {
|
resource "openstack_networking_network_v2" "network_1" {
|
||||||
name = "network_1"
|
name = "network_1"
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
|
@ -188,61 +197,68 @@ var testAccNetworkingV2Subnet_update = fmt.Sprintf(`
|
||||||
|
|
||||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||||
name = "subnet_1"
|
name = "subnet_1"
|
||||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
|
||||||
cidr = "192.168.199.0/24"
|
cidr = "192.168.199.0/24"
|
||||||
gateway_ip = "192.168.199.1"
|
gateway_ip = "192.168.199.1"
|
||||||
|
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||||
|
|
||||||
allocation_pools {
|
allocation_pools {
|
||||||
start = "192.168.199.100"
|
start = "192.168.199.100"
|
||||||
end = "192.168.199.200"
|
end = "192.168.199.200"
|
||||||
}
|
}
|
||||||
}`)
|
}
|
||||||
|
`
|
||||||
|
|
||||||
var testAccNetworkingV2Subnet_enableDHCP = fmt.Sprintf(`
|
const testAccNetworkingV2Subnet_enableDHCP = `
|
||||||
resource "openstack_networking_network_v2" "network_1" {
|
resource "openstack_networking_network_v2" "network_1" {
|
||||||
name = "network_1"
|
name = "network_1"
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||||
name = "tf-test-subnet"
|
name = "subnet_1"
|
||||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
|
||||||
cidr = "192.168.199.0/24"
|
cidr = "192.168.199.0/24"
|
||||||
gateway_ip = "192.168.199.1"
|
gateway_ip = "192.168.199.1"
|
||||||
enable_dhcp = true
|
enable_dhcp = true
|
||||||
}`)
|
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
var testAccNetworkingV2Subnet_disableDHCP = fmt.Sprintf(`
|
const testAccNetworkingV2Subnet_disableDHCP = `
|
||||||
resource "openstack_networking_network_v2" "network_1" {
|
resource "openstack_networking_network_v2" "network_1" {
|
||||||
name = "network_1"
|
name = "network_1"
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||||
name = "tf-test-subnet"
|
name = "subnet_1"
|
||||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
|
||||||
cidr = "192.168.199.0/24"
|
cidr = "192.168.199.0/24"
|
||||||
enable_dhcp = false
|
enable_dhcp = false
|
||||||
}`)
|
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
var testAccNetworkingV2Subnet_noGateway = fmt.Sprintf(`
|
const testAccNetworkingV2Subnet_noGateway = `
|
||||||
resource "openstack_networking_network_v2" "network_1" {
|
resource "openstack_networking_network_v2" "network_1" {
|
||||||
name = "network_1"
|
name = "network_1"
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||||
name = "tf-test-subnet"
|
name = "subnet_1"
|
||||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
|
||||||
cidr = "192.168.199.0/24"
|
cidr = "192.168.199.0/24"
|
||||||
no_gateway = true
|
no_gateway = true
|
||||||
}`)
|
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
var testAccNetworkingV2Subnet_impliedGateway = fmt.Sprintf(`
|
const testAccNetworkingV2Subnet_impliedGateway = `
|
||||||
resource "openstack_networking_network_v2" "network_1" {
|
resource "openstack_networking_network_v2" "network_1" {
|
||||||
name = "network_1"
|
name = "network_1"
|
||||||
admin_state_up = "true"
|
admin_state_up = "true"
|
||||||
}
|
}
|
||||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||||
name = "tf-test-subnet"
|
name = "subnet_1"
|
||||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
|
||||||
cidr = "192.168.199.0/24"
|
cidr = "192.168.199.0/24"
|
||||||
}`)
|
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAccObjectStorageV1Container_basic(t *testing.T) {
|
func TestAccObjectStorageV1Container_basic(t *testing.T) {
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
|
@ -19,14 +18,17 @@ func TestAccObjectStorageV1Container_basic(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccObjectStorageV1Container_basic,
|
Config: testAccObjectStorageV1Container_basic,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
resource.TestCheckResourceAttr("openstack_objectstorage_container_v1.container_1", "name", "tf-test-container"),
|
resource.TestCheckResourceAttr(
|
||||||
resource.TestCheckResourceAttr("openstack_objectstorage_container_v1.container_1", "content_type", "application/json"),
|
"openstack_objectstorage_container_v1.container_1", "name", "container_1"),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"openstack_objectstorage_container_v1.container_1", "content_type", "application/json"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccObjectStorageV1Container_update,
|
Config: testAccObjectStorageV1Container_update,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
resource.TestCheckResourceAttr("openstack_objectstorage_container_v1.container_1", "content_type", "text/plain"),
|
resource.TestCheckResourceAttr(
|
||||||
|
"openstack_objectstorage_container_v1.container_1", "content_type", "text/plain"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -54,22 +56,22 @@ func testAccCheckObjectStorageV1ContainerDestroy(s *terraform.State) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var testAccObjectStorageV1Container_basic = fmt.Sprintf(`
|
const testAccObjectStorageV1Container_basic = `
|
||||||
resource "openstack_objectstorage_container_v1" "container_1" {
|
resource "openstack_objectstorage_container_v1" "container_1" {
|
||||||
name = "tf-test-container"
|
name = "container_1"
|
||||||
metadata {
|
metadata {
|
||||||
test = "true"
|
test = "true"
|
||||||
}
|
}
|
||||||
content_type = "application/json"
|
content_type = "application/json"
|
||||||
}
|
}
|
||||||
`)
|
`
|
||||||
|
|
||||||
var testAccObjectStorageV1Container_update = fmt.Sprintf(`
|
const testAccObjectStorageV1Container_update = `
|
||||||
resource "openstack_objectstorage_container_v1" "container_1" {
|
resource "openstack_objectstorage_container_v1" "container_1" {
|
||||||
name = "tf-test-container"
|
name = "container_1"
|
||||||
metadata {
|
metadata {
|
||||||
test = "true"
|
test = "true"
|
||||||
}
|
}
|
||||||
content_type = "text/plain"
|
content_type = "text/plain"
|
||||||
}
|
}
|
||||||
`)
|
`
|
||||||
|
|
Loading…
Reference in New Issue