if libvirt version is < 10.10(below rhel 6.5), won't set nic throttling

This commit is contained in:
Edison Su 2014-10-09 16:36:22 -07:00
parent 15a2ea7c7e
commit 6dc6e8a900
2 changed files with 12 additions and 2 deletions

View File

@ -46,6 +46,7 @@ public class BridgeVifDriver extends VifDriverBase {
private String _modifyVlanPath;
private String _modifyVxlanPath;
private String bridgeNameSchema;
private Long libvirtVersion;
@Override
public void configure(Map<String, Object> params) throws ConfigurationException {
@ -74,6 +75,11 @@ public class BridgeVifDriver extends VifDriverBase {
throw new ConfigurationException("Unable to find modifyvxlan.sh");
}
libvirtVersion = (Long) params.get("libvirtVersion");
if (libvirtVersion == null) {
libvirtVersion = 0L;
}
try {
createControlNetwork();
} catch (LibvirtException e) {
@ -102,8 +108,12 @@ public class BridgeVifDriver extends VifDriverBase {
throw new InternalErrorException("Nicira NVP Logicalswitches are not supported by the BridgeVifDriver");
}
String trafficLabel = nic.getName();
Integer networkRateKBps = 0;
if (libvirtVersion > ((10 * 1000 + 10))) {
networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
}
if (nic.getType() == Networks.TrafficType.Guest) {
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan) && (vNetId != null) && (protocol != null) && (!vNetId.equalsIgnoreCase("untagged")) ||
(nic.getBroadcastType() == Networks.BroadcastDomainType.Vxlan)) {
if (trafficLabel != null && !trafficLabel.isEmpty()) {
@ -122,7 +132,6 @@ public class BridgeVifDriver extends VifDriverBase {
createControlNetwork();
intf.defBridgeNet(_bridges.get("linklocal"), null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter));
} else if (nic.getType() == Networks.TrafficType.Public) {
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan) && (vNetId != null) && (protocol != null) && (!vNetId.equalsIgnoreCase("untagged")) ||
(nic.getBroadcastType() == Networks.BroadcastDomainType.Vxlan)) {
if (trafficLabel != null && !trafficLabel.isEmpty()) {

View File

@ -953,6 +953,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
params.put("libvirt.host.pifs", _pifs);
params.put("libvirt.computing.resource", this);
params.put("libvirtVersion", _hypervisorLibvirtVersion);
configureVifDrivers(params);