I am trying to get the UUID of a virtual machine, but keep coming up with an invalid request error. Below is my code that I am using. VmwareDistrubutedVirtualSwitch extends DistributedVirtualSwitch, and all of the DistributedVirtualSwitch methods did work for me ( like getName() and getServerConnection() ). But, methods in VmwareDistributed like (getUUID) are not working for me and throwing the error.
I am trying to get the UUID of a virtual machine, but keep coming up with an invalid request error. Below is my code that I am using. VmwareDistrubutedVirtualSwitch extends DistributedVirtualSwitch, and all of the DistributedVirtualSwitch methods did work for me ( like getName() and getServerConnection() ). But, methods in VmwareDistributed like (getUUID) are not working for me and throwing the error.
Code:
http://pastebin.com/YAgqUhs5
ManagedObjectReference mor = new ManagedObjectReference();
mor.setType( "VirtualMachine" );
mor.set_value( "Test" );
VmwareDistributedVirtualSwitch vd = new VmwareDistributedVirtualSwitch( si.getServerConnection(), mor );
System.out.println( vd.getUuid() );
System.out.println( vms[3].getName() );
Hello Dominic,
InvalidRequest comes into picture when:
either missing some required parameters, or giving inappropriate values.
To get UUID of virtual distributed switch, please use below code.
ManagedEntity[] DVSwitch = new InventoryNavigator(vc.si.getRootFolder()).searchManagedEntities("DistributedVirtualSwitch");
for(ManagedEntity swi : DVSwitch)
{
String name = swi.getName();
if(name.equalsIgnoreCase(dvs)) // dvs is the string form of distributed virtual switch whom u //want to find UUID
{
DistributedVirtualSwitch DVS = (DistributedVirtualSwitch) swi;
UUID = DVS.getUuid();
break;
}
}
PLease revert if need further clarification.
Thanks,
Last edit: asif masood 2015-08-20