Function: Find a vCACEntity object or a vCenter Cluster Compute Resource by Name

by Simon Sparks · 27 January 2026

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

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

Filename: vRealizeAutomation.ts

Function VCACEntityGetCluster

Description: The following code finds a vCACEntity object for a vCenter Cluster Compute Resource by Name.

public VCACEntityGetCluster (strHostName: string): VCACEntity
{
    let strFilter: string = `HostName eq '${strHostName}' and IsCluster eq true and MachineType eq 0`;
    let strExpand: string = null;
    let strOrderBy: string = null;
    let strSelect: string = null;
    let intTop: number = null;
    let intSkip: number = 0;
    let objPropertiesHeaders: Properties = new Properties();

    let arrVCACEntityHost: VCACEntity[] = vCACEntityManager.readModelEntitiesBySystemExpandQuery(this.objVCACHost.id, "ManagementModelEntities.svc", "Hosts", strFilter, strExpand, strOrderBy, strSelect, intTop, intSkip, objPropertiesHeaders);

    let objVCACEntityHost: VCACEntity = arrVCACEntityHost.find((objVCACEntity:VCACEntity):boolean=>{
        return objVCACEntity.getProperty("HostName") === strHostName;
    });

    return objVCACEntityHost;
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like