<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Powershell Add-NaNetRoute messing with /etc/rc file in Active IQ Unified Manager Discussions</title>
    <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Powershell-Add-NaNetRoute-messing-with-etc-rc-file/m-p/98104#M17334</link>
    <description>&lt;P&gt;Hi, please add Data ONTAP version and PowerShell toolkit version. I see this is not expected behavior - it should have the options and savecore after execution of the command even.&lt;/P&gt;</description>
    <pubDate>Fri, 05 Dec 2014 07:27:56 GMT</pubDate>
    <dc:creator>rajeshr</dc:creator>
    <dc:date>2014-12-05T07:27:56Z</dc:date>
    <item>
      <title>Powershell Add-NaNetRoute messing with /etc/rc file</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Powershell-Add-NaNetRoute-messing-with-etc-rc-file/m-p/97035#M17206</link>
      <description>&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Hello All,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;I am trying to create a vFiler using WFA and could not find a command to add a default gateway for the vFiler.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;When i try to create a new command and test's&amp;nbsp;Add-NaNetRoute it is able to able to add the gateway and also make an entry in the /etc/rc file but makes a lots of changed in the file leaving only the network configuration and removing all other options that we set:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Before the command was executed the /etc/rc looks like:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;hostname inblrx900&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;ifgrp create vif e0b e0c&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;vlan create vif 1 2 3 4 5 6 7&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;ifconfig e0a `hostname`-e0a mediatype auto flowcontrol full mtusize 1500&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;ifconfig e0d 192.168.16.10 netmask 255.255.255.0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;ifconfig vif-6 192.168.160.10 netmask 255.255.255.0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;ifconfig vif-7 192.168.170.10 netmask 255.255.255.0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;ifconfig vif-6 alias 192.168.160.11 netmask 255.255.255.0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;ifconfig vif-6 alias 192.168.170.11 netmask 255.255.255.0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;route add default 192.168.220.1 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;routed on&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;options dns.enable off&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;options nis.enable off&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;savecore&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;After the following command was executed:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Add-NaNetRoute default 192.168.16.1 1 -Creator inblrx802&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;the /etc/rc file became like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;hostname inblrx900&lt;BR /&gt;ifgrp create multi vif -b ip e0b e0c&lt;BR /&gt;vlan create vif 1&lt;BR /&gt;vlan add vif 2&lt;BR /&gt;vlan add vif 3&lt;BR /&gt;vlan add vif 4&lt;BR /&gt;vlan add vif 5&lt;BR /&gt;vlan add vif 6&lt;BR /&gt;vlan add vif 7&lt;BR /&gt;ifconfig e0a `hostname`-e0a netmask 255.255.255.0 broadcast 192.168.220.255 flowcontrol full up&lt;BR /&gt;ifconfig e0b flowcontrol full up&lt;BR /&gt;ifconfig e0c flowcontrol full up&lt;BR /&gt;ifconfig e0d `hostname`-e0d netmask 255.255.255.0 broadcast 192.168.16.255 flowcontrol full up&lt;BR /&gt;ifconfig vif up&lt;BR /&gt;ifconfig vif-1 up&lt;BR /&gt;ifconfig vif-2 up&lt;BR /&gt;ifconfig vif-3 up&lt;BR /&gt;ifconfig vif-4 up&lt;BR /&gt;ifconfig vif-5 up&lt;BR /&gt;ifconfig vif-6 `hostname`-vif-6 netmask 255.255.255.0 broadcast 192.168.160.255 up&lt;BR /&gt;ifconfig vif-6 alias 192.168.160.11 netmask 255.255.255.0 broadcast 192.168.160.255 up&lt;BR /&gt;ifconfig vif-6 alias 192.168.170.11 netmask 255.255.255.0 broadcast 192.168.170.255 up&lt;BR /&gt;ifconfig vif-7 `hostname`-vif-7 netmask 255.255.255.0 broadcast 192.168.170.255 up&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;Do we have any other way to add the default gateway to a newly created vfiler and make an entry in the /etc/rc file in a much cleaner way?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;,Sheel&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Nov 2014 13:35:16 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Powershell-Add-NaNetRoute-messing-with-etc-rc-file/m-p/97035#M17206</guid>
      <dc:creator>sheelnidhig</dc:creator>
      <dc:date>2014-11-17T13:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Add-NaNetRoute messing with /etc/rc file</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Powershell-Add-NaNetRoute-messing-with-etc-rc-file/m-p/98104#M17334</link>
      <description>&lt;P&gt;Hi, please add Data ONTAP version and PowerShell toolkit version. I see this is not expected behavior - it should have the options and savecore after execution of the command even.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Dec 2014 07:27:56 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Powershell-Add-NaNetRoute-messing-with-etc-rc-file/m-p/98104#M17334</guid>
      <dc:creator>rajeshr</dc:creator>
      <dc:date>2014-12-05T07:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Add-NaNetRoute messing with /etc/rc file</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Powershell-Add-NaNetRoute-messing-with-etc-rc-file/m-p/98415#M17366</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the same issue that when WFA creates a vFiler /etc/rc and /etc/hosts files are messed up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The cmdlets used by the creation process are the following:&lt;/P&gt;&lt;P&gt;New-NaNetIpspace&lt;/P&gt;&lt;P&gt;Set-NaNetIpspace&lt;/P&gt;&lt;P&gt;New-NaVfiler&lt;/P&gt;&lt;P&gt;Set-NaVfilerAddress&lt;/P&gt;&lt;P&gt;Set-NaVfilerDns&lt;/P&gt;&lt;P&gt;Set-NaVfilerNis&lt;/P&gt;&lt;P&gt;Set-NaVfilerAdminHost&lt;/P&gt;&lt;P&gt;Set-NaVfilerPassword&lt;/P&gt;&lt;P&gt;Set-NaVfilerProtocol&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea where should i put the case for this? The WFA versions is 2.2.0.2.6 and i can get the PSTK version as well if needed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also find a bug which might be relevant (746083).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any hints are welcome!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Assen&lt;/P&gt;</description>
      <pubDate>Mon, 15 Dec 2014 13:13:41 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Powershell-Add-NaNetRoute-messing-with-etc-rc-file/m-p/98415#M17366</guid>
      <dc:creator>AssenLS</dc:creator>
      <dc:date>2014-12-15T13:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Add-NaNetRoute messing with /etc/rc file</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Powershell-Add-NaNetRoute-messing-with-etc-rc-file/m-p/99028#M17466</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Request you to call up NetApp support and open a support case for the same.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Abhi&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 11:38:19 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Powershell-Add-NaNetRoute-messing-with-etc-rc-file/m-p/99028#M17466</guid>
      <dc:creator>abhit</dc:creator>
      <dc:date>2015-01-08T11:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Add-NaNetRoute messing with /etc/rc file</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Powershell-Add-NaNetRoute-messing-with-etc-rc-file/m-p/112465#M19906</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I developed a solution to this issue as a workaround for BURT 746803. Instead of using the PowerShell CmdLet just use SSH.&lt;/P&gt;&lt;P&gt;Rather than using the WFA Certified Commands I created custom commands that use the "Invoke-NaSsh" CmdLet to run the SSH commands you would use to create a vfiler as per the following KB article:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A title="https://kb.netapp.com/support/index?page=content&amp;amp;id=1011779" href="https://kb.netapp.com/support/index?page=content&amp;amp;id=1011779" target="_blank"&gt;https://kb.netapp.com/support/index?page=content&amp;amp;id=1011779&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See source code for the WFA commands below to create a vfiler and a vlan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create and configure vfiler using SSH:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Param(
   [Parameter(Mandatory=$True, HelpMessage="The name or IP address of the controller")]
   [String]$Array,
   [Parameter(Mandatory=$True, HelpMessage="The name of the vFiler")]
   [String]$VfilerName,
   [Parameter(Mandatory=$False, HelpMessage="The name or IP address of the partner controller")]
   [String]$Partner,
   [Parameter(Mandatory=$True, HelpMessage="Delimited list of ip_address:netmask:interface to be bound to the new vFiler eg 10.10.10.10:255.255.0.0:e0a")]
   [Array]$IpAddressBindings,
   [Parameter(Mandatory=$False, HelpMessage="The IP Address of the vFilers default route to add")]
   [String]$DefaultRoute,
   [Parameter(Mandatory=$True, HelpMessage="Comma separated list of volume or qtree paths to be owned by the new vFiler")]
   [Array]$Storage,
   [Parameter(Mandatory=$False, HelpMessage="IPspace of the new vFiler. If it does not exist it will be created. If not provided, the vFiler will be created in the default-ipspace")]
   [String]$IpSpace,
   [Parameter(Mandatory=$False, HelpMessage="DNS domain name for the vFiler")]
   [String]$DnsDomainName,
   [Parameter(Mandatory=$False, HelpMessage="Comma separated list of DNS servers for the vFiler")]
   [Array]$DnsServers,
   [Parameter(Mandatory=$False, HelpMessage="NIS domain name for the vFiler")]
   [String]$NisDomainName,
   [Parameter(Mandatory=$False, HelpMessage="Comma separated list of NIS servers for the vFiler")]
   [Array]$NisServers,
   [Parameter(Mandatory=$False, HelpMessage="Administrative host name for the vFiler")]
   [String]$AdminHostName,
   [Parameter(Mandatory=$False, HelpMessage="Administrative host IP address for the vFiler")]
   [String]$AdminHostIpAddress,
   [Parameter(Mandatory=$False, HelpMessage="Enable CIFS on the new vFiler")]
   [Bool]$CifsSupported=$True,
   [Parameter(Mandatory=$False, HelpMessage="Enable NFS on the new vFiler")]
   [Bool]$NfsSupported=$True,
   [Parameter(Mandatory=$False, HelpMessage="Enable HTTP on the new vFiler")]
   [Bool]$HttpSupported=$True,
   [Parameter(Mandatory=$False, HelpMessage="Enable FTP on the new vFiler")]
   [Bool]$FtpSupported=$True,
   [Parameter(Mandatory=$False, HelpMessage="Enable iSCSI on the new vFiler")]
   [Bool]$IscsiSupported=$True,
   [Parameter(Mandatory=$False, HelpMessage="Enable RSH on the new vFiler")]
   [Bool]$RshSupported=$True,
   [Parameter(Mandatory=$False, HelpMessage="Enable SSH on the new vFiler")]
   [Bool]$SshSupported=$True
)
#'------------------------------------------------------------------------------
#Validate input paramaters ensuring there is atleast one IPAddress binding info in the command input.
#'------------------------------------------------------------------------------
If($IpAddressBindings.Length -eq 0){
   Throw "At least one IpAddress binding should be provided";
}
#'------------------------------------------------------------------------------
#'Ensure that either both DNS domain name and servers or none are provided.
#'------------------------------------------------------------------------------
If(($DnsDomainName -And !$DnsServers) -Or (!$DnsDomainName -and $DnsServers)){
   Throw "Both DNS Domain name and servers should be provided";
}
#'------------------------------------------------------------------------------
#'Ensure that either both NIS domain name and servers or none are provided.
#'------------------------------------------------------------------------------
If(($NisDomainName -And !$NisServers) -Or (!$NisDomainName -and $NisServers)){
   Throw "Both NIS Domain name and servers should be provided";
}
#'------------------------------------------------------------------------------
#'Store only the IP Addresses from the IPAddressBiding array as only IpAddresses are required for New-NaVfiler
#'Complete binding information is required for New-NaVFilerIPAddress in the form of array of IpBindingInfo objects
#'List of interfaces are derived from array of IpAddressBinding. Required for assigning the interfaces to a non-default IPspace if specified.
#'------------------------------------------------------------------------------
[String]$filePath   = "/vol/vol0/etc/rc"
[Array]$ipAddresses = @()
[Array]$interfaces  = @()
#'------------------------------------------------------------------------------
#'Each element in $IpAddressBindings is in the form of &amp;lt;IpAddress&amp;gt;:&amp;lt;Netmask&amp;gt;:&amp;lt;Interface&amp;gt;
#'------------------------------------------------------------------------------
ForEach($ipAddressBindingInfo In $IpAddressBindings){
   $binding = $ipAddressBindingInfo.split(":")
   If($binding.Length -ne 3){
      Throw "Each element in the IpAddressBindings must be in the format of`: &amp;lt;IpAddress&amp;gt;`:&amp;lt;Netmask&amp;gt;`:&amp;lt;Interface&amp;gt;"
   }
   [Array]$ipAddresses  += $binding[0]
   [Array]$interfaces   += $binding[2]
   [String]$vFilerSubnet = $binding[0].SubString(0, $binding[0].LastIndexOfAny("."))
}
#'------------------------------------------------------------------------------
#'Check if the vFilers Default Route is on the same subnet as the vfiler.
#'------------------------------------------------------------------------------
If($DefaultRoute){
   [String]$routeSubnet = $DefaultRoute.SubString(0, $DefaultRoute.LastIndexOfAny("."))
   If($vFilerSubnet -ne $routeSubnet){
      Get-WFALogger -Info -Message "The vFilers default Route ""$DefaultRoute"" is not on the same subnet as ""$ipAddresses"""
      #Throw "The vFilers default Route ""$DefaultRoute"" is not on the same subnet as ""$ipAddresses"""
   }
}
#'------------------------------------------------------------------------------
#'Connect to the controller.
#'------------------------------------------------------------------------------
Connect-WfaController -Array $Array
Get-WFALogger -Info -Message $("Creating vFiler`: name`: " + $VfilerName + ", IP addresses`: " + $IpAddressBindings + ", storage`: " + $Storage + ", IP space: " + $Ipspace)
#'------------------------------------------------------------------------------
#'Check if the IPspace exists on the controller.
#'------------------------------------------------------------------------------
If($Ipspace){
   Try{
      $ipSpaceInArray = Get-NaNetIpspace -ErrorAction Stop | Where-Object {$_.ipspace -eq $Ipspace}
      Get-WFALogger -Info -Message "Enumerated IP Space ""$Ipspace"" on controller ""$Array"""
   }Catch{
      Get-WFALogger -Error -Message $("Failed enumerating IP Space ""$Ipspace"" on controller ""$Array"". Error " + $_.Exception.Message)
      Throw "Failed enumerating IP Space ""$Ipspace"""
   }
   #'---------------------------------------------------------------------------
   #'Ensure the IPspace is created on the controller.
   #'---------------------------------------------------------------------------
   If(-Not($ipSpaceInArray)){
      Try{
         Get-WFALogger -Info -message "Creating Ipspace ""$Ipspace"" on controller ""$Array"""
         [String]$command = "ipspace create $Ipspace"
         #New-NaNetIpspace -Name $Ipspace
         Invoke-NaSsh -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 creating IPspace ""$Ipspace""  on controller ""$Array"""
      }
      Get-WFALogger -Info -Message "Created IPspace ""$Ipspace"" on controller ""$Array"""
   }Else{
      Get-WFALogger -Info -Message "The IPspace ""$Ipspace"" already exists on controller ""$Array"""
   }
   #'---------------------------------------------------------------------------
   #'Enumerate the network interface.
   #'---------------------------------------------------------------------------
   ForEach($interface In $interfaces){
      #Check if interface is already in ipspace. Addition will fail if it is.
      Try{
         $interfaceInIpSpace = Get-NaNetInterface -Name $interface -ErrorAction Stop | Where-Object {$_.IpspaceName -eq $Ipspace}
         Get-WFALogger -Info -Message "Enumerated network interface ""$interface"" on controller ""$Array"""
      }Catch{
         Get-WFALogger -Error -Message $("Failed enumerating network interface ""$interface"" on controller ""$Array"". Error`: " + $_.Exception.Message)
         Throw "Failed enumerating network interface ""$interface"" on controller ""$Array"""
      }
      #'------------------------------------------------------------------------
      #'Assign the network interface to the ipspace if the vfiler is being created in a non-default IPspace.
      #'------------------------------------------------------------------------
      If(-Not($interfaceInIpSpace)){
         Try{
            Get-WFALogger -Info -Message $("Assigning interface " + $interface + " to IPspace " + $Ipspace)
            #Set-NaNetIpspace -Name $Ipspace -Interfaces $interfaces -ErrorAction Stop
            [String]$command = "ipspace assign $Ipspace $interface"
            Invoke-NaSsh -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 to assign IP Space ""$Ipspace"" to network interface ""$interface"" on controller ""$Array"""
         }
      }Else{
         Get-WFALogger -Info -Message "The network interface ""$interface"" is already in IPspace ""$Ipspace"""
      }
   }
}Else{
   $Ipspace = "default-ipspace";
}
#'------------------------------------------------------------------------------
#'Re-Enumerate the network interface now that it has been assigned to the IP Space
#'------------------------------------------------------------------------------
Try{
   $interfaceInIpSpace = Get-NaNetInterface -Name $interface -ErrorAction Stop | Where-Object {$_.IpspaceName -eq $Ipspace}
   Get-WFALogger -Info -Message "Enumerated network interface ""$interface"" on controller ""$Array"""
}Catch{
   Get-WFALogger -Error -Message $("Failed enumerating network interface ""$interface"" on controller ""$Array"". Error`: " + $_.Exception.Message)
   Throw "Failed enumerating network interface ""$interface"" on controller ""$Array"""
}
#'------------------------------------------------------------------------------
#'Get the MTU Size if it is specified on the interface.
#'------------------------------------------------------------------------------
[Bool]$setMtu = $False
If($interfaceInIpSpace.MtusizeSpecified){
   [Int]$mtuSize = $interfaceInIpSpace.Mtusize
   [Bool]$setMtu = $True
}
#'------------------------------------------------------------------------------
#'Create the vFiler.
#'------------------------------------------------------------------------------
Try{
   [String]$vFilerRootVolume = $Storage[$Storage.GetLowerBound(0)]
   Get-WFALogger -Info -Message "Creating new vfiler ""$VfilerName"" on controller ""$Array"""
   #New-NaVfiler -Name $VfilerName -Addresses $ipAddresses -Storage $Storage -Ipspace $Ipspace -ErrorAction stop
   [String]$command = "vfiler create $VfilerName -n -s $Ipspace -i $ipAddresses $vFilerRootVolume"
   Invoke-NaSsh -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 to create vFiler ""$VfilerName"" on controller ""$Array"""
}
#'------------------------------------------------------------------------------
#'Setup IP Address bindings for the vFiler.
#'------------------------------------------------------------------------------
[Array]$sourceEtcLines  = @()
[Array]$parnterEtcLines = @()
[Array]$vFilerRoutes    = @()
Try{
   ForEach($ipAddressBindingInfo in $IpAddressBindings){
      $binding = $ipAddressBindingInfo.split(":")
      Get-WFALogger -Info -Message $("Setting vfiler Address " + $binding[0] + " Interface " + $binding[2] + " Netmask " + $binding[1])
      If($setMtu){
         #Set-NaVfilerAddress -Name $VfilerName -Addresses $binding[0] -Interface $binding[2] -Netmask $binding[1]  -ErrorAction Stop
         [String]$command         = "ifconfig " + $binding[2] + " " + $binding[0] + " up netmask " + $binding[1] + " mtusize " + $mtuSize + " partner " + $binding[2]
         [Array]$sourceEtcLines  += "ifconfig " + $binding[2] + " " + $binding[0] + " netmask "    + $binding[1] + " mtusize " + $mtuSize + " partner " + $binding[2]
         [Array]$parnterEtcLines += "ifconfig " + $binding[2] + " mtusize " + $mtuSize + " partner " + $binding[2]
         Invoke-NaSsh -Command $command -ErrorAction Stop
         Get-WFALogger -Info -Message "Executed Command`: $command"
      }Else{
         [String]$command         = "ifconfig " + $binding[2] + " " + $binding[0] + " up netmask " + $binding[1] + " partner " + $binding[2]
         [Array]$sourceEtcLines  += "ifconfig " + $binding[2] + " " + $binding[0] + " netmask "    + $binding[1] + " partner " + $binding[2]
         [Array]$parnterEtcLines += "ifconfig " + $binding[2] + " partner " + $binding[2]
         Invoke-NaSsh -Command $command -ErrorAction Stop
         Get-WFALogger -Info -Message "Executed Command`: $command"
      }
   }
}Catch{
   Get-WFALogger -Error -Message $("Failed Executing Command`: $command. " + $_.Exception.Message)
   Throw "Failed to set the IP configuration for vFiler ""$VfilerName"" on controller ""$Array"""
}
#'------------------------------------------------------------------------------
#'Add the vfilers default route if required.
#'------------------------------------------------------------------------------
If($DefaultRoute -ne ""){
   Get-WFALogger -Info -Message "Adding default route for vFiler ""$VfilerName"" on controller ""$Array"""
   Try{
      [String]$command      = "vfiler run $VfilerName route add default $DefaultRoute 1"
      [Array]$vFilerRoutes += $command
      Invoke-NaSsh -Command $command
      Get-WFALogger -Info -Message "Executed Command`: $command"
   }Catch{
      Get-WFALogger -Error -Message $("Failed Executing Command`: $command. Error: " + $_.Exception.Message)
      Throw "Failed to add the default route for vFiler ""$VfilerName"" on controller ""$Array"""
   }
}
#'------------------------------------------------------------------------------
#'Setup DNS for the vFiler.
#'------------------------------------------------------------------------------
If($DnsDomainName){
   Get-WFALogger -Info -Message "Setting up DNS for vFiler ""$VfilerName"" on controller ""$Array"""
   Try{
      #Set-NaVfilerDns -Name $VfilerName -DnsDomain $DnsDomainName -DnsServerAddresses $DnsServers -ErrorAction Stop
      [String]$command = "vfiler run $VfilerName setup -d $DnsDomainName`:$DnsServers"
      Invoke-NaSsh -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 to set the DNS domain for vFiler ""$VfilerName"" on controller ""$Array"""
   }
}
#'------------------------------------------------------------------------------
#'Setup NIS for the vFiler
#'------------------------------------------------------------------------------
If($NISDomainName){
   Get-WFALogger -Info -Message "Setting up NIS for vFiler ""$VfilerName"" on controller ""$Array"""
   Try{
      #Set-NaVfilerNis -Name $VfilerName -NisDomain $NISDomainName -NisServerAddresses $NisServers -ErrorAction Stop
      [String]$command = "vfiler run $VfilerName setup -n $NISDomainName`:$NisServers"
      Invoke-NaSsh -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 to set the NIS domain for vFiler ""$VfilerName"" on controller ""$Array"""
   }
}
#'------------------------------------------------------------------------------
#'Setup administrative host for the vFiler
#'------------------------------------------------------------------------------
If($AdminHostIPAddress){
   Get-WFALogger -Info -Message "Setting vfiler AdminHost ""$AdminHostName"" IP Address ""$AdminHostIpAddress"""
   Try{
      #Set-NaVfilerAdminHost -Name $VfilerName -Hostname $AdminHostName -Address $AdminHostIpAddress -ErrorAction Stop
      [String]$command = "vfiler run $VfilerName setup -a $AdminHostName`:$AdminHostIpAddress"
      Invoke-NaSsh -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 to set the administrative host for vFiler ""$VfilerName"" on controller ""$Array"""
   }
}
#'------------------------------------------------------------------------------
#'Setup the vfiler root password
#'------------------------------------------------------------------------------
$credentials = Get-WfaCredentials -Host $ipAddresses[0]
If($credentials){
   [String]$username = $credentials.GetNetworkCredential().username
   [String]$password = $credentials.GetNetworkCredential().password
   Get-WFALogger -Info -Message "Setting up vfiler password for user ""$userName"" on vfiler ""$VfilerName"" on controller ""$Array"""
   #Set-NaVfilerPassword -Name $VfilerName -Credential $cred -ErrorAction Stop
   [String]$command  = "vfiler run $VfilerName setup -p $password"
   #'---------------------------------------------------------------------------
   #'Mask the password so it does not get written to the log in clear text.
   #'---------------------------------------------------------------------------
   [String]$passwordMask = ""
   For($i = 0; $i -le $password.Length; $i++){
      [String]$passwordMask += "*"
   }
   [String]$passwordMask    = $passwordMask.SubString(0, ($passwordMask.Length -1))
   [String]$passwordCommand = "vfiler run $VfilerName setup -p $passwordMask"
   #'---------------------------------------------------------------------------
   Try{
      Invoke-NaSsh -Command $command -ErrorAction Stop
      Get-WFALogger -Info -Message "Executed Command`: $passwordCommand"
   }Catch{
      Get-WFALogger -Error -Message $("Failed Executing Command: $passwordCommand. Error`: " + $_.Exception.Message)
      Throw "Failed to set password for user ""$username"" on vFiler ""$VfilerName"" on controller ""$Array"""
   }     
}Else{
   Get-WFALogger -Info -Message $("The VFiler Credentials were not found for IP address " + $ipAddresses[0])
}
#'------------------------------------------------------------------------------
#'Set the vfiler disallowed protocols.
#'------------------------------------------------------------------------------
If($NfsSupported -And $CifsSupported -And $IscsiSupported -And $HttpSupported -And $FtpSupported -And $RshSupported -And $SshSupported){
   #'Since it's a new vfiler all protocols are enabled by default.
}Else{
   [Array]$disAllowProtocols = @()
   If(!$NfsSupported){
      [Array]$disAllowProtocols += "proto=nfs"
   }
   If(!$CifsSupported){
      [Array]$disAllowProtocols += "proto=cifs"
   }
   If(!$IscsiSupported){
      [Array]$disAllowProtocols += "proto=iscsi"
   }
   If(!$HttpSupported){
      [Array]$disAllowProtocols += "proto=http"
   }
   If(!$FtpSupported){
      [Array]$disAllowProtocols += "proto=ftp"
   }
   If(!$RshSupported){
      [Array]$disAllowProtocols += "proto=rsh"
   }
   If(!$SshSupported){
      [Array]$disAllowProtocols += "proto=ssh"
   }
   Get-WFALogger -Info -message $("Disabling protocols on " + $VfilerName)
   Try{
      #Set-NaVfilerProtocol -Name $VFilerName -DisallowProtocols $disAllowProtocols -ErrorAction Stop
      [String]$command = "vfiler disallow $VfilerName $disAllowProtocols"
      Invoke-NaSsh -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 disallowing protocols for vFiler ""$VfilerName"" on controller ""$Array"""
   }
}
#'------------------------------------------------------------------------------
#'Update the ifconfig commands in the /etc/rc file.
#'------------------------------------------------------------------------------
Get-WFALogger -Info -Message "Appending ifconfig commands to the ""$filePath"" file on controller ""$Array"""
ForEach($sourceEtcLine In $sourceEtcLines){
   Try{
      Write-NaFile -Path $filePath -Data $sourceEtcLine -AppendLine -ErrorAction Stop
      Get-WFALogger -Info -Message "Added line to ""$filePath"" on controller ""$Array"". Line`: $sourceEtcLine"
   }Catch{
      Get-WFALogger -Error -Message $("Failed adding line to ""$filePath"" on controller ""$Array"". Line`: $sourceEtcLine. Error " + $_.Exception.Message)
      Throw "Failed adding line to ""$filePath"" on controller ""$Array"". Line`: $sourceEtcLine"
   }
}
#'------------------------------------------------------------------------------
#'Update the vfiler route commands in the /etc/rc file.
#'------------------------------------------------------------------------------
Get-WFALogger -Info -Message "Appending route commands to the ""$filePath"" file on controller ""$Array"""
ForEach($vFilerRoute In $vFilerRoutes){
   Try{
      Write-NaFile -Path $filePath -Data $vFilerRoute -AppendLine -ErrorAction Stop
      Get-WFALogger -Info -Message "Added line to ""$filePath"" on controller ""$Array"". Line`: $vFilerRoute"""
   }Catch{
      Get-WFALogger -Error -Message $("Failed adding line to ""$filePath"" on controller ""$Array"". Line`: $vFilerRoute. Error " + $_.Exception.Message)
      Throw "Failed adding line to ""$filePath"" on controller ""$Array"". Line`: $vFilerRoute"""
   }
}
#'------------------------------------------------------------------------------
#'Connect to the partner controller if specified.
#'------------------------------------------------------------------------------
If($Partner){
   Connect-WfaController -Array $Partner
   #'---------------------------------------------------------------------------
   Get-WFALogger -Info -Message "Appending ifconfig commands to the ""$filePath"" file on controller ""$partnerName"""
   #'---------------------------------------------------------------------------
   #'Update the ifconfig commands in the /etc/rc file on the partner.
   #'---------------------------------------------------------------------------
   ForEach($parnterEtcLine In $parnterEtcLines){
      Try{
         Write-NaFile -Path $filePath -Data $parnterEtcLine -AppendLine -ErrorAction Stop
         Get-WFALogger -Info -Message "Added line to ""$filePath"" on controller ""$Partner"". Line`: $parnterEtcLine"
      }Catch{
         Get-WFALogger -Error -Message $("Failed adding line to ""$filePath"" on controller ""$Partner"". Line`: $parnterEtcLine. Error " + $_.Exception.Message)
         Throw "Failed adding line to ""$filePath"" on controller ""$partnerName"". Line`: $parnterEtcLine"
      }
   }
}
#'------------------------------------------------------------------------------&lt;/PRE&gt;&lt;P&gt;Create VLAN using SSH:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;param(
  [Parameter(Mandatory=$True, HelpMessage="Array name or IP address")]
  [String]$Array,
  [Parameter(Mandatory=$True, HelpMessage="Interface to add a VLAN to")]
  [String]$Interface,
  [Parameter(Mandatory=$True, HelpMessage="Vlan ID")]
  [ValidateRange(1,4094)]
  [Int]$VlanID
)
#'------------------------------------------------------------------------------
# Connect to controller
#'------------------------------------------------------------------------------
Connect-WfaController -Array $Array	
Get-WFALogger -Info -Message "Connected to controller ""$Array"""
#'------------------------------------------------------------------------------
#'Parameter setup
#'------------------------------------------------------------------------------
[Bool]$foundVlan      = $False
[Bool]$foundIpspace   = $False
[String]$newInterface = $Interface + "-" + $VlanID
[String]$filePath     = "/vol/vol0/etc/rc"
#'------------------------------------------------------------------------------
#'Enumerate the VLANs
#'------------------------------------------------------------------------------
Try{
   $vlans = Get-NaNetVlan -ErrorAction Stop
   Get-WFALogger -Info -Message "Enumerated VLANs on controller ""$Array"""
}Catch{
   Get-WFALogger -Error -Message $("Failed enumerating VLANs on controller ""$Array"". Error " + $_.Exception.Message)
   Throw "Failed enumerating VLANs on controller ""$Array"""
}
#'------------------------------------------------------------------------------
#'Check if the VLAN exists.
#'------------------------------------------------------------------------------
ForEach($vlan in $vlans){
   If($VlanID -eq $vlan.tag -And $Interface -eq $vlan.parentinterface){
      Get-WFALogger -Info -Message "The VLAN ""$vlan"" already exists"
      [Bool]$foundVlan = $True
   }
}
#'------------------------------------------------------------------------------
#'Ensure the VLAN is created if it doesn't exist.
#'------------------------------------------------------------------------------
If(-Not($foundVlan)){
   Get-WFALogger -Info -Message "Creating VLAN on Network Interface"
   Try{
      #Add-NaNetVlan -Interface $Interface -Vlans $VlanID -ErrorAction Stop
      [String]$command = "vlan add $Interface $VlanID"
      Invoke-NaSsh -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 creating VLAN ""$VlanID"" for interface ""$Interface"" on controller ""$Array"""
   }
}
#'------------------------------------------------------------------------------
#'Update the VLAN create command in the /etc/rc file.
#'------------------------------------------------------------------------------
If(-Not($foundVlan)){
   Get-WFALogger -Info -Message "Appending vlan create command to the ""$filePath"" file on controller ""$Array"""
   Try{
      Write-NaFile -Path $filePath -Data $command -AppendLine -ErrorAction Stop
      Get-WFALogger -Info -Message "Added line to ""$filePath"" on controller ""$Array"". Line`: $command"
   }Catch{
      Get-WFALogger -Error -Message $("Failed adding line to ""$filePath"" on controller ""$Array"". Line`: $command. Error " + $_.Exception.Message)
      Throw "Failed adding line to ""$filePath"" on controller ""$Array"". Line`: $command"
   }
}
#'------------------------------------------------------------------------------&lt;/PRE&gt;&lt;P&gt;Hope that helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/matt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 04:25:27 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Powershell-Add-NaNetRoute-messing-with-etc-rc-file/m-p/112465#M19906</guid>
      <dc:creator>mbeattie</dc:creator>
      <dc:date>2015-11-12T04:25:27Z</dc:date>
    </item>
  </channel>
</rss>

