Closed jatinpurohit92 closed 3 years ago
The cause of the failure is down to this test in GetDatastore action in VMware.vSphereDSC.psm1
if ($null -ne $datastoreInvCenter) {
throw ($this.CouldNotCreateDatastoreWithTheSpecifiedNameMessage -f $this.Name, $this.VMHost.Name, $this.Connection.Name)
}
Whilst the test for an existing datastore of the same name is valid non-NFS datastores, it's not relevant for NFS.
The bug was fixed with PR #297, so the name validation for NFS Datastores is no longer applicable and everything should work as expected with the latest version of the module.
The NfsDatastore module does not appear to allow the addition of multiple hosts to a Nfs Datastore. The "VMHostName" accepts a single value, and subsequent executions create a new datastore mapped to the additional hosts instead of mapping the host to the existing datastore.
Specs:
get-module VMware.vSphereDSC -list | fl
Name : VMware.vSphereDSC
Description : This PowerShell module contains DSC Resources for vSphere.
ModuleType : Script
Version : 2.2.0.84
Sample code:
$NfsDatastoreResource = @()
foreach ($ESXiHost in $Node.ESXiHosts) {
$NfsDatastoreResource += "[NfsDatastore]Nfs_$ESXiHost"
NfsDatastore "Nfs_$ESXiHost" {
Server = $Server
Credential = $Credential
VMHostName = $ESXiHost
Name = 'Nfs'
Path = '/nfs'
NfsHost = 'nfs.demo.local'
FileSystemVersion = '3'
Ensure = 'Present'
DependsOn = $ESXiHostResource #"[vCenterVMHost]ESXiHost_$ESXiHost"
}
}
Result:
Get-Datastore
Name FreeSpaceGB CapacityGB
---- ----------- ----------
Nfs (1) 191.621 195.858
Nfs 195.117 195.858
Expected Result (from configuring from vCenter GUI):
Get-Datastore
Name FreeSpaceGB CapacityGB
---- ----------- ----------
Nfs 195.117 195.858
The Current DSCResource NfsDatastore, Creates a NFS datastore but does not allow the same datastore to mount on other ESXi hosts. Request is to modify this DSC Resource so that-