|
|
|
|
@ -503,6 +503,60 @@ func TestAccComputeV2Instance_multiEphemeral(t *testing.T) {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestAccComputeV2Instance_accessIPv4(t *testing.T) {
|
|
|
|
|
var instance servers.Server
|
|
|
|
|
var testAccComputeV2Instance_accessIPv4 = fmt.Sprintf(`
|
|
|
|
|
resource "openstack_compute_floatingip_v2" "myip" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "openstack_networking_network_v2" "network_1" {
|
|
|
|
|
name = "network_1"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "openstack_networking_subnet_v2" "subnet_1" {
|
|
|
|
|
name = "subnet_1"
|
|
|
|
|
network_id = "${openstack_networking_network_v2.network_1.id}"
|
|
|
|
|
cidr = "192.168.1.0/24"
|
|
|
|
|
ip_version = 4
|
|
|
|
|
enable_dhcp = true
|
|
|
|
|
no_gateway = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "openstack_compute_instance_v2" "instance_1" {
|
|
|
|
|
depends_on = ["openstack_networking_subnet_v2.subnet_1"]
|
|
|
|
|
|
|
|
|
|
name = "instance_1"
|
|
|
|
|
security_groups = ["default"]
|
|
|
|
|
floating_ip = "${openstack_compute_floatingip_v2.myip.address}"
|
|
|
|
|
|
|
|
|
|
network {
|
|
|
|
|
uuid = "%s"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
network {
|
|
|
|
|
uuid = "${openstack_networking_network_v2.network_1.id}"
|
|
|
|
|
fixed_ip_v4 = "192.168.1.100"
|
|
|
|
|
access_network = true
|
|
|
|
|
}
|
|
|
|
|
}`, os.Getenv("OS_NETWORK_ID"))
|
|
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
|
Providers: testAccProviders,
|
|
|
|
|
CheckDestroy: testAccCheckComputeV2InstanceDestroy,
|
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
|
resource.TestStep{
|
|
|
|
|
Config: testAccComputeV2Instance_accessIPv4,
|
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
|
testAccCheckComputeV2InstanceExists(t, "openstack_compute_instance_v2.instance_1", &instance),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"openstack_compute_instance_v2.instance_1", "access_ip_v4", "192.168.1.100"),
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func testAccCheckComputeV2InstanceDestroy(s *terraform.State) error {
|
|
|
|
|
config := testAccProvider.Meta().(*Config)
|
|
|
|
|
computeClient, err := config.computeV2Client(OS_REGION_NAME)
|
|
|
|
|
|