use of com.vmware.vim25.LongPolicy in project cloudstack by apache.
the class HypervisorHostHelperTest method testIsSpecMatchConfigSpecWithAutoExpandUpdate.
@Test
public void testIsSpecMatchConfigSpecWithAutoExpandUpdate() throws Exception {
int currentNumPorts = 512;
int currentvlanId = 100;
boolean currentAutoExpand = false;
DVSTrafficShapingPolicy currentTrafficShapingPolicy = new DVSTrafficShapingPolicy();
BoolPolicy currentIsEnabled = new BoolPolicy();
currentIsEnabled.setValue(true);
LongPolicy currentAvgBw = new LongPolicy();
currentAvgBw.setValue(200L);
LongPolicy currentBurstSize = new LongPolicy();
currentBurstSize.setValue(400L);
LongPolicy currentPeakBw = new LongPolicy();
currentPeakBw.setValue(2000L);
VMwareDVSPortSetting currentVmwareDvsPortSetting = new VMwareDVSPortSetting();
VmwareDistributedVirtualSwitchVlanIdSpec currentVlanIdSpec = new VmwareDistributedVirtualSwitchVlanIdSpec();
currentVlanIdSpec.setVlanId(currentvlanId);
currentVmwareDvsPortSetting.setVlan(currentVlanIdSpec);
currentTrafficShapingPolicy.setAverageBandwidth(currentAvgBw);
currentTrafficShapingPolicy.setBurstSize(currentBurstSize);
currentTrafficShapingPolicy.setPeakBandwidth(currentPeakBw);
currentTrafficShapingPolicy.setEnabled(currentIsEnabled);
currentVmwareDvsPortSetting.setInShapingPolicy(currentTrafficShapingPolicy);
when(currentDvPortgroupInfo.getNumPorts()).thenReturn(currentNumPorts);
when(currentDvPortgroupInfo.isAutoExpand()).thenReturn(currentAutoExpand);
when(currentDvPortgroupInfo.getDefaultPortConfig()).thenReturn(currentVmwareDvsPortSetting);
int newNumPorts = 256;
int newvlanId = 100;
boolean newAutoExpand = true;
DVSTrafficShapingPolicy newTrafficShapingPolicy = new DVSTrafficShapingPolicy();
BoolPolicy newIsEnabled = new BoolPolicy();
newIsEnabled.setValue(true);
LongPolicy newAvgBw = new LongPolicy();
newAvgBw.setValue(200L);
LongPolicy newBurstSize = new LongPolicy();
newBurstSize.setValue(400L);
LongPolicy newPeakBw = new LongPolicy();
newPeakBw.setValue(2000L);
VMwareDVSPortSetting newVmwareDvsPortSetting = new VMwareDVSPortSetting();
VmwareDistributedVirtualSwitchVlanIdSpec newVlanIdSpec = new VmwareDistributedVirtualSwitchVlanIdSpec();
newVlanIdSpec.setVlanId(newvlanId);
newVmwareDvsPortSetting.setVlan(newVlanIdSpec);
newTrafficShapingPolicy.setAverageBandwidth(newAvgBw);
newTrafficShapingPolicy.setBurstSize(newBurstSize);
newTrafficShapingPolicy.setPeakBandwidth(newPeakBw);
newTrafficShapingPolicy.setEnabled(newIsEnabled);
newVmwareDvsPortSetting.setInShapingPolicy(newTrafficShapingPolicy);
when(dvPortgroupConfigSpec.getNumPorts()).thenReturn(newNumPorts);
when(dvPortgroupConfigSpec.isAutoExpand()).thenReturn(newAutoExpand);
when(dvPortgroupConfigSpec.getDefaultPortConfig()).thenReturn(newVmwareDvsPortSetting);
boolean specCompareResult = HypervisorHostHelper.isSpecMatch(currentDvPortgroupInfo, dvPortgroupConfigSpec);
assertFalse(specCompareResult);
}
use of com.vmware.vim25.LongPolicy in project cloudstack by apache.
the class HypervisorHostHelperTest method testIsSpecMatchConfigSpecWithMoreDvPortsAndAutoExpandDisabled.
@Test
public void testIsSpecMatchConfigSpecWithMoreDvPortsAndAutoExpandDisabled() throws Exception {
int currentNumPorts = 512;
int currentvlanId = 100;
boolean currentAutoExpand = false;
DVSTrafficShapingPolicy currentTrafficShapingPolicy = new DVSTrafficShapingPolicy();
BoolPolicy currentIsEnabled = new BoolPolicy();
currentIsEnabled.setValue(true);
LongPolicy currentAvgBw = new LongPolicy();
currentAvgBw.setValue(200L);
LongPolicy currentBurstSize = new LongPolicy();
currentBurstSize.setValue(400L);
LongPolicy currentPeakBw = new LongPolicy();
currentPeakBw.setValue(2000L);
VMwareDVSPortSetting currentVmwareDvsPortSetting = new VMwareDVSPortSetting();
VmwareDistributedVirtualSwitchVlanIdSpec currentVlanIdSpec = new VmwareDistributedVirtualSwitchVlanIdSpec();
currentVlanIdSpec.setVlanId(currentvlanId);
currentVmwareDvsPortSetting.setVlan(currentVlanIdSpec);
currentTrafficShapingPolicy.setAverageBandwidth(currentAvgBw);
currentTrafficShapingPolicy.setBurstSize(currentBurstSize);
currentTrafficShapingPolicy.setPeakBandwidth(currentPeakBw);
currentTrafficShapingPolicy.setEnabled(currentIsEnabled);
currentVmwareDvsPortSetting.setInShapingPolicy(currentTrafficShapingPolicy);
when(currentDvPortgroupInfo.getNumPorts()).thenReturn(currentNumPorts);
when(currentDvPortgroupInfo.isAutoExpand()).thenReturn(currentAutoExpand);
when(currentDvPortgroupInfo.getDefaultPortConfig()).thenReturn(currentVmwareDvsPortSetting);
int newNumPorts = 256;
int newvlanId = 100;
boolean newAutoExpand = false;
DVSTrafficShapingPolicy newTrafficShapingPolicy = new DVSTrafficShapingPolicy();
BoolPolicy newIsEnabled = new BoolPolicy();
newIsEnabled.setValue(true);
LongPolicy newAvgBw = new LongPolicy();
newAvgBw.setValue(200L);
LongPolicy newBurstSize = new LongPolicy();
newBurstSize.setValue(400L);
LongPolicy newPeakBw = new LongPolicy();
newPeakBw.setValue(2000L);
VMwareDVSPortSetting newVmwareDvsPortSetting = new VMwareDVSPortSetting();
VmwareDistributedVirtualSwitchVlanIdSpec newVlanIdSpec = new VmwareDistributedVirtualSwitchVlanIdSpec();
newVlanIdSpec.setVlanId(newvlanId);
newVmwareDvsPortSetting.setVlan(newVlanIdSpec);
newTrafficShapingPolicy.setAverageBandwidth(newAvgBw);
newTrafficShapingPolicy.setBurstSize(newBurstSize);
newTrafficShapingPolicy.setPeakBandwidth(newPeakBw);
newTrafficShapingPolicy.setEnabled(newIsEnabled);
newVmwareDvsPortSetting.setInShapingPolicy(newTrafficShapingPolicy);
when(dvPortgroupConfigSpec.getNumPorts()).thenReturn(newNumPorts);
when(dvPortgroupConfigSpec.isAutoExpand()).thenReturn(newAutoExpand);
when(dvPortgroupConfigSpec.getDefaultPortConfig()).thenReturn(newVmwareDvsPortSetting);
boolean specCompareResult = HypervisorHostHelper.isSpecMatch(currentDvPortgroupInfo, dvPortgroupConfigSpec);
assertFalse(specCompareResult);
}
use of com.vmware.vim25.LongPolicy in project cloudstack by apache.
the class HypervisorHostHelperTest method testIsSpecMatchConfigSpecWithHighBandwidthShapingPolicy.
@Test
public void testIsSpecMatchConfigSpecWithHighBandwidthShapingPolicy() throws Exception {
// Tests case of network offering upgrade in terms of bandwidth
int currentNumPorts = 256;
int currentvlanId = 100;
boolean currentAutoExpand = true;
DVSTrafficShapingPolicy currentTrafficShapingPolicy = new DVSTrafficShapingPolicy();
BoolPolicy currentIsEnabled = new BoolPolicy();
currentIsEnabled.setValue(true);
LongPolicy currentAvgBw = new LongPolicy();
currentAvgBw.setValue(200L);
LongPolicy currentBurstSize = new LongPolicy();
currentBurstSize.setValue(400L);
LongPolicy currentPeakBw = new LongPolicy();
currentPeakBw.setValue(2000L);
VMwareDVSPortSetting currentVmwareDvsPortSetting = new VMwareDVSPortSetting();
VmwareDistributedVirtualSwitchVlanIdSpec currentVlanIdSpec = new VmwareDistributedVirtualSwitchVlanIdSpec();
currentVlanIdSpec.setVlanId(currentvlanId);
currentVmwareDvsPortSetting.setVlan(currentVlanIdSpec);
currentTrafficShapingPolicy.setAverageBandwidth(currentAvgBw);
currentTrafficShapingPolicy.setBurstSize(currentBurstSize);
currentTrafficShapingPolicy.setPeakBandwidth(currentPeakBw);
currentTrafficShapingPolicy.setEnabled(currentIsEnabled);
currentVmwareDvsPortSetting.setInShapingPolicy(currentTrafficShapingPolicy);
when(currentDvPortgroupInfo.getNumPorts()).thenReturn(currentNumPorts);
when(currentDvPortgroupInfo.isAutoExpand()).thenReturn(currentAutoExpand);
when(currentDvPortgroupInfo.getDefaultPortConfig()).thenReturn(currentVmwareDvsPortSetting);
int newNumPorts = 256;
int newvlanId = 100;
boolean newAutoExpand = true;
DVSTrafficShapingPolicy newTrafficShapingPolicy = new DVSTrafficShapingPolicy();
BoolPolicy newIsEnabled = new BoolPolicy();
newIsEnabled.setValue(true);
LongPolicy newAvgBw = new LongPolicy();
newAvgBw.setValue(400L);
LongPolicy newBurstSize = new LongPolicy();
newBurstSize.setValue(800L);
LongPolicy newPeakBw = new LongPolicy();
newPeakBw.setValue(4000L);
VMwareDVSPortSetting newVmwareDvsPortSetting = new VMwareDVSPortSetting();
VmwareDistributedVirtualSwitchVlanIdSpec newVlanIdSpec = new VmwareDistributedVirtualSwitchVlanIdSpec();
newVlanIdSpec.setVlanId(newvlanId);
newVmwareDvsPortSetting.setVlan(newVlanIdSpec);
newTrafficShapingPolicy.setAverageBandwidth(newAvgBw);
newTrafficShapingPolicy.setBurstSize(newBurstSize);
newTrafficShapingPolicy.setPeakBandwidth(newPeakBw);
newTrafficShapingPolicy.setEnabled(newIsEnabled);
newVmwareDvsPortSetting.setInShapingPolicy(newTrafficShapingPolicy);
when(dvPortgroupConfigSpec.getNumPorts()).thenReturn(newNumPorts);
when(dvPortgroupConfigSpec.isAutoExpand()).thenReturn(newAutoExpand);
when(dvPortgroupConfigSpec.getDefaultPortConfig()).thenReturn(newVmwareDvsPortSetting);
boolean specCompareResult = HypervisorHostHelper.isSpecMatch(currentDvPortgroupInfo, dvPortgroupConfigSpec);
assertFalse(specCompareResult);
}
use of com.vmware.vim25.LongPolicy in project cloudstack by apache.
the class HypervisorHostHelperTest method testIsSpecMatch.
@Test
public void testIsSpecMatch() throws Exception {
int currentNumPorts = 256;
int currentvlanId = 100;
boolean currentAutoExpand = true;
DVSTrafficShapingPolicy currentTrafficShapingPolicy = new DVSTrafficShapingPolicy();
BoolPolicy currentIsEnabled = new BoolPolicy();
currentIsEnabled.setValue(true);
LongPolicy currentAvgBw = new LongPolicy();
currentAvgBw.setValue(200L);
LongPolicy currentBurstSize = new LongPolicy();
currentBurstSize.setValue(400L);
LongPolicy currentPeakBw = new LongPolicy();
currentPeakBw.setValue(2000L);
VMwareDVSPortSetting currentVmwareDvsPortSetting = new VMwareDVSPortSetting();
VmwareDistributedVirtualSwitchVlanIdSpec currentVlanIdSpec = new VmwareDistributedVirtualSwitchVlanIdSpec();
currentVlanIdSpec.setVlanId(currentvlanId);
currentVmwareDvsPortSetting.setVlan(currentVlanIdSpec);
currentTrafficShapingPolicy.setAverageBandwidth(currentAvgBw);
currentTrafficShapingPolicy.setBurstSize(currentBurstSize);
currentTrafficShapingPolicy.setPeakBandwidth(currentPeakBw);
currentTrafficShapingPolicy.setEnabled(currentIsEnabled);
currentVmwareDvsPortSetting.setInShapingPolicy(currentTrafficShapingPolicy);
when(currentDvPortgroupInfo.getNumPorts()).thenReturn(currentNumPorts);
when(currentDvPortgroupInfo.isAutoExpand()).thenReturn(currentAutoExpand);
when(currentDvPortgroupInfo.getDefaultPortConfig()).thenReturn(currentVmwareDvsPortSetting);
int newNumPorts = 256;
int newvlanId = 100;
boolean newAutoExpand = true;
DVSTrafficShapingPolicy newTrafficShapingPolicy = new DVSTrafficShapingPolicy();
BoolPolicy newIsEnabled = new BoolPolicy();
newIsEnabled.setValue(true);
LongPolicy newAvgBw = new LongPolicy();
newAvgBw.setValue(200L);
LongPolicy newBurstSize = new LongPolicy();
newBurstSize.setValue(400L);
LongPolicy newPeakBw = new LongPolicy();
newPeakBw.setValue(2000L);
VMwareDVSPortSetting newVmwareDvsPortSetting = new VMwareDVSPortSetting();
VmwareDistributedVirtualSwitchVlanIdSpec newVlanIdSpec = new VmwareDistributedVirtualSwitchVlanIdSpec();
newVlanIdSpec.setVlanId(newvlanId);
newVmwareDvsPortSetting.setVlan(newVlanIdSpec);
newTrafficShapingPolicy.setAverageBandwidth(newAvgBw);
newTrafficShapingPolicy.setBurstSize(newBurstSize);
newTrafficShapingPolicy.setPeakBandwidth(newPeakBw);
newTrafficShapingPolicy.setEnabled(newIsEnabled);
newVmwareDvsPortSetting.setInShapingPolicy(newTrafficShapingPolicy);
when(dvPortgroupConfigSpec.getNumPorts()).thenReturn(newNumPorts);
when(dvPortgroupConfigSpec.isAutoExpand()).thenReturn(newAutoExpand);
when(dvPortgroupConfigSpec.getDefaultPortConfig()).thenReturn(newVmwareDvsPortSetting);
boolean specCompareResult = HypervisorHostHelper.isSpecMatch(currentDvPortgroupInfo, dvPortgroupConfigSpec);
assertTrue(specCompareResult);
}
use of com.vmware.vim25.LongPolicy in project cloudstack by apache.
the class HypervisorHostHelper method isSpecMatch.
public static boolean isSpecMatch(DVPortgroupConfigInfo configInfo, Integer vid, DVSTrafficShapingPolicy shapingPolicy) {
DVSTrafficShapingPolicy currentTrafficShapingPolicy;
currentTrafficShapingPolicy = configInfo.getDefaultPortConfig().getInShapingPolicy();
assert (currentTrafficShapingPolicy != null);
LongPolicy averageBandwidth = currentTrafficShapingPolicy.getAverageBandwidth();
LongPolicy burstSize = currentTrafficShapingPolicy.getBurstSize();
LongPolicy peakBandwidth = currentTrafficShapingPolicy.getPeakBandwidth();
BoolPolicy isEnabled = currentTrafficShapingPolicy.getEnabled();
if (!isEnabled.equals(shapingPolicy.getEnabled())) {
return false;
}
if (averageBandwidth != null && !averageBandwidth.equals(shapingPolicy.getAverageBandwidth())) {
if (s_logger.isInfoEnabled()) {
s_logger.info("Average bandwidth setting in shaping policy doesn't match with existing setting.");
}
return false;
} else if (burstSize != null && !burstSize.equals(shapingPolicy.getBurstSize())) {
if (s_logger.isInfoEnabled()) {
s_logger.info("Burst size setting in shaping policy doesn't match with existing setting.");
}
return false;
} else if (peakBandwidth != null && !peakBandwidth.equals(shapingPolicy.getPeakBandwidth())) {
if (s_logger.isInfoEnabled()) {
s_logger.info("Peak bandwidth setting in shaping policy doesn't match with existing setting.");
}
return false;
}
return true;
}
Aggregations