SDK issue getting the mac address of machine
Posted: 4. Jul 2010, 04:02
Hello all,
I'm doing an application where I need to get some data of the current machines running in a host.
but for any reason the mac address that I get from the SDK call is not correct.
here is the code that Im using to get the mac
even after I set the mac address fixed, like this
and can get the correct mac address in the machine
I still get the following list of data from the call
where the machine that I changed the mac is the one with 128 of memory
{"uuid":"b5fa6910-3b45-4666-8486-5d2109e46e41","macaddress":"080027E55D31","memorySize":128,"status":"Running"}
note the wrong Mac address ...
any ideas ?
I'm doing an application where I need to get some data of the current machines running in a host.
but for any reason the mac address that I get from the SDK call is not correct.
here is the code that Im using to get the mac
Code: Select all
public VirtualMachineVO[] getVMs() {
VirtualMachineVO[] result = new VirtualMachineVO[0];
try {
// Call IVirtualBox::getMachines, which yields an array
// of managed object references to all machines which have
// been registered:
String[] aMachines = _port.IVirtualBox_getMachines(_oVbox);
result = new VirtualMachineVO[aMachines.length];
for (int i = 0; i < aMachines.length; i++) {
String oMachine = aMachines[i];
String machinename = _port.IMachine_getHardwareUUID(oMachine);
UnsignedInt slot = new UnsignedInt(1);
String netWorkAdapter = _port.IMachine_getNetworkAdapter(oMachine, slot);
logger.debug("netWorkAdapter: " + netWorkAdapter);
String macaddress = _port.INetworkAdapter_getMACAddress(netWorkAdapter);
logger.debug("macaddress: " + macaddress);
UnsignedInt memorySize = _port.IMachine_getMemorySize(oMachine);
logger.debug("Machine " + i + ": " + oMachine + " - " + machinename + " mac=" + macaddress);
result[i] = new VirtualMachineVO();
result[i].setUuid(machinename);
result[i].setMacaddress(macaddress);
result[i].setMemorySize(memorySize.intValue());
result[i].setStatus( _port.IMachine_getState(oMachine).getValue());
// release managed object reference
_port.IManagedObjectRef_release(oMachine);
}
} catch (Exception e) {
logger.error("getVMs()", e);
}
return result;
}
Code: Select all
[{"uuid":"9e161cb5-cc58-44dc-9b88-a2f0b70ed0ff","macaddress":"08002794F850","memorySize":768,"status":"Saved"},
{"uuid":"6decd679-d6ef-4445-9b23-9a989774f005","macaddress":"0800278051E8","memorySize":796,"status":"PoweredOff"},
{"uuid":"442d9002-a4ee-4884-8ccb-b3fa6a6b6269","macaddress":"0800277DF164","memorySize":1024,"status":"Saved"},
{"uuid":"b5fa6910-3b45-4666-8486-5d2109e46e41","macaddress":"080027E55D31","memorySize":128,"status":"Running"}]
{"uuid":"b5fa6910-3b45-4666-8486-5d2109e46e41","macaddress":"080027E55D31","memorySize":128,"status":"Running"}
note the wrong Mac address ...
any ideas ?