Adds Fixed IP support to os-floating-ips
This commit enables the ability to specify a fixed IP when associating a
floating IP to an instance. If a fixed IP is not specified, Nova will
attempt to associate the floating IP to the first detected fixed IP, as it
did prior to this patch.
diff --git a/openstack/compute/v2/extensions/floatingip/requests_test.go b/openstack/compute/v2/extensions/floatingip/requests_test.go
index ed2460e..b92496b 100644
--- a/openstack/compute/v2/extensions/floatingip/requests_test.go
+++ b/openstack/compute/v2/extensions/floatingip/requests_test.go
@@ -57,7 +57,7 @@
th.AssertNoErr(t, err)
}
-func TestAssociate(t *testing.T) {
+func TestAssociateDeprecated(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleAssociateSuccessfully(t)
@@ -68,7 +68,36 @@
th.AssertNoErr(t, err)
}
-func TestDisassociate(t *testing.T) {
+func TestAssociate(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ HandleAssociateSuccessfully(t)
+
+ associateOpts := AssociateOpts{
+ ServerID: "4d8c3732-a248-40ed-bebc-539a6ffd25c0",
+ FloatingIP: "10.10.10.2",
+ }
+
+ err := AssociateFloatingIP(client.ServiceClient(), associateOpts).ExtractErr()
+ th.AssertNoErr(t, err)
+}
+
+func TestAssociateFixed(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ HandleAssociateFixedSuccessfully(t)
+
+ associateOpts := AssociateOpts{
+ ServerID: "4d8c3732-a248-40ed-bebc-539a6ffd25c0",
+ FloatingIP: "10.10.10.2",
+ FixedIP: "166.78.185.201",
+ }
+
+ err := AssociateFloatingIP(client.ServiceClient(), associateOpts).ExtractErr()
+ th.AssertNoErr(t, err)
+}
+
+func TestDisassociateDeprecated(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleDisassociateSuccessfully(t)
@@ -78,3 +107,17 @@
err := Disassociate(client.ServiceClient(), serverId, fip).ExtractErr()
th.AssertNoErr(t, err)
}
+
+func TestDisassociateFloatingIP(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ HandleDisassociateSuccessfully(t)
+
+ associateOpts := AssociateOpts{
+ ServerID: "4d8c3732-a248-40ed-bebc-539a6ffd25c0",
+ FloatingIP: "10.10.10.2",
+ }
+
+ err := DisassociateFloatingIP(client.ServiceClient(), associateOpts).ExtractErr()
+ th.AssertNoErr(t, err)
+}