Subscribe

Problem with Invoke-NcSsh

[ Edited ]

Hello,

 

I try to execute a command via NcSsh for downloading shelf and other firmware on several clusters.

When I copy the command which the WFA creates to the commandline of a system it is working.

 

Here is the code:

 

param (
	[parameter(Mandatory=$true, HelpMessage="Cluster Name")]
	[string]$ClusterName,

	[parameter(Mandatory=$true, HelpMessage="Source of package")]
	[string]$Source

)
Get-WFALogger -Info -message $("Downloading shelf update to Cluster: $ClusterName")

#Define download path
if ($Source -eq "FRD"){

	$DownloadPath = "http://<ip>/all_shelf_fw.zip"	

}elseif ($Source -eq "NRT"){

	$DownloadPath = "another path"
}

Connect-WfaCluster -Node $ClusterName -ErrorAction stop

$clusternodes = Get-NcClusterNode -ErrorAction stop

Get-WFALogger -Info -message $("Will download shelf package from $DownloadPath to cluster $ClusterName.")

foreach($node in $clusternodes.NodeName){
	Get-WFALogger -Info -message $("Will download shelf package to Node $node on cluster $ClusterName.")
	Invoke-NcSsh "set -privilege advanced -confirmations off; storage firmware download -node $node -package-url $DownloadPath"  -ErrorAction stop
	Get-WFALogger -Info -message $("Shelf package download to Node $node on cluster $ClusterName done.")
}

Get-WFALogger -Info -message $("Shelf update package downloaded to cluster $ClusterName.")

 

In another command I download the Ontap package to the system, that works because there is a cmdlet available.

 

Any idea I do wrong?

 

WFA: 4.0

Ontap:8.3.2P4

 

Regards

Matthias

Re: Problem with Invoke-NcSsh

 Looks ok.

 

Try this

 

"set -privilege advanced -confirmations off; storage firmware download -node $($node) -package-url $($DownloadPath)"

 

Re: Problem with Invoke-NcSsh

Thank you for your tip.

 

Unfortunately, the same behaviour as before

Re: Problem with Invoke-NcSsh

@matthias_beck

 

What is the exact error you are getting?

 

 

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

Re: Problem with Invoke-NcSsh

@matthias_beck

 

 

Okay, now as I tried your code, I think your WFA command passed but it didn't do what you wanted it to. Correct?

 

Why this happened?

---

 

This is common mistake people make with powershell cmdlets like Invoke-NcSsh or Invoke-Command basically cmdlets that connect remotely on another system and excute another command there. Using -ErrorAction stop is NOT going to fail, the action provided erroraction is the erroraction for the Invoke-Ncssh and not the command you passed into for execution. So any error that happens in the passed command is NOT going to be thrown as an error by Invoke-NcSsh. Hence the execution continues without any visible problems.

 

Use the below code. It perhaps is not going to make work, but it will give you the error why the firmware upgrade is failing. The WFA command will not sliently finish as before.

 

My changes are in Blue.

 

-----

 

param (
	[parameter(Mandatory=$true, HelpMessage="Cluster Name")]
	[string]$ClusterName,

	[parameter(Mandatory=$true, HelpMessage="Source of package")]
	[string]$Source

)
Get-WFALogger -Info -message $("Downloading shelf update to Cluster: $ClusterName")

#Define download path
if ($Source -eq "FRD"){

	$DownloadPath = "http://<ip>/all_shelf_fw.zip"	

}elseif ($Source -eq "NRT"){

	$DownloadPath = "another path"
}

Connect-WfaCluster -Node $ClusterName -ErrorAction stop

$clusternodes = Get-NcClusterNode -ErrorAction stop

Get-WFALogger -Info -message $("Will download shelf package from $DownloadPath to cluster $ClusterName.")

foreach($node in $clusternodes.NodeName){
	Get-WFALogger -Info -message $("Will download shelf package to Node $node on cluster $ClusterName.")
	$result=Invoke-NcSsh "set -privilege advanced -confirmations off; storage firmware download -node $node -package-url $DownloadPath"  -ErrorAction stop
	if ($result -Match 'Error')
		{
			throw "$result"
		}

	Get-WFALogger -Info -message $("Shelf package download to Node $node on cluster $ClusterName done.")
}

Get-WFALogger -Info -message $("Shelf update package downloaded to cluster $ClusterName.")

 

 

There are other problems in this code design, which results in slow execution and redundant  work. WFA provides great optimization that can be very useful. But that all later once you get this working.

 

 

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

Re: Problem with Invoke-NcSsh

Hello sinhaa,

 

Thank you for your support.

I have added the parts to my command and executed it.

Unfortunately with the additional parts, WFA does not show any error.

Re: Problem with Invoke-NcSsh

@matthias_beck

 

No errors even with the new code? and it doesn't do firmware upgrade too??

 

Okay.. lets try to root cause by eliminating WFA and connecting using PSTK..

 

1. Launch a Powershell ISE on your WFA windows server.

 

2. Modify the Cluster Ip, username, Passwd and download url as per your setiing. Execute it.

 

3. Post the error if any.

 

---

 

 

Import-Module 'C:\Program Files\NetApp\WFA\PoSH\profile.ps1'

$DownloadPath = "http://server/index.zip"
$Cluster = "10.1.1.1"
$user = "admin"
$passwd = "mypass!"
$creds = New-Object System.Management.Automation.PSCredential ($user, (ConvertTo-SecureString $passwd -AsPlainText -Force)) Connect-NcController -Name $Cluster -Credential $creds $clusternodes = Get-NcClusterNode -ErrorAction stop Write-Host $("Will download shelf package from $DownloadPath to cluster $ClusterName.") foreach($node in $clusternodes.NodeName){ Write-Host $("Will download shelf package to Node $node on cluster $ClusterName.") $result=Invoke-NcSsh "set -privilege advanced -confirmations off; storage firmware download -node $node -package-url $DownloadPath" -ErrorAction stop if ($result -Match 'Error') { throw "$result" } Write-Host $("Shelf package download to Node $node on cluster $ClusterName done.") }

 

 

 

 

 

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

Re: Problem with Invoke-NcSsh

[ Edited ]

@sinhaa

 

With your code, it works.

 

What I can see, you used a different method to connect to the cluster. I used the Connect-WfaCluster cmdlet and you the Connect-NCController. Is this the key?


Can I use the Connect-NCController cmdlet also with the credential repository from WFA?

Re: Problem with Invoke-NcSsh

@matthias_beck

 

Interesting.. 

 

Make sure you've added the Cluster Credentials in WFA.

 

Do the Test of the WFA command I provided and please post the command excution details . You can even add an image. 

 

Connect-WfaCluster doesn't do too much different from Connect-NcController. But lets see.

 

Please provide the command test execution logs, we can get to the real problem.

 

sinhaa

 

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

Re: Problem with Invoke-NcSsh

@sinhaa

 

Thank you for your support.

 

We think we found the problem. The account which is used by WFA has a special character in the password, the character is a quotation mark. :-/

We tried a different user and than it worked. We also tried to fetch a error from the Connect-WfaCluster cmdlet, but it did not show one.

 

We will replace the password for the system and try the workflow again.

 

Thank you so far.