Search in sources :

Example 16 with BoolPolicy

use of com.vmware.vim25.BoolPolicy in project cloudstack by apache.

the class HypervisorHostHelperTest method testIsSpecMatchConfigSpecWithCurrentShapingPolicyDisabled.

@Test
public void testIsSpecMatchConfigSpecWithCurrentShapingPolicyDisabled() throws Exception {
    int currentNumPorts = 512;
    int currentvlanId = 100;
    boolean currentAutoExpand = true;
    DVSTrafficShapingPolicy currentTrafficShapingPolicy = new DVSTrafficShapingPolicy();
    BoolPolicy currentIsEnabled = new BoolPolicy();
    currentIsEnabled.setValue(false);
    VMwareDVSPortSetting currentVmwareDvsPortSetting = new VMwareDVSPortSetting();
    VmwareDistributedVirtualSwitchVlanIdSpec currentVlanIdSpec = new VmwareDistributedVirtualSwitchVlanIdSpec();
    currentVlanIdSpec.setVlanId(currentvlanId);
    currentVmwareDvsPortSetting.setVlan(currentVlanIdSpec);
    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, false);
    assertFalse(specCompareResult);
}
Also used : LongPolicy(com.vmware.vim25.LongPolicy) VMwareDVSPortSetting(com.vmware.vim25.VMwareDVSPortSetting) DVSTrafficShapingPolicy(com.vmware.vim25.DVSTrafficShapingPolicy) BoolPolicy(com.vmware.vim25.BoolPolicy) VmwareDistributedVirtualSwitchVlanIdSpec(com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec) Test(org.junit.Test)

Aggregations

BoolPolicy (com.vmware.vim25.BoolPolicy)15 DVSTrafficShapingPolicy (com.vmware.vim25.DVSTrafficShapingPolicy)12 LongPolicy (com.vmware.vim25.LongPolicy)11 VMwareDVSPortSetting (com.vmware.vim25.VMwareDVSPortSetting)9 VmwareDistributedVirtualSwitchVlanIdSpec (com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec)9 Test (org.junit.Test)7 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 DVSSecurityPolicy (com.vmware.vim25.DVSSecurityPolicy)2 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)2 NicTO (com.cloud.agent.api.to.NicTO)1 CloudException (com.cloud.exception.CloudException)1 InternalErrorException (com.cloud.exception.InternalErrorException)1 VmwareContext (com.cloud.hypervisor.vmware.util.VmwareContext)1 Pair (com.cloud.utils.Pair)1 DVPortConfigInfo (com.vmware.vim25.DVPortConfigInfo)1 DVPortConfigSpec (com.vmware.vim25.DVPortConfigSpec)1 DVPortgroupConfigInfo (com.vmware.vim25.DVPortgroupConfigInfo)1 DistributedVirtualPort (com.vmware.vim25.DistributedVirtualPort)1 DistributedVirtualSwitchPortConnection (com.vmware.vim25.DistributedVirtualSwitchPortConnection)1 DistributedVirtualSwitchPortCriteria (com.vmware.vim25.DistributedVirtualSwitchPortCriteria)1