on 05-May-2015 06:57
Problem this snippet solves:
If you like coding in Go (as I love to do), here's a package that leverages the REST API to allow you to manage (create, modify, delete, etc.) pools, nodes, virtual servers, routes, self IP's, vlans, interfaces, trunks, route domains, etc.
The official documentation can be found here.
Here's a blog post that goes into more detailed examples.
How to use this snippet:
The example below is a small example of how to create and manage nodes, pools, and virtual servers.
Code :
package main import ( "github.com/scottdware/go-bigip" ) func main() { f5 := bigip.NewSession("f5.company.com", "admin", "secret") // Node creation f5.CreateNode("web-server1", "10.5.1.10") f5.CreateNode("web-server2", "10.5.1.11") f5.CreateNode("web-server3", "10.5.1.12") // Create our pool f5.CreatePool("web_443_pool") // Add members to our pool f5.AddPoolMember("web_443_pool", "web-server1:443") f5.AddPoolMember("web_443_pool", "web-server2:443") f5.AddPoolMember("web_443_pool", "web-server3:443") // Take our #3 web server offline (disable) f5.PoolMemberStatus("web_443_pool", "web-server3:443", "disable") // Create a virtual server using the above pool // The second parameter is our destination, and the third is the mask. You can use CIDR notation if you wish (as shown here) f5.CreateVirtualServer("web_443", "0.0.0.0", "0", "web_443_pool", 443) // Take the #3 web server offline for all pools f5.NodeStatus("web-server3", "disable") // Remove the server from our pool f5.DeletePoolMember("web_443_pool", "web-server3:443") }