VMware Cloud Community
jacksonecac
Enthusiast
Enthusiast

Deploying to the 'best' host

I have a very large workflow that determines the best host to deploy a new virtual machine on. I am trying to determine what that logic would look like. The best scenario that I can come up with is something like this:

/** input     A cluster object     New memory for a vm     New vcpu for a vm */ 
var bestHost = null;
var hosts = cluster.hosts;
hosts.sort(function(a,b){ if(a.summary.runtime.quickstates.overallCpuUsage != b.a.summary.runtime.quickstates.overallCpuUsage) return a.summary.runtime.quickstates.overallCpuUsage - b.summary.runtime.quickstates.overallCpuUsage; else return a.summary.runtime.quickstates.overallMemoryUsage - b.summary.runtime.quickstates.overallMemoryUsage});
hosts.reverse();
for each(var host in hosts)
{
    if(host.cpu + new cpu < capacity) //psuedo code
        continue;
   if(host.memory + new memory < capacity) //psuedo code
       bestHost = host;
}

Tags (1)
Reply
0 Kudos
1 Reply
Dan_Linsley
VMware Employee
VMware Employee

Just depends how you wish to over provision.  Core count or Memory Size.  Your capacity figures should reflect that.

Sounds like you have DRS disabled and/or don't like how DRS would distribute VMs in a cluster?

Reply
0 Kudos