Fix Floating IP Disassociation (#103)
This commit fixes floating IP disassociation by changing the PortID to a
string pointer rather than a string. This allows a value of "null" to be
passed which is what the Networking API is looking for.
diff --git a/acceptance/openstack/networking/v2/networking.go b/acceptance/openstack/networking/v2/networking.go
index 86c3545..9432dda 100644
--- a/acceptance/openstack/networking/v2/networking.go
+++ b/acceptance/openstack/networking/v2/networking.go
@@ -42,7 +42,7 @@
createOpts := ports.CreateOpts{
NetworkID: networkID,
Name: portName,
- AdminStateUp: gophercloud.Disabled,
+ AdminStateUp: gophercloud.Enabled,
FixedIPs: []ports.IP{ports.IP{SubnetID: subnetID}},
}
@@ -51,9 +51,18 @@
return port, err
}
+ if err := WaitForPortToCreate(client, port.ID, 60); err != nil {
+ return port, err
+ }
+
+ newPort, err := ports.Get(client, port.ID).Extract()
+ if err != nil {
+ return newPort, err
+ }
+
t.Logf("Successfully created port: %s", portName)
- return port, nil
+ return newPort, nil
}
// CreateSubnet will create a subnet on the specified Network ID. An error
@@ -180,3 +189,18 @@
t.Logf("Name: %s", versionResource.Name)
t.Logf("Collection: %s", versionResource.Collection)
}
+
+func WaitForPortToCreate(client *gophercloud.ServiceClient, portID string, secs int) error {
+ return gophercloud.WaitFor(secs, func() (bool, error) {
+ p, err := ports.Get(client, portID).Extract()
+ if err != nil {
+ return false, err
+ }
+
+ if p.Status == "ACTIVE" || p.Status == "DOWN" {
+ return true, nil
+ }
+
+ return false, nil
+ })
+}