Programmer's Guide (Supporting ADX v03.1.00) Manual

Brocade Virtual ADX XML API Programmer’s Guide 831
53-1003248-01
Example: Adding and binding a real server and a VIP
B
/////////////////////////////////////////////////////////////////////////////
// Name: ConfigureLoadBalancing
//
// Description: This function create the virtual server and real server and
binds the same
// as per the input given by the user
//
// Parameters: -
//
/////////////////////////////////////////////////////////////////////////////
public void ConfigureLoadBalancing()
{
string sSaveConfig = null;
//Get the utils class object
Utils objUtils = ConfigureSLB.Utils.GetUtilsInstance();
ServerPort objVirtualServerPort = null;
ServerPort objRealServerPort = null;
//Creates the virtual server and virtual server port
objVirtualServerPort = CreateVirtualServer();
//Creates the real server and real server port
objRealServerPort = CreateRealServer();
WriteObject("Binding real server port with virtual server port...");
//Bind the realserver port with virtualserver port
objUtils.GetSLBObject().bindRealServerPortToVipPort(objVirtualServerPort,
objRealServerPort);
objUtils.WL("Virtual server and RealServer has been configured
successfully", "");
WriteObject("\r\nDo you want to save the configuration(y/n):");
sSaveConfig = Console.ReadLine();
if (sSaveConfig == "y" || sSaveConfig == "Y")
{
objUtils.GetSYSObject().writeConfig();
}
WriteObject("\r\nVirtual server and RealServer has been configured
successfully\r\n");
}
/////////////////////////////////////////////////////////////////////////////
// Name: CreateVirtualServer
//
// Description: This function creates the virtual server and virtual
server port
// by calling the appropriate WSDL API
//
// Parameters: -
//
/////////////////////////////////////////////////////////////////////////////
public ServerPort CreateVirtualServer()
{
//Gets the utils object
Utils objUtils = ConfigureSLB.Utils.GetUtilsInstance();
string sVIPName, sVIPAddress, sVIPPort;
WriteObject("\nSpecify inputs for creating virtual server: ");
WriteObject("\r\nEnter the VIP Name:");
sVIPName = Console.ReadLine();
WriteObject("\r\nEnter the VIP Address:");