Fix code regarding to the latest gophercloud code

This commit is contained in:
Guillaume Giamarchi 2015-02-17 22:07:01 +01:00 committed by Jon Perritt
parent cfd3329e00
commit d6733fb379
6 changed files with 30 additions and 37 deletions

View File

@ -8,7 +8,6 @@ import (
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/schema"
"github.com/racker/perigee"
"github.com/rackspace/gophercloud" "github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls" "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls"
) )
@ -114,7 +113,7 @@ func resourceFirewallRead(d *schema.ResourceData, meta interface{}) error {
firewall, err := firewalls.Get(networkingClient, d.Id()).Extract() firewall, err := firewalls.Get(networkingClient, d.Id()).Extract()
if err != nil { if err != nil {
httpError, ok := err.(*perigee.UnexpectedResponseCodeError) httpError, ok := err.(*gophercloud.UnexpectedResponseCodeError)
if !ok { if !ok {
return err return err
} }
@ -145,13 +144,11 @@ func resourceFirewallUpdate(d *schema.ResourceData, meta interface{}) error {
opts := firewalls.UpdateOpts{} opts := firewalls.UpdateOpts{}
if d.HasChange("name") { if d.HasChange("name") {
name := d.Get("name").(string) opts.Name = d.Get("name").(string)
opts.Name = &name
} }
if d.HasChange("description") { if d.HasChange("description") {
description := d.Get("description").(string) opts.Description = d.Get("description").(string)
opts.Description = &description
} }
if d.HasChange("policy_id") { if d.HasChange("policy_id") {
@ -227,7 +224,7 @@ func WaitForFirewallDeletion(networkingClient *gophercloud.ServiceClient, id str
log.Printf("[DEBUG] Get firewall %s => %#v", id, fw) log.Printf("[DEBUG] Get firewall %s => %#v", id, fw)
if err != nil { if err != nil {
httpStatus := err.(*perigee.UnexpectedResponseCodeError) httpStatus := err.(*gophercloud.UnexpectedResponseCodeError)
log.Printf("[DEBUG] Get firewall %s status is %d", id, httpStatus.Actual) log.Printf("[DEBUG] Get firewall %s status is %d", id, httpStatus.Actual)
if httpStatus.Actual == 404 { if httpStatus.Actual == 404 {

View File

@ -7,7 +7,7 @@ import (
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
"github.com/racker/perigee" "github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls" "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls"
) )
@ -51,7 +51,7 @@ func testAccCheckOpenstackFirewallDestroy(s *terraform.State) error {
if err == nil { if err == nil {
return fmt.Errorf("Firewall (%s) still exists.", rs.Primary.ID) return fmt.Errorf("Firewall (%s) still exists.", rs.Primary.ID)
} }
httpError, ok := err.(*perigee.UnexpectedResponseCodeError) httpError, ok := err.(*gophercloud.UnexpectedResponseCodeError)
if !ok || httpError.Actual != 404 { if !ok || httpError.Actual != 404 {
return httpError return httpError
} }
@ -84,7 +84,7 @@ func testAccCheckFirewallExists(n, expectedName, expectedDescription string, pol
// if we get a 404 error. Fail on any other error. // if we get a 404 error. Fail on any other error.
found, err = firewalls.Get(networkingClient, rs.Primary.ID).Extract() found, err = firewalls.Get(networkingClient, rs.Primary.ID).Extract()
if err != nil { if err != nil {
httpError, ok := err.(*perigee.UnexpectedResponseCodeError) httpError, ok := err.(*gophercloud.UnexpectedResponseCodeError)
if !ok || httpError.Actual != 404 { if !ok || httpError.Actual != 404 {
time.Sleep(time.Second) time.Sleep(time.Second)
continue continue

View File

@ -7,7 +7,7 @@ import (
"github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/schema"
"github.com/racker/perigee" "github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies" "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies"
) )
@ -119,7 +119,7 @@ func resourceFirewallPolicyRead(d *schema.ResourceData, meta interface{}) error
policy, err := policies.Get(networkingClient, d.Id()).Extract() policy, err := policies.Get(networkingClient, d.Id()).Extract()
if err != nil { if err != nil {
httpError, ok := err.(*perigee.UnexpectedResponseCodeError) httpError, ok := err.(*gophercloud.UnexpectedResponseCodeError)
if !ok { if !ok {
return err return err
} }
@ -150,13 +150,11 @@ func resourceFirewallPolicyUpdate(d *schema.ResourceData, meta interface{}) erro
opts := policies.UpdateOpts{} opts := policies.UpdateOpts{}
if d.HasChange("name") { if d.HasChange("name") {
name := d.Get("name").(string) opts.Name = d.Get("name").(string)
opts.Name = &name
} }
if d.HasChange("description") { if d.HasChange("description") {
description := d.Get("description").(string) opts.Description = d.Get("description").(string)
opts.Description = &description
} }
if d.HasChange("rules") { if d.HasChange("rules") {
@ -193,7 +191,7 @@ func resourceFirewallPolicyDelete(d *schema.ResourceData, meta interface{}) erro
break break
} }
httpError, ok := err.(*perigee.UnexpectedResponseCodeError) httpError, ok := err.(*gophercloud.UnexpectedResponseCodeError)
if !ok || httpError.Actual != 409 { if !ok || httpError.Actual != 409 {
return err return err
} }

View File

@ -8,7 +8,7 @@ import (
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
"github.com/racker/perigee" "github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies" "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies"
) )
@ -70,7 +70,7 @@ func testAccCheckOpenstackFirewallPolicyDestroy(s *terraform.State) error {
if err == nil { if err == nil {
return fmt.Errorf("Firewall policy (%s) still exists.", rs.Primary.ID) return fmt.Errorf("Firewall policy (%s) still exists.", rs.Primary.ID)
} }
httpError, ok := err.(*perigee.UnexpectedResponseCodeError) httpError, ok := err.(*gophercloud.UnexpectedResponseCodeError)
if !ok || httpError.Actual != 404 { if !ok || httpError.Actual != 404 {
return httpError return httpError
} }
@ -103,7 +103,7 @@ func testAccCheckFirewallPolicyExists(n string, expected *policies.Policy) resou
// if we get a 404 error. Fail on any other error. // if we get a 404 error. Fail on any other error.
found, err = policies.Get(networkingClient, rs.Primary.ID).Extract() found, err = policies.Get(networkingClient, rs.Primary.ID).Extract()
if err != nil { if err != nil {
httpError, ok := err.(*perigee.UnexpectedResponseCodeError) httpError, ok := err.(*gophercloud.UnexpectedResponseCodeError)
if !ok || httpError.Actual != 404 { if !ok || httpError.Actual != 404 {
time.Sleep(time.Second) time.Sleep(time.Second)
continue continue

View File

@ -5,7 +5,7 @@ import (
"log" "log"
"github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/schema"
"github.com/racker/perigee" "github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules" "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules"
) )
@ -137,7 +137,7 @@ func resourceFirewallRuleRead(d *schema.ResourceData, meta interface{}) error {
rule, err := rules.Get(networkingClient, d.Id()).Extract() rule, err := rules.Get(networkingClient, d.Id()).Extract()
if err != nil { if err != nil {
httpError, ok := err.(*perigee.UnexpectedResponseCodeError) httpError, ok := err.(*gophercloud.UnexpectedResponseCodeError)
if !ok { if !ok {
return err return err
} }
@ -172,12 +172,10 @@ func resourceFirewallRuleUpdate(d *schema.ResourceData, meta interface{}) error
opts := rules.UpdateOpts{} opts := rules.UpdateOpts{}
if d.HasChange("name") { if d.HasChange("name") {
name := d.Get("name").(string) opts.Name = d.Get("name").(string)
opts.Name = &name
} }
if d.HasChange("description") { if d.HasChange("description") {
description := d.Get("description").(string) opts.Description = d.Get("description").(string)
opts.Description = &description
} }
if d.HasChange("protocol") { if d.HasChange("protocol") {
opts.Protocol = d.Get("protocol").(string) opts.Protocol = d.Get("protocol").(string)

View File

@ -8,7 +8,7 @@ import (
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
"github.com/racker/perigee" "github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules" "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules"
) )
@ -88,7 +88,7 @@ func testAccCheckOpenstackFirewallRuleDestroy(s *terraform.State) error {
if err == nil { if err == nil {
return fmt.Errorf("Firewall rule (%s) still exists.", rs.Primary.ID) return fmt.Errorf("Firewall rule (%s) still exists.", rs.Primary.ID)
} }
httpError, ok := err.(*perigee.UnexpectedResponseCodeError) httpError, ok := err.(*gophercloud.UnexpectedResponseCodeError)
if !ok || httpError.Actual != 404 { if !ok || httpError.Actual != 404 {
return httpError return httpError
} }
@ -121,7 +121,7 @@ func testAccCheckFirewallRuleExists(n string, expected *rules.Rule) resource.Tes
// if we get a 404 error. Fail on any other error. // if we get a 404 error. Fail on any other error.
found, err = rules.Get(networkingClient, rs.Primary.ID).Extract() found, err = rules.Get(networkingClient, rs.Primary.ID).Extract()
if err != nil { if err != nil {
httpError, ok := err.(*perigee.UnexpectedResponseCodeError) httpError, ok := err.(*gophercloud.UnexpectedResponseCodeError)
if !ok || httpError.Actual != 404 { if !ok || httpError.Actual != 404 {
time.Sleep(time.Second) time.Sleep(time.Second)
continue continue