diff --git a/builtin/providers/openstack/resource_openstack_networking_floatingip_v2.go b/builtin/providers/openstack/resource_openstack_networking_floatingip_v2.go index b22301c93..9712dd156 100644 --- a/builtin/providers/openstack/resource_openstack_networking_floatingip_v2.go +++ b/builtin/providers/openstack/resource_openstack_networking_floatingip_v2.go @@ -24,6 +24,11 @@ func resourceNetworkingFloatingIPV2() *schema.Resource { State: schema.ImportStatePassthrough, }, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(10 * time.Minute), + Delete: schema.DefaultTimeout(10 * time.Minute), + }, + Schema: map[string]*schema.Schema{ "region": &schema.Schema{ Type: schema.TypeString, @@ -101,7 +106,7 @@ func resourceNetworkFloatingIPV2Create(d *schema.ResourceData, meta interface{}) stateConf := &resource.StateChangeConf{ Target: []string{"ACTIVE"}, Refresh: waitForFloatingIPActive(networkingClient, floatingIP.ID), - Timeout: 2 * time.Minute, + Timeout: d.Timeout(schema.TimeoutCreate), Delay: 5 * time.Second, MinTimeout: 3 * time.Second, } @@ -175,7 +180,7 @@ func resourceNetworkFloatingIPV2Delete(d *schema.ResourceData, meta interface{}) Pending: []string{"ACTIVE"}, Target: []string{"DELETED"}, Refresh: waitForFloatingIPDelete(networkingClient, d.Id()), - Timeout: 2 * time.Minute, + Timeout: d.Timeout(schema.TimeoutDelete), Delay: 5 * time.Second, MinTimeout: 3 * time.Second, } diff --git a/builtin/providers/openstack/resource_openstack_networking_floatingip_v2_test.go b/builtin/providers/openstack/resource_openstack_networking_floatingip_v2_test.go index b8b31e8b9..1eefea90b 100644 --- a/builtin/providers/openstack/resource_openstack_networking_floatingip_v2_test.go +++ b/builtin/providers/openstack/resource_openstack_networking_floatingip_v2_test.go @@ -69,6 +69,24 @@ func TestAccNetworkingV2FloatingIP_fixedip_bind(t *testing.T) { }) } +func TestAccNetworkingV2FloatingIP_timeout(t *testing.T) { + var fip floatingips.FloatingIP + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckNetworkingV2FloatingIPDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccNetworkingV2FloatingIP_timeout, + Check: resource.ComposeTestCheckFunc( + testAccCheckNetworkingV2FloatingIPExists("openstack_networking_floatingip_v2.fip_1", &fip), + ), + }, + }, + }) +} + func testAccCheckNetworkingV2FloatingIPDestroy(s *terraform.State) error { config := testAccProvider.Meta().(*Config) networkClient, err := config.networkingV2Client(OS_REGION_NAME) @@ -218,3 +236,12 @@ resource "openstack_networking_floatingip_v2" "fip_1" { fixed_ip = "${openstack_networking_port_v2.port_1.fixed_ip.1.ip_address}" } `, OS_EXTGW_ID, OS_POOL_NAME) + +const testAccNetworkingV2FloatingIP_timeout = ` +resource "openstack_networking_floatingip_v2" "fip_1" { + timeouts { + create = "5m" + delete = "5m" + } +} +` diff --git a/builtin/providers/openstack/resource_openstack_networking_network_v2.go b/builtin/providers/openstack/resource_openstack_networking_network_v2.go index 96ff47d72..9f1af3e28 100644 --- a/builtin/providers/openstack/resource_openstack_networking_network_v2.go +++ b/builtin/providers/openstack/resource_openstack_networking_network_v2.go @@ -23,6 +23,11 @@ func resourceNetworkingNetworkV2() *schema.Resource { State: schema.ImportStatePassthrough, }, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(10 * time.Minute), + Delete: schema.DefaultTimeout(10 * time.Minute), + }, + Schema: map[string]*schema.Schema{ "region": &schema.Schema{ Type: schema.TypeString, @@ -108,7 +113,7 @@ func resourceNetworkingNetworkV2Create(d *schema.ResourceData, meta interface{}) Pending: []string{"BUILD"}, Target: []string{"ACTIVE"}, Refresh: waitForNetworkActive(networkingClient, n.ID), - Timeout: 2 * time.Minute, + Timeout: d.Timeout(schema.TimeoutCreate), Delay: 5 * time.Second, MinTimeout: 3 * time.Second, } @@ -196,7 +201,7 @@ func resourceNetworkingNetworkV2Delete(d *schema.ResourceData, meta interface{}) Pending: []string{"ACTIVE"}, Target: []string{"DELETED"}, Refresh: waitForNetworkDelete(networkingClient, d.Id()), - Timeout: 2 * time.Minute, + Timeout: d.Timeout(schema.TimeoutDelete), Delay: 5 * time.Second, MinTimeout: 3 * time.Second, } diff --git a/builtin/providers/openstack/resource_openstack_networking_network_v2_test.go b/builtin/providers/openstack/resource_openstack_networking_network_v2_test.go index 14415f884..b2e9ac32b 100644 --- a/builtin/providers/openstack/resource_openstack_networking_network_v2_test.go +++ b/builtin/providers/openstack/resource_openstack_networking_network_v2_test.go @@ -90,6 +90,24 @@ func TestAccNetworkingV2Network_fullstack(t *testing.T) { }) } +func TestAccNetworkingV2Network_timeout(t *testing.T) { + var network networks.Network + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckNetworkingV2NetworkDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccNetworkingV2Network_timeout, + Check: resource.ComposeTestCheckFunc( + testAccCheckNetworkingV2NetworkExists("openstack_networking_network_v2.network_1", &network), + ), + }, + }, + }) +} + func testAccCheckNetworkingV2NetworkDestroy(s *terraform.State) error { config := testAccProvider.Meta().(*Config) networkingClient, err := config.networkingV2Client(OS_REGION_NAME) @@ -225,3 +243,15 @@ resource "openstack_compute_instance_v2" "instance_1" { } } ` + +const testAccNetworkingV2Network_timeout = ` +resource "openstack_networking_network_v2" "network_1" { + name = "network_1" + admin_state_up = "true" + + timeouts { + create = "5m" + delete = "5m" + } +} +` diff --git a/builtin/providers/openstack/resource_openstack_networking_port_v2.go b/builtin/providers/openstack/resource_openstack_networking_port_v2.go index 418662f18..aea9cb8dd 100644 --- a/builtin/providers/openstack/resource_openstack_networking_port_v2.go +++ b/builtin/providers/openstack/resource_openstack_networking_port_v2.go @@ -24,6 +24,11 @@ func resourceNetworkingPortV2() *schema.Resource { State: schema.ImportStatePassthrough, }, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(10 * time.Minute), + Delete: schema.DefaultTimeout(10 * time.Minute), + }, + Schema: map[string]*schema.Schema{ "region": &schema.Schema{ Type: schema.TypeString, @@ -162,7 +167,7 @@ func resourceNetworkingPortV2Create(d *schema.ResourceData, meta interface{}) er stateConf := &resource.StateChangeConf{ Target: []string{"ACTIVE"}, Refresh: waitForNetworkPortActive(networkingClient, p.ID), - Timeout: 2 * time.Minute, + Timeout: d.Timeout(schema.TimeoutCreate), Delay: 5 * time.Second, MinTimeout: 3 * time.Second, } @@ -280,7 +285,7 @@ func resourceNetworkingPortV2Delete(d *schema.ResourceData, meta interface{}) er Pending: []string{"ACTIVE"}, Target: []string{"DELETED"}, Refresh: waitForNetworkPortDelete(networkingClient, d.Id()), - Timeout: 2 * time.Minute, + Timeout: d.Timeout(schema.TimeoutDelete), Delay: 5 * time.Second, MinTimeout: 3 * time.Second, } diff --git a/builtin/providers/openstack/resource_openstack_networking_port_v2_test.go b/builtin/providers/openstack/resource_openstack_networking_port_v2_test.go index 0b849ac31..ec731fe7a 100644 --- a/builtin/providers/openstack/resource_openstack_networking_port_v2_test.go +++ b/builtin/providers/openstack/resource_openstack_networking_port_v2_test.go @@ -102,6 +102,28 @@ func TestAccNetworkingV2Port_multipleFixedIPs(t *testing.T) { }) } +func TestAccNetworkingV2Port_timeout(t *testing.T) { + var network networks.Network + var port ports.Port + var subnet subnets.Subnet + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckNetworkingV2PortDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccNetworkingV2Port_timeout, + Check: resource.ComposeTestCheckFunc( + testAccCheckNetworkingV2SubnetExists("openstack_networking_subnet_v2.subnet_1", &subnet), + testAccCheckNetworkingV2NetworkExists("openstack_networking_network_v2.network_1", &network), + testAccCheckNetworkingV2PortExists("openstack_networking_port_v2.port_1", &port), + ), + }, + }, + }) +} + func testAccCheckNetworkingV2PortDestroy(s *terraform.State) error { config := testAccProvider.Meta().(*Config) networkingClient, err := config.networkingV2Client(OS_REGION_NAME) @@ -304,3 +326,33 @@ resource "openstack_networking_port_v2" "port_1" { } } ` + +const testAccNetworkingV2Port_timeout = ` +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_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}" + ip_address = "192.168.199.23" + } + + timeouts { + create = "5m" + delete = "5m" + } +} +` diff --git a/builtin/providers/openstack/resource_openstack_networking_router_interface_v2.go b/builtin/providers/openstack/resource_openstack_networking_router_interface_v2.go index 6ca90e887..4a4ae8685 100644 --- a/builtin/providers/openstack/resource_openstack_networking_router_interface_v2.go +++ b/builtin/providers/openstack/resource_openstack_networking_router_interface_v2.go @@ -19,6 +19,11 @@ func resourceNetworkingRouterInterfaceV2() *schema.Resource { Read: resourceNetworkingRouterInterfaceV2Read, Delete: resourceNetworkingRouterInterfaceV2Delete, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(10 * time.Minute), + Delete: schema.DefaultTimeout(10 * time.Minute), + }, + Schema: map[string]*schema.Schema{ "region": &schema.Schema{ Type: schema.TypeString, @@ -70,7 +75,7 @@ func resourceNetworkingRouterInterfaceV2Create(d *schema.ResourceData, meta inte Pending: []string{"BUILD", "PENDING_CREATE", "PENDING_UPDATE"}, Target: []string{"ACTIVE"}, Refresh: waitForRouterInterfaceActive(networkingClient, n.PortID), - Timeout: 2 * time.Minute, + Timeout: d.Timeout(schema.TimeoutCreate), Delay: 5 * time.Second, MinTimeout: 3 * time.Second, } @@ -115,7 +120,7 @@ func resourceNetworkingRouterInterfaceV2Delete(d *schema.ResourceData, meta inte Pending: []string{"ACTIVE"}, Target: []string{"DELETED"}, Refresh: waitForRouterInterfaceDelete(networkingClient, d), - Timeout: 5 * time.Minute, + Timeout: d.Timeout(schema.TimeoutDelete), Delay: 5 * time.Second, MinTimeout: 3 * time.Second, } diff --git a/builtin/providers/openstack/resource_openstack_networking_router_interface_v2_test.go b/builtin/providers/openstack/resource_openstack_networking_router_interface_v2_test.go index 0f41db18b..c6289050c 100644 --- a/builtin/providers/openstack/resource_openstack_networking_router_interface_v2_test.go +++ b/builtin/providers/openstack/resource_openstack_networking_router_interface_v2_test.go @@ -61,6 +61,29 @@ func TestAccNetworkingV2RouterInterface_basic_port(t *testing.T) { }) } +func TestAccNetworkingV2RouterInterface_timeout(t *testing.T) { + var network networks.Network + var router routers.Router + var subnet subnets.Subnet + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckNetworkingV2RouterInterfaceDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccNetworkingV2RouterInterface_timeout, + Check: resource.ComposeTestCheckFunc( + testAccCheckNetworkingV2NetworkExists("openstack_networking_network_v2.network_1", &network), + testAccCheckNetworkingV2SubnetExists("openstack_networking_subnet_v2.subnet_1", &subnet), + testAccCheckNetworkingV2RouterExists("openstack_networking_router_v2.router_1", &router), + testAccCheckNetworkingV2RouterInterfaceExists("openstack_networking_router_interface_v2.int_1"), + ), + }, + }, + }) +} + func testAccCheckNetworkingV2RouterInterfaceDestroy(s *terraform.State) error { config := testAccProvider.Meta().(*Config) networkingClient, err := config.networkingV2Client(OS_REGION_NAME) @@ -168,3 +191,31 @@ resource "openstack_networking_port_v2" "port_1" { } } ` + +const testAccNetworkingV2RouterInterface_timeout = ` +resource "openstack_networking_router_v2" "router_1" { + name = "router_1" + admin_state_up = "true" +} + +resource "openstack_networking_router_interface_v2" "int_1" { + subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}" + router_id = "${openstack_networking_router_v2.router_1.id}" + + timeouts { + create = "5m" + delete = "5m" + } +} + +resource "openstack_networking_network_v2" "network_1" { + name = "network_1" + admin_state_up = "true" +} + +resource "openstack_networking_subnet_v2" "subnet_1" { + cidr = "192.168.199.0/24" + ip_version = 4 + network_id = "${openstack_networking_network_v2.network_1.id}" +} +` diff --git a/builtin/providers/openstack/resource_openstack_networking_router_v2.go b/builtin/providers/openstack/resource_openstack_networking_router_v2.go index efbab162e..d979a53e6 100644 --- a/builtin/providers/openstack/resource_openstack_networking_router_v2.go +++ b/builtin/providers/openstack/resource_openstack_networking_router_v2.go @@ -19,6 +19,11 @@ func resourceNetworkingRouterV2() *schema.Resource { Update: resourceNetworkingRouterV2Update, Delete: resourceNetworkingRouterV2Delete, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(10 * time.Minute), + Delete: schema.DefaultTimeout(10 * time.Minute), + }, + Schema: map[string]*schema.Schema{ "region": &schema.Schema{ Type: schema.TypeString, @@ -108,7 +113,7 @@ func resourceNetworkingRouterV2Create(d *schema.ResourceData, meta interface{}) Pending: []string{"BUILD", "PENDING_CREATE", "PENDING_UPDATE"}, Target: []string{"ACTIVE"}, Refresh: waitForRouterActive(networkingClient, n.ID), - Timeout: 10 * time.Minute, + Timeout: d.Timeout(schema.TimeoutCreate), Delay: 5 * time.Second, MinTimeout: 3 * time.Second, } @@ -198,7 +203,7 @@ func resourceNetworkingRouterV2Delete(d *schema.ResourceData, meta interface{}) Pending: []string{"ACTIVE"}, Target: []string{"DELETED"}, Refresh: waitForRouterDelete(networkingClient, d.Id()), - Timeout: 10 * time.Minute, + Timeout: d.Timeout(schema.TimeoutDelete), Delay: 5 * time.Second, MinTimeout: 3 * time.Second, } diff --git a/builtin/providers/openstack/resource_openstack_networking_router_v2_test.go b/builtin/providers/openstack/resource_openstack_networking_router_v2_test.go index bff9c4fbd..2c08f9b92 100644 --- a/builtin/providers/openstack/resource_openstack_networking_router_v2_test.go +++ b/builtin/providers/openstack/resource_openstack_networking_router_v2_test.go @@ -60,6 +60,24 @@ func TestAccNetworkingV2Router_update_external_gw(t *testing.T) { }) } +func TestAccNetworkingV2Router_timeout(t *testing.T) { + var router routers.Router + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckNetworkingV2RouterDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccNetworkingV2Router_timeout, + Check: resource.ComposeTestCheckFunc( + testAccCheckNetworkingV2RouterExists("openstack_networking_router_v2.router_1", &router), + ), + }, + }, + }) +} + func testAccCheckNetworkingV2RouterDestroy(s *terraform.State) error { config := testAccProvider.Meta().(*Config) networkingClient, err := config.networkingV2Client(OS_REGION_NAME) @@ -145,3 +163,16 @@ resource "openstack_networking_router_v2" "router_1" { external_gateway = "%s" } `, OS_EXTGW_ID) + +const testAccNetworkingV2Router_timeout = ` +resource "openstack_networking_router_v2" "router_1" { + name = "router_1" + admin_state_up = "true" + distributed = "false" + + timeouts { + create = "5m" + delete = "5m" + } +} +` diff --git a/builtin/providers/openstack/resource_openstack_networking_secgroup_rule_v2.go b/builtin/providers/openstack/resource_openstack_networking_secgroup_rule_v2.go index bb7017c40..39a675967 100644 --- a/builtin/providers/openstack/resource_openstack_networking_secgroup_rule_v2.go +++ b/builtin/providers/openstack/resource_openstack_networking_secgroup_rule_v2.go @@ -22,6 +22,10 @@ func resourceNetworkingSecGroupRuleV2() *schema.Resource { State: schema.ImportStatePassthrough, }, + Timeouts: &schema.ResourceTimeout{ + Delete: schema.DefaultTimeout(10 * time.Minute), + }, + Schema: map[string]*schema.Schema{ "region": &schema.Schema{ Type: schema.TypeString, @@ -185,7 +189,7 @@ func resourceNetworkingSecGroupRuleV2Delete(d *schema.ResourceData, meta interfa Pending: []string{"ACTIVE"}, Target: []string{"DELETED"}, Refresh: waitForSecGroupRuleDelete(networkingClient, d.Id()), - Timeout: 2 * time.Minute, + Timeout: d.Timeout(schema.TimeoutDelete), Delay: 5 * time.Second, MinTimeout: 3 * time.Second, } diff --git a/builtin/providers/openstack/resource_openstack_networking_secgroup_rule_v2_test.go b/builtin/providers/openstack/resource_openstack_networking_secgroup_rule_v2_test.go index bdc787c06..dae6dc3f7 100644 --- a/builtin/providers/openstack/resource_openstack_networking_secgroup_rule_v2_test.go +++ b/builtin/providers/openstack/resource_openstack_networking_secgroup_rule_v2_test.go @@ -63,6 +63,28 @@ func TestAccNetworkingV2SecGroupRule_lowerCaseCIDR(t *testing.T) { }) } +func TestAccNetworkingV2SecGroupRule_timeout(t *testing.T) { + var secgroup_1 groups.SecGroup + var secgroup_2 groups.SecGroup + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckNetworkingV2SecGroupRuleDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccNetworkingV2SecGroupRule_timeout, + Check: resource.ComposeTestCheckFunc( + testAccCheckNetworkingV2SecGroupExists( + "openstack_networking_secgroup_v2.secgroup_1", &secgroup_1), + testAccCheckNetworkingV2SecGroupExists( + "openstack_networking_secgroup_v2.secgroup_2", &secgroup_2), + ), + }, + }, + }) +} + func testAccCheckNetworkingV2SecGroupRuleDestroy(s *terraform.State) error { config := testAccProvider.Meta().(*Config) networkingClient, err := config.networkingV2Client(OS_REGION_NAME) @@ -164,3 +186,43 @@ resource "openstack_networking_secgroup_rule_v2" "secgroup_rule_1" { security_group_id = "${openstack_networking_secgroup_v2.secgroup_1.id}" } ` + +const testAccNetworkingV2SecGroupRule_timeout = ` +resource "openstack_networking_secgroup_v2" "secgroup_1" { + name = "secgroup_1" + description = "terraform security group rule acceptance test" +} + +resource "openstack_networking_secgroup_v2" "secgroup_2" { + name = "secgroup_2" + description = "terraform security group rule acceptance test" +} + +resource "openstack_networking_secgroup_rule_v2" "secgroup_rule_1" { + direction = "ingress" + ethertype = "IPv4" + port_range_max = 22 + port_range_min = 22 + protocol = "tcp" + remote_ip_prefix = "0.0.0.0/0" + security_group_id = "${openstack_networking_secgroup_v2.secgroup_1.id}" + + timeouts { + create = "5m" + } +} + +resource "openstack_networking_secgroup_rule_v2" "secgroup_rule_2" { + direction = "ingress" + ethertype = "IPv4" + port_range_max = 80 + port_range_min = 80 + protocol = "tcp" + remote_group_id = "${openstack_networking_secgroup_v2.secgroup_1.id}" + security_group_id = "${openstack_networking_secgroup_v2.secgroup_2.id}" + + timeouts { + delete = "5m" + } +} +` diff --git a/builtin/providers/openstack/resource_openstack_networking_secgroup_v2.go b/builtin/providers/openstack/resource_openstack_networking_secgroup_v2.go index 0023193ab..f76d24c57 100644 --- a/builtin/providers/openstack/resource_openstack_networking_secgroup_v2.go +++ b/builtin/providers/openstack/resource_openstack_networking_secgroup_v2.go @@ -22,6 +22,10 @@ func resourceNetworkingSecGroupV2() *schema.Resource { State: schema.ImportStatePassthrough, }, + Timeouts: &schema.ResourceTimeout{ + Delete: schema.DefaultTimeout(10 * time.Minute), + }, + Schema: map[string]*schema.Schema{ "region": &schema.Schema{ Type: schema.TypeString, @@ -130,7 +134,7 @@ func resourceNetworkingSecGroupV2Delete(d *schema.ResourceData, meta interface{} Pending: []string{"ACTIVE"}, Target: []string{"DELETED"}, Refresh: waitForSecGroupDelete(networkingClient, d.Id()), - Timeout: 2 * time.Minute, + Timeout: d.Timeout(schema.TimeoutDelete), Delay: 5 * time.Second, MinTimeout: 3 * time.Second, } diff --git a/builtin/providers/openstack/resource_openstack_networking_secgroup_v2_test.go b/builtin/providers/openstack/resource_openstack_networking_secgroup_v2_test.go index b4ac4b43e..aa6e7fff8 100644 --- a/builtin/providers/openstack/resource_openstack_networking_secgroup_v2_test.go +++ b/builtin/providers/openstack/resource_openstack_networking_secgroup_v2_test.go @@ -57,6 +57,25 @@ func TestAccNetworkingV2SecGroup_noDefaultRules(t *testing.T) { }) } +func TestAccNetworkingV2SecGroup_timeout(t *testing.T) { + var security_group groups.SecGroup + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckNetworkingV2SecGroupDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccNetworkingV2SecGroup_timeout, + Check: resource.ComposeTestCheckFunc( + testAccCheckNetworkingV2SecGroupExists( + "openstack_networking_secgroup_v2.secgroup_1", &security_group), + ), + }, + }, + }) +} + func testAccCheckNetworkingV2SecGroupDestroy(s *terraform.State) error { config := testAccProvider.Meta().(*Config) networkingClient, err := config.networkingV2Client(OS_REGION_NAME) @@ -143,3 +162,14 @@ resource "openstack_networking_secgroup_v2" "secgroup_1" { delete_default_rules = true } ` + +const testAccNetworkingV2SecGroup_timeout = ` +resource "openstack_networking_secgroup_v2" "secgroup_1" { + name = "security_group" + description = "terraform security group acceptance test" + + timeouts { + delete = "5m" + } +} +` diff --git a/builtin/providers/openstack/resource_openstack_networking_subnet_v2.go b/builtin/providers/openstack/resource_openstack_networking_subnet_v2.go index cbe88877e..e0b2fcab9 100644 --- a/builtin/providers/openstack/resource_openstack_networking_subnet_v2.go +++ b/builtin/providers/openstack/resource_openstack_networking_subnet_v2.go @@ -22,6 +22,11 @@ func resourceNetworkingSubnetV2() *schema.Resource { State: schema.ImportStatePassthrough, }, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(10 * time.Minute), + Delete: schema.DefaultTimeout(10 * time.Minute), + }, + Schema: map[string]*schema.Schema{ "region": &schema.Schema{ Type: schema.TypeString, @@ -178,7 +183,7 @@ func resourceNetworkingSubnetV2Create(d *schema.ResourceData, meta interface{}) stateConf := &resource.StateChangeConf{ Target: []string{"ACTIVE"}, Refresh: waitForSubnetActive(networkingClient, s.ID), - Timeout: 10 * time.Minute, + Timeout: d.Timeout(schema.TimeoutCreate), Delay: 5 * time.Second, MinTimeout: 3 * time.Second, } @@ -309,7 +314,7 @@ func resourceNetworkingSubnetV2Delete(d *schema.ResourceData, meta interface{}) Pending: []string{"ACTIVE"}, Target: []string{"DELETED"}, Refresh: waitForSubnetDelete(networkingClient, d.Id()), - Timeout: 10 * time.Minute, + Timeout: d.Timeout(schema.TimeoutDelete), Delay: 5 * time.Second, MinTimeout: 3 * time.Second, } diff --git a/builtin/providers/openstack/resource_openstack_networking_subnet_v2_test.go b/builtin/providers/openstack/resource_openstack_networking_subnet_v2_test.go index 942d30755..1c9d645c1 100644 --- a/builtin/providers/openstack/resource_openstack_networking_subnet_v2_test.go +++ b/builtin/providers/openstack/resource_openstack_networking_subnet_v2_test.go @@ -119,6 +119,24 @@ func TestAccNetworkingV2Subnet_impliedGateway(t *testing.T) { }) } +func TestAccNetworkingV2Subnet_timeout(t *testing.T) { + var subnet subnets.Subnet + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckNetworkingV2SubnetDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccNetworkingV2Subnet_timeout, + Check: resource.ComposeTestCheckFunc( + testAccCheckNetworkingV2SubnetExists("openstack_networking_subnet_v2.subnet_1", &subnet), + ), + }, + }, + }) +} + func testAccCheckNetworkingV2SubnetDestroy(s *terraform.State) error { config := testAccProvider.Meta().(*Config) networkingClient, err := config.networkingV2Client(OS_REGION_NAME) @@ -262,3 +280,25 @@ resource "openstack_networking_subnet_v2" "subnet_1" { network_id = "${openstack_networking_network_v2.network_1.id}" } ` + +const testAccNetworkingV2Subnet_timeout = ` +resource "openstack_networking_network_v2" "network_1" { + name = "network_1" + admin_state_up = "true" +} + +resource "openstack_networking_subnet_v2" "subnet_1" { + cidr = "192.168.199.0/24" + network_id = "${openstack_networking_network_v2.network_1.id}" + + allocation_pools { + start = "192.168.199.100" + end = "192.168.199.200" + } + + timeouts { + create = "5m" + delete = "5m" + } +} +`