func resourceFWRuleV1Delete(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Destroy firewall rule: %s", d.Id()) config := meta.(*Config) networkingClient, err := config.networkingV2Client(d.Get("region").(string)) if err != nil { return fmt.Errorf("Error creating OpenStack networking client: %s", err) } rule, err := rules.Get(networkingClient, d.Id()).Extract() if err != nil { return err } if rule.PolicyID != "" { err := policies.RemoveRule(networkingClient, rule.PolicyID, rule.ID) if err != nil { return err } } return rules.Delete(networkingClient, d.Id()).Err }
func removeRuleFromPolicy(t *testing.T, policyID string, ruleID string) { err := policies.RemoveRule(base.Client, policyID, ruleID) th.AssertNoErr(t, err) t.Logf("Removed rule [%s] from policy ID [%s]", ruleID, policyID) }