From 717cd66082a1a7c8ab7b2435eee8c4571e6d3099 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Sat, 16 Mar 2013 01:50:35 +0000 Subject: [PATCH] Spice things up a little by putting in a vitals and a power test case, testing out the command send command TODO: repackage the xml object into intended powershell objects Output types: -xCATData -xCATNodeData -xCATNoderangeData xCAT Data has error and data not contained within a node xCATNodeData has error and data contained within a node xCATNoderangeData will be an aggregation of the above (to be treated differently ps1xml wise hopefully) The original noderange will be chucked into any of these, for Merge-xCATNodeData to have as a hint maybe git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@15545 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- .../share/xcat/netboot/windows/xCAT.psm1 | 53 ++++++++++++++----- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/windows/xCAT.psm1 b/xCAT-server/share/xcat/netboot/windows/xCAT.psm1 index 0c26330e8..c4d517595 100644 --- a/xCAT-server/share/xcat/netboot/windows/xCAT.psm1 +++ b/xCAT-server/share/xcat/netboot/windows/xCAT.psm1 @@ -63,19 +63,48 @@ Function Connect-xCAT { $script:xcatreader = New-Object System.IO.StreamReader($script:securexCATStream) } -Function Get-Power { +Function Get-NodePower { Param( $nodeRange ) - Connect-xCAT - $data = "`n`trpower`n`tstat`n`t$nodeRange`n`n" - $script:xcatwriter.WriteLine($data) - $script:xcatwriter.Flush() - $response="" - $lastline="" - while (! $lastline.Contains("") -and $script:xcatreader) { - $lastline = $script:xcatreader.ReadLine() - $response = $response + $lastline - } - write-host $response + $xcatrequest=@{'command'='rpower';'noderange'=$nodeRange;'args'=@('stat')} + Send-xCATCommand($xcatrequest) } +Function Get-NodeVitals { + Param( + $nodeRange, + $vitalTypes="all" + ) + $xcatrequest=@{'command'='rvitals';'noderange'=$nodeRange;'args'=@($vitalTypes)} + Send-xCATCommand($xcatrequest) +} +Function Send-xCATCommand { + Param( + $xcatRequest + ) + Connect-xCAT + $requestxml = "`n`t"+$xcatRequest.command+"`n" + if ($xcatRequest.noderange) { + $requestxml = $requestxml + "`t"+$xcatRequest.noderange+"`n" + } + foreach ($arg in $xcatRequest.args) { + $requestxml = $requestxml + "`t"+$arg+"`n" + } + $requestxml = $requestxml + "`n" + $script:xcatwriter.WriteLine($requestxml) + $script:xcatwriter.Flush() + $serverdone=0 + while (! $serverdone -and $script:xcatreader) { + $responsexml="" + $lastline="" + while ($lastline -ne $null -and ! $lastline.Contains("") -and $script:xcatreader) { + $lastline = $script:xcatreader.ReadLine() + $responsexml = $responsexml + $lastline + } + [xml]$response = $responsexml + $response.xcatresponse.node.name + $response.xcatresponse.node.data + if ($response.xcatresponse.serverdone -ne $null) { $serverdone=1 } + } +} +