Search in sources :

Example 6 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 7 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 8 with DVSTrafficShapingPolicy

use of com.vmware.vim25.DVSTrafficShapingPolicy in project CloudStack-archive by CloudStack-extras.

the class HypervisorHostHelper method prepareNetwork.

/**
	 * @param ethPortProfileName
	 * @param namePrefix
	 * @param hostMo
	 * @param vlanId
	 * @param networkRateMbps
	 * @param networkRateMulticastMbps
	 * @param timeOutMs
	 * @return
	 * @throws Exception
	 */
public static Pair<ManagedObjectReference, String> prepareNetwork(String ethPortProfileName, String namePrefix, HostMO hostMo, String vlanId, Integer networkRateMbps, Integer networkRateMulticastMbps, long timeOutMs) throws Exception {
    ManagedObjectReference morNetwork = null;
    VmwareContext context = hostMo.getContext();
    ManagedObjectReference dcMor = hostMo.getHyperHostDatacenter();
    DatacenterMO dataCenterMo = new DatacenterMO(context, dcMor);
    ManagedObjectReference morEthernetPortProfile = dataCenterMo.getDvPortGroupMor(ethPortProfileName);
    if (morEthernetPortProfile == null) {
        String msg = "Unable to find Ethernet port profile " + ethPortProfileName;
        s_logger.error(msg);
        throw new Exception(msg);
    } else {
        s_logger.info("Found Ethernet port profile " + ethPortProfileName);
    }
    boolean createGCTag = false;
    String networkName;
    Integer vid = null;
    if (vlanId != null && !UNTAGGED_VLAN_NAME.equalsIgnoreCase(vlanId)) {
        createGCTag = true;
        vid = Integer.parseInt(vlanId);
    }
    networkName = composeCloudNetworkName(namePrefix, vlanId, networkRateMbps, ethPortProfileName);
    // TODO(sateesh): Enable this for VMware DVS.
    //        DVSTrafficShapingPolicy shapingPolicy = null;
    //        if (networkRateMbps != null && networkRateMbps.intValue() > 0) {
    //            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);
    //        }
    DVPortgroupConfigInfo spec = dataCenterMo.getDvPortGroupSpec(networkName);
    long averageBandwidth = 0L;
    if (networkRateMbps != null && networkRateMbps.intValue() > 0) {
        averageBandwidth = (long) (networkRateMbps.intValue() * 1024L * 1024L);
    }
    // We chose 50% higher allocation than average bandwidth.
    // TODO(sateesh): Also let user specify the peak coefficient
    long peakBandwidth = (long) (averageBandwidth * 1.5);
    // TODO(sateesh): Also let user specify the burst coefficient
    long burstSize = 5 * averageBandwidth / 8;
    boolean bWaitPortGroupReady = false;
    if (!dataCenterMo.hasDvPortGroup(networkName)) {
        s_logger.info("Port profile " + networkName + " not found.");
        createPortProfile(context, ethPortProfileName, networkName, vid, networkRateMbps, peakBandwidth, burstSize);
        bWaitPortGroupReady = true;
    } else {
        s_logger.info("Port profile " + networkName + " found.");
        bWaitPortGroupReady = true;
        updatePortProfile(context, ethPortProfileName, networkName, vid, networkRateMbps, peakBandwidth, burstSize);
    }
    // Wait for dvPortGroup on vCenter		
    if (bWaitPortGroupReady)
        morNetwork = waitForDvPortGroupReady(dataCenterMo, networkName, timeOutMs);
    else
        morNetwork = dataCenterMo.getDvPortGroupMor(networkName);
    if (morNetwork == null) {
        String msg = "Failed to create guest network " + networkName;
        s_logger.error(msg);
        throw new Exception(msg);
    }
    if (createGCTag) {
        NetworkMO networkMo = new NetworkMO(hostMo.getContext(), morNetwork);
        networkMo.setCustomFieldValue(CustomFieldConstants.CLOUD_GC_DVP, "true");
        s_logger.debug("Added custom field : " + CustomFieldConstants.CLOUD_GC_DVP);
    }
    return new Pair<ManagedObjectReference, String>(morNetwork, networkName);
}
Also used : VmwareContext(com.cloud.hypervisor.vmware.util.VmwareContext) URISyntaxException(java.net.URISyntaxException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference) DVPortgroupConfigInfo(com.vmware.vim25.DVPortgroupConfigInfo) Pair(com.cloud.utils.Pair)

Example 9 with DVSTrafficShapingPolicy

use of com.vmware.vim25.DVSTrafficShapingPolicy in project CloudStack-archive by CloudStack-extras.

the class HypervisorHostHelper method isSpecMatch.

// This method would be used for VMware Distributed Virtual Switch.
private static boolean isSpecMatch(DVPortgroupConfigInfo spec, Integer vid, DVSTrafficShapingPolicy shapingPolicy) {
    DVSTrafficShapingPolicy currentTrafficShapingPolicy;
    currentTrafficShapingPolicy = spec.getDefaultPortConfig().getInShapingPolicy();
    assert (currentTrafficShapingPolicy != null);
    LongPolicy averageBandwidth = currentTrafficShapingPolicy.getAverageBandwidth();
    LongPolicy burstSize = currentTrafficShapingPolicy.getBurstSize();
    LongPolicy peakBandwidth = currentTrafficShapingPolicy.getPeakBandwidth();
    BoolPolicy isEnabled = currentTrafficShapingPolicy.getEnabled();
    if (!isEnabled.getValue())
        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 10 with DVSTrafficShapingPolicy

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

the class HypervisorHostHelper method getDVSShapingPolicy.

public static DVSTrafficShapingPolicy getDVSShapingPolicy(Integer networkRateMbps) {
    DVSTrafficShapingPolicy shapingPolicy = new DVSTrafficShapingPolicy();
    BoolPolicy isEnabled = new BoolPolicy();
    if (networkRateMbps == null || networkRateMbps.intValue() <= 0) {
        isEnabled.setValue(false);
        shapingPolicy.setEnabled(isEnabled);
        return shapingPolicy;
    }
    LongPolicy averageBandwidth = new LongPolicy();
    LongPolicy peakBandwidth = new LongPolicy();
    LongPolicy burstSize = new LongPolicy();
    isEnabled.setValue(true);
    averageBandwidth.setValue(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(5 * averageBandwidth.getValue() / 8);
    shapingPolicy.setEnabled(isEnabled);
    shapingPolicy.setAverageBandwidth(averageBandwidth);
    shapingPolicy.setPeakBandwidth(peakBandwidth);
    shapingPolicy.setBurstSize(burstSize);
    return shapingPolicy;
}
Also used : LongPolicy(com.vmware.vim25.LongPolicy) DVSTrafficShapingPolicy(com.vmware.vim25.DVSTrafficShapingPolicy) BoolPolicy(com.vmware.vim25.BoolPolicy)

Aggregations

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