dvsPortSetting.setOutShapingPolicy(shapingPolicy);
return dvsPortSetting;
}
public static DVSTrafficShapingPolicy getDVSShapingPolicy(Integer networkRateMbps) {
DVSTrafficShapingPolicy shapingPolicy = new DVSTrafficShapingPolicy();
if (networkRateMbps == null || networkRateMbps.intValue() <= 0) {
return shapingPolicy;
}
shapingPolicy = new DVSTrafficShapingPolicy();
BoolPolicy isEnabled = new BoolPolicy();
LongPolicy averageBandwidth = new LongPolicy();
LongPolicy peakBandwidth = new LongPolicy();
LongPolicy burstSize = new LongPolicy();
isEnabled.setValue(true);
averageBandwidth.setValue((long) networkRateMbps.intValue() * 1024L * 1024L);
// We chose 50% higher allocation than average bandwidth.
// TODO(sateesh): Also let user specify the peak coefficient
peakBandwidth.setValue((long) (averageBandwidth.getValue() * 1.5));
// TODO(sateesh): Also let user specify the burst coefficient
burstSize.setValue((long) (5 * averageBandwidth.getValue() / 8));
shapingPolicy.setEnabled(isEnabled);
shapingPolicy.setAverageBandwidth(averageBandwidth);
shapingPolicy.setPeakBandwidth(peakBandwidth);
shapingPolicy.setBurstSize(burstSize);
return shapingPolicy;
}