Microsoft Virtualization Discussions

Rename LIF using Update-NcNetInterface Fails

JohnChampion
6,456 Views

Trying to rename the node management LIFs using Update-NcNetInterface but it does not rename the lif even though it reports a success count of 1.

 

PS C:\> $q = get-NcNetInterface -Template
PS C:\> $q.InterfaceName = "CLUSTER-01_mgmt1"
PS C:\> $a = Get-NcNetInterface -Template
PS C:\> $a.InterfaceName = "CLUSTER-A_mgmt"
PS C:\> Update-NcNetInterface -Query $q -Attributes $a

 

NcController : xx.xx.xx.xx
SuccessCount : 1
FailureCount : 0
SuccessList : {CLUSTER-01_mgmt1}
FailureList : {}

 

I have also attempted this on data lifs with the same result so it's not specific to management lifs.  Also tried setting the AdministrativeStatus to "down" prior to rename - same result.

 

Renaming the LIF from the CLI works perfectly!

 

Could make a new LIF and then delete the old one but this should work.  It sets any other property EXCEPT the InterfaceName and it works from the CLI.

 

Any ideas?

1 ACCEPTED SOLUTION

mbeattie
6,437 Views

Hi John,

 

I suspect it's because it may require shell access to rename the node management LIF and the PowerShell CmdLets invoke ZAPI's instead of shell commands.

You can use the Invoke-NcSsh CmdLet. Here is an example of a WFA command i wrote to rename a logical interface name:

 

Param(
   [Parameter(Mandatory=$True, HelpMessage="The hostname or IP Address of the cluster")]
   [String]$ClusterName,
   [Parameter(Mandatory=$True, HelpMessage="The name of the vserver")]
   [String]$VserverName,
   [Parameter(Mandatory=$True, HelpMessage="The name of the logical interface to rename")]
   [String]$LogicalInterfaceName,
   [Parameter(Mandatory=$True, HelpMessage="The new name of the logical interface")]
   [String]$NewLogicalInterfaceName     
)
#'------------------------------------------------------------------------------
#'Connect to the cluster
#'------------------------------------------------------------------------------
Get-WFALogger -Info -Message "Renaming logical interface ""$LogicalInterfaceName"" to ""$NewLogicalInterfaceName"" on vserver ""$VserverName"" on cluster ""$ClusterName"""
Connect-WFACluster $ClusterName
#'------------------------------------------------------------------------------
#'Ensure the logical interface exists.
#'------------------------------------------------------------------------------
$attributes = Get-NcNetInterface -Template
$attributes.InterfaceName = ""
Try{
   $interface = Get-NcNetInterface -Name $LogicalInterfaceName -Vserver $VserverName -Attributes $attributes -ErrorAction Stop
   [String]$lifName = $interface.InterfaceName
   Get-WFALogger -Info -Message "Enumerated logical interface ""$LogicalInterfaceName"" on vserver ""$VserverName"""
}Catch{
   Get-WFALogger -Error -Message $("Failed enumerating logical interface ""$LogicalInterfaceName"" on vserver ""$VserverName"". Error " + $_.Exception.Message)
   Throw "Failed enumerating logical interface ""$LogicalInterfaceName"" on vserver ""$VserverName"""
}
If($lifName -eq "" -Or $lifName -eq $Null){
   Throw "The logical interface ""$LogicalInterfaceName"" on vserver ""$vserverName"" does not exist"
}
#'------------------------------------------------------------------------------
#'Rename the logical interface using SSH.
#'------------------------------------------------------------------------------
[String]$command = "network interface rename -vserver $VserverName -lif $LogicalInterfaceName -newname $NewLogicalInterfaceName"
Try{
   Invoke-NcSsh -Command $command -ErrorAction Stop
   Get-WFALogger -Info -Message "Executed command`: $command"
}Catch{
   Get-WFALogger -Error -Message $("Failed executing command`: $command. Error " + $_.Exception.Message)
   Throw "Failed renaming network interface ""$LogicalInterfaceName"" to ""$NewLogicalInterfaceName"""
}
#'------------------------------------------------------------------------------
#'Enumerate the logical interface after it has been renamed.
#'------------------------------------------------------------------------------
$attributes = Get-NcNetInterface -Template
$attributes.InterfaceName = ""
Try{
   $interface = Get-NcNetInterface -Name $NewLogicalInterfaceName -Vserver $VserverName -Attributes $attributes -ErrorAction Stop
   [String]$lifName = $interface.InterfaceName
   Get-WFALogger -Info -Message "Enumerated logical interface ""$NewLogicalInterfaceName"" on vserver ""$VserverName"""
}Catch{
   Get-WFALogger -Error -Message $("Failed enumerating logical interface ""$NewLogicalInterfaceName"" on vserver ""$VserverName"". Error " + $_.Exception.Message)
   Throw "Failed enumerating logical interface ""$NewLogicalInterfaceName"" on vserver ""$VserverName"""
}
#'------------------------------------------------------------------------------
#'Ensure the logical interface has been renamed.
#'------------------------------------------------------------------------------
If($NewLogicalInterfaceName -ne $lifName){
   Throw "Failed renaming logical interface ""$LogicalInterfaceName"" to ""$NewLogicalInterfaceName"" on vserver ""$VserverName"""
}Else{
   Get-WFALogger -Info -Message "The logical interface ""$LogicalInterfaceName"" has been renamed to ""$NewLogicalInterfaceName"" on vserver ""$VserverName"""
}
#'------------------------------------------------------------------------------

Here is an example of the logs:

 

10:03:04.498 INFO  [rename_logical_interface] ### Command 'rename_logical_interface' in 'POWER_SHELL' ###
10:03:08.217 INFO  [rename_logical_interface] Renaming logical interface "vserver1_cifs_lif2" to "vserver1_cifs_lif3" on vserver "vserver1" on cluster "cluster1.testlab.local"
10:03:08.280 INFO  [rename_logical_interface] Get-WfaCredentials -Host cluster1.testlab.local
10:03:08.327 INFO  [rename_logical_interface] Credentials successfully provided for 'cluster1.testlab.local'
10:03:08.342 INFO  [rename_logical_interface] Connect-Controller -Type CLUSTER -Name cluster1.testlab.local -Credential System.Management.Automation.PSCredential -Vserver  -Timeout 60000
10:03:08.389 INFO  [rename_logical_interface] Connect-NcController (with credentials) -Name cluster1.testlab.local -Timeout 60000 -ErrorAction Stop
10:03:22.670 INFO  [rename_logical_interface] Connected to cluster node
10:03:23.280 INFO  [rename_logical_interface] Enumerated logical interface "vserver1_cifs_lif2" on vserver "vserver1"
10:03:24.999 INFO  [rename_logical_interface] Executed command: network interface rename -vserver vserver1 -lif vserver1_cifs_lif2 -newname vserver1_cifs_lif3
10:03:25.045 INFO  [rename_logical_interface] Enumerated logical interface "vserver1_cifs_lif3" on vserver "vserver1"
10:03:25.061 INFO  [rename_logical_interface] The logical interface "vserver1_cifs_lif2" has been renamed to "vserver1_cifs_lif3" on vserver "vserver1"
10:03:25.202 INFO  [rename_logical_interface] Command completed, took 20704 milliseconds

 

Hope that helps

 

/matt

 

 

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

View solution in original post

4 REPLIES 4

mbeattie
6,438 Views

Hi John,

 

I suspect it's because it may require shell access to rename the node management LIF and the PowerShell CmdLets invoke ZAPI's instead of shell commands.

You can use the Invoke-NcSsh CmdLet. Here is an example of a WFA command i wrote to rename a logical interface name:

 

Param(
   [Parameter(Mandatory=$True, HelpMessage="The hostname or IP Address of the cluster")]
   [String]$ClusterName,
   [Parameter(Mandatory=$True, HelpMessage="The name of the vserver")]
   [String]$VserverName,
   [Parameter(Mandatory=$True, HelpMessage="The name of the logical interface to rename")]
   [String]$LogicalInterfaceName,
   [Parameter(Mandatory=$True, HelpMessage="The new name of the logical interface")]
   [String]$NewLogicalInterfaceName     
)
#'------------------------------------------------------------------------------
#'Connect to the cluster
#'------------------------------------------------------------------------------
Get-WFALogger -Info -Message "Renaming logical interface ""$LogicalInterfaceName"" to ""$NewLogicalInterfaceName"" on vserver ""$VserverName"" on cluster ""$ClusterName"""
Connect-WFACluster $ClusterName
#'------------------------------------------------------------------------------
#'Ensure the logical interface exists.
#'------------------------------------------------------------------------------
$attributes = Get-NcNetInterface -Template
$attributes.InterfaceName = ""
Try{
   $interface = Get-NcNetInterface -Name $LogicalInterfaceName -Vserver $VserverName -Attributes $attributes -ErrorAction Stop
   [String]$lifName = $interface.InterfaceName
   Get-WFALogger -Info -Message "Enumerated logical interface ""$LogicalInterfaceName"" on vserver ""$VserverName"""
}Catch{
   Get-WFALogger -Error -Message $("Failed enumerating logical interface ""$LogicalInterfaceName"" on vserver ""$VserverName"". Error " + $_.Exception.Message)
   Throw "Failed enumerating logical interface ""$LogicalInterfaceName"" on vserver ""$VserverName"""
}
If($lifName -eq "" -Or $lifName -eq $Null){
   Throw "The logical interface ""$LogicalInterfaceName"" on vserver ""$vserverName"" does not exist"
}
#'------------------------------------------------------------------------------
#'Rename the logical interface using SSH.
#'------------------------------------------------------------------------------
[String]$command = "network interface rename -vserver $VserverName -lif $LogicalInterfaceName -newname $NewLogicalInterfaceName"
Try{
   Invoke-NcSsh -Command $command -ErrorAction Stop
   Get-WFALogger -Info -Message "Executed command`: $command"
}Catch{
   Get-WFALogger -Error -Message $("Failed executing command`: $command. Error " + $_.Exception.Message)
   Throw "Failed renaming network interface ""$LogicalInterfaceName"" to ""$NewLogicalInterfaceName"""
}
#'------------------------------------------------------------------------------
#'Enumerate the logical interface after it has been renamed.
#'------------------------------------------------------------------------------
$attributes = Get-NcNetInterface -Template
$attributes.InterfaceName = ""
Try{
   $interface = Get-NcNetInterface -Name $NewLogicalInterfaceName -Vserver $VserverName -Attributes $attributes -ErrorAction Stop
   [String]$lifName = $interface.InterfaceName
   Get-WFALogger -Info -Message "Enumerated logical interface ""$NewLogicalInterfaceName"" on vserver ""$VserverName"""
}Catch{
   Get-WFALogger -Error -Message $("Failed enumerating logical interface ""$NewLogicalInterfaceName"" on vserver ""$VserverName"". Error " + $_.Exception.Message)
   Throw "Failed enumerating logical interface ""$NewLogicalInterfaceName"" on vserver ""$VserverName"""
}
#'------------------------------------------------------------------------------
#'Ensure the logical interface has been renamed.
#'------------------------------------------------------------------------------
If($NewLogicalInterfaceName -ne $lifName){
   Throw "Failed renaming logical interface ""$LogicalInterfaceName"" to ""$NewLogicalInterfaceName"" on vserver ""$VserverName"""
}Else{
   Get-WFALogger -Info -Message "The logical interface ""$LogicalInterfaceName"" has been renamed to ""$NewLogicalInterfaceName"" on vserver ""$VserverName"""
}
#'------------------------------------------------------------------------------

Here is an example of the logs:

 

10:03:04.498 INFO  [rename_logical_interface] ### Command 'rename_logical_interface' in 'POWER_SHELL' ###
10:03:08.217 INFO  [rename_logical_interface] Renaming logical interface "vserver1_cifs_lif2" to "vserver1_cifs_lif3" on vserver "vserver1" on cluster "cluster1.testlab.local"
10:03:08.280 INFO  [rename_logical_interface] Get-WfaCredentials -Host cluster1.testlab.local
10:03:08.327 INFO  [rename_logical_interface] Credentials successfully provided for 'cluster1.testlab.local'
10:03:08.342 INFO  [rename_logical_interface] Connect-Controller -Type CLUSTER -Name cluster1.testlab.local -Credential System.Management.Automation.PSCredential -Vserver  -Timeout 60000
10:03:08.389 INFO  [rename_logical_interface] Connect-NcController (with credentials) -Name cluster1.testlab.local -Timeout 60000 -ErrorAction Stop
10:03:22.670 INFO  [rename_logical_interface] Connected to cluster node
10:03:23.280 INFO  [rename_logical_interface] Enumerated logical interface "vserver1_cifs_lif2" on vserver "vserver1"
10:03:24.999 INFO  [rename_logical_interface] Executed command: network interface rename -vserver vserver1 -lif vserver1_cifs_lif2 -newname vserver1_cifs_lif3
10:03:25.045 INFO  [rename_logical_interface] Enumerated logical interface "vserver1_cifs_lif3" on vserver "vserver1"
10:03:25.061 INFO  [rename_logical_interface] The logical interface "vserver1_cifs_lif2" has been renamed to "vserver1_cifs_lif3" on vserver "vserver1"
10:03:25.202 INFO  [rename_logical_interface] Command completed, took 20704 milliseconds

 

Hope that helps

 

/matt

 

 

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

JGPSHNTAP
6,412 Views

^^

Ok, I will admit I hate the implementation of powershell for cDOT.   I'm a huge fan of powershell on 7-mode, beening using it heavily since 7-mode v1.0.  (Check my post archives)

 

In my mind, invoke-ncssh is a "patch" on how to run an SSH command.  These should all be done via API with powershell.

 

There is no reason on my mind we shouldn't be able to do this

 

get-ncnetinterface | ? {$_.interfacename -eq "blah"} | set-ncnetinterfacen -interfacename "newblah"

 

I might be ranting a little, but this is my opinion and i'm pretty strong on this.

asulliva
6,402 Views

This appears to be a limitation of ZAPI, not the PSTK.  ZAPI uses the vserver + name as the unique identifier for the LIF, and there is no option to change the name.

 

Andrew

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

JohnChampion
6,393 Views

I figured as much - even tried using just the IP Address in the query template to get around this - but if ZAPI insists .... well.  Long term this should be worked out without resorting to NcSsh I think.  Especially considering there is a CLI command. Maybe Ontapi 1.40 😉

Thanks Andrew

Public