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

840 Brocade Virtual ADX XML API Programmer’s Guide
53-1003248-01
Example - Provisioning real and virtual servers
B
/////////////////////////////////////////////////////////////////////////////
// Name: WL
//
// Description: This function to write the log message to the file.
//
// Parameters: sLogMessage - the log message to be written to the log file.
//
/////////////////////////////////////////////////////////////////////////////
public void WL(string sLogMessage, string sLogMessage1)
{
if (m_StreamWriter == null)
{
//Do not write the log if the log file is not opened
if (false == OpenRCloseLog(true))
return;
}
m_StreamWriter.Write("\r\n");
m_StreamWriter.WriteLine("{0}: --{1} {2}--", DateTime.Now,
sLogMessage, sLogMessage1);
//Update the underlying file.
m_StreamWriter.Flush();
}
}
/////////////////////////////////////////////////////////////////////////////
// Name: Provision-SLB cmdlet
//
// Description: This cmdlet will be called when the user executes
Provision-SLB
// in powershell after loading the Provisioning.dll. This cmdlet
// is used to configure the virtual server and add multiple real server
// along with setting common parameters to all realservers and to
// bind the same with the real server
//
// 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 .\Provisioning.dll
// Provision-SLB -DeviceName <IP> -UserName <UserName> -Password <Password>
/////////////////////////////////////////////////////////////////////////////
[Cmdlet("Provision", "SLB")]
public class ProvisionSLB : 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 = Provisioning.Utils.GetUtilsInstance();
try
{