From c519c111ec814572a25661d982c5d8e7713cabe6 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Sat, 16 Mar 2013 23:27:53 +0000 Subject: [PATCH] Add some inital table formatting for typical output Fix problem where Powershell replaces commas with spaces (hopefully fixed) git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@15546 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- .../xcat/netboot/windows/xCAT.format.ps1xml | 40 ++++++++++++ .../share/xcat/netboot/windows/xCAT.psd1 | Bin 5422 -> 5458 bytes .../share/xcat/netboot/windows/xCAT.psm1 | 60 ++++++++++++++++-- 3 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 xCAT-server/share/xcat/netboot/windows/xCAT.format.ps1xml diff --git a/xCAT-server/share/xcat/netboot/windows/xCAT.format.ps1xml b/xCAT-server/share/xcat/netboot/windows/xCAT.format.ps1xml new file mode 100644 index 000000000..7fbeb3816 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/windows/xCAT.format.ps1xml @@ -0,0 +1,40 @@ + + + + + children + + xCATNodeData + + + + + 12 + + + 20 + + + + + + + + + + Node + + + Description + + + Data + + + + + + + + + diff --git a/xCAT-server/share/xcat/netboot/windows/xCAT.psd1 b/xCAT-server/share/xcat/netboot/windows/xCAT.psd1 index 656364a762206508a761d6330df502dc573a48b6..345c04144a900d05df5c02d05d22509870a41c2b 100755 GIT binary patch delta 54 zcmZ3dbxCVO8QAOHXW diff --git a/xCAT-server/share/xcat/netboot/windows/xCAT.psm1 b/xCAT-server/share/xcat/netboot/windows/xCAT.psm1 index c4d517595..d9b92f3da 100644 --- a/xCAT-server/share/xcat/netboot/windows/xCAT.psm1 +++ b/xCAT-server/share/xcat/netboot/windows/xCAT.psm1 @@ -70,10 +70,18 @@ Function Get-NodePower { $xcatrequest=@{'command'='rpower';'noderange'=$nodeRange;'args'=@('stat')} Send-xCATCommand($xcatrequest) } +Function Get-Nodes { + Param( + [parameter(Position=0)] $nodeRange, + [parameter(ValueFromRemainingArguments=$true)] $tabcols + ) + $xcatrequest=@{'command'='nodels';'noderange'=$nodeRange;'args'=@($tabcols)} + Send-xCATCommand($xcatrequest) +} Function Get-NodeVitals { Param( - $nodeRange, - $vitalTypes="all" + [parameter(Position=0)] $nodeRange, + [parameter(ValueFromRemainingArguments=$true)] $vitalTypes="all" ) $xcatrequest=@{'command'='rvitals';'noderange'=$nodeRange;'args'=@($vitalTypes)} Send-xCATCommand($xcatrequest) @@ -85,10 +93,20 @@ Function Send-xCATCommand { Connect-xCAT $requestxml = "`n`t"+$xcatRequest.command+"`n" if ($xcatRequest.noderange) { + if ($xcatRequest.noderange -is [System.Array]) { #powershell wants to arrayify commas because it can't make up its mind + #whether it's a scripting language or a shell language, try to undo the + #damage + $xcatRequest.noderange=[string]::Join(",",$xcatRequest.noderange); + } $requestxml = $requestxml + "`t"+$xcatRequest.noderange+"`n" } foreach ($arg in $xcatRequest.args) { - $requestxml = $requestxml + "`t"+$arg+"`n" + if ($arg) { + if ($arg -is [System.Array]) { + $arg=[string]::join(",",$arg); + } + $requestxml = $requestxml + "`t"+$arg+"`n" + } } $requestxml = $requestxml + "`n" $script:xcatwriter.WriteLine($requestxml) @@ -102,9 +120,41 @@ Function Send-xCATCommand { $responsexml = $responsexml + $lastline } [xml]$response = $responsexml - $response.xcatresponse.node.name - $response.xcatresponse.node.data + foreach ($elem in $response.xcatresponse.node) { + New-xCATDataFromXmlElement $elem -NodeRangeHint $xcatRequest.noderange + } + #$response.xcatresponse.node.name + #$response.xcatresponse.node.data if ($response.xcatresponse.serverdone -ne $null) { $serverdone=1 } } } +Function New-xCATDataFromXmlElement { + Param( + $xmlElement, + $NodeRangeHint + ) + $myprops = @{} + if ($NodeRangeHint) { #hypothetically, 'xcoll' implementation might find this handy + $myprops.NodeRangeHint=$NodeRangeHint + } + if ($xmlElement.name) { + $myprops.Node=$xmlElement.name + } + if ($xmlElement.data.desc) { + $myprops.Description=$xmlElement.data.desc + } + if ($xmlElement.data.contents) { + $myprops.Data=$xmlElement.data.contents + } else { + $myprops.Data="" + } + $myobj=New-Object -TypeName PSObject -Prop $myprops + $myobj.PSObject.TypeNames.Insert(0,'xCATNodeData') + return $myobj +} + + + + +