provider/openstack: Adding Timeouts to FWaaS v1 Resources (#12863)
This commit is contained in:
parent
fbf11d070b
commit
42ff9103b7
|
@ -21,6 +21,12 @@ func resourceFWFirewallV1() *schema.Resource {
|
|||
State: schema.ImportStatePassthrough,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Create: schema.DefaultTimeout(10 * time.Minute),
|
||||
Update: schema.DefaultTimeout(10 * time.Minute),
|
||||
Delete: schema.DefaultTimeout(10 * time.Minute),
|
||||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -94,7 +100,7 @@ func resourceFWFirewallV1Create(d *schema.ResourceData, meta interface{}) error
|
|||
Pending: []string{"PENDING_CREATE"},
|
||||
Target: []string{"ACTIVE"},
|
||||
Refresh: waitForFirewallActive(networkingClient, firewall.ID),
|
||||
Timeout: 30 * time.Second,
|
||||
Timeout: d.Timeout(schema.TimeoutCreate),
|
||||
Delay: 0,
|
||||
MinTimeout: 2 * time.Second,
|
||||
}
|
||||
|
@ -165,7 +171,7 @@ func resourceFWFirewallV1Update(d *schema.ResourceData, meta interface{}) error
|
|||
Pending: []string{"PENDING_CREATE", "PENDING_UPDATE"},
|
||||
Target: []string{"ACTIVE"},
|
||||
Refresh: waitForFirewallActive(networkingClient, d.Id()),
|
||||
Timeout: 30 * time.Second,
|
||||
Timeout: d.Timeout(schema.TimeoutUpdate),
|
||||
Delay: 0,
|
||||
MinTimeout: 2 * time.Second,
|
||||
}
|
||||
|
@ -189,11 +195,12 @@ func resourceFWFirewallV1Delete(d *schema.ResourceData, meta interface{}) error
|
|||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
// Ensure the firewall was fully created/updated before being deleted.
|
||||
stateConf := &resource.StateChangeConf{
|
||||
Pending: []string{"PENDING_CREATE", "PENDING_UPDATE"},
|
||||
Target: []string{"ACTIVE"},
|
||||
Refresh: waitForFirewallActive(networkingClient, d.Id()),
|
||||
Timeout: 30 * time.Second,
|
||||
Timeout: d.Timeout(schema.TimeoutUpdate),
|
||||
Delay: 0,
|
||||
MinTimeout: 2 * time.Second,
|
||||
}
|
||||
|
@ -210,7 +217,7 @@ func resourceFWFirewallV1Delete(d *schema.ResourceData, meta interface{}) error
|
|||
Pending: []string{"DELETING"},
|
||||
Target: []string{"DELETED"},
|
||||
Refresh: waitForFirewallDeletion(networkingClient, d.Id()),
|
||||
Timeout: 2 * time.Minute,
|
||||
Timeout: d.Timeout(schema.TimeoutDelete),
|
||||
Delay: 0,
|
||||
MinTimeout: 2 * time.Second,
|
||||
}
|
||||
|
|
|
@ -36,6 +36,24 @@ func TestAccFWFirewallV1_basic(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestAccFWFirewallV1_timeout(t *testing.T) {
|
||||
var policyID *string
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckFWFirewallV1Destroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccFWFirewallV1_timeout,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckFWFirewallV1Exists("openstack_fw_firewall_v1.fw_1", "", "", policyID),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccCheckFWFirewallV1Destroy(s *terraform.State) error {
|
||||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
|
@ -135,3 +153,19 @@ resource "openstack_fw_policy_v1" "policy_2" {
|
|||
name = "policy_2"
|
||||
}
|
||||
`
|
||||
|
||||
const testAccFWFirewallV1_timeout = `
|
||||
resource "openstack_fw_firewall_v1" "fw_1" {
|
||||
policy_id = "${openstack_fw_policy_v1.policy_1.id}"
|
||||
|
||||
timeouts {
|
||||
create = "5m"
|
||||
update = "5m"
|
||||
delete = "5m"
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_fw_policy_v1" "policy_1" {
|
||||
name = "policy_1"
|
||||
}
|
||||
`
|
||||
|
|
|
@ -21,6 +21,10 @@ func resourceFWPolicyV1() *schema.Resource {
|
|||
State: schema.ImportStatePassthrough,
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Create: schema.DefaultTimeout(10 * time.Minute),
|
||||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -194,7 +198,7 @@ func resourceFWPolicyV1Delete(d *schema.ResourceData, meta interface{}) error {
|
|||
Pending: []string{"ACTIVE"},
|
||||
Target: []string{"DELETED"},
|
||||
Refresh: waitForFirewallPolicyDeletion(networkingClient, d.Id()),
|
||||
Timeout: 120 * time.Second,
|
||||
Timeout: d.Timeout(schema.TimeoutCreate),
|
||||
Delay: 0,
|
||||
MinTimeout: 2 * time.Second,
|
||||
}
|
||||
|
|
|
@ -62,6 +62,23 @@ func TestAccFWPolicyV1_deleteRules(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestAccFWPolicyV1_timeout(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckFWPolicyV1Destroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccFWPolicyV1_timeout,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckFWPolicyV1Exists(
|
||||
"openstack_fw_policy_v1.policy_1", "", "", 0),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccCheckFWPolicyV1Destroy(s *terraform.State) error {
|
||||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
|
@ -172,3 +189,11 @@ resource "openstack_fw_rule_v1" "udp_deny" {
|
|||
action = "deny"
|
||||
}
|
||||
`
|
||||
|
||||
const testAccFWPolicyV1_timeout = `
|
||||
resource "openstack_fw_policy_v1" "policy_1" {
|
||||
timeouts {
|
||||
create = "5m"
|
||||
}
|
||||
}
|
||||
`
|
||||
|
|
Loading…
Reference in New Issue