From f11d3795de12e8c63f4be600f63616f456a031cc Mon Sep 17 00:00:00 2001 From: Bill Hurt Date: Sat, 25 Apr 2020 05:49:59 -0700 Subject: [PATCH] Implement embedded instance strategy --- .../DSC_xServiceResource/DSC_xServiceResource.psm1 | 10 +++++----- .../DSC_xServiceResource.schema.mof | 11 +++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/source/DSCResources/DSC_xServiceResource/DSC_xServiceResource.psm1 b/source/DSCResources/DSC_xServiceResource/DSC_xServiceResource.psm1 index 7650039c5..b20c95c9a 100644 --- a/source/DSCResources/DSC_xServiceResource/DSC_xServiceResource.psm1 +++ b/source/DSCResources/DSC_xServiceResource/DSC_xServiceResource.psm1 @@ -315,7 +315,7 @@ function Set-TargetResource $FailureCommand, [Parameter()] - [System.Object[]] + [Microsoft.Management.Infrastructure.CimInstance[]] $FailureActionsCollection, [Parameter()] @@ -600,7 +600,7 @@ function Test-TargetResource $FailureCommand, [Parameter()] - [System.Object[]] + [Microsoft.Management.Infrastructure.CimInstance[]] $FailureActionsCollection, [Parameter()] @@ -1835,7 +1835,7 @@ function Set-ServiceProperty $FailureCommand, [Parameter()] - [System.Object[]] + [Microsoft.Management.Infrastructure.CimInstance[]] $FailureActionsCollection, [Parameter()] @@ -2349,7 +2349,7 @@ function Set-ServiceFailureActionProperty { $FailureCommand, [Parameter()] - [System.Object[]] + [Microsoft.Management.Infrastructure.CimInstance[]] $FailureActionsCollection, [Parameter()] @@ -2433,7 +2433,7 @@ function Set-ServiceFailureActionProperty { # Iterate over the actions and their properties to add the integers that they encode to the array. foreach ($action in $failureActions.ActionsCollection) { - $integerData.add($action.type) | Out-Null + $integerData.add([ACTION_TYPE]$action.type) | Out-Null $integerData.add($action.delaySeconds) | Out-Null } diff --git a/source/DSCResources/DSC_xServiceResource/DSC_xServiceResource.schema.mof b/source/DSCResources/DSC_xServiceResource/DSC_xServiceResource.schema.mof index 2876dbea2..d409201f2 100644 --- a/source/DSCResources/DSC_xServiceResource/DSC_xServiceResource.schema.mof +++ b/source/DSCResources/DSC_xServiceResource/DSC_xServiceResource.schema.mof @@ -16,4 +16,15 @@ class DSC_xServiceResource : OMI_BaseResource [Write,Description("An array of strings indicating the names of the dependencies of the service.")] String Dependencies[]; [Write,Description("The time to wait for the service to start in milliseconds. Defaults to 30000.")] uint32 StartupTimeout; [Write,Description("The time to wait for the service to stop in milliseconds. Defaults to 30000.")] uint32 TerminateTimeout; + [Write,Description("The time to wait for the Failure count to reset in seconds.")] UInt32 ResetPeriodSeconds; + [Write,Description("The command line to run if a service fails.")] String FailureCommand; + [Write,EmbeddedInstance("DSC_xFailureAction"),Description("The actions to take when a service fails.")] String FailureActionsCollection[]; + [Write,Description("A flag indicating whether failure actions should be invoked on non-crash failures.")] Boolean FailureActionsOnNonCrashFailures; +}; + +[ClassVersion("1.0.0")] +class DSC_xFailureAction +{ + [Write, Description("The action to take on failure"), ValueMap{"NONE", "RESTART", "REBOOT", "RUN_COMMAND"}, Values{"NONE", "RESTART", "REBOOT", "RUN_COMMAND"}] String Type; + [Write, Description("Delay in seconds to wait before taking the specified action")] UInt32 DelaySeconds; };