Skip to content

Commit be4a648

Browse files
authored
Create global configuration to allow changing the default nic adapter for user VMs in VMware (#7954)
Co-authored-by: Gabriel <gabriel.fernandes@scclouds.com.br>
1 parent 1f29f6f commit be4a648

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VmwareVmImplementer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,15 @@ VirtualMachineTO implement(VirtualMachineProfile vm, VirtualMachineTO to, long c
129129
}
130130
}
131131
} else {
132-
// for user-VM, use E1000 as default
133132
if (nicDeviceType == null) {
134-
details.put(VmDetailConstants.NIC_ADAPTER, VirtualEthernetCardType.E1000.toString());
133+
details.put(VmDetailConstants.NIC_ADAPTER, vmwareMgr.VmwareUserVmNicDeviceType.value());
135134
} else {
136135
try {
137136
VirtualEthernetCardType.valueOf(nicDeviceType);
138137
} catch (Exception e) {
139-
LOGGER.warn("Invalid NIC device type " + nicDeviceType + " is specified in VM details, switch to default E1000");
140-
details.put(VmDetailConstants.NIC_ADAPTER, VirtualEthernetCardType.E1000.toString());
138+
LOGGER.warn(String.format("Invalid NIC device type [%s] specified in VM details, switching to value [%s] of configuration [%s].",
139+
nicDeviceType, vmwareMgr.VmwareUserVmNicDeviceType.value(), vmwareMgr.VmwareUserVmNicDeviceType.toString()));
140+
details.put(VmDetailConstants.NIC_ADAPTER, vmwareMgr.VmwareUserVmNicDeviceType.value());
141141
}
142142
}
143143
}

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ public interface VmwareManager {
5353
"VMware interval window (in seconds) to collect metrics. If this is set to less than 20, then default (300 seconds) will be used. The interval used must be enabled in vCenter for this change to work, "
5454
+ "otherwise the collection of metrics will result in an error. Check VMWare docs to know how to enable metrics interval.", true);
5555

56+
static final ConfigKey<String> VmwareUserVmNicDeviceType = new ConfigKey<String>(
57+
String.class,
58+
"vmware.uservm.nic.device.type",
59+
"Advanced",
60+
"E1000",
61+
"Specify the default network device type for user VMs, valid values are E1000, PCNet32, Vmxnet2, Vmxnet3",
62+
true, ConfigKey.Scope.Global, null, null, null, null, null, ConfigKey.Kind.Select, "E1000,PCNet32,Vmxnet2,Vmxnet3");
63+
5664
String composeWorkerName();
5765

5866
String getSystemVMIsoFileNameOnDatastore();

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ public String getConfigComponentName() {
296296

297297
@Override
298298
public ConfigKey<?>[] getConfigKeys() {
299-
return new ConfigKey<?>[] {s_vmwareNicHotplugWaitTimeout, s_vmwareCleanOldWorderVMs, templateCleanupInterval, s_vmwareSearchExcludeFolder, s_vmwareOVAPackageTimeout, s_vmwareCleanupPortGroups, VMWARE_STATS_TIME_WINDOW};
299+
return new ConfigKey<?>[] {s_vmwareNicHotplugWaitTimeout, s_vmwareCleanOldWorderVMs, templateCleanupInterval, s_vmwareSearchExcludeFolder, s_vmwareOVAPackageTimeout, s_vmwareCleanupPortGroups, VMWARE_STATS_TIME_WINDOW, VmwareUserVmNicDeviceType};
300300
}
301301
@Override
302302
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {

0 commit comments

Comments
 (0)