Search in sources :

Example 1 with VMwareDVSPvlanMapEntry

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

the class DistributedVirtualSwitchMO method retrieveVlanPvlan.

public Map<Integer, HypervisorHostHelper.PvlanType> retrieveVlanPvlan(int vlanid, int secondaryvlanid, ManagedObjectReference dvSwitchMor) throws Exception {
    assert (dvSwitchMor != null);
    Map<Integer, HypervisorHostHelper.PvlanType> result = new HashMap<Integer, HypervisorHostHelper.PvlanType>();
    VMwareDVSConfigInfo configinfo = (VMwareDVSConfigInfo) _context.getVimClient().getDynamicProperty(dvSwitchMor, "config");
    List<VMwareDVSPvlanMapEntry> pvlanconfig = null;
    pvlanconfig = configinfo.getPvlanConfig();
    if (null == pvlanconfig || 0 == pvlanconfig.size()) {
        return result;
    }
    for (VMwareDVSPvlanMapEntry mapEntry : pvlanconfig) {
        int entryVlanid = mapEntry.getPrimaryVlanId();
        int entryPvlanid = mapEntry.getSecondaryVlanId();
        if (entryVlanid == entryPvlanid) {
            // promiscuous
            if (vlanid == entryVlanid) {
                // pvlan type will always be promiscuous in this case.
                result.put(vlanid, HypervisorHostHelper.PvlanType.valueOf(mapEntry.getPvlanType()));
            } else if ((vlanid != secondaryvlanid) && secondaryvlanid == entryVlanid) {
                result.put(secondaryvlanid, HypervisorHostHelper.PvlanType.valueOf(mapEntry.getPvlanType()));
            }
        } else {
            if (vlanid == entryVlanid) {
                // vlan id in entry is promiscuous
                result.put(vlanid, HypervisorHostHelper.PvlanType.promiscuous);
            } else if (vlanid == entryPvlanid) {
                result.put(vlanid, HypervisorHostHelper.PvlanType.valueOf(mapEntry.getPvlanType()));
            }
            if ((vlanid != secondaryvlanid) && secondaryvlanid == entryVlanid) {
                //promiscuous
                result.put(secondaryvlanid, HypervisorHostHelper.PvlanType.promiscuous);
            } else if (secondaryvlanid == entryPvlanid) {
                result.put(secondaryvlanid, HypervisorHostHelper.PvlanType.valueOf(mapEntry.getPvlanType()));
            }
        }
        // go over the entire list. Return.
        if (result.containsKey(vlanid) && result.get(vlanid) != HypervisorHostHelper.PvlanType.promiscuous)
            return result;
        // If we've already found both vlanid and pvlanid, we have enough info to make a decision. Return.
        if (result.containsKey(vlanid) && result.containsKey(secondaryvlanid))
            return result;
    }
    return result;
}
Also used : VMwareDVSConfigInfo(com.vmware.vim25.VMwareDVSConfigInfo) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) VMwareDVSPvlanMapEntry(com.vmware.vim25.VMwareDVSPvlanMapEntry)

Example 2 with VMwareDVSPvlanMapEntry

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

the class HypervisorHostHelper method createDVPortPvlanConfigSpec.

public static VMwareDVSPvlanConfigSpec createDVPortPvlanConfigSpec(int vlanId, int secondaryVlanId, PvlanType pvlantype, PvlanOperation operation) {
    VMwareDVSPvlanConfigSpec pvlanConfigSpec = new VMwareDVSPvlanConfigSpec();
    VMwareDVSPvlanMapEntry map = new VMwareDVSPvlanMapEntry();
    map.setPvlanType(pvlantype.toString());
    map.setPrimaryVlanId(vlanId);
    map.setSecondaryVlanId(secondaryVlanId);
    pvlanConfigSpec.setPvlanEntry(map);
    pvlanConfigSpec.setOperation(operation.toString());
    return pvlanConfigSpec;
}
Also used : VMwareDVSPvlanConfigSpec(com.vmware.vim25.VMwareDVSPvlanConfigSpec) VMwareDVSPvlanMapEntry(com.vmware.vim25.VMwareDVSPvlanMapEntry)

Aggregations

VMwareDVSPvlanMapEntry (com.vmware.vim25.VMwareDVSPvlanMapEntry)2 VMwareDVSConfigInfo (com.vmware.vim25.VMwareDVSConfigInfo)1 VMwareDVSPvlanConfigSpec (com.vmware.vim25.VMwareDVSPvlanConfigSpec)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1