Function: Create an Empty vCloud vApp and link it to a Virtual Data Center Network

by Simon Sparks · 5 September 2025

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

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

Filename: vCloudService.ts

Description: Orchestrator Function to Create an Empty vCloud vApp and the linking of it to a virtual data center network.

Function VclVAppCreate

public VclVAppCreate(objVclVdc: VclVdc, strVclVAppName: string, objVclOrgVdcNetwork: VclOrgVdcNetwork, strGateway: string, strSubnetMask: string, strIpSyslogServerPrimary: string, strIpSyslogServerSecondary: string, strIpDnsServerPrimary: string, strIpDnsServerSecondary: string, strDnsSuffix: string, strIpAddressRangeStart: string, strIpAddressRangeEnd: string, intSubnetPrefixLength: number = 24): void {

  let objVclSyslogServerSettings: VclSyslogServerSettings = new VclSyslogServerSettings();
  objVclSyslogServerSettings.syslogServerIp1 = strIpSyslogServerPrimary;
  objVclSyslogServerSettings.syslogServerIp2 = strIpSyslogServerSecondary;

  let objVclIpRange: VclIpRange = new VclIpRange();
  objVclIpRange.startAddress = strIpAddressRangeStart;
  objVclIpRange.endAddress = strIpAddressRangeEnd;

  let objVclIpRanges: VclIpRanges = new VclIpRanges();
  objVclIpRanges.ipRange.add(objVclIpRange);

  let objVclIpScope: VclIpScope = new VclIpScope();
  objVclIpScope.dns1 = "";
  objVclIpScope.dns2 = "";
  objVclIpScope.isEnabled = true;
  objVclIpScope.gateway = strGateway;
  objVclIpScope.netmask = strSubnetMask;
  objVclIpScope.subnetPrefixLength = intSubnetPrefixLength;
  objVclIpScope.ipRanges = objVclIpRanges;
  objVclIpScope.dns1 = strIpDnsServerPrimary;
  objVclIpScope.dns2 = strIpDnsServerSecondary;
  objVclIpScope.dnsSuffix = strDnsSuffix;

  let objVclNetworkConfiguration: VclNetworkConfiguration = new VclNetworkConfiguration();
  objVclNetworkConfiguration.ipScope = objVclIpScope;
  objVclNetworkConfiguration.parentNetwork = objVclOrgVdcNetwork.getReference();
  objVclNetworkConfiguration.fenceMode = "bridged";
  objVclNetworkConfiguration.features = null;
  objVclNetworkConfiguration.routerInfo = null;
  objVclNetworkConfiguration.backwardCompatibilityMode = false;
  objVclNetworkConfiguration.retainNetInfoAcrossDeployments = false;
  objVclNetworkConfiguration.syslogServerSettings = objVclSyslogServerSettings;

  let objVclVAppNetworkConfiguration: VclVAppNetworkConfiguration = new VclVAppNetworkConfiguration();
  objVclVAppNetworkConfiguration.configuration = objVclNetworkConfiguration;
  objVclVAppNetworkConfiguration.description = objVclOrgVdcNetwork.name;
  objVclVAppNetworkConfiguration.networkName = objVclOrgVdcNetwork.name;
  objVclVAppNetworkConfiguration.isDeployed = true;

  let objVclMsg: VclMsg = new VclMsg();
  objVclMsg.value = "NetworkConfigSection";

  let objVclNetworkConfigSection: VclNetworkConfigSection = new VclNetworkConfigSection();
  objVclNetworkConfigSection.info = objVclMsg;
  objVclNetworkConfigSection.networkConfig.add(objVclVAppNetworkConfiguration);

  let objVclInstantiationParams: VclInstantiationParams = new VclInstantiationParams()
  objVclInstantiationParams.section.add(objVclNetworkConfigSection);

  let objVclComposeVAppParams: VclComposeVAppParams = new VclComposeVAppParams();
  objVclComposeVAppParams.name = strVclVAppName;
  objVclComposeVAppParams.description = "Orchestrator Deployed vApp - " + strVclVAppName;
  objVclComposeVAppParams.deploy = false;
  objVclComposeVAppParams.powerOn = false;
  objVclComposeVAppParams.allEULAsAccepted = true;
  objVclComposeVAppParams.linkedClone = true;
  objVclComposeVAppParams.instantiationParams = objVclInstantiationParams;

  let objVclVApp: VclVApp = objVclVdc.composeVApp(objVclComposeVAppParams);

  let objVclTasksInProgress: VclTasksInProgress = objVclVApp.tasks;

  if (objVclTasksInProgress != null) {
      let arrVclTask: VclTask[] = objVclTasksInProgress.getTasks();

      let objVclTask: VclTask = arrVclTask[0];

      this.WaitForVclTask(objVclTask, 1);
  }

  objVclVApp.updateInternalState();
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like