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

830 Brocade Virtual ADX XML API Programmer’s Guide
53-1003248-01
Example: Adding and binding a real server and a VIP
B
//Update the underlying file.
m_StreamWriter.Flush();
}
}
/////////////////////////////////////////////////////////////////////////////
// Name: Configure-SLB cmdlet
//
// Description: This cmdlet will be called when the user executes
Configure-SLB
// in powershell after loading the configureslb.dll. This cmdlet
// is used to configure the virtual server and real server and to
// bind the same
//
// Parameters: DeviceName - The IP Adress of the ADX Box
// UserName - The user name associated with the ADX Box
// Password - The password associated with the ADX Box
//
// How to call: PS> import-module .\ConfigureSLB.dll
// Configure-SLB -DeviceName <IP> -UserName <UserName> -Password <Password>
/////////////////////////////////////////////////////////////////////////////
[Cmdlet("Configure", "SLB")]
public class ConfigureADXSLB : PSCmdlet
{
#region Parameters
[Parameter(Mandatory = true, ValueFromPipeline = true)]
[ValidateNotNullOrEmpty]//validates for empty value
public string DeviceName;
[Parameter(Mandatory = true, ValueFromPipeline = true)]
public string UserName;
[Parameter(Mandatory = true, ValueFromPipeline = true)]
public string Password;
#endregion
protected override void ProcessRecord()
{
//Get the utils class object
Utils objUtils = ConfigureSLB.Utils.GetUtilsInstance();
try
{
//Open the log file to write
objUtils.OpenRCloseLog(true);
objUtils.WL("Configure 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("Configure SLB END", "");
//Close the log file
objUtils.OpenRCloseLog(false);
}
catch (Exception ex)
{
objUtils.WL("EXCEPTION Raised in Configure SLB", ex.Message);
//Close the log file
objUtils.OpenRCloseLog(false);
WriteObject(ex.Message);
}
}