2 Replies Latest reply on Feb 19, 2020 1:52 AM by WJPConway

    vRO Workflow to Place vCD vAPP VM's in a DRS Affinity Rule

    WJPConway Novice

      First of all apologies I am not a coder am an infrastructure guy so expect some stupidity below


      I have a vro workflow that creates multiple vAPPs from a specified template.

      All this is working fine for me


      But now need to add a new step where it will create 2 DRS Affinity Rules an assign all the VMs to one of the rules based on a fairly simple pattern.

      The rules will be

      Rule-A and Rule-B

      The VMs that will go into RuleA have Random names but the names will not contain 'VM-B-' - and the VMs that will go into RuleB will all have VM names that begin with 'VM-B-' then random characters.


      So far I have

      input is the vapp variable vapp



      var vms = System.getModule("com.vmware.library.vCloud.vApp").getVmsFromVApp(vapp) ;

          for each (var vm in vms) {

      if (vm.Name ='VM-B-'*){   //note sure is this the right syntax for like

      System.log (vm.Name+' Should go into Rule-B')

      //add vm.Name to array of VMs - B




      System.log (vm.Name+' Should go into Rule-A')

      //add vm.Name to array of VMs - A



      //Create DRS Affinity Rule A with array of vms A

      var rulea = System.getModule("com.vmware.library.vCloud.schema.objects").createVmAffinityRule(isEnabledArg,isMandatoryArg,'rulea',operationKeyArg,polarityArg,scopeArg,vmReferencesArg) ;


      //Create DRS Affinity Rule B with array of vms B

      var ruleb= System.getModule("com.vmware.library.vCloud.schema.objects").createVmAffinityRule(isEnabledArg,isMandatoryArg,'ruleb',operationKeyArg,polarityArg,scopeArg,vmReferencesArg) ;






      1) When creating the rule - how do i plug in the standard values the only variables should be the names  - to create the syntax seems to be

      System.getModule("com.vmware.library.vCloud.schema.objects").createVmAffinityRule(isEnabledArg,isMandatoryArg,'rulea',operationKeyArg,polarityArg,scopeArg,vmReferencesArg) ;

      Can I just plug in boolen values directly like below (where can I get exactly what they are looking for here)

      System.getModule("com.vmware.library.vCloud.schema.objects").createVmAffinityRule('1','1','rulea',operationKeyArg,'Affinity',scopeArg,vmReferencesArg) ;


      2) Is vmReferenceArg an array of vms -