Brocade Virtual ADX XML API Programmer’s Guide (Supporting ADX v03.1.00) User Manual

Page 851

Advertising
background image

Brocade Virtual ADX XML API Programmer’s Guide

841

53-1003248-01

Example - Provisioning real and virtual servers

B

//Open the log file to write

objUtils.OpenRCloseLog(true);

objUtils.WL("Provisioning SLB START", "");

objUtils.WL("Establishing connection with ", DeviceName);

//Create the connection object and set the username and password

associated to it

objUtils.OpenConnection(ref DeviceName, ref UserName, ref

Password);

//Configure the virtual server and real server

ConfigureLoadBalancing();

objUtils.WL("Provisioning SLB END", "");

//Close the log file

objUtils.OpenRCloseLog(false);

}

catch (Exception ex)

{

objUtils.WL("EXCEPTION Raised in Provisioning SLB", ex.Message);

//Close the log file

objUtils.OpenRCloseLog(false);

WriteObject(ex.Message);

}

}

/////////////////////////////////////////////////////////////////////////////

// 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 = Provisioning.Utils.GetUtilsInstance();

ServerPort objVirtualServerPort = null;

ServerPort[] objRealServerPorts = null;

//Creates the virtual server and virtual server port

objVirtualServerPort = CreateVirtualServer();

//Creates the real server and real server port

objRealServerPorts = CreateRealServers();

WriteObject("Binding real server port with virtual server port...");

//Bind the realserver port with virtualserver port

objUtils.GetSLBObject().bindRealServerPortsToVipPort(objVirtualServerPort,

objRealServerPorts);

objUtils.WL("Virtual server and RealServer has been configured

successfully", "");

//To disable the seletected real server

DisableRealServer();

//To delete all or selected real server

DeleteRealServer();

WriteObject("\r\nDo you want to save the configuration(y/n):");

sSaveConfig = Console.ReadLine();

if (sSaveConfig == "y" || sSaveConfig == "Y")

{

Advertising