Fix null pointer error and FloatingIp struct tag.
diff --git a/floating_ips.go b/floating_ips.go
index 4c27347..1163667 100644
--- a/floating_ips.go
+++ b/floating_ips.go
@@ -1,6 +1,7 @@
package gophercloud
import (
+ "errors"
"fmt"
"github.com/racker/perigee"
)
@@ -24,7 +25,7 @@
}
func (gsp *genericServersProvider) CreateFloatingIp(pool string) (FloatingIp, error) {
- var fip *FloatingIp
+ fip := new(FloatingIp)
err := gsp.context.WithReauth(gsp.access, func() error {
url := gsp.endpoint + "/os-floating-ips"
@@ -42,6 +43,10 @@
})
})
+ if fip.Ip == "" {
+ return *fip, errors.New("Error creating floating IP")
+ }
+
return *fip, err
}
@@ -63,7 +68,7 @@
func (gsp *genericServersProvider) DeleteFloatingIp(ip FloatingIp) error {
return gsp.context.WithReauth(gsp.access, func() error {
- ep := fmt.Sprintf("%s/os-floating-ips/%s", gsp.endpoint, ip.Id)
+ ep := fmt.Sprintf("%s/os-floating-ips/%d", gsp.endpoint, ip.Id)
return perigee.Delete(ep, perigee.Options{
CustomClient: gsp.context.httpClient,
MoreHeaders: map[string]string{
@@ -75,7 +80,7 @@
}
type FloatingIp struct {
- Id string `json:"id"`
+ Id int `json:"id"`
Pool string `json:"pool"`
Ip string `json:"ip"`
FixedIp string `json:"fixed_ip"`