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

public CreateDatastoreNFS(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 {

    let objVcHostNasVolumeSpec: VcHostNasVolumeSpec = new VcHostNasVolumeSpec();
    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;
    }

    let objVcHostConfigManager: VcHostConfigManager = objVcHostSystem.configManager;

    let objVcHostDatastoreSystem: VcHostDatastoreSystem = objVcHostConfigManager.datastoreSystem;

    let objVcDatastore: VcDatastore = objVcHostDatastoreSystem.createNasDatastore(objVcHostNasVolumeSpec);

    return objVcDatastore;
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like