FWaaS version is actually v1 not v2

Rename files and methods.

Confusion have been made between neutron
version and FWaaS extension version.
This commit is contained in:
Guillaume Giamarchi 2015-02-19 22:55:54 +01:00 committed by Jon Perritt
parent 1efaaeeca6
commit 16a963313f
7 changed files with 81 additions and 81 deletions

View File

@ -64,9 +64,9 @@ func Provider() terraform.ResourceProvider {
"openstack_compute_keypair_v2": resourceComputeKeypairV2(), "openstack_compute_keypair_v2": resourceComputeKeypairV2(),
"openstack_compute_secgroup_v2": resourceComputeSecGroupV2(), "openstack_compute_secgroup_v2": resourceComputeSecGroupV2(),
"openstack_compute_floatingip_v2": resourceComputeFloatingIPV2(), "openstack_compute_floatingip_v2": resourceComputeFloatingIPV2(),
"openstack_fw_firewall_v2": resourceFWFirewallV2(), "openstack_fw_firewall_v1": resourceFWFirewallV1(),
"openstack_fw_policy_v2": resourceFWPolicyV2(), "openstack_fw_policy_v1": resourceFWPolicyV1(),
"openstack_fw_rule_v2": resourceFWRuleV2(), "openstack_fw_rule_v1": resourceFWRuleV1(),
"openstack_lb_monitor_v1": resourceLBMonitorV1(), "openstack_lb_monitor_v1": resourceLBMonitorV1(),
"openstack_lb_pool_v1": resourceLBPoolV1(), "openstack_lb_pool_v1": resourceLBPoolV1(),
"openstack_lb_vip_v1": resourceLBVipV1(), "openstack_lb_vip_v1": resourceLBVipV1(),

View File

@ -12,12 +12,12 @@ import (
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls" "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls"
) )
func resourceFWFirewallV2() *schema.Resource { func resourceFWFirewallV1() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
Create: resourceFirewallCreate, Create: resourceFWFirewallV1Create,
Read: resourceFirewallRead, Read: resourceFWFirewallV1Read,
Update: resourceFirewallUpdate, Update: resourceFWFirewallV1Update,
Delete: resourceFirewallDelete, Delete: resourceFWFirewallV1Delete,
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"region": &schema.Schema{ "region": &schema.Schema{
@ -52,7 +52,7 @@ func resourceFWFirewallV2() *schema.Resource {
} }
} }
func resourceFirewallCreate(d *schema.ResourceData, meta interface{}) error { func resourceFWFirewallV1Create(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config) config := meta.(*Config)
networkingClient, err := config.networkingV2Client(d.Get("region").(string)) networkingClient, err := config.networkingV2Client(d.Get("region").(string))
@ -82,7 +82,7 @@ func resourceFirewallCreate(d *schema.ResourceData, meta interface{}) error {
stateConf := &resource.StateChangeConf{ stateConf := &resource.StateChangeConf{
Pending: []string{"PENDING_CREATE"}, Pending: []string{"PENDING_CREATE"},
Target: "ACTIVE", Target: "ACTIVE",
Refresh: WaitForFirewallActive(networkingClient, firewall.ID), Refresh: waitForFirewallActive(networkingClient, firewall.ID),
Timeout: 30 * time.Second, Timeout: 30 * time.Second,
Delay: 0, Delay: 0,
MinTimeout: 2 * time.Second, MinTimeout: 2 * time.Second,
@ -95,7 +95,7 @@ func resourceFirewallCreate(d *schema.ResourceData, meta interface{}) error {
return nil return nil
} }
func resourceFirewallRead(d *schema.ResourceData, meta interface{}) error { func resourceFWFirewallV1Read(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] Retrieve information about firewall: %s", d.Id()) log.Printf("[DEBUG] Retrieve information about firewall: %s", d.Id())
config := meta.(*Config) config := meta.(*Config)
@ -151,7 +151,7 @@ func resourceFirewallRead(d *schema.ResourceData, meta interface{}) error {
return nil return nil
} }
func resourceFirewallUpdate(d *schema.ResourceData, meta interface{}) error { func resourceFWFirewallV1Update(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config) config := meta.(*Config)
networkingClient, err := config.networkingV2Client(d.Get("region").(string)) networkingClient, err := config.networkingV2Client(d.Get("region").(string))
@ -183,7 +183,7 @@ func resourceFirewallUpdate(d *schema.ResourceData, meta interface{}) error {
stateConf := &resource.StateChangeConf{ stateConf := &resource.StateChangeConf{
Pending: []string{"PENDING_CREATE", "PENDING_UPDATE"}, Pending: []string{"PENDING_CREATE", "PENDING_UPDATE"},
Target: "ACTIVE", Target: "ACTIVE",
Refresh: WaitForFirewallActive(networkingClient, d.Id()), Refresh: waitForFirewallActive(networkingClient, d.Id()),
Timeout: 30 * time.Second, Timeout: 30 * time.Second,
Delay: 0, Delay: 0,
MinTimeout: 2 * time.Second, MinTimeout: 2 * time.Second,
@ -194,7 +194,7 @@ func resourceFirewallUpdate(d *schema.ResourceData, meta interface{}) error {
return firewalls.Update(networkingClient, d.Id(), opts).Err return firewalls.Update(networkingClient, d.Id(), opts).Err
} }
func resourceFirewallDelete(d *schema.ResourceData, meta interface{}) error { func resourceFWFirewallV1Delete(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] Destroy firewall: %s", d.Id()) log.Printf("[DEBUG] Destroy firewall: %s", d.Id())
config := meta.(*Config) config := meta.(*Config)
@ -206,7 +206,7 @@ func resourceFirewallDelete(d *schema.ResourceData, meta interface{}) error {
stateConf := &resource.StateChangeConf{ stateConf := &resource.StateChangeConf{
Pending: []string{"PENDING_CREATE", "PENDING_UPDATE"}, Pending: []string{"PENDING_CREATE", "PENDING_UPDATE"},
Target: "ACTIVE", Target: "ACTIVE",
Refresh: WaitForFirewallActive(networkingClient, d.Id()), Refresh: waitForFirewallActive(networkingClient, d.Id()),
Timeout: 30 * time.Second, Timeout: 30 * time.Second,
Delay: 0, Delay: 0,
MinTimeout: 2 * time.Second, MinTimeout: 2 * time.Second,
@ -223,7 +223,7 @@ func resourceFirewallDelete(d *schema.ResourceData, meta interface{}) error {
stateConf = &resource.StateChangeConf{ stateConf = &resource.StateChangeConf{
Pending: []string{"DELETING"}, Pending: []string{"DELETING"},
Target: "DELETED", Target: "DELETED",
Refresh: WaitForFirewallDeletion(networkingClient, d.Id()), Refresh: waitForFirewallDeletion(networkingClient, d.Id()),
Timeout: 2 * time.Minute, Timeout: 2 * time.Minute,
Delay: 0, Delay: 0,
MinTimeout: 2 * time.Second, MinTimeout: 2 * time.Second,
@ -234,7 +234,7 @@ func resourceFirewallDelete(d *schema.ResourceData, meta interface{}) error {
return err return err
} }
func WaitForFirewallActive(networkingClient *gophercloud.ServiceClient, id string) resource.StateRefreshFunc { func waitForFirewallActive(networkingClient *gophercloud.ServiceClient, id string) resource.StateRefreshFunc {
return func() (interface{}, string, error) { return func() (interface{}, string, error) {
fw, err := firewalls.Get(networkingClient, id).Extract() fw, err := firewalls.Get(networkingClient, id).Extract()
@ -247,7 +247,7 @@ func WaitForFirewallActive(networkingClient *gophercloud.ServiceClient, id strin
} }
} }
func WaitForFirewallDeletion(networkingClient *gophercloud.ServiceClient, id string) resource.StateRefreshFunc { func waitForFirewallDeletion(networkingClient *gophercloud.ServiceClient, id string) resource.StateRefreshFunc {
return func() (interface{}, string, error) { return func() (interface{}, string, error) {
fw, err := firewalls.Get(networkingClient, id).Extract() fw, err := firewalls.Get(networkingClient, id).Extract()

View File

@ -11,32 +11,32 @@ import (
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls" "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls"
) )
func TestAccOpenstackFirewall(t *testing.T) { func TestAccFWFirewallV1(t *testing.T) {
var policyID *string var policyID *string
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
CheckDestroy: testAccCheckOpenstackFirewallDestroy, CheckDestroy: testAccCheckFWFirewallV1Destroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ resource.TestStep{
Config: testFirewallConfig, Config: testFirewallConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccCheckFirewallExists("openstack_fw_firewall_v2.accept_test", "", "", policyID), testAccCheckFWFirewallV1Exists("openstack_fw_firewall_v1.accept_test", "", "", policyID),
), ),
}, },
resource.TestStep{ resource.TestStep{
Config: testFirewallConfigUpdated, Config: testFirewallConfigUpdated,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccCheckFirewallExists("openstack_fw_firewall_v2.accept_test", "accept_test", "terraform acceptance test", policyID), testAccCheckFWFirewallV1Exists("openstack_fw_firewall_v1.accept_test", "accept_test", "terraform acceptance test", policyID),
), ),
}, },
}, },
}) })
} }
func testAccCheckOpenstackFirewallDestroy(s *terraform.State) error { func testAccCheckFWFirewallV1Destroy(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)
@ -59,7 +59,7 @@ func testAccCheckOpenstackFirewallDestroy(s *terraform.State) error {
return nil return nil
} }
func testAccCheckFirewallExists(n, expectedName, expectedDescription string, policyID *string) resource.TestCheckFunc { func testAccCheckFWFirewallV1Exists(n, expectedName, expectedDescription string, policyID *string) resource.TestCheckFunc {
return func(s *terraform.State) error { return func(s *terraform.State) error {
@ -117,23 +117,23 @@ func testAccCheckFirewallExists(n, expectedName, expectedDescription string, pol
} }
const testFirewallConfig = ` const testFirewallConfig = `
resource "openstack_fw_firewall_v2" "accept_test" { resource "openstack_fw_firewall_v1" "accept_test" {
policy_id = "${openstack_fw_policy_v2.accept_test_policy_1.id}" policy_id = "${openstack_fw_policy_v1.accept_test_policy_1.id}"
} }
resource "openstack_fw_policy_v2" "accept_test_policy_1" { resource "openstack_fw_policy_v1" "accept_test_policy_1" {
name = "policy-1" name = "policy-1"
} }
` `
const testFirewallConfigUpdated = ` const testFirewallConfigUpdated = `
resource "openstack_fw_firewall_v2" "accept_test" { resource "openstack_fw_firewall_v1" "accept_test" {
name = "accept_test" name = "accept_test"
description = "terraform acceptance test" description = "terraform acceptance test"
policy_id = "${openstack_fw_policy_v2.accept_test_policy_2.id}" policy_id = "${openstack_fw_policy_v1.accept_test_policy_2.id}"
} }
resource "openstack_fw_policy_v2" "accept_test_policy_2" { resource "openstack_fw_policy_v1" "accept_test_policy_2" {
name = "policy-2" name = "policy-2"
} }
` `

View File

@ -11,12 +11,12 @@ import (
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies" "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies"
) )
func resourceFWPolicyV2() *schema.Resource { func resourceFWPolicyV1() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
Create: resourceFirewallPolicyCreate, Create: resourceFWPolicyV1Create,
Read: resourceFirewallPolicyRead, Read: resourceFWPolicyV1Read,
Update: resourceFirewallPolicyUpdate, Update: resourceFWPolicyV1Update,
Delete: resourceFirewallPolicyDelete, Delete: resourceFWPolicyV1Delete,
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"region": &schema.Schema{ "region": &schema.Schema{
@ -60,7 +60,7 @@ func resourceFWPolicyV2() *schema.Resource {
} }
} }
func resourceFirewallPolicyCreate(d *schema.ResourceData, meta interface{}) error { func resourceFWPolicyV1Create(d *schema.ResourceData, meta interface{}) error {
// TODO To remove // TODO To remove
time.Sleep(time.Second * 5) time.Sleep(time.Second * 5)
@ -107,7 +107,7 @@ func resourceFirewallPolicyCreate(d *schema.ResourceData, meta interface{}) erro
return nil return nil
} }
func resourceFirewallPolicyRead(d *schema.ResourceData, meta interface{}) error { func resourceFWPolicyV1Read(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] Retrieve information about firewall policy: %s", d.Id()) log.Printf("[DEBUG] Retrieve information about firewall policy: %s", d.Id())
config := meta.(*Config) config := meta.(*Config)
@ -163,7 +163,7 @@ func resourceFirewallPolicyRead(d *schema.ResourceData, meta interface{}) error
return nil return nil
} }
func resourceFirewallPolicyUpdate(d *schema.ResourceData, meta interface{}) error { func resourceFWPolicyV1Update(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config) config := meta.(*Config)
networkingClient, err := config.networkingV2Client(d.Get("region").(string)) networkingClient, err := config.networkingV2Client(d.Get("region").(string))
@ -199,7 +199,7 @@ func resourceFirewallPolicyUpdate(d *schema.ResourceData, meta interface{}) erro
return policies.Update(networkingClient, d.Id(), opts).Err return policies.Update(networkingClient, d.Id(), opts).Err
} }
func resourceFirewallPolicyDelete(d *schema.ResourceData, meta interface{}) error { func resourceFWPolicyV1Delete(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] Destroy firewall policy: %s", d.Id()) log.Printf("[DEBUG] Destroy firewall policy: %s", d.Id())
config := meta.(*Config) config := meta.(*Config)

View File

@ -11,33 +11,33 @@ import (
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies" "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies"
) )
func TestAccOpenstackFirewallPolicy(t *testing.T) { func TestAccFWPolicyV1(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,
CheckDestroy: testAccCheckOpenstackFirewallPolicyDestroy, CheckDestroy: testAccCheckFWPolicyV1Destroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ resource.TestStep{
Config: testFirewallPolicyConfig, Config: testFirewallPolicyConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccCheckFirewallPolicyExists( testAccCheckFWPolicyV1Exists(
"openstack_fw_policy_v2.accept_test", "openstack_fw_policy_v1.accept_test",
"", "", 0), "", "", 0),
), ),
}, },
resource.TestStep{ resource.TestStep{
Config: testFirewallPolicyConfigAddRules, Config: testFirewallPolicyConfigAddRules,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccCheckFirewallPolicyExists( testAccCheckFWPolicyV1Exists(
"openstack_fw_policy_v2.accept_test", "openstack_fw_policy_v1.accept_test",
"accept_test", "terraform acceptance test", 2), "accept_test", "terraform acceptance test", 2),
), ),
}, },
resource.TestStep{ resource.TestStep{
Config: testFirewallPolicyUpdateDeleteRule, Config: testFirewallPolicyUpdateDeleteRule,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccCheckFirewallPolicyExists( testAccCheckFWPolicyV1Exists(
"openstack_fw_policy_v2.accept_test", "openstack_fw_policy_v1.accept_test",
"accept_test", "terraform acceptance test", 1), "accept_test", "terraform acceptance test", 1),
), ),
}, },
@ -45,7 +45,7 @@ func TestAccOpenstackFirewallPolicy(t *testing.T) {
}) })
} }
func testAccCheckOpenstackFirewallPolicyDestroy(s *terraform.State) error { func testAccCheckFWPolicyV1Destroy(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)
@ -53,7 +53,7 @@ func testAccCheckOpenstackFirewallPolicyDestroy(s *terraform.State) error {
return fmt.Errorf("(testAccCheckOpenstackFirewallPolicyDestroy) Error creating OpenStack networking client: %s", err) return fmt.Errorf("(testAccCheckOpenstackFirewallPolicyDestroy) Error creating OpenStack networking client: %s", err)
} }
for _, rs := range s.RootModule().Resources { for _, rs := range s.RootModule().Resources {
if rs.Type != "openstack_fw_policy_v2" { if rs.Type != "openstack_fw_policy_v1" {
continue continue
} }
_, err = policies.Get(networkingClient, rs.Primary.ID).Extract() _, err = policies.Get(networkingClient, rs.Primary.ID).Extract()
@ -68,7 +68,7 @@ func testAccCheckOpenstackFirewallPolicyDestroy(s *terraform.State) error {
return nil return nil
} }
func testAccCheckFirewallPolicyExists(n, name, description string, ruleCount int) resource.TestCheckFunc { func testAccCheckFWPolicyV1Exists(n, name, description string, ruleCount int) resource.TestCheckFunc {
return func(s *terraform.State) error { return func(s *terraform.State) error {
@ -123,42 +123,42 @@ func testAccCheckFirewallPolicyExists(n, name, description string, ruleCount int
} }
const testFirewallPolicyConfig = ` const testFirewallPolicyConfig = `
resource "openstack_fw_policy_v2" "accept_test" { resource "openstack_fw_policy_v1" "accept_test" {
} }
` `
const testFirewallPolicyConfigAddRules = ` const testFirewallPolicyConfigAddRules = `
resource "openstack_fw_policy_v2" "accept_test" { resource "openstack_fw_policy_v1" "accept_test" {
name = "accept_test" name = "accept_test"
description = "terraform acceptance test" description = "terraform acceptance test"
rules = [ rules = [
"${openstack_fw_rule_v2.accept_test_udp_deny.id}", "${openstack_fw_rule_v1.accept_test_udp_deny.id}",
"${openstack_fw_rule_v2.accept_test_tcp_allow.id}" "${openstack_fw_rule_v1.accept_test_tcp_allow.id}"
] ]
} }
resource "openstack_fw_rule_v2" "accept_test_tcp_allow" { resource "openstack_fw_rule_v1" "accept_test_tcp_allow" {
protocol = "tcp" protocol = "tcp"
action = "allow" action = "allow"
} }
resource "openstack_fw_rule_v2" "accept_test_udp_deny" { resource "openstack_fw_rule_v1" "accept_test_udp_deny" {
protocol = "udp" protocol = "udp"
action = "deny" action = "deny"
} }
` `
const testFirewallPolicyUpdateDeleteRule = ` const testFirewallPolicyUpdateDeleteRule = `
resource "openstack_fw_policy_v2" "accept_test" { resource "openstack_fw_policy_v1" "accept_test" {
name = "accept_test" name = "accept_test"
description = "terraform acceptance test" description = "terraform acceptance test"
rules = [ rules = [
"${openstack_fw_rule_v2.accept_test_udp_deny.id}" "${openstack_fw_rule_v1.accept_test_udp_deny.id}"
] ]
} }
resource "openstack_fw_rule_v2" "accept_test_udp_deny" { resource "openstack_fw_rule_v1" "accept_test_udp_deny" {
protocol = "udp" protocol = "udp"
action = "deny" action = "deny"
} }

View File

@ -10,12 +10,12 @@ import (
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules" "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules"
) )
func resourceFWRuleV2() *schema.Resource { func resourceFWRuleV1() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
Create: resourceFirewallRuleCreate, Create: resourceFWRuleV1Create,
Read: resourceFirewallRuleRead, Read: resourceFWRuleV1Read,
Update: resourceFirewallRuleUpdate, Update: resourceFWRuleV1Update,
Delete: resourceFirewallRuleDelete, Delete: resourceFWRuleV1Delete,
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"region": &schema.Schema{ "region": &schema.Schema{
@ -75,7 +75,7 @@ func resourceFWRuleV2() *schema.Resource {
} }
} }
func resourceFirewallRuleCreate(d *schema.ResourceData, meta interface{}) error { func resourceFWRuleV1Create(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config) config := meta.(*Config)
networkingClient, err := config.networkingV2Client(d.Get("region").(string)) networkingClient, err := config.networkingV2Client(d.Get("region").(string))
@ -114,7 +114,7 @@ func resourceFirewallRuleCreate(d *schema.ResourceData, meta interface{}) error
return nil return nil
} }
func resourceFirewallRuleRead(d *schema.ResourceData, meta interface{}) error { func resourceFWRuleV1Read(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] Retrieve information about firewall rule: %s", d.Id()) log.Printf("[DEBUG] Retrieve information about firewall rule: %s", d.Id())
config := meta.(*Config) config := meta.(*Config)
@ -191,7 +191,7 @@ func resourceFirewallRuleRead(d *schema.ResourceData, meta interface{}) error {
return nil return nil
} }
func resourceFirewallRuleUpdate(d *schema.ResourceData, meta interface{}) error { func resourceFWRuleV1Update(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config) config := meta.(*Config)
networkingClient, err := config.networkingV2Client(d.Get("region").(string)) networkingClient, err := config.networkingV2Client(d.Get("region").(string))
if err != nil { if err != nil {
@ -241,7 +241,7 @@ func resourceFirewallRuleUpdate(d *schema.ResourceData, meta interface{}) error
return rules.Update(networkingClient, d.Id(), opts).Err return rules.Update(networkingClient, d.Id(), opts).Err
} }
func resourceFirewallRuleDelete(d *schema.ResourceData, meta interface{}) error { func resourceFWRuleV1Delete(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] Destroy firewall rule: %s", d.Id()) log.Printf("[DEBUG] Destroy firewall rule: %s", d.Id())
config := meta.(*Config) config := meta.(*Config)

View File

@ -12,17 +12,17 @@ import (
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules" "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules"
) )
func TestAccOpenstackFirewallRule(t *testing.T) { func TestAccFWRuleV1(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,
CheckDestroy: testAccCheckOpenstackFirewallRuleDestroy, CheckDestroy: testAccCheckFWRuleV1Destroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ resource.TestStep{
Config: testFirewallRuleMinimalConfig, Config: testFirewallRuleMinimalConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccCheckFirewallRuleExists( testAccCheckFWRuleV1Exists(
"openstack_fw_rule_v2.accept_test_minimal", "openstack_fw_rule_v1.accept_test_minimal",
&rules.Rule{ &rules.Rule{
Protocol: "udp", Protocol: "udp",
Action: "deny", Action: "deny",
@ -34,8 +34,8 @@ func TestAccOpenstackFirewallRule(t *testing.T) {
resource.TestStep{ resource.TestStep{
Config: testFirewallRuleConfig, Config: testFirewallRuleConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccCheckFirewallRuleExists( testAccCheckFWRuleV1Exists(
"openstack_fw_rule_v2.accept_test", "openstack_fw_rule_v1.accept_test",
&rules.Rule{ &rules.Rule{
Name: "accept_test", Name: "accept_test",
Protocol: "udp", Protocol: "udp",
@ -53,8 +53,8 @@ func TestAccOpenstackFirewallRule(t *testing.T) {
resource.TestStep{ resource.TestStep{
Config: testFirewallRuleUpdateAllFieldsConfig, Config: testFirewallRuleUpdateAllFieldsConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccCheckFirewallRuleExists( testAccCheckFWRuleV1Exists(
"openstack_fw_rule_v2.accept_test", "openstack_fw_rule_v1.accept_test",
&rules.Rule{ &rules.Rule{
Name: "accept_test_updated_2", Name: "accept_test_updated_2",
Protocol: "tcp", Protocol: "tcp",
@ -73,7 +73,7 @@ func TestAccOpenstackFirewallRule(t *testing.T) {
}) })
} }
func testAccCheckOpenstackFirewallRuleDestroy(s *terraform.State) error { func testAccCheckFWRuleV1Destroy(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)
@ -96,7 +96,7 @@ func testAccCheckOpenstackFirewallRuleDestroy(s *terraform.State) error {
return nil return nil
} }
func testAccCheckFirewallRuleExists(n string, expected *rules.Rule) resource.TestCheckFunc { func testAccCheckFWRuleV1Exists(n string, expected *rules.Rule) resource.TestCheckFunc {
return func(s *terraform.State) error { return func(s *terraform.State) error {
@ -148,14 +148,14 @@ func testAccCheckFirewallRuleExists(n string, expected *rules.Rule) resource.Tes
} }
const testFirewallRuleMinimalConfig = ` const testFirewallRuleMinimalConfig = `
resource "openstack_fw_rule_v2" "accept_test_minimal" { resource "openstack_fw_rule_v1" "accept_test_minimal" {
protocol = "udp" protocol = "udp"
action = "deny" action = "deny"
} }
` `
const testFirewallRuleConfig = ` const testFirewallRuleConfig = `
resource "openstack_fw_rule_v2" "accept_test" { resource "openstack_fw_rule_v1" "accept_test" {
name = "accept_test" name = "accept_test"
description = "Terraform accept test" description = "Terraform accept test"
protocol = "udp" protocol = "udp"
@ -170,7 +170,7 @@ resource "openstack_fw_rule_v2" "accept_test" {
` `
const testFirewallRuleUpdateAllFieldsConfig = ` const testFirewallRuleUpdateAllFieldsConfig = `
resource "openstack_fw_rule_v2" "accept_test" { resource "openstack_fw_rule_v1" "accept_test" {
name = "accept_test_updated_2" name = "accept_test_updated_2"
description = "Terraform accept test updated" description = "Terraform accept test updated"
protocol = "tcp" protocol = "tcp"