Diagnostic Script for High Bandwidth VM Migration Write Action Type PRO

Emulex.Pro.DiagnosticPSScriptForHighIoVMMigrationWATypePRO (WriteActionModuleType)

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
InputTypeSystem.BaseData
OutputTypeSystem.CommandOutput

Member Modules:

ID Module Type TypeId RunAs 
Emulex.Pro.MigrateVMWAForDiagnosticPRO WriteAction System.CommandExecuter Default

Overrideable Parameters:

IDParameterTypeSelector
EventDescriptionstring$Config/EventDescription$

Source Code:

<WriteActionModuleType ID="Emulex.Pro.DiagnosticPSScriptForHighIoVMMigrationWATypePRO" Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element minOccurs="1" name="EventDescription" type="xsd:string"/>
<xsd:element minOccurs="1" name="ActionDetails" type="xsd:string"/>
<xsd:element minOccurs="1" name="ActionScript" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="EventDescription" Selector="$Config/EventDescription$" ParameterType="string"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<WriteAction ID="Emulex.Pro.MigrateVMWAForDiagnosticPRO" TypeID="System!System.CommandExecuter">
<ApplicationName>%SystemRoot%\system32\windowspowershell\v1.0\powershell.exe</ApplicationName>
<WorkingDirectory/>
<CommandLine>-Command "&amp; {.\DiagnosticPSScriptForHighIoVMMigration.ps1 '$Config/EventDescription$'}"</CommandLine>
<TimeoutSeconds>86400</TimeoutSeconds>
<RequireOutput>false</RequireOutput>
<Files>
<File>
<Name>DiagnosticPSScriptForHighIoVMMigration.ps1</Name>
<Contents><Script>

$eventContent = $args[0];
$eventContent = $eventContent.Split(':');

if ($eventContent.Count -Lt 4) {
$debugMessage = 'Invalid number of parameters are passed to the script. Number of Parameters passed: ' + $eventContent.Count;
eventcreate /T Error /ID 100 /L APPLICATION /SO VmmPro /D $debugMessage;
return;
}

$strHostName = $eventContent[$eventContent.Count - 4].Replace('\n','').Trim();
$strServerName = $eventContent[$eventContent.Count - 3].Trim();
$strProtipId = $eventContent[$eventContent.Count - 2].Trim();
$strVmErrorCode = $eventContent[$eventContent.Count - 1].Trim()[0];

$debugMessage = 'Starting Diagnostic Task execution. Parameters passed: Host Name: ' + $strHostName + ', Server Name: ' + `
$strServerName + ', Tip Id : ' + $strProtipId + ', VM Error Code: ' + $strVmErrorCode

eventcreate /T Information /ID 100 /L APPLICATION /SO VmmPro /D $debugMessage;

$Error.Clear();
$VmmSnapinName = "Microsoft.SystemCenter.VirtualMachineManager"
$AllPsSnapins = Get-PSSnapin | Where-Object { $_.Name -eq $VmmSnapinName }
if ($AllPsSnapins -eq $null) {
add-pssnapin -name $VmmSnapinName;
}

if( $Error.Count -ne 0 ) { eventcreate /T Error /ID 111 /L APPLICATION /SO VmmPro /D $Error[0]; return; }

# Begin ActionScript
$strActionScript = ""

# End ActionScript

$strActionDetails = 'The PRO Tip implementation will migrate the VM (Virtual Machine) with the highest I/O utilization to another host in the host group to reduce the I/O load and improve performance on the affected server.'

function Main {
$Error.Clear();
$serverObj = get-vmmserver -computerName $strServerName
if( $Error.Count -ne 0 ) { eventcreate /T Error /ID 111 /L APPLICATION /SO VmmPro /D $Error[0]; return; }

# Set-PROTip -PROTipId $strProtipId -ActionScript -ActionDetails $strActionDetails;
}

Main;
</Script></Contents>
<Unicode>true</Unicode>
</File>
</Files>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="Emulex.Pro.MigrateVMWAForDiagnosticPRO"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.CommandOutput</OutputType>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>