VMware Aria Automation Orchestrator

 View Only
  • 1.  Adding VM to existing DRS rule?

    Posted Feb 08, 2018 02:31 PM

    Has anyone successfully modifed an existing DRS rule and added a new VM to a rule?  I can add a new one with a duplicate name, but I cannot seem to modify an existing rule.  If I run the following it does nothing to the DRS rule.

    var antiaffinitySpec = new VcClusterAntiAffinityRuleSpec()
    antiaffinitySpec.enabled = true
    antiaffinitySpec.name = rulename
    antiaffinitySpec.userCreated = true
    antiaffinitySpec.vm = groupArray

    var clusterRuleSpec = new Array(new VcClusterRuleSpec());
    clusterRuleSpec[0] = new VcClusterRuleSpec()

    // If I change this to VcArrayUpdateOperation.add it will add a rule with a duplicate name
    clusterRuleSpec[0].operation = VcArrayUpdateOperation.edit;
    clusterRuleSpec[0].info = antiaffinitySpec;

    var clusterConfigSpec = new VcClusterConfigSpecEx();
    clusterConfigSpec.rulesSpec = clusterRuleSpec;

    att_task = cluster.reconfigureComputeResource_Task(clusterConfigSpec, true);

    var affinitySpec = new VcClusterAntiAffinityRuleSpec()
    affinitySpec.enabled = true
    affinitySpec.name = rulename
    affinitySpec.userCreated = true
    affinitySpec.vm = groupArray
     
    var clusterRuleSpec = new Array(new VcClusterRuleSpec());
    clusterRuleSpec[0] = new VcClusterRuleSpec()
    clusterRuleSpec[0].operation = VcArrayUpdateOperation.remove;
    clusterRuleSpec[0].info = affinitySpec;
     
    var clusterConfigSpec = new VcClusterConfigSpecEx();
    clusterConfigSpec.rulesSpec = clusterRuleSpec;
    //clusterConfigSpec.groupSpec =clusterGroupSpec;
     
    //clusterConfigSpec.groupSpec[0].operation = VcArrayUpdateOperation.edit
     
    att_task = cluster.reconfigureComputeResource_Task(clusterConfigSpec, true);


  • 2.  RE: Adding VM to existing DRS rule?

    Posted Feb 08, 2018 05:44 PM

    You don't need to modify the rule necessarily unless you are adding another vm or host group to the rule.  We just add the vm to the vm group specified in the rule.  There are canned workflows for this.  I ended up writing my own action based on the canned stuff that works a bit more to my personal taste.  I'll attach it.



  • 3.  RE: Adding VM to existing DRS rule?

    Posted Feb 26, 2020 09:50 AM

    This is the workflow you can use to add VMs to an existing VM Group: "Add virtual machines to DRS group"



  • 4.  RE: Adding VM to existing DRS rule?

    Posted Nov 07, 2023 03:22 PM

    A bit late but I just started using this product and needed to do this. I am adding VMs that get deployed to a DRS group using powershell in Action Based Extensibility:

    Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false
    Connect-VIServer -Server vsphere.corp.com -User $vsphereUser -Password $vspherePass
    function handler($context, $inputs) {
       # Hostname generated during abx static name creation
       $vm_name = $inputs.customProperties.vmname
       Get-DrsClusterGroup "group_name" | Set-DrsClusterGroup -VM $vm_name -Add
       # Return updated outputs object containing hostname deployment process
       return $vm_name
    }

     

    Then using 'Compute Post Provision' as an Event Topic in the Subscription