Skip to content

Commit 4f8b88b

Browse files
authored
vmware: while plugging in nics get existing sorted nic devices (#4336)
In large environments, with VR having multiple nics when plugging in nic, it must get existing nics by sorted device ID otherwise it may cause incorrect nic plugging/order. Fixes #4246 Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent d657ef7 commit 4f8b88b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ private PlugNicAnswer execute(PlugNicCommand cmd) {
11801180
}
11811181

11821182
// find a usable device number in VMware environment
1183-
VirtualDevice[] nicDevices = vmMo.getNicDevices();
1183+
VirtualDevice[] nicDevices = vmMo.getSortedNicDevices();
11841184
int deviceNumber = -1;
11851185
for (VirtualDevice device : nicDevices) {
11861186
if (device.getUnitNumber() > deviceNumber)
@@ -1380,7 +1380,7 @@ private void plugPublicNic(VirtualMachineMO vmMo, final String vlanId, final IpA
13801380
int nicIndex = allocPublicNicIndex(vmMo);
13811381

13821382
try {
1383-
VirtualDevice[] nicDevices = vmMo.getNicDevices();
1383+
VirtualDevice[] nicDevices = vmMo.getSortedNicDevices();
13841384

13851385
VirtualEthernetCard device = (VirtualEthernetCard) nicDevices[nicIndex];
13861386

vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3060,6 +3060,10 @@ else if (unitNumber0 > unitNumber1)
30603060
return nics;
30613061
}
30623062

3063+
public VirtualDevice[] getSortedNicDevices() throws Exception {
3064+
return getNicDevices(true).toArray(new VirtualDevice[0]);
3065+
}
3066+
30633067
public VirtualDevice[] getNicDevices() throws Exception {
30643068
return getNicDevices(false).toArray(new VirtualDevice[0]);
30653069
}

0 commit comments

Comments
 (0)