Enthusiast
Enthusiast

Facing issue while try to set affinity rule through VCO workflow

Jump to solution

Facing issue while try to set affinity rule through VCO workflow I am try to write VCO workflow to set cluster level affinity rule but it throws  error Cannot convert ClusterComputeResource'mycluster' to com.vmware.vim.vi4.ClusterConfigSpec (Workflow:Create vm-vm affinity rule / Scriptable task (item1)#19) My workflow script is var rule = new VcClusterAntiAffinityRuleSpec(); rule.key = -30; rule.enabled = true; rule.name = ruleName; rule.userCreated = true; rule.vm = vms; var clusterSpecRules = new Array(); var clusterSpecRule = new VcClusterRuleSpec(); clusterSpecRule.operation = VcArrayUpdateOperation.add; clusterSpecRule.info = rule; clusterSpecRules.push(clusterSpecRule); var clusterSpec = new VcClusterConfigSpec(); clusterSpec.rulesSpec = clusterSpecRules; //var m = computeCluster.vimHost //spec = task = computeCluster.reconfigureCluster_Task(computeCluster, spec , true); Note: In the above code these are the input parameter computeCluster is input parameter of type VC:clusterComputeResource ruleName  is input parameter of type String --AVR

1 Solution

Accepted Solutions
Enthusiast
Enthusiast

Here's the code I use, give it a shot.

var affinitySpec = new VcClusterAffinityRuleSpec();
affinitySpec.enabled = true;
affinitySpec.name = att_ruleName;
affinitySpec.userCreated = true;
affinitySpec.vm = att_vmArray;

var clusterRuleSpec = new Array(new VcClusterRuleSpec());
clusterRuleSpec[0] = new VcClusterRuleSpec()
clusterRuleSpec[0].operation = VcArrayUpdateOperation.add;
clusterRuleSpec[0].info = affinitySpec;

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

att_task = att_clusterComputeResource.reconfigureComputeResource_Task(clusterConfigSpec, true);

View solution in original post

3 Replies
Enthusiast
Enthusiast

Facing issue while try to set affinity rule through VCO workflow

I am try to write VCO workflow to set cluster level affinity rule but it throws  error

Cannot convert ClusterComputeResource<domain-c7>'mycluster' to com.vmware.vim.vi4.ClusterConfigSpec (Workflow:Create vm-vm affinity rule / Scriptable task (item1)#19)

My workflow script is

var rule = new VcClusterAntiAffinityRuleSpec();

rule.key = -30;

rule.enabled = true;

rule.name = ruleName;

rule.userCreated = true;

rule.vm = vms;

var clusterSpecRules = new Array();

var clusterSpecRule = new VcClusterRuleSpec();

clusterSpecRule.operation = VcArrayUpdateOperation.add;

clusterSpecRule.info = rule;

clusterSpecRules.push(clusterSpecRule);

var clusterSpec = new VcClusterConfigSpec();

clusterSpec.rulesSpec = clusterSpecRules;

//var m = computeCluster.vimHost

//spec =

task = computeCluster.reconfigureCluster_Task(computeCluster, spec , true);

Note: In the above code these are the input parameters

computeCluster is input parameter of type VC:clusterComputeResource

ruleName  is input parameter of type String

any clue where I am wrong

--AVR

0 Kudos
Enthusiast
Enthusiast

Here's the code I use, give it a shot.

var affinitySpec = new VcClusterAffinityRuleSpec();
affinitySpec.enabled = true;
affinitySpec.name = att_ruleName;
affinitySpec.userCreated = true;
affinitySpec.vm = att_vmArray;

var clusterRuleSpec = new Array(new VcClusterRuleSpec());
clusterRuleSpec[0] = new VcClusterRuleSpec()
clusterRuleSpec[0].operation = VcArrayUpdateOperation.add;
clusterRuleSpec[0].info = affinitySpec;

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

att_task = att_clusterComputeResource.reconfigureComputeResource_Task(clusterConfigSpec, true);

View solution in original post

Enthusiast
Enthusiast

Thanks dear your answer resolved my issue.

-AVR

0 Kudos