Adding get vip operation
diff --git a/openstack/networking/v2/extensions/lbaas/vips/requests.go b/openstack/networking/v2/extensions/lbaas/vips/requests.go
index f325bce..a75f14f 100644
--- a/openstack/networking/v2/extensions/lbaas/vips/requests.go
+++ b/openstack/networking/v2/extensions/lbaas/vips/requests.go
@@ -226,3 +226,15 @@
return res
}
+
+// Get retrieves a particular virtual IP based on its unique ID.
+func Get(c *gophercloud.ServiceClient, id string) GetResult {
+ var res GetResult
+ _, err := perigee.Request("GET", resourceURL(c, id), perigee.Options{
+ MoreHeaders: c.Provider.AuthenticatedHeaders(),
+ Results: &res.Resp,
+ OkCodes: []int{200},
+ })
+ res.Err = err
+ return res
+}
diff --git a/openstack/networking/v2/extensions/lbaas/vips/requests_test.go b/openstack/networking/v2/extensions/lbaas/vips/requests_test.go
index 15e380f..5230eae 100644
--- a/openstack/networking/v2/extensions/lbaas/vips/requests_test.go
+++ b/openstack/networking/v2/extensions/lbaas/vips/requests_test.go
@@ -98,7 +98,7 @@
Protocol: "HTTP",
ProtocolPort: 80,
PoolID: "cfc6589d-f949-4c66-99d2-c2da56ef3764",
- //Persistence: SessionPersistence{},
+ Persistence: SessionPersistence{},
ConnLimit: 0,
AdminStateUp: true,
Status: "ACTIVE",
@@ -114,7 +114,7 @@
Protocol: "TCP",
ProtocolPort: 3306,
PoolID: "41efe233-7591-43c5-9cf7-923964759f9e",
- //Persistence: SessionPersistence{Type: "SOURCE_IP"},
+ Persistence: SessionPersistence{Type: "SOURCE_IP"},
ConnLimit: 2000,
AdminStateUp: true,
Status: "INACTIVE",
@@ -204,3 +204,50 @@
th.AssertEquals(t, "c987d2be-9a3c-4ac9-a046-e8716b1350e2", r.ID)
th.AssertEquals(t, "NewVip", r.Name)
}
+
+func TestGet(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+
+ th.Mux.HandleFunc("/v2.0/lb/vips/4ec89087-d057-4e2c-911f-60a3b47ee304", func(w http.ResponseWriter, r *http.Request) {
+ th.TestMethod(t, r, "GET")
+ th.TestHeader(t, r, "X-Auth-Token", tokenID)
+
+ w.Header().Add("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+
+ fmt.Fprintf(w, `
+{
+ "vip": {
+ "status": "ACTIVE",
+ "protocol": "HTTP",
+ "description": "",
+ "admin_state_up": true,
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "connection_limit": 1000,
+ "pool_id": "72741b06-df4d-4715-b142-276b6bce75ab",
+ "session_persistence": {
+ "cookie_name": "MyAppCookie",
+ "type": "APP_COOKIE"
+ },
+ "address": "10.0.0.10",
+ "protocol_port": 80,
+ "port_id": "b5a743d6-056b-468b-862d-fb13a9aa694e",
+ "id": "4ec89087-d057-4e2c-911f-60a3b47ee304",
+ "name": "my-vip"
+ }
+}
+ `)
+ })
+
+ vip, err := Get(serviceClient(), "4ec89087-d057-4e2c-911f-60a3b47ee304").Extract()
+ th.AssertNoErr(t, err)
+
+ th.AssertEquals(t, "ACTIVE", vip.Status)
+ th.AssertEquals(t, "HTTP", vip.Protocol)
+ th.AssertEquals(t, "", vip.Description)
+ th.AssertEquals(t, true, vip.AdminStateUp)
+ th.AssertEquals(t, 1000, vip.ConnLimit)
+ th.AssertEquals(t, SessionPersistence{Type: "APP_COOKIE", CookieName: "MyAppCookie"}, vip.Persistence)
+}
diff --git a/openstack/networking/v2/extensions/lbaas/vips/results.go b/openstack/networking/v2/extensions/lbaas/vips/results.go
index 5b2718d..62efe09 100644
--- a/openstack/networking/v2/extensions/lbaas/vips/results.go
+++ b/openstack/networking/v2/extensions/lbaas/vips/results.go
@@ -25,7 +25,10 @@
// same member of the pool.
type SessionPersistence struct {
// The type of persistence mode
- Type string
+ Type string `mapstructure:"type" json:"type"`
+
+ // Name of cookie if persistence mode is set appropriately
+ CookieName string `mapstructure:"cookie_name" json:"cookie_name"`
}
// VirtualIP is the primary load balancing configuration object that specifies
@@ -67,7 +70,7 @@
// Indicates whether connections in the same session will be processed by the
// same pool member or not.
- //Persistence SessionPersistence `mapstructure:"session_persistence" json:"session_persistence"`
+ Persistence SessionPersistence `mapstructure:"session_persistence" json:"session_persistence"`
// The maximum number of connections allowed for the VIP. Default is -1,
// meaning no limit.