First of all, thank you if you attended the session I presented with Dan Mitchell on the Self Healing Datacenter. Also a big thanks to Kim Jahnz and Dan for giving me the opportunity to go up there and talk about some of the things I’ve been working on.
Here is the detailed walkthrough of the 1st example I gave.
In this example I demonstrated how you could effectively use vCO as a Configuration Management tool for vSphere settings. Now this does not mean that there aren’t more advanced tools out there for configuration management. Puppet, Chef etc. are your big knife tools for more serious configuration management, but vCO can fill some very easy gaps without needing to go to more complex tools.
Always start with a goal in mind and then work your way through all the components required.
- HA Settings
- HA should be turned on
- HA admission control should be enabled
- HA Admission Control policy should be set to percentage based and allow for 1 host in the cluster to be out of service. (e.g. for a 4 host cluster, I would set this to 25%)
- DRS should be turned on
- DRS should be set to fully automated
Break it down:
The very first time I created this workflow, I used workflows containing scriptable tasks. Later I improved it ahead of VMWorld and turned that workflow of scriptable tasks into an action item.
I don’t think there is a right or wrong answer to this, but using the action item seems cleaner and more reusable, with less chance of error.
The main workflow:
Now for the action item code…
Part 1: Calculating your HA % for the amount of hosts in your cluster.
var Hosts = System.getModule("com.vmware.library.vc.cluster").getAllHostSystemsOfCluster(cluster); System.log("Number of Hosts in Cluster: " + Hosts.length); var HApercent = ((1/Hosts.length)*100); HApercent = HApercent.toFixed(0); System.log("HA Percent which will be used for cluster is: " + HApercent);
Part 2: The cluster specifications and task to reconfigure the cluster
//Create variables for DRS/HA config var clusterConfigSpec = new VcClusterConfigSpecEx(); clusterConfigSpec.drsConfig = new VcClusterDrsConfigInfo(); clusterConfigSpec.dasConfig = new VcClusterDasConfigInfo(); //Enable DRS/HA clusterConfigSpec.dasConfig.enabled = true; clusterConfigSpec.drsConfig.enabled = true; //Set DRS to INPUT (Passed to the Action) System.log("Setting DRS to Fully Automated"); clusterConfigSpec.drsConfig.defaultVmBehavior = drsBehaviour; //Fix Admissions control policy System.log("Updating HA Admission Control policy for " + cluster.name); clusterConfigSpec.dasConfig.admissionControlPolicy = new VcClusterFailoverResourcesAdmissionControlPolicy(); clusterConfigSpec.dasConfig.admissionControlEnabled = true; //Set host monitoring to the setting passed to the action clusterConfigSpec.dasConfig.hostMonitoring = haHostMonitoring; clusterConfigSpec.dasConfig.admissionControlPolicy.cpuFailoverResourcesPercent = HApercent; clusterConfigSpec.dasConfig.admissionControlPolicy.memoryFailoverResourcesPercent = HApercent; //Reconfigure the cluster, by adding the True parameter this ensures any previous settings remain System.log("Executing Cluster Reconfiguration for " + cluster.name); task = cluster.reconfigureComputeResource_Task(clusterConfigSpec, true);
Putting it all together:
So now we have an action item which can take in the following inputs:
1. Cluster (Type: VCCluster)
2. DRS Behaviour (Type: DRS Behaviour)
3. HA Host Monitoring (Type: Boolean)
Now comes the easy part, you can just create a workflow where the 3 inputs required above are inputs, or general attributes. If you use Inputs then you will be prompted each time. If you choose general attributes then they are set permanently in the vCO workflow unless you change them.
I chose to set the DRS Behaviour/HA Host Monitoring settings as general attributes inside the workflow which I called “Configure HA/DRS Settings for Cluster”. Then I would just select the cluster I wanted to apply the settings to when I ran the workflow.
Now once I decided this worked great, I wanted to push the settings out to ALL of my clusters, so I created the main operational workflow “Configure HA/DRS for ALL Clusters”. I then made an array of clusters as the general attribute, which I could add in, or take out clusters as I wanted to.
Finally, schedule the workflow in vCO to run every night at midnight, and you know that all your clusters are exactly as they should be. If you are working on a cluster, just take it out of the array and put it back in when you are done.