vCO Workflow Script to Enable vCenter HA

vCO Workflow Script to Enable vCenter HA

var arrDNSServers = new Array();
	arrDNSServers.push("192.168.0.1")
	
var arrGateway = new Array();
	arrGateway.push("192.168.0.1")

var objVcCustomizationFixedIpFailover = new VcCustomizationFixedIp();
	objVcCustomizationFixedIpFailover.ipAddress = "192.168.0.10";

var objVcCustomizationIPSettingsFailover = new VcCustomizationIPSettings();
	objVcCustomizationIPSettingsFailover.dnsDomain = "lab.local";
	objVcCustomizationIPSettingsFailover.dnsServerList = arrDNSServers;
	objVcCustomizationIPSettingsFailover.gateway = arrGateway;
	objVcCustomizationIPSettingsFailover.ip = objVcCustomizationFixedIpFailover;
	objVcCustomizationIPSettingsFailover.ipV6Spec = null;
	objVcCustomizationIPSettingsFailover.netBIOS = VcCustomizationNetBIOSMode.enableNetBIOS;
	objVcCustomizationIPSettingsFailover.primaryWINS = "";
	objVcCustomizationIPSettingsFailover.secondaryWINS = "";
	objVcCustomizationIPSettingsFailover.subnetMask = "255.255.255.0";

var objVcCustomizationFixedIpCluster = new VcCustomizationFixedIp();
	objVcCustomizationFixedIpCluster.ipAddress = "192.168.0.10";

var objVcCustomizationIPSettingsCluster = new VcCustomizationIPSettings();
	objVcCustomizationIPSettingsCluster.dnsDomain = "lab.local";
	objVcCustomizationIPSettingsCluster.dnsServerList = arrDNSServers;
	objVcCustomizationIPSettingsCluster.gateway = arrGateway;
	objVcCustomizationIPSettingsCluster.ip = objVcCustomizationFixedIpCluster;
	objVcCustomizationIPSettingsCluster.ipV6Spec = null;
	objVcCustomizationIPSettingsCluster.netBIOS = VcCustomizationNetBIOSMode.enableNetBIOS;
	objVcCustomizationIPSettingsCluster.primaryWINS = "";
	objVcCustomizationIPSettingsCluster.secondaryWINS = "";
	objVcCustomizationIPSettingsCluster.subnetMask = "255.255.255.0";
	
var objVcCustomizationFixedIpPassive = new VcCustomizationFixedIp();
	objVcCustomizationFixedIpPassive.ipAddress = "192.168.0.10";

var objVcCustomizationIPSettingsPassive = new VcCustomizationIPSettings();
	objVcCustomizationIPSettingsPassive.dnsDomain = "lab.local";
	objVcCustomizationIPSettingsPassive.dnsServerList = arrDNSServers;
	objVcCustomizationIPSettingsPassive.gateway = arrGateway;
	objVcCustomizationIPSettingsPassive.ip = objVcCustomizationFixedIpPassive;
	objVcCustomizationIPSettingsPassive.ipV6Spec = null;
	objVcCustomizationIPSettingsPassive.netBIOS = VcCustomizationNetBIOSMode.enableNetBIOS;
	objVcCustomizationIPSettingsPassive.primaryWINS = "";
	objVcCustomizationIPSettingsPassive.secondaryWINS = "";
	objVcCustomizationIPSettingsPassive.subnetMask = "255.255.255.0";
		
var objVcCustomizationFixedIpActive = new VcCustomizationFixedIp();
	objVcCustomizationFixedIpActive.ipAddress = "192.168.0.10";

var objVcCustomizationIPSettingsActive = new VcCustomizationIPSettings();
	objVcCustomizationIPSettingsActive.dnsDomain = "lab.local";
	objVcCustomizationIPSettingsActive.dnsServerList = arrDNSServers;
	objVcCustomizationIPSettingsActive.gateway = arrGateway;
	objVcCustomizationIPSettingsActive.ip = objVcCustomizationFixedIpActive;
	objVcCustomizationIPSettingsActive.ipV6Spec = null;
	objVcCustomizationIPSettingsActive.netBIOS = VcCustomizationNetBIOSMode.enableNetBIOS;
	objVcCustomizationIPSettingsActive.primaryWINS = "";
	objVcCustomizationIPSettingsActive.secondaryWINS = "";
	objVcCustomizationIPSettingsActive.subnetMask = "255.255.255.0";
	
var objVcClusterNetworkConfigSpec = new VcClusterNetworkConfigSpec();
	objVcClusterNetworkConfigSpec.ipSettings = objVcCustomizationIPSettingsActive;
	objVcClusterNetworkConfigSpec.networkPortGroup = objVcNetworkPublic

var objVcServiceLocatorNamePassword  = new VcServiceLocatorNamePassword ();
	objVcServiceLocatorNamePassword.username = strUsername;
	objVcServiceLocatorNamePassword.password = strPassword;

var objVcServiceLocator = new VcServiceLocator();
	objVcServiceLocator.credential = objVcServiceLocatorNamePassword;
	objVcServiceLocator.url = "https://" + objVcSdkConnection.sdkId;;
	objVcServiceLocator.instanceUuid = objVcSdkConnection.instanceUuid;
	objVcServiceLocator.sslThumbprint = strSSLThumbprint;

var objVcSourceNodeSpec = new VcSourceNodeSpec();
	objVcSourceNodeSpec.activeVc = objVcVirtualMachine;
	objVcSourceNodeSpec.managementVc = objVcServiceLocator;

var objVcPassiveNodeDeploymentSpec = new VcPassiveNodeDeploymentSpec();
	objVcPassiveNodeDeploymentSpec.clusterNetworkPortGroup = objVcNetworkCluster;
	objVcPassiveNodeDeploymentSpec.datastore = objVcDatastore;
	objVcPassiveNodeDeploymentSpec.esxHost = objVcHostSystem;
	objVcPassiveNodeDeploymentSpec.failoverIpSettings = objVcCustomizationIPSettingsFailover;
	objVcPassiveNodeDeploymentSpec.folder = objVcVmFolder;
	objVcPassiveNodeDeploymentSpec.ipSettings = objVcCustomizationIPSettingsPassive;
	objVcPassiveNodeDeploymentSpec.managementVc = objVcServiceLocator;
	objVcPassiveNodeDeploymentSpec.nodeName = strNodeName + "-PASSIVE";
	objVcPassiveNodeDeploymentSpec.publicNetworkPortGroup = objVcNetworkPublic;
	objVcPassiveNodeDeploymentSpec.resourcePool = objVcResourcePool;

var objVcNodeDeploymentSpec = new VcNodeDeploymentSpec();
	objVcNodeDeploymentSpec.clusterNetworkPortGroup = objVcNetworkCluster;
	objVcNodeDeploymentSpec.datastore = objVcDatastore;
	objVcNodeDeploymentSpec.esxHost = objVcHostSystem;
	objVcNodeDeploymentSpec.folder = objVcVmFolder;
	objVcNodeDeploymentSpec.ipSettings = objVcCustomizationIPSettingsActive;
	objVcNodeDeploymentSpec.managementVc = objVcServiceLocator;
	objVcNodeDeploymentSpec.nodeName = strNodeName + "-WITNESS";
	objVcNodeDeploymentSpec.publicNetworkPortGroup = objVcNetworkPublic;
	objVcNodeDeploymentSpec.resourcePool = objVcResourcePool;

var objVcVchaClusterDeploymentSpec = new VcVchaClusterDeploymentSpec() ;
	objVcVchaClusterDeploymentSpec.activeVcNetworkConfig = objVcClusterNetworkConfigSpec;
	objVcVchaClusterDeploymentSpec.activeVcSpec = objVcSourceNodeSpec;
	objVcVchaClusterDeploymentSpec.passiveDeploymentSpec = objVcPassiveNodeDeploymentSpec;
	objVcVchaClusterDeploymentSpec.witnessDeploymentSpec = objVcNodeDeploymentSpec;

var objVcManagedObjectReference = new VcManagedObjectReference();
	objVcManagedObjectReference.type = "ServiceInstance";
	objVcManagedObjectReference.value = "ServiceInstance";
	
var objVcServiceInstance = VcPlugin.convertToVimManagedObject(objVcSdkConnection, objVcManagedObjectReference);

var objVcServiceContent = objVcServiceInstance.retrieveServiceContent();

var objVcFailoverClusterConfigurator = objVcServiceContent.failoverClusterConfigurator;

var objVcTask = objVcFailoverClusterConfigurator.deployVcha_Task(objVcVchaClusterDeploymentSpec);

Leave a Reply