Function: vCenter Datastore Create NFS

by Simon Sparks · 24 March 2026

To use this function add it to the class library file named PluginVCDatastoreService.ts

GitHub Repository: https://github.com/SimonSparksUK/Orchestrator

Filename: PluginVCDatastoreService.ts

Description: Orchestrator Function to Create an NFS Datastore

Public Function: CreateDatastoreNFS

publicCreateDatastoreNFS(objVcHostSystem:VcHostSystem,strRemoteHostFQDN:string,strRemoteHostPath:string,strVcDatastoreName:string,blnVmkNicBound:boolean,strVmkNicToBind:""|"vmk1"|"vmk2"|"vmk3"|"vmk4"|"vmk5"|"vmk6"|"vmk7"|"vmk8"|"vmk9",strAccessMode:"readWrite"|"readOnly",strVcHostFileSystemVolumeFileSystemType:"NFS"|"NFS41"|"CIFS"|"OTHER"|"PMEM"|"VFFS"|"VMFS"|"VVOL"):VcDatastore{

letobjVcHostNasVolumeSpec: VcHostNasVolumeSpec=newVcHostNasVolumeSpec();
objVcHostNasVolumeSpec.remotePath=strRemoteHostPath;
objVcHostNasVolumeSpec.remoteHost=strRemoteHostFQDN;
objVcHostNasVolumeSpec.localPath=strVcDatastoreName;
objVcHostNasVolumeSpec.accessMode=strAccessMode;
objVcHostNasVolumeSpec.type=strVcHostFileSystemVolumeFileSystemType;

if (blnVmkNicBound===true&&strVmkNicToBind!==""){
//@ts-ignore
objVcHostNasVolumeSpec.vmknicBound=blnVmkNicBound;
//@ts-ignore
objVcHostNasVolumeSpec.vmknicToBind=strVmkNicToBind;
}

letobjVcHostConfigManager: VcHostConfigManager=objVcHostSystem.configManager;

letobjVcHostDatastoreSystem: VcHostDatastoreSystem=objVcHostConfigManager.datastoreSystem;

letobjVcDatastore: VcDatastore=objVcHostDatastoreSystem.createNasDatastore(objVcHostNasVolumeSpec);

returnobjVcDatastore;
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like