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_secgroup_v2": resourceComputeSecGroupV2(),
"openstack_compute_floatingip_v2": resourceComputeFloatingIPV2(),
"openstack_fw_firewall_v2": resourceFWFirewallV2(),
"openstack_fw_policy_v2": resourceFWPolicyV2(),
"openstack_fw_rule_v2": resourceFWRuleV2(),
"openstack_fw_firewall_v1": resourceFWFirewallV1(),
"openstack_fw_policy_v1": resourceFWPolicyV1(),
"openstack_fw_rule_v1": resourceFWRuleV1(),
"openstack_lb_monitor_v1": resourceLBMonitorV1(),
"openstack_lb_pool_v1": resourceLBPoolV1(),
"openstack_lb_vip_v1": resourceLBVipV1(),

View File

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

View File

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

View File

@ -11,12 +11,12 @@ import (
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies"
)
func resourceFWPolicyV2() *schema.Resource {
func resourceFWPolicyV1() *schema.Resource {
return &schema.Resource{
Create: resourceFirewallPolicyCreate,
Read: resourceFirewallPolicyRead,
Update: resourceFirewallPolicyUpdate,
Delete: resourceFirewallPolicyDelete,
Create: resourceFWPolicyV1Create,
Read: resourceFWPolicyV1Read,
Update: resourceFWPolicyV1Update,
Delete: resourceFWPolicyV1Delete,
Schema: map[string]*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
time.Sleep(time.Second * 5)
@ -107,7 +107,7 @@ func resourceFirewallPolicyCreate(d *schema.ResourceData, meta interface{}) erro
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())
config := meta.(*Config)
@ -163,7 +163,7 @@ func resourceFirewallPolicyRead(d *schema.ResourceData, meta interface{}) error
return nil
}
func resourceFirewallPolicyUpdate(d *schema.ResourceData, meta interface{}) error {
func resourceFWPolicyV1Update(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
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
}
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())
config := meta.(*Config)

View File

@ -11,33 +11,33 @@ import (
"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{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckOpenstackFirewallPolicyDestroy,
CheckDestroy: testAccCheckFWPolicyV1Destroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testFirewallPolicyConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckFirewallPolicyExists(
"openstack_fw_policy_v2.accept_test",
testAccCheckFWPolicyV1Exists(
"openstack_fw_policy_v1.accept_test",
"", "", 0),
),
},
resource.TestStep{
Config: testFirewallPolicyConfigAddRules,
Check: resource.ComposeTestCheckFunc(
testAccCheckFirewallPolicyExists(
"openstack_fw_policy_v2.accept_test",
testAccCheckFWPolicyV1Exists(
"openstack_fw_policy_v1.accept_test",
"accept_test", "terraform acceptance test", 2),
),
},
resource.TestStep{
Config: testFirewallPolicyUpdateDeleteRule,
Check: resource.ComposeTestCheckFunc(
testAccCheckFirewallPolicyExists(
"openstack_fw_policy_v2.accept_test",
testAccCheckFWPolicyV1Exists(
"openstack_fw_policy_v1.accept_test",
"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)
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)
}
for _, rs := range s.RootModule().Resources {
if rs.Type != "openstack_fw_policy_v2" {
if rs.Type != "openstack_fw_policy_v1" {
continue
}
_, err = policies.Get(networkingClient, rs.Primary.ID).Extract()
@ -68,7 +68,7 @@ func testAccCheckOpenstackFirewallPolicyDestroy(s *terraform.State) error {
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 {
@ -123,42 +123,42 @@ func testAccCheckFirewallPolicyExists(n, name, description string, ruleCount int
}
const testFirewallPolicyConfig = `
resource "openstack_fw_policy_v2" "accept_test" {
resource "openstack_fw_policy_v1" "accept_test" {
}
`
const testFirewallPolicyConfigAddRules = `
resource "openstack_fw_policy_v2" "accept_test" {
resource "openstack_fw_policy_v1" "accept_test" {
name = "accept_test"
description = "terraform acceptance test"
rules = [
"${openstack_fw_rule_v2.accept_test_udp_deny.id}",
"${openstack_fw_rule_v2.accept_test_tcp_allow.id}"
"${openstack_fw_rule_v1.accept_test_udp_deny.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"
action = "allow"
}
resource "openstack_fw_rule_v2" "accept_test_udp_deny" {
resource "openstack_fw_rule_v1" "accept_test_udp_deny" {
protocol = "udp"
action = "deny"
}
`
const testFirewallPolicyUpdateDeleteRule = `
resource "openstack_fw_policy_v2" "accept_test" {
resource "openstack_fw_policy_v1" "accept_test" {
name = "accept_test"
description = "terraform acceptance test"
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"
action = "deny"
}

View File

@ -10,12 +10,12 @@ import (
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules"
)
func resourceFWRuleV2() *schema.Resource {
func resourceFWRuleV1() *schema.Resource {
return &schema.Resource{
Create: resourceFirewallRuleCreate,
Read: resourceFirewallRuleRead,
Update: resourceFirewallRuleUpdate,
Delete: resourceFirewallRuleDelete,
Create: resourceFWRuleV1Create,
Read: resourceFWRuleV1Read,
Update: resourceFWRuleV1Update,
Delete: resourceFWRuleV1Delete,
Schema: map[string]*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)
networkingClient, err := config.networkingV2Client(d.Get("region").(string))
@ -114,7 +114,7 @@ func resourceFirewallRuleCreate(d *schema.ResourceData, meta interface{}) error
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())
config := meta.(*Config)
@ -191,7 +191,7 @@ func resourceFirewallRuleRead(d *schema.ResourceData, meta interface{}) error {
return nil
}
func resourceFirewallRuleUpdate(d *schema.ResourceData, meta interface{}) error {
func resourceFWRuleV1Update(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := config.networkingV2Client(d.Get("region").(string))
if err != nil {
@ -241,7 +241,7 @@ func resourceFirewallRuleUpdate(d *schema.ResourceData, meta interface{}) error
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())
config := meta.(*Config)

View File

@ -12,17 +12,17 @@ import (
"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{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckOpenstackFirewallRuleDestroy,
CheckDestroy: testAccCheckFWRuleV1Destroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testFirewallRuleMinimalConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckFirewallRuleExists(
"openstack_fw_rule_v2.accept_test_minimal",
testAccCheckFWRuleV1Exists(
"openstack_fw_rule_v1.accept_test_minimal",
&rules.Rule{
Protocol: "udp",
Action: "deny",
@ -34,8 +34,8 @@ func TestAccOpenstackFirewallRule(t *testing.T) {
resource.TestStep{
Config: testFirewallRuleConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckFirewallRuleExists(
"openstack_fw_rule_v2.accept_test",
testAccCheckFWRuleV1Exists(
"openstack_fw_rule_v1.accept_test",
&rules.Rule{
Name: "accept_test",
Protocol: "udp",
@ -53,8 +53,8 @@ func TestAccOpenstackFirewallRule(t *testing.T) {
resource.TestStep{
Config: testFirewallRuleUpdateAllFieldsConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckFirewallRuleExists(
"openstack_fw_rule_v2.accept_test",
testAccCheckFWRuleV1Exists(
"openstack_fw_rule_v1.accept_test",
&rules.Rule{
Name: "accept_test_updated_2",
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)
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
@ -96,7 +96,7 @@ func testAccCheckOpenstackFirewallRuleDestroy(s *terraform.State) error {
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 {
@ -148,14 +148,14 @@ func testAccCheckFirewallRuleExists(n string, expected *rules.Rule) resource.Tes
}
const testFirewallRuleMinimalConfig = `
resource "openstack_fw_rule_v2" "accept_test_minimal" {
resource "openstack_fw_rule_v1" "accept_test_minimal" {
protocol = "udp"
action = "deny"
}
`
const testFirewallRuleConfig = `
resource "openstack_fw_rule_v2" "accept_test" {
resource "openstack_fw_rule_v1" "accept_test" {
name = "accept_test"
description = "Terraform accept test"
protocol = "udp"
@ -170,7 +170,7 @@ resource "openstack_fw_rule_v2" "accept_test" {
`
const testFirewallRuleUpdateAllFieldsConfig = `
resource "openstack_fw_rule_v2" "accept_test" {
resource "openstack_fw_rule_v1" "accept_test" {
name = "accept_test_updated_2"
description = "Terraform accept test updated"
protocol = "tcp"