Skip to content

Commit 2726aca

Browse files
author
Alexandru Bagu
committed
rebase to 4.20 and adapt code to match other PR
1 parent 4a40b00 commit 2726aca

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

core/src/main/java/com/cloud/agent/api/GetVmIpAddressCommand.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ public class GetVmIpAddressCommand extends Command {
2323

2424
String vmName;
2525
String vmNetworkCidr;
26-
String vmNicMac;
2726
boolean windows = false;
27+
String macAddress;
2828

29-
public GetVmIpAddressCommand(String vmName, String vmNetworkCidr, String vmNicMac, boolean windows) {
29+
public GetVmIpAddressCommand(String vmName, String vmNetworkCidr, boolean windows, String macAddress) {
3030
this.vmName = vmName;
3131
this.windows = windows;
3232
this.vmNetworkCidr = vmNetworkCidr;
33-
this.vmNicMac = vmNicMac;
33+
this.macAddress = macAddress;
3434
}
3535

3636
@Override
@@ -50,7 +50,7 @@ public String getVmNetworkCidr() {
5050
return vmNetworkCidr;
5151
}
5252

53-
public String getVmNicMac() {
54-
return vmNicMac;
53+
public String getMacAddress() {
54+
return macAddress;
5555
}
5656
}

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5756,7 +5756,7 @@ protected Answer execute(GetVmIpAddressCommand cmd) {
57565756
if (toolsStatus == VirtualMachineToolsStatus.TOOLS_NOT_INSTALLED) {
57575757
details += "Vmware tools not installed.";
57585758
} else {
5759-
var normalizedMac = cmd.getVmNicMac().replaceAll("-", ":");
5759+
var normalizedMac = cmd.getMacAddress().replaceAll("-", ":");
57605760
for(var guestInfoNic : guestInfo.getNet()) {
57615761
var normalizedNicMac = guestInfoNic.getMacAddress().replaceAll("-", ":");
57625762
if (!result && normalizedNicMac.equalsIgnoreCase(normalizedMac)) {

plugins/hypervisors/xenserver/src/test/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixRequestWrapperTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1934,7 +1934,7 @@ public void testGetVmIpAddressCommand() throws XenAPIException, XmlRpcException
19341934
vmIpsMap.put("Test", "127.0.0.1");
19351935
rec.networks = vmIpsMap;
19361936

1937-
final GetVmIpAddressCommand getVmIpAddrCmd = new GetVmIpAddressCommand("Test", "127.0.0.1/24", "00:1b:63:84:45:e6", false);
1937+
final GetVmIpAddressCommand getVmIpAddrCmd = new GetVmIpAddressCommand("Test", "127.0.0.1/24", false, null);
19381938

19391939
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
19401940
assertNotNull(wrapper);

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -749,23 +749,25 @@ private class VmIpAddrFetchThread extends ManagedContextRunnable {
749749
boolean isWindows;
750750
Long hostId;
751751
String networkCidr;
752+
String macAddress;
752753

753-
public VmIpAddrFetchThread(long vmId, String vmUuid, long nicId, String instanceName, boolean windows, Long hostId, String networkCidr) {
754+
public VmIpAddrFetchThread(long vmId, String vmUuid, long nicId, String instanceName, boolean windows, Long hostId, String networkCidr, String macAddress) {
754755
this.vmId = vmId;
755756
this.vmUuid = vmUuid;
756757
this.nicId = nicId;
757758
this.vmName = instanceName;
758759
this.isWindows = windows;
759760
this.hostId = hostId;
760761
this.networkCidr = networkCidr;
762+
this.macAddress = macAddress;
761763
}
762764

763765
@Override
764766
protected void runInContext() {
765-
NicVO nic = _nicDao.findById(nicId);
766-
GetVmIpAddressCommand cmd = new GetVmIpAddressCommand(vmName, networkCidr, nic.getMacAddress(), isWindows);
767+
GetVmIpAddressCommand cmd = new GetVmIpAddressCommand(vmName, networkCidr, isWindows, macAddress);
767768
boolean decrementCount = true;
768769

770+
NicVO nic = _nicDao.findById(nicId);
769771
try {
770772
logger.debug("Trying IP retrieval for VM [id: {}, uuid: {}, name: {}], nic {}", vmId, vmUuid, vmName, nic);
771773
Answer answer = _agentMgr.send(hostId, cmd);
@@ -2686,7 +2688,7 @@ protected void runInContext() {
26862688
boolean isWindows = _guestOSCategoryDao.findById(_guestOSDao.findById(vm.getGuestOSId()).getCategoryId()).getName().equalsIgnoreCase("Windows");
26872689

26882690
_vmIpFetchThreadExecutor.execute(new VmIpAddrFetchThread(vmId, vmInstance.getUuid(), nicId, vmInstance.getInstanceName(),
2689-
isWindows, vm.getHostId(), network.getCidr()));
2691+
isWindows, vm.getHostId(), network.getCidr(), nicVo.getMacAddress()));
26902692

26912693
}
26922694
} catch (Exception e) {

0 commit comments

Comments
 (0)