Search in sources :

Example 6 with NumericRange

use of org.osate.aadl2.NumericRange in project cloudstack by apache.

the class HypervisorHostHelper method createDVPortVlanSpec.

public static VmwareDistributedVirtualSwitchVlanSpec createDVPortVlanSpec(Integer vlanId, String vlanRange) {
    if (vlanId != null && vlanId == 4095) {
        vlanId = null;
        vlanRange = "0-4094";
    }
    if (vlanId == null && vlanRange != null && !vlanRange.isEmpty()) {
        s_logger.debug("Creating dvSwitch port vlan-trunk spec with range: " + vlanRange);
        VmwareDistributedVirtualSwitchTrunkVlanSpec trunkVlanSpec = new VmwareDistributedVirtualSwitchTrunkVlanSpec();
        for (final String vlanRangePart : vlanRange.split(",")) {
            if (vlanRangePart == null || vlanRange.isEmpty()) {
                continue;
            }
            final NumericRange numericRange = new NumericRange();
            if (vlanRangePart.contains("-")) {
                final String[] range = vlanRangePart.split("-");
                if (range.length == 2 && range[0] != null && range[1] != null) {
                    numericRange.setStart(NumbersUtil.parseInt(range[0], 0));
                    numericRange.setEnd(NumbersUtil.parseInt(range[1], 0));
                } else {
                    continue;
                }
            } else {
                numericRange.setStart(NumbersUtil.parseInt(vlanRangePart, 0));
                numericRange.setEnd(NumbersUtil.parseInt(vlanRangePart, 0));
            }
            trunkVlanSpec.getVlanId().add(numericRange);
        }
        if (trunkVlanSpec.getVlanId().size() != 0) {
            return trunkVlanSpec;
        }
    }
    VmwareDistributedVirtualSwitchVlanIdSpec vlanIdSpec = new VmwareDistributedVirtualSwitchVlanIdSpec();
    vlanIdSpec.setVlanId(vlanId == null ? 0 : vlanId);
    s_logger.debug("Creating dvSwitch port vlan-id spec with id: " + vlanIdSpec.getVlanId());
    return vlanIdSpec;
}
Also used : NumericRange(com.vmware.vim25.NumericRange) VmwareDistributedVirtualSwitchTrunkVlanSpec(com.vmware.vim25.VmwareDistributedVirtualSwitchTrunkVlanSpec) VmwareDistributedVirtualSwitchVlanIdSpec(com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec)

Aggregations

NumericRange (org.osate.aadl2.NumericRange)4 NumericRange (com.vmware.vim25.NumericRange)1 VmwareDistributedVirtualSwitchTrunkVlanSpec (com.vmware.vim25.VmwareDistributedVirtualSwitchTrunkVlanSpec)1 VmwareDistributedVirtualSwitchVlanIdSpec (com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec)1 EOperation (org.eclipse.emf.ecore.EOperation)1 EPackage (org.eclipse.emf.ecore.EPackage)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 Action (org.eclipse.xtext.Action)1 Parameter (org.eclipse.xtext.Parameter)1 ParserRule (org.eclipse.xtext.ParserRule)1 org.osate.aadl2 (org.osate.aadl2)1 AadlBoolean (org.osate.aadl2.AadlBoolean)1 AadlInteger (org.osate.aadl2.AadlInteger)1 AadlPackage (org.osate.aadl2.AadlPackage)1 AadlReal (org.osate.aadl2.AadlReal)1 AadlString (org.osate.aadl2.AadlString)1 AbstractFeature (org.osate.aadl2.AbstractFeature)1 AbstractImplementation (org.osate.aadl2.AbstractImplementation)1 AbstractPrototype (org.osate.aadl2.AbstractPrototype)1 AbstractSubcomponent (org.osate.aadl2.AbstractSubcomponent)1