Allow finding load balancer node by IP and Port
diff --git a/rackspace/lb/v1/nodes/requests.go b/rackspace/lb/v1/nodes/requests.go
index dc2d46c..939cc3e 100644
--- a/rackspace/lb/v1/nodes/requests.go
+++ b/rackspace/lb/v1/nodes/requests.go
@@ -249,3 +249,36 @@
return NodeEventPage{pagination.SinglePageBase(r)}
})
}
+
+// FindNodeByIPPort locates a load balancer node by IP and port.
+func FindNodeByIPPort(
+ client *gophercloud.ServiceClient,
+ loadBalancerID int,
+ address string,
+ port int,
+) (*Node, error) {
+
+ // nil until found
+ var found *Node
+
+ List(client, loadBalancerID, nil).EachPage(func(page pagination.Page) (bool, error) {
+ lbNodes, err := ExtractNodes(page)
+ if err != nil {
+ return false, err
+ }
+
+ for _, trialNode := range lbNodes {
+ if trialNode.Address == address && trialNode.Port == port {
+ found = &trialNode
+ return false, nil
+ }
+
+ }
+
+ return true, nil
+ })
+
+ // TODO: When found is nil, return an error
+
+ return found, nil
+}