Active IQ Unified Manager Discussions
Active IQ Unified Manager Discussions
I'm pretty new to working with WFA 2.0. Has anyone looked into or thought about creating a workflow to add/modify the netgroups file? I started looking into creating a command but there doesn't seem to be a cmdlet available to manipulate the /etc/netgroup file. Any thoughts on how this might be accomplished?
Hi Patrick,
Please use the following cmdlet to add/modify entries to the desired files:
7mode:
Write-NaFile -Path /vol/vol0/etc/netgroup -Data untrusted_hosts -AppendLine
C-mode
Write-NcFile -Path <path> -Data <data>
Hope this helps in creating the command/workflow you need.
-Sharu
Thanks. That's helpful. I assume an addition to already existing entry in the /etc/netgroup would be more involved?
If you're referring to making a change to an existing line, yes it would be more involved. You should first make a backup of the existing file, then look into modifying it.
Check out the example workflow I posted for manipulating /etc/hosts for some ideas, here: https://communities.netapp.com/docs/DOC-23962
Hope this helps,
Dave
So I'm working on my command in WFA.
It actually does what I want it to do. after the last line of code is done, this message show up in the test window.
21:58:23.941 ERROR [Add New Entry to Existing NetGroup] Failed executing command. Exception: Cannot bind argument to parameter 'Data' because it is an empty string.
By removing certain parts of the command script, I have the part that seems to cause this error. Anyone know why?
Get-Content $tempFile | where {$_ -notmatch $ClusterName } | Write-NaFile -Path $File -AppendLine |
Since the results of the where are getting written to $File, I don't get it.
Yes, I've seen this before with the Write-NaFile cmdlet. If memory serves, Write-NaFile didn't like lines that are blank or only contain whitespace. You could try filtering them out as well, with something like:
Get-Content $tempFile | where {$_ -notmatch $ClusterName -and $_ -notmatch "^\s*$" } | Write-NaFile -Path $File -AppendLine
that did it. Thanks so much!
Could you provide your example command to add to an existing line in the netgroups file. I'm looking to do this as well but not sure how to get started. Thanks.
Branden Taber wrote:
Could you provide your example command to add to an existing line in the netgroups file. I'm looking to do this as well but not sure how to get started. Thanks.
Here is the command to write a new entry. I'm no powershell expert, so I'm sure there may be an easier way to do this.
param (
[parameter(Mandatory=$true, HelpMessage="Array name or IP address")]
[string]$Array,
[parameter(Mandatory=$true, HelpMessage="New Cluster / Netgroup entry")]
[string]$ClusterName,
[parameter(Mandatory=$true, HelpMessage="New IP Address 1")]
[string]$NetGroupEntry01,
[parameter(Mandatory=$false, HelpMessage="New IP Address 2")]
[string]$NetGroupEntry02,
[parameter(Mandatory=$false, HelpMessage="New IP Address 3")]
[string]$NetGroupEntry03,
[parameter(Mandatory=$false, HelpMessage="New IP Address 4")]
[string]$NetGroupEntry04,
[parameter(Mandatory=$false, HelpMessage="New IP Address 5")]
[string]$NetGroupEntry05,
[parameter(Mandatory=$false, HelpMessage="New IP Address 6")]
[string]$NetGroupEntry06,
[parameter(Mandatory=$false, HelpMessage="New IP Address 7")]
[string]$NetGroupEntry07,
[parameter(Mandatory=$false, HelpMessage="New IP Address 8")]
[string]$NetGroupEntry08,
[parameter(Mandatory=$false, HelpMessage="New IP Address 9")]
[string]$NetGroupEntry09,
[parameter(Mandatory=$false, HelpMessage="New IP Address 10")]
[string]$NetGroupEntry10,
[parameter(Mandatory=$false, HelpMessage="New IP Address 11")]
[string]$NetGroupEntry11,
[parameter(Mandatory=$false, HelpMessage="New IP Address 12")]
[string]$NetGroupEntry12,
[parameter(Mandatory=$false, HelpMessage="New IP Address 13")]
[string]$NetGroupEntry13,
[parameter(Mandatory=$false, HelpMessage="New IP Address 14")]
[string]$NetGroupEntry14,
[parameter(Mandatory=$false, HelpMessage="New IP Address 15")]
[string]$NetGroupEntry15,
[parameter(Mandatory=$false, HelpMessage="New IP Address 16")]
[string]$NetGroupEntry16
)
# connect to controller
Connect-WFAController -Array $Array
$File = "/vol/vol0/etc/netgroup"
$backupFile = $File + ".wfabak"
# Back up the original file
try
{
Read-NaFile $File | Write-NaFile $backupFile
}
catch
{
$msg = "Failed to back up: " + $File + " on: " + $Array + ". Message: " + $_.Exception.Message
throw $msg
}
Get-WFALogger -Info -message $($File + " backed up successfully to: " + $backupFile + " on: " + $Array)
# Add NetGroup Entry
try
{
$allIPs = $NetGroupEntry01 + " " + $NetGroupEntry02 + " " + $NetGroupEntry03 + " " + $NetGroupEntry04 + " " + $NetGroupEntry05 + " " + $NetGroupEntry06 + " " + $NetGroupEntry07 + " " + $NetGroupEntry08 + " " + $NetGroupEntry09 + " " + $NetGroupEntry10 + " " + $NetGroupEntry11 + " " + $NetGroupEntry12 + " " + $NetGroupEntry13 + " " + $NetGroupEntry14 + " " + $NetGroupEntry15 + " " + $NetGroupEntry16
foreach ($IP in $allIPs.split(" "))
{
if ($IP -ne "")
{
$newclusterips = $newclusterips + "(" + $IP + ",,) "
}
}
$newline = $ClusterName + " " + $newclusterips
Write-NaFile -Path $File -AppendLine -Data $newline
}
catch
{
$msg = "Failed to form the netgroup line entry from: " + $File + ". Message: " + $_.Exception.Message
throw $msg
}
Get-WFALogger -Info -message $("New NetGroup Entry Created: " + $File + " on: " + $Array)
# End of Command