Better result handling

reviewable/pr18780/r1
Trond Hindenes 10 years ago
parent 8e16962596
commit ba507553b0

@ -92,23 +92,31 @@ Elseif ($state -eq "absent") {
# Loop through results and create a hash containing details about # Loop through results and create a hash containing details about
# each role/feature that is installed/removed # each role/feature that is installed/removed
$installed_features = @() $installed_features = @()
ForEach ($item in $featureresult.FeatureResult) { #$featureresult.featureresult is filled if anything was changed
$installed_features += New-Object psobject @{ if ($featureresult.FeatureResult)
id = $item.id.ToString() {
display_name = $item.DisplayName ForEach ($item in $featureresult.FeatureResult) {
message = $item.Message.ToString() $installed_features += New-Object psobject @{
restart_needed = $item.RestartNeeded.ToString() id = $item.id.ToString()
skip_reason = $item.SkipReason.ToString() display_name = $item.DisplayName
success = $item.Success.ToString() message = $item.Message.ToString()
restart_needed = $item.RestartNeeded.ToString()
skip_reason = $item.SkipReason.ToString()
success = $item.Success.ToString()
}
} }
Set-Attr $result "feature_result" $installed_features
$result.changed = $true
}
Else
{
Set-Attr $result "feature_result" $null
} }
Set-Attr $result "feature_result" $installed_features
Set-Attr $result "feature_success" $featureresult.Success.ToString() Set-Attr $result "feature_success" $featureresult.Success.ToString()
Set-Attr $result "feature_exitcode" $featureresult.ExitCode.ToString() Set-Attr $result "feature_exitcode" $featureresult.ExitCode.ToString()
Set-Attr $result "feature_restart_needed" $featureresult.RestartNeeded.ToString() Set-Attr $result "feature_restart_needed" $featureresult.RestartNeeded.ToString()
If ($result.feature_result.Length -gt 0) {
$result.changed = $true
}
Exit-Json $result; Exit-Json $result;

Loading…
Cancel
Save