Skip to content

Commit

Permalink
Add a fake Start-PuppetTask function
Browse files Browse the repository at this point in the history
  • Loading branch information
glennsarti committed Nov 15, 2017
1 parent ee0e2eb commit 70b014a
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion PuppetPSDrive.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
# NestedModules = @()

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @()
FunctionsToExport = @('Start-PuppetTask')

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
Expand Down
54 changes: 54 additions & 0 deletions PuppetPSDrive.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -524,3 +524,57 @@ Function Script:Invoke-PuppetRequest($URI, $Method = 'GET', $Body = $null) {

Return $result.Content
}

# Fake Function
Function Start-PuppetTask {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true, Position=0)]
[PuppetConsoleTask] $Task,

[Parameter(Mandatory=$true, ParameterSetName="ByNodeName")]
[String[]] $Nodes = $null,

[Parameter(Mandatory=$true, ParameterSetName="ByNodeObject", ValueFromPipeline=$true)]
[Object[]] $InputObject = $null,

[Alias('Params','Param')]
[hashtable]$Parameters = @{},

[Switch]$Wait
)

Begin {
$MissingParams = @()
$Task.RequiredParameters | % {
if (-Not ($Parameters.ContainsKey($_))) {
$MissingParams += $_
}
}

if ($MissingParams -ne @()) { Throw "Missing required parameters $($MissingParams -join ', ')"; return }

$NodeNames = New-Object -TypeName System.Collections.ArrayList
}

Process {
if ($_ -ne $null) {
$thisNode = $_
} else {
$thisNode = $Nodes[0]
}
if ($thisNode.GetType().ToString() -eq 'PuppetConsoleNode') { $thisNode = $thisNode.Name }

# Fake the job
if ($Wait) {
$obj = New-Object -TypeName PSObject -Property @{'Node Name' = $thisNode; 'Status' = 'completed' }
Write-Output $obj
} else {
$obj = New-Object -TypeName PSObject -Property @{'Node Name' = $thisNode; 'Status' = 'submitted' }
Write-Output $obj
}
}

End {
}
}

0 comments on commit 70b014a

Please sign in to comment.