DataONTAP.Cluster.AddModifyRemove.WriteActionModuleType (WriteActionModuleType)

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityInternal
RunAsDataONTAP.SecureReference.RunAsProfile
InputTypeSystem.BaseData

Member Modules:

ID Module Type TypeId RunAs 
WA WriteAction Microsoft.Windows.PowerShellWriteAction Default

Overrideable Parameters:

IDParameterTypeSelector
VserverListstring$Config/VserverList$
TimeoutSecondsint$Config/TimeoutSeconds$

Source Code:

<WriteActionModuleType ID="DataONTAP.Cluster.AddModifyRemove.WriteActionModuleType" Accessibility="Internal" Batching="false" RunAs="DS!DataONTAP.SecureReference.RunAsProfile">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="MonitoringMethodName" type="xsd:string" minOccurs="1"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="VserverList" type="xsd:string" minOccurs="1"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeoutSeconds" type="xsd:integer" minOccurs="1"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="StrictErrorHandling" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="VserverList" Selector="$Config/VserverList$" ParameterType="string"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<WriteAction ID="WA" TypeID="Windows!Microsoft.Windows.PowerShellWriteAction">
<!-- ScriptName specifies the name of the script. -->
<ScriptName>TriggerDiscovery.ps1</ScriptName>
<!-- ScriptBody is the text of the script. -->
<ScriptBody><Script>##############################################################################
# Copyright (c) 2013 NetApp.
#
# TriggerDiscovery.ps1
#
# This script to run clustered storage discovery.
#
##############################################################################
param($MonitoringMethodName, $VserverList)

##############################################################################
#Script utilities
function GetInstallPath
{
$netappRegPath = "HKLM:\SOFTWARE\NetApp\OnCommand\MS_Plugin"
$ibmRegPath = "HKLM:\SOFTWARE\IBM\OnCommand\MS_Plugin"

if (Test-Path -path $netappRegPath)
{
# Check for the registry key value of the install location for NetApp
$key = get-itemproperty $netappRegPath
}
elseif (Test-Path -path $ibmRegPath)
{
# Check for IBM registry key since can't find NetApp
$key= get-itemproperty $ibmRegPath
}
else
{
throw ("OnCommand Plug-in for Microsoft is not installed on " + $env:COMPUTERNAME + "`r`n")
}

return $key.InstallPath
}

function CreateAppDomain
{
$setup = [AppDomain]::CurrentDomain.SetupInformation;
$setup.ShadowCopyFiles = $true
return [AppDomain]::CreateDomain("OC.Cluster.OM.Powershell.NonDefaultAppDomain",
$null,
$setup);
}

function InvokeMethodInAppDomain([AppDomain]$appDomain,
[string]$assemblyPath,
[string]$typename,
[array]$contructorParameters,
[string]$methodName,
[array]$methodParameters)
{
#In SCOM a Powershell script is executed in a MonitoringHost.exe process.
#Lifetime of a MonitoringHost.exe is not controlled by us and it continues to run after the script is done, possibly
#running other scripts or the same script again. A script is executed in a default AppDomain (by SCOM design) and
#as a result any assemblies loaded by script can not be unloaded because the defualt AppDomain can not be unloaded.
#Impossibility of unloading an assembly becomes a problem when then the assembly DLL is being updated
#(i.e. during an istallation), the problem is that even after the assembly DLL is updated,
#the new assembly code is not loaded if the assembly is already loaded.
#The solution for this problem is to load an assembly to a non-default domain which can be unloaded when the script is done.

#The OC.Cluster.OM.AppDomainInvoker assembly has to be in the GAC
$AppDomainInvokerAssembly = [System.Reflection.Assembly]::LoadWithPartialName('OC.Cluster.OM.AppDomainInvoker')

$result = [OC.Cluster.OM.AppDomainInvoker.AppDomainInvoker]::InvokeMethod($appDomain,
$assemblyPath,
$typename,
$contructorParameters,
$methodName,
$methodParameters)

return $result
}
##############################################################################

import-module operationsmanager

$Error.Clear();

$scriptName = "TriggerDiscovery.ps1"

try
{
$api = new-object -comObject 'MOM.ScriptAPI'

$api.LogScriptEvent($scriptName, 2100, 0, "Starting Cluster Data ONTAP discovery after adding/modifying storage system(s)")

$nonDefaultAppDomain = CreateAppDomain

$installPath = GetInstallPath

$discoveryOutput = InvokeMethodInAppDomain $nonDefaultAppDomain `
(Join-Path $installPath 'OC.Cluster.OM.Server.dll') `
"OC.Cluster.OM.Server.Discovery.StorageDiscovery" `
@("localhost") `
$MonitoringMethodName `
@($VserverList)

#write the discovery ouput to the script output
$discoveryOutput

$api.LogScriptEvent($scriptName, 2101, 0, "Clustered Data ONTAP discovery succeeded after adding/modifying storage system(s).`r`n" + $discoveryOutput)
}
catch
{
if ($api)
{
$api.LogScriptEvent($scriptName, 2102, 1, "Clustered Data ONTAP discovery failed after adding/modifying storage system(s).`r`n" + $Error)
}

#throw the current error so that it will be displayed in the SCOM task output and status of the task will be set as failed
throw
}
finally
{
if ($nonDefaultAppDomain)
{
[AppDomain]::Unload($nonDefaultAppDomain)
$nonDefaultAppDomain = $null
}
}

</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>MonitoringMethodName</Name>
<Value>$Config/MonitoringMethodName$</Value>
</Parameter>
<Parameter>
<Name>VserverList</Name>
<Value>"$Config/VserverList$"</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>1800</TimeoutSeconds>
<StrictErrorHandling>false</StrictErrorHandling>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="WA"/>
</Composition>
</Composite>
</ModuleImplementation>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>