Microsoft Virtualization Discussions
Microsoft Virtualization Discussions
Hi,
I am just getting started with PowerShell in general and the NetApp PowerShell toolkit, and I have a couple of newbie questions.
From my first Powershell scripts, I understand that a Clustered ONTAP cluster is referred to as a "(Nc)Controller" and
the nodes as "(Nc)Node".
Given the following connection to a clustered ONTAP system:
$credentials = get-credential
$controller = Connect-NcController –Name na-test-cl1 -Credential $credentials -https
I am confused why these three actions work:
get-ncclusternode | get-ncdisk
get-ncnode | get-ncdisk
get-ncdisk -Controller $controller
while putting the clustername (without using a variablename) on the commandline like this doesn't work "as I would expect":
get-ncdisk -Controller na-test-cl1
Returns:
get-ncdisk : Incorrect credentials for na-test-cl1.
At line:1 char:1
+ get-ncdisk -Controller na-test-cl1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (na-test-cl1:NcController) [Get-NcDisk], NaAuthException
+ FullyQualifiedErrorId : ApiException,DataONTAP.C.PowerShell.SDK.Cmdlets.Disk.GetNcDisk
More specifically, I get from piping the output of get-ncclusternode and get-ncnode to Get-Member that
they return objects of types DataONTAP.C.Types.Cluster.ClusterNodeInfo and DataONTAP.C.Types.System.NodeDetailsInfo respectively.
$controller is of type NetApp.Ontapi.Filer.C.NcController
How/why does get-ncdisk figure out how to return disk information from three different object types, yet it doesn't understand a literal such as na-test-cl1 ?
So the values passed to "-Controller" and "-NodeName" must always be object instances ?
Lastly, I am trying to achieve the following:
I would like to go over a cluster's nodes and create an excel file per HA pair, containing the shelf info and disk info for that HA pair.
I want an excel file per HA pair in the cluster, not per node.
How do I go about filtering out the HA pair info ?
I can get the nodes in the cluster via:
$nodes = Get-NcclusterNode
And I can get a node's HA partner like this:
$partner = get-ncclusterhapartner -node $node
but what would be the recommended PowerShell way filter out partner nodes to avoid going over both nodes of an HA pair in a cluster when looking up the shelf & disk info ?
(I am coming from a Perl scripting background so I guess getting my head around an object based approach is what's going to be the biggest challenge).
Thanks in advance for answering one or two questions 🙂
Solved! See The Solution
@uptimenowI know this probably wont help you, but maybe it will help someone else with the same question. I had the same thoughts regarding HA pairs and came up with this:
Get-NcNode | ForEach-Object {
[PSCustomObject]@{
Model = [String] $_.NodeModel
Nodes = @( $_.Node ) + @( ( Get-NcClusterHaPartner -Node $_.Node ).Partner ) | Sort-Object
}
} | Select-Object * -Unique
which will give you an object that lists the HA pairs:
Model Nodes
----- -----
FAS8040 {dc2-dot-01, dc2-dot-02}
FAS8200 {dc2-dot-03, dc2-dot-04}
Which you could then use to do something like this:
Get-NcNode | ForEach-Object {
[PSCustomObject]@{
Model = [String] $_.NodeModel
Nodes = @( $_.Node ) + @( ( Get-NcClusterHaPartner -Node $_.Node ).Partner ) | Sort-Object
}
} | Select-Object * -Unique | ForEach-Object {
$_.Nodes | Select-Object -First 1 | ForEach-Object {
Get-NcShelf -Node $_
}
}
Which will let you run commands against the first controller in the pair ordered alphabetically. But I would like to point out that you technically could have different configurations on each controller so you may actually want to run against both controllers in the pair regardless... I would recommend running against both controllers and then using Group-Object based on a commonality instead (ShelfID or similar).
@uptimenowI know this probably wont help you, but maybe it will help someone else with the same question. I had the same thoughts regarding HA pairs and came up with this:
Get-NcNode | ForEach-Object {
[PSCustomObject]@{
Model = [String] $_.NodeModel
Nodes = @( $_.Node ) + @( ( Get-NcClusterHaPartner -Node $_.Node ).Partner ) | Sort-Object
}
} | Select-Object * -Unique
which will give you an object that lists the HA pairs:
Model Nodes
----- -----
FAS8040 {dc2-dot-01, dc2-dot-02}
FAS8200 {dc2-dot-03, dc2-dot-04}
Which you could then use to do something like this:
Get-NcNode | ForEach-Object {
[PSCustomObject]@{
Model = [String] $_.NodeModel
Nodes = @( $_.Node ) + @( ( Get-NcClusterHaPartner -Node $_.Node ).Partner ) | Sort-Object
}
} | Select-Object * -Unique | ForEach-Object {
$_.Nodes | Select-Object -First 1 | ForEach-Object {
Get-NcShelf -Node $_
}
}
Which will let you run commands against the first controller in the pair ordered alphabetically. But I would like to point out that you technically could have different configurations on each controller so you may actually want to run against both controllers in the pair regardless... I would recommend running against both controllers and then using Group-Object based on a commonality instead (ShelfID or similar).