Search in sources :

Example 1 with DVSTrafficShapingPolicy

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

the class HypervisorHostHelper method createVmwareDVPortSettingSpec.

public static VMwareDVSPortSetting createVmwareDVPortSettingSpec(DVSTrafficShapingPolicy shapingPolicy, DVSSecurityPolicy secPolicy, VmwareDistributedVirtualSwitchVlanSpec vlanSpec) {
    VMwareDVSPortSetting dvsPortSetting = new VMwareDVSPortSetting();
    dvsPortSetting.setVlan(vlanSpec);
    dvsPortSetting.setSecurityPolicy(secPolicy);
    dvsPortSetting.setInShapingPolicy(shapingPolicy);
    dvsPortSetting.setOutShapingPolicy(shapingPolicy);
    return dvsPortSetting;
}
Also used : VMwareDVSPortSetting(com.vmware.vim25.VMwareDVSPortSetting)

Example 2 with DVSTrafficShapingPolicy

use of com.vmware.vim25.DVSTrafficShapingPolicy 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;
}
Also used : LongPolicy(com.vmware.vim25.LongPolicy) DVSTrafficShapingPolicy(com.vmware.vim25.DVSTrafficShapingPolicy) BoolPolicy(com.vmware.vim25.BoolPolicy)

Example 3 with DVSTrafficShapingPolicy

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

the class HypervisorHostHelper method createVmwareDVPortSettingSpec.

public static VMwareDVSPortSetting createVmwareDVPortSettingSpec(DVSTrafficShapingPolicy shapingPolicy, DVSSecurityPolicy secPolicy, DVSMacManagementPolicy macManagementPolicy, VmwareDistributedVirtualSwitchVlanSpec vlanSpec, boolean dvSwitchSupportNewPolicies) {
    VMwareDVSPortSetting dvsPortSetting = new VMwareDVSPortSetting();
    dvsPortSetting.setVlan(vlanSpec);
    dvsPortSetting.setSecurityPolicy(secPolicy);
    if (dvSwitchSupportNewPolicies) {
        dvsPortSetting.setMacManagementPolicy(macManagementPolicy);
    }
    dvsPortSetting.setInShapingPolicy(shapingPolicy);
    dvsPortSetting.setOutShapingPolicy(shapingPolicy);
    return dvsPortSetting;
}
Also used : VMwareDVSPortSetting(com.vmware.vim25.VMwareDVSPortSetting)

Example 4 with DVSTrafficShapingPolicy

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

the class HypervisorHostHelper method isSpecMatch.

public static boolean isSpecMatch(DVPortgroupConfigInfo currentDvPortgroupInfo, DVPortgroupConfigSpec newDvPortGroupSpec, boolean dvSwitchSupportNewPolicies) {
    String dvPortGroupName = newDvPortGroupSpec.getName();
    s_logger.debug("Checking if configuration of dvPortGroup [" + dvPortGroupName + "] has changed.");
    DVSTrafficShapingPolicy currentTrafficShapingPolicy;
    currentTrafficShapingPolicy = currentDvPortgroupInfo.getDefaultPortConfig().getInShapingPolicy();
    assert (currentTrafficShapingPolicy != null);
    LongPolicy oldAverageBandwidthPolicy = currentTrafficShapingPolicy.getAverageBandwidth();
    LongPolicy oldBurstSizePolicy = currentTrafficShapingPolicy.getBurstSize();
    LongPolicy oldPeakBandwidthPolicy = currentTrafficShapingPolicy.getPeakBandwidth();
    BoolPolicy oldIsEnabledPolicy = currentTrafficShapingPolicy.getEnabled();
    Long oldAverageBandwidth = null;
    Long oldBurstSize = null;
    Long oldPeakBandwidth = null;
    Boolean oldIsEnabled = null;
    if (oldAverageBandwidthPolicy != null) {
        oldAverageBandwidth = oldAverageBandwidthPolicy.getValue();
    }
    if (oldBurstSizePolicy != null) {
        oldBurstSize = oldBurstSizePolicy.getValue();
    }
    if (oldPeakBandwidthPolicy != null) {
        oldPeakBandwidth = oldPeakBandwidthPolicy.getValue();
    }
    if (oldIsEnabledPolicy != null) {
        oldIsEnabled = oldIsEnabledPolicy.isValue();
    }
    DVSTrafficShapingPolicy newTrafficShapingPolicyInbound = newDvPortGroupSpec.getDefaultPortConfig().getInShapingPolicy();
    LongPolicy newAverageBandwidthPolicy = newTrafficShapingPolicyInbound.getAverageBandwidth();
    LongPolicy newBurstSizePolicy = newTrafficShapingPolicyInbound.getBurstSize();
    LongPolicy newPeakBandwidthPolicy = newTrafficShapingPolicyInbound.getPeakBandwidth();
    BoolPolicy newIsEnabledPolicy = newTrafficShapingPolicyInbound.getEnabled();
    Long newAverageBandwidth = null;
    Long newBurstSize = null;
    Long newPeakBandwidth = null;
    Boolean newIsEnabled = null;
    if (newAverageBandwidthPolicy != null) {
        newAverageBandwidth = newAverageBandwidthPolicy.getValue();
    }
    if (newBurstSizePolicy != null) {
        newBurstSize = newBurstSizePolicy.getValue();
    }
    if (newPeakBandwidthPolicy != null) {
        newPeakBandwidth = newPeakBandwidthPolicy.getValue();
    }
    if (newIsEnabledPolicy != null) {
        newIsEnabled = newIsEnabledPolicy.isValue();
    }
    if (!oldIsEnabled.equals(newIsEnabled)) {
        s_logger.info("Detected change in state of shaping policy (enabled/disabled) [" + newIsEnabled + "]");
        return false;
    }
    if (oldIsEnabled || newIsEnabled) {
        if (oldAverageBandwidth != null && !oldAverageBandwidth.equals(newAverageBandwidth)) {
            s_logger.info("Average bandwidth setting in new shaping policy doesn't match the existing setting.");
            return false;
        } else if (oldBurstSize != null && !oldBurstSize.equals(newBurstSize)) {
            s_logger.info("Burst size setting in new shaping policy doesn't match the existing setting.");
            return false;
        } else if (oldPeakBandwidth != null && !oldPeakBandwidth.equals(newPeakBandwidth)) {
            s_logger.info("Peak bandwidth setting in new shaping policy doesn't match the existing setting.");
            return false;
        }
    }
    boolean oldAutoExpandSetting = currentDvPortgroupInfo.isAutoExpand();
    boolean autoExpandEnabled = newDvPortGroupSpec.isAutoExpand();
    if (oldAutoExpandSetting != autoExpandEnabled) {
        return false;
    }
    if (!autoExpandEnabled) {
        // Allow update of number of dvports per dvPortGroup is auto expand is not enabled.
        int oldNumPorts = currentDvPortgroupInfo.getNumPorts();
        int newNumPorts = newDvPortGroupSpec.getNumPorts();
        if (oldNumPorts < newNumPorts) {
            s_logger.info("Need to update the number of dvports for dvPortGroup :[" + dvPortGroupName + "] from existing number of dvports " + oldNumPorts + " to " + newNumPorts);
            return false;
        } else if (oldNumPorts > newNumPorts) {
            s_logger.warn("Detected that new number of dvports [" + newNumPorts + "] in dvPortGroup [" + dvPortGroupName + "] is less than existing number of dvports [" + oldNumPorts + "]. Attempt to update this dvPortGroup may fail!");
            return false;
        }
    }
    VMwareDVSPortSetting currentPortSetting = ((VMwareDVSPortSetting) currentDvPortgroupInfo.getDefaultPortConfig());
    VMwareDVSPortSetting newPortSetting = ((VMwareDVSPortSetting) newDvPortGroupSpec.getDefaultPortConfig());
    return isDVSPortConfigSame(dvPortGroupName, currentPortSetting, newPortSetting, dvSwitchSupportNewPolicies);
}
Also used : LongPolicy(com.vmware.vim25.LongPolicy) VMwareDVSPortSetting(com.vmware.vim25.VMwareDVSPortSetting) DVSTrafficShapingPolicy(com.vmware.vim25.DVSTrafficShapingPolicy) BoolPolicy(com.vmware.vim25.BoolPolicy)

Example 5 with DVSTrafficShapingPolicy

use of com.vmware.vim25.DVSTrafficShapingPolicy 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, 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

DVSTrafficShapingPolicy (com.vmware.vim25.DVSTrafficShapingPolicy)14 BoolPolicy (com.vmware.vim25.BoolPolicy)12 VMwareDVSPortSetting (com.vmware.vim25.VMwareDVSPortSetting)12 LongPolicy (com.vmware.vim25.LongPolicy)11 VmwareDistributedVirtualSwitchVlanIdSpec (com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec)8 Test (org.junit.Test)7 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)5 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)5 URISyntaxException (java.net.URISyntaxException)5 CloudException (com.cloud.exception.CloudException)4 IOException (java.io.IOException)4 InvalidParameterException (java.security.InvalidParameterException)4 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)4 TransformerException (javax.xml.transform.TransformerException)4 SAXException (org.xml.sax.SAXException)4 VmwareContext (com.cloud.hypervisor.vmware.util.VmwareContext)3 Pair (com.cloud.utils.Pair)3 DVPortgroupConfigInfo (com.vmware.vim25.DVPortgroupConfigInfo)3 BroadcastDomainType (com.cloud.network.Networks.BroadcastDomainType)2 DVPortgroupConfigSpec (com.vmware.vim25.DVPortgroupConfigSpec)2