Forum Discussion
hassar10_35518
Nimbostratus
Feb 27, 2008console app
Sorry to bother you again, BUT I was wondering if one could guide on how to do
A console application (.NET), which will take two parameters, pool name and array of node list and then add those nodes to the given pool
Is this do able using F5 SDK
2 Replies
- To build a console app, do the following:
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace cstest { class Program { public iControl.Interfaces m_interfaces = new iControl.Interfaces(); public string m_bigip = null; public long m_port = 443; public string m_user = null; public string m_pass = null; public bool Run(string[] args) { bool bSuccess = false; if (args.Length > 3) { m_bigip = args[0]; m_user = args[1]; m_pass = args[2]; bSuccess = m_interfaces.initialize(m_bigip, m_user, m_pass); } if (bSuccess) { if (args.Length > 5) { String pool = args[3]; String[] members = new string[args.Length - 4]; for (int i = 4; i < args.Length; i++) { members[i - 4] = args[ i ]; } bSuccess = addMembersToPool(pool, members); } } return bSuccess; } public bool addMembersToPool(string pool, string[] members) { bool bSuccess = false; iControl.CommonIPPortDefinition[] member_defs = new iControl.CommonIPPortDefinition[members.Length]; for(int i=0; i { String [] seps = members[ i ].Split(new char [] {':'}); member_defs[ i ] = new iControl.CommonIPPortDefinition(); member_defs[ i ].address = seps[ 0 ]; member_defs[ i ].port = Convert.ToInt32(seps[ 1 ]); } iControl.CommonIPPortDefinition [][] member_def_lists = new iControl.CommonIPPortDefinition[ 1 ][]; member_def_lists[ 0 ] = member_defs; try { m_interfaces.LocalLBPool.add_member( new string [] {pool}, member_def_lists); bSuccess = true; } catch(Exception ex) { Console.WriteLine(ex.Message.ToString()); } return bSuccess; } static void Main(string[] args) { Program p = new Program(); p.Run(args); } } }
- JRahm
Admin
BTW, the args.Length should be greater than 4 not 5. Otherwise you'd need at least two pool members for the update.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects