Microsoft Virtualization Discussions

Re: Issue with Invoke-NcSystemApi

mbeattie
2,733 Views

Hi Jai

 

Try this (worked in my lab using a simulator)

 

#'------------------------------------------------------------------------------
Import-Module DataONTAP
Connect-NcController -Name cluster1.testlab.local -HTTPS -Credential (Get-Credential -Credential admin) | Out-Null
$nodes = Get-NcNode
$ports = Get-NcNetPort
ForEach($node In $nodes){
   $ports = Get-NcNetPort -Node $node
   ForEach($port In $ports){
      $command  = @("system", "node", "run", "-node", $node.Node, "-command", "ifstat", $port.Port)
      $api      = $("<system-cli><args><arg>" + ($command -join "</arg><arg>") + "</arg></args></system-cli>")
      $output   = Invoke-NcSystemApi -Request $api -ErrorAction Stop
      Write-Host $("Executed Command`: " + $([String]::Join(" ", $command)))
      Write-Host ""
      Write-Host $("Port """ + $port.Port + """ on Node """ + $node.Node + """") -ForegroundColor Cyan
      Write-Host ""
      If($output.results."cli-result-value" -eq 1){
         [Array]$lines = $output.results."cli-output".Trim().Split("`n")
         $lines
      }
   }
}
#'------------------------------------------------------------------------------

Example output:

 

Name                 Address           Vserver              Version                                                         
----                 -------           -------              -------                                                         
cluster1.testlab.... 192.168.100.2                          NetApp Release 9.1: Thu Dec 22 23:05:58 UTC 2016                
Executed Command: system node run -node testc1n1 -command ifstat e0a

Port "e0a" on Node "testc1n1"

-- interface  e0a  (61 days, 11 hours, 46 minutes, 5 seconds) --

RECEIVE
 Frames/second:       0  | Bytes/second:        0  | Errors/minute:       0 
 Discards/minute:     0  | Total frames:    18502  | Total bytes:      1258k
 Total errors:        0  | Total discards:      0  | Multi/broadcast:   271 
 No buffers:          0  | Non-primary u/c:     0  | L2 terminate:      432 
 Tag drop:            0  | Vlan tag drop:       0  | Vlan untag drop:     0 
 Vlan forwards:       0  | CRC errors:          0  | Runt frames:         0 
 Fragment:            0  | Long frames:         0  | Jabber:              0 
 Alignment errors:    0  | Bus overruns:        0  | Queue overflows:     0 
 Xon:                 0  | Xoff:                0  | Jumbo:               0 
 Reset:               0  | Reset1:              0  | Reset2:              0 
TRANSMIT
 Frames/second:       0  | Bytes/second:        0  | Errors/minute:       0 
 Discards/minute:     0  | Total frames:    55534  | Total bytes:      2443k
 Total errors:        0  | Total discards:      0  | Multi/broadcast:     0 
 Queue overflows:     0  | No buffers:          0  | Max collisions:      0 
 Single collision:    0  | Multi collisions:    0  | Late collisions:     0 
 Timeout:             0  | Xon:                 0  | Xoff:                0 
 Jumbo:               0 
LINK_INFO
 Current state:       up | Up to downs:         0  | Auto:                on
 Speed:            1000m | Duplex:            full | Flowcontrol:       none
Executed Command: system node run -node testc1n1 -command ifstat e0b

Port "e0b" on Node "testc1n1"

-- interface  e0b  (61 days, 11 hours, 46 minutes, 5 seconds) --

RECEIVE
 Frames/second:       0  | Bytes/second:        0  | Errors/minute:       0 
 Discards/minute:     0  | Total frames:    18507  | Total bytes:      1184k
 Total errors:        0  | Total discards:      0  | Multi/broadcast:   271 
 No buffers:          0  | Non-primary u/c:     0  | L2 terminate:      432 
 Tag drop:            0  | Vlan tag drop:       0  | Vlan untag drop:     0 
 Vlan forwards:       0  | CRC errors:          0  | Runt frames:         0 
 Fragment:            0  | Long frames:         0  | Jabber:              0 
 Alignment errors:    0  | Bus overruns:        0  | Queue overflows:     0 
 Xon:                 0  | Xoff:                0  | Jumbo:               0 
 Reset:               0  | Reset1:              0  | Reset2:              0 
TRANSMIT
 Frames/second:       0  | Bytes/second:        0  | Errors/minute:       0 
 Discards/minute:     0  | Total frames:    18527  | Total bytes:      1185k
 Total errors:        0  | Total discards:      0  | Multi/broadcast:     0 
 Queue overflows:     0  | No buffers:          0  | Max collisions:      0 
 Single collision:    0  | Multi collisions:    0  | Late collisions:     0 
 Timeout:             0  | Xon:                 0  | Xoff:                0 
 Jumbo:               0 
LINK_INFO
 Current state:       up | Up to downs:         0  | Auto:                on
 Speed:            1000m | Duplex:            full | Flowcontrol:       none
Executed Command: system node run -node testc1n1 -command ifstat e0c

Port "e0c" on Node "testc1n1"

-- interface  e0c  (61 days, 11 hours, 46 minutes, 5 seconds) --

RECEIVE
 Frames/second:      20  | Bytes/second:     5094  | Errors/minute:       0 
 Discards/minute:     0  | Total frames:    26275k | Total bytes:      3152m
 Total errors:        0  | Total discards:      0  | Multi/broadcast: 10996k
 No buffers:          0  | Non-primary u/c:     0  | L2 terminate:     3239 
 Tag drop:            0  | Vlan tag drop:       0  | Vlan untag drop:     0 
 Vlan forwards:       0  | CRC errors:          0  | Runt frames:         0 
 Fragment:            0  | Long frames:         0  | Jabber:              0 
 Alignment errors:    0  | Bus overruns:        0  | Queue overflows:     0 
 Xon:                 0  | Xoff:                0  | Jumbo:               0 
 Reset:               0  | Reset1:              0  | Reset2:              0 
TRANSMIT
 Frames/second:      15  | Bytes/second:     6955  | Errors/minute:       0 
 Discards/minute:     0  | Total frames:    17565k | Total bytes:     11175m
 Total errors:        0  | Total discards:      0  | Multi/broadcast: 98001 
 Queue overflows:     0  | No buffers:          0  | Max collisions:      0 
 Single collision:    0  | Multi collisions:    0  | Late collisions:     0 
 Timeout:             0  | Xon:                 0  | Xoff:                0 
 Jumbo:               0 
LINK_INFO
 Current state:       up | Up to downs:         2  | Auto:                on
 Speed:            1000m | Duplex:            full | Flowcontrol:       none
Executed Command: system node run -node testc1n1 -command ifstat e0d

Port "e0d" on Node "testc1n1"

-- interface  e0d  (61 days, 11 hours, 46 minutes, 5 seconds) --

RECEIVE
 Frames/second:       4  | Bytes/second:      244  | Errors/minute:       0 
 Discards/minute:     0  | Total frames:    14906k | Total bytes:      1020m
 Total errors:        0  | Total discards:      0  | Multi/broadcast: 10999k
 No buffers:          0  | Non-primary u/c:     0  | L2 terminate:     4079 
 Tag drop:            0  | Vlan tag drop:       0  | Vlan untag drop:     0 
 Vlan forwards:       0  | CRC errors:          0  | Runt frames:         0 
 Fragment:            0  | Long frames:         0  | Jabber:              0 
 Alignment errors:    0  | Bus overruns:        0  | Queue overflows:     0 
 Xon:                 0  | Xoff:                0  | Jumbo:               0 
 Reset:               0  | Reset1:              0  | Reset2:              0 
TRANSMIT
 Frames/second:       1  | Bytes/second:       51  | Errors/minute:       0 
 Discards/minute:     0  | Total frames:     4006k | Total bytes:       223m
 Total errors:        0  | Total discards:      0  | Multi/broadcast: 95304 
 Queue overflows:     0  | No buffers:          0  | Max collisions:      0 
 Single collision:    0  | Multi collisions:    0  | Late collisions:     0 
 Timeout:             0  | Xon:                 0  | Xoff:                0 
 Jumbo:               0 
LINK_INFO
 Current state:       up | Up to downs:         2  | Auto:                on
 Speed:            1000m | Duplex:            full | Flowcontrol:       none

Hope that helps

 

/Matt

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.
2 REPLIES 2

Parker_Bradshaw
2,385 Views

This is awesome! I got it to work in our sandbox. I am running 9.5P10. I ran it against our prod clusters and I get response 0. Is there anything that needs to be done to enable Invoke-NcSystemApi? I didn't do anything special on our sandbox cluster that I can remember. I can't get the script to return anything though except for on the sandbox. And like I said they are all running the same 9.5P10 version of code. 

 

Thanks!

mbeattie
2,194 Views

Hi Parker,

 

The only reason i can think of why that might be the case is that the account used to connect to your production system doesn't have privileges to run the command. Did you try running it as a user with the admin role to ensure it works then delegate permissions? Another example below of using Invoke-NcSystemApi and formatting output. Might be useful:

 

https://community.netapp.com/t5/Data-ONTAP-Discussions/Netapp-Powershell-Output/td-p/155674 

 

/Matt

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.
Public