VMware Cloud Community
kristofasaert
Contributor
Contributor
Jump to solution

vRO : Set latency level on VM

Hello,

I'm trying to set the latency level on a VM with vRO.
I'm able to fetch the current status => System.log( "sens level: "+ vCenterVm.config.latencySensitivity.level);

However I've already tried several things to set the sensitivity but I always get error messages.
Currently I'm here:

System.log( "sens level: "+ vCenterVm.config.latencySensitivity.level);

var configSpec = new VcVirtualMachineConfigSpec();
configSpec.LatencySensitivity = new VcLatencySensitivity();
configSpec.LatencySensitivity.level = "high" ;

And this is the error I get:

Error in (Workflow:Change Latency Sensitivity / Scriptable task (item4)#35) Cannot convert high to com.vmware.vim.binding.vim.LatencySensitivity$SensitivityLevel

0 Kudos
2 Solutions

Accepted Solutions
emacintosh
Hot Shot
Hot Shot
Jump to solution

ok, maybe it's just an enumeration and not an object.  This one didn't yell at me at all....

 

var configSpec = new VcVirtualMachineConfigSpec();
configSpec.LatencySensitivity = new VcLatencySensitivity();
configSpec.LatencySensitivity.level = VcLatencySensitivitySensitivityLevel.high;

View solution in original post

Tags (1)
xian_
Expert
Expert
Jump to solution

var task = vCenterVm.reconfigVM_Task(configSpec);
System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(task, true , 1);

View solution in original post

10 Replies
emacintosh
Hot Shot
Hot Shot
Jump to solution

I'm not familiar with that setting, but it sounds like it's expecting an object or enumeration, and I found one in the API Explorer.  So maybe somethin like this?

 

 

var configSpec = new VcVirtualMachineConfigSpec();
var latencySensitivity = new VcLatencySensitivitySensitivityLevel(); 
configSpec.LatencySensitivity = new VcLatencySensitivity();
configSpec.LatencySensitivity.level = latencySensitivity.high;

 

0 Kudos
kristofasaert
Contributor
Contributor
Jump to solution

Hey emacintosh,

When I enter that I get this error:
2021-06-29 20:21:57.233] [E] Unable to create object : VcLatencySensitivitySensitivityLevel : com.vmware.vim.binding.vim.LatencySensitivity$SensitivityLevel
[2021-06-29 20:21:57.252] [E] Workflow execution stack:
***
item: 'Change Latency Sensitivity/item4', state: 'failed', business state: 'null', exception: 'Unable to create object : VcLatencySensitivitySensitivityLevel : com.vmware.vim.binding.vim.LatencySensitivity$SensitivityLevel'
workflow: 'Change Latency Sensitivity' (03c8f3bd-a90b-4824-bbd3-2a8fd71c2009)
| 'attribute': name=optionKey type=string value=__NULL__
| 'attribute': name=optionValue type=string value=__NULL__
| 'attribute': name=vCenterVm type=VC:VirtualMachine value=dunes://service.dunes.ch/CustomSDKObject?id='aa02lvicw110.ds02.ds4f.net%2Cid:vm-699634'&dunesName='VC:VirtualMachine'
| 'attribute': name=vmuuid type=string value=50202784-198d-4490-991a-3b3886a0b3be
| 'attribute': name=actionTask type=VC:Task value=__NULL__
| 'no inputs'
| 'no outputs'
*** End of execution stack.

0 Kudos
emacintosh
Hot Shot
Hot Shot
Jump to solution

ok, maybe it's just an enumeration and not an object.  This one didn't yell at me at all....

 

var configSpec = new VcVirtualMachineConfigSpec();
configSpec.LatencySensitivity = new VcLatencySensitivity();
configSpec.LatencySensitivity.level = VcLatencySensitivitySensitivityLevel.high;
Tags (1)
kristofasaert
Contributor
Contributor
Jump to solution

Indeed, it doesn't complain but now it didn't change the setting

My code:

System.log( "sens level: "+ vCenterVm.config.latencySensitivity.level);
var configSpec = new VcVirtualMachineConfigSpec();
configSpec.LatencySensitivity = new VcLatencySensitivity();
configSpec.LatencySensitivity.level = VcLatencySensitivitySensitivityLevel.high;
System.log( "sens level: "+ vCenterVm.config.latencySensitivity.level);

My log:

[2021-06-29 20:53:48.207] [I] sens level: DynamicWrapper (Instance) : [VcLatencySensitivitySensitivityLevel]-[class com.vmware.vim.binding.vim.LatencySensitivity$SensitivityLevel] -- VALUE : normal
[2021-06-29 20:53:48.209] [I] sens level: DynamicWrapper (Instance) : [VcLatencySensitivitySensitivityLevel]-[class com.vmware.vim.binding.vim.LatencySensitivity$SensitivityLevel] -- VALUE : normal

Tags (1)
0 Kudos
kristofasaert
Contributor
Contributor
Jump to solution

It doesn't complain either but the setting isn't changed...

My code:

System.log( "sens level: "+ vCenterVm.config.latencySensitivity.level);
var configSpec = new VcVirtualMachineConfigSpec();
configSpec.LatencySensitivity = new VcLatencySensitivity();
configSpec.LatencySensitivity.level = VcLatencySensitivitySensitivityLevel.high;
System.log( "sens level: "+ vCenterVm.config.latencySensitivity.level);

My logs:

[2021-06-29 20:53:48.207] [I] sens level: DynamicWrapper (Instance) : [VcLatencySensitivitySensitivityLevel]-[class com.vmware.vim.binding.vim.LatencySensitivity$SensitivityLevel] -- VALUE : normal
[2021-06-29 20:53:48.209] [I] sens level: DynamicWrapper (Instance) : [VcLatencySensitivitySensitivityLevel]-[class com.vmware.vim.binding.vim.LatencySensitivity$SensitivityLevel] -- VALUE : normal

0 Kudos
kristofasaert
Contributor
Contributor
Jump to solution

Indeed no error message but the setting isn't changed.

My code:

System.log( "sens level: "+ vCenterVm.config.latencySensitivity.level);
var configSpec = new VcVirtualMachineConfigSpec();
configSpec.LatencySensitivity = new VcLatencySensitivity();
configSpec.LatencySensitivity.level = VcLatencySensitivitySensitivityLevel.high;
System.log( "sens level: "+ vCenterVm.config.latencySensitivity.level);

My Log:

[2021-06-29 20:53:48.207] [I] sens level: DynamicWrapper (Instance) : [VcLatencySensitivitySensitivityLevel]-[class com.vmware.vim.binding.vim.LatencySensitivity$SensitivityLevel] -- VALUE : normal
[2021-06-29 20:53:48.209] [I] sens level: DynamicWrapper (Instance) : [VcLatencySensitivitySensitivityLevel]-[class com.vmware.vim.binding.vim.LatencySensitivity$SensitivityLevel] -- VALUE : normal

0 Kudos
JoseCavalheri
Contributor
Contributor
Jump to solution

0 Kudos
kristofasaert
Contributor
Contributor
Jump to solution

Hey Jose 😁,

I don't have a powershell host so I prefer to solve it in vRO natively.

But I've already found the powershell scripts for that function.

0 Kudos
xian_
Expert
Expert
Jump to solution

var task = vCenterVm.reconfigVM_Task(configSpec);
System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(task, true , 1);
kristofasaert
Contributor
Contributor
Jump to solution

Ok so the post of Xian & emacintosh together cracked the case 🤑
Below code gives you the complete solution

var configSpec = new VcVirtualMachineConfigSpec();
configSpec.LatencySensitivity = new VcLatencySensitivity();
configSpec.LatencySensitivity.level = VcLatencySensitivitySensitivityLevel.high;
var task = vCenterVm.reconfigVM_Task(configSpec);
System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(task, true , 1);