VMware Cloud Community
kmarty009
Contributor
Contributor
Jump to solution

Add Nas File Systems in a script -- Help!

I have 15 ESXi servers and I need  to add about 10 NFS Volumes per server.  There is "NO WAY" I'm doing  that manually.  I know how to add a NAS store via the vMA command line.   What I need help with is adding into a script for all the NFS  connections.

Can  anyone help me get started to create a script where I can add all the  connections so I don't have to add each volume manually?

vicfg-nas --server myesx-host.com --add --nasserver my.netapp.com -s /mount dir nfsstore.

Can I add all my NFS connections in a file/script so I can just execute and all the NFS volumes are mounted?

Remember, I need an example if possible, i'm a little green on writing scripts for the vMA.

Just trying to make my life easier with the vMA and your assistance.  Thanks for your help in advance.

0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager
Jump to solution

If you take a look at the blog posts, they go over some examples on how to use vi-fastpass.

Here is another thread that maybe useful - http://communities.vmware.com/message/1587207#1587207

View solution in original post

0 Kudos
7 Replies
lamw
Community Manager
Community Manager
Jump to solution

You have a few options, all of which allows you to create a simple script which loops and adds the NFS volume(s) to host. As it stands, it depends on what your requirements are, are you using the root credentials, are you using vi-fastpass on vMA? Active Directory integration? vCenter access? Depending on what your configuration/environment looks like, there are a few ways of accomplishing this.

kmarty009
Contributor
Contributor
Jump to solution

Right now I'm using the root credentials when prompted.  But I'm looking at creating a session file.   For now, I'm fine with using root.  But do you have a suggestion.  I would like to hear what your thoughts are on it.

Thanks for helping!  I appreciate it.

0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

Sessionfile would be a good way for this type of work if you don't want to use vi-fastpass as you do have to do some setup, but it also buys you quite a bit as well. If you need help on creating session file or using other types of authentication, you can take a look at the vCLI documentation for some examples - http://www.vmware.com/support/developer/vcli/

If you're interested in configuring vi-fastpass, here are a few blog articles that maybe helpful to understand the differences including how to configure:

http://www.virtuallyghetto.com/2010/07/vma-41-authentication-policy-fpauth-vs.html

http://www.virtuallyghetto.com/2010/11/how-to-configure-and-use-vmas-vi.html

0 Kudos
kmarty009
Contributor
Contributor
Jump to solution

OK, if I use vi-fastpass can you assist me on getting the scripot going to add multiple NFS Connections per my 1st thread?  Any assistance you can porvide is greatly appreciated!

0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

If you take a look at the blog posts, they go over some examples on how to use vi-fastpass.

Here is another thread that maybe useful - http://communities.vmware.com/message/1587207#1587207

0 Kudos
gekko
Enthusiast
Enthusiast
Jump to solution

How about using PowerCLI to do the work for you ? ..

I use a CSV file that looks something like this :

TargetNFSIP;TargetDatastoreName;TargetDatastorePath
ipaddressorDNStoNASserver;DatastoreName;/DatastorePath/

and a Powershell script as something like below .. :

$TargetVC = Read-Host "Enter vCenter name"
Connect-VIserver $TargetVC
$Filename = "C:\Path to CSV file"
$Targets = Import-CSV $Filename -Delimiter ";"
$TargetCluster = Read-Host "Enter Cluster to add datastores to"
Write-Host ""

foreach ($ESXhost in get-cluster $TargetCluster| get-vmhost)
{
$targets | foreach {
          New-datastore –nfs –vmhost $ESXhost –name $_.TargetDatastoreName –path $_.TargetDatastorePath –nfshost $_.TargetNFSIP
  }
}

- Kenth

0 Kudos
aworkman
Enthusiast
Enthusiast
Jump to solution

Here is a slick way I do it with NetApp.  This will create the volume, set the NFS permissions, and add it to all of the esx servers inside the RamseyMN Location.

$newvol = "vmware_isos"

$esx_storage_subnet = "192.168.252.0/24"

$location = "RamseyMN"

$storageip = "192.168.252.2"

$size = "100g"

$aggregate = "aggr2"

New-NaVol -Aggregate $aggregate -Name $newvol -Confirm:$false -Size $size -SpaceReserve none

Set-NaNfsExport -Path "/vol/$newvol" -Persistent -ReadWrite " $esx_storage_subnet" -Root "$esx_storage_subnet"

Set-NaVolOption -Key "nosnapdir" -Value "on" -Name $newvol

Get-VMHost -Location $location | New-Datastore -Nfs -Name $newvol -Path "/vol/$newvol" -NfsHost $storageip

0 Kudos