Search in sources :

Example 11 with VlanId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId in project netvirt by opendaylight.

the class PolicyAceFlowProgrammer method getIngressInterfaceFlow.

private Optional<PolicyAceFlowWrapper> getIngressInterfaceFlow(IngressInterface ingressInterface) {
    String interfaceName = ingressInterface.getName();
    if (interfaceName == null) {
        LOG.error("Invalid ingress interface augmentation. missing interface name");
        return Optional.absent();
    }
    String flowName = "INGRESS_INTERFACE_" + interfaceName;
    int flowPriority = PolicyServiceConstants.POLICY_ACL_TRUNK_INTERFACE_FLOW_PRIOPITY;
    VlanId vlanId = ingressInterface.getVlanId();
    if (vlanId != null) {
        Optional<String> vlanMemberInterfaceOpt = policyServiceUtil.getVlanMemberInterface(interfaceName, vlanId);
        if (!vlanMemberInterfaceOpt.isPresent()) {
            LOG.debug("Vlan member {} missing for trunk {}", vlanId.getValue(), interfaceName);
            return Optional.of(new PolicyAceFlowWrapper(flowName, PolicyAceFlowWrapper.PARTIAL));
        }
        interfaceName = vlanMemberInterfaceOpt.get();
        flowPriority = PolicyServiceConstants.POLICY_ACL_VLAN_INTERFACE_FLOW_PRIOPITY;
    }
    List<MatchInfoBase> matches = policyFlowUtil.getIngressInterfaceMatches(interfaceName);
    if (matches == null || matches.isEmpty()) {
        LOG.debug("Failed to get ingress interface {} matches", interfaceName);
        return Optional.of(new PolicyAceFlowWrapper(flowName, PolicyAceFlowWrapper.PARTIAL));
    }
    BigInteger dpId = interfaceManager.getDpnForInterface(interfaceName);
    if (dpId == null) {
        dpId = BigInteger.ZERO;
    }
    return Optional.of(new PolicyAceFlowWrapper(flowName, matches, flowPriority, dpId));
}
Also used : BigInteger(java.math.BigInteger) VlanId(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Example 12 with VlanId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId in project openflowplugin by opendaylight.

the class FlowConvertor method isSetVlanIdActionCasePresent.

// check if set vlanid action is present in the flow
private static boolean isSetVlanIdActionCasePresent(Flow flow) {
    // If yes,then we would need to two flows
    if (flow.getInstructions() != null && flow.getInstructions().getInstruction() != null) {
        for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction instruction : flow.getInstructions().getInstruction()) {
            org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curInstruction = instruction.getInstruction();
            if (curInstruction instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase) {
                org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase applyActionscase = (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase) curInstruction;
                ApplyActions applyActions = applyActionscase.getApplyActions();
                for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action action : applyActions.getAction()) {
                    if (action.getAction() instanceof SetVlanIdActionCase) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : SetVlanIdActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase) ApplyActionsCase(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.cases.ApplyActionsCase) ApplyActions(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActions)

Example 13 with VlanId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId in project genius by opendaylight.

the class FlowBasedServicesUtils method getMatchInfoForVlanPortAtIngressTable.

public static List<MatchInfo> getMatchInfoForVlanPortAtIngressTable(BigInteger dpId, long portNo, Interface iface) {
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(new MatchInPort(dpId, portNo));
    int vlanId = 0;
    IfL2vlan l2vlan = iface.getAugmentation(IfL2vlan.class);
    if (l2vlan != null) {
        vlanId = l2vlan.getVlanId() == null ? 0 : l2vlan.getVlanId().getValue();
    }
    if (vlanId >= 0 && l2vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Transparent) {
        matches.add(new MatchVlanVid(vlanId));
    }
    return matches;
}
Also used : MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) MatchVlanVid(org.opendaylight.genius.mdsalutil.matches.MatchVlanVid) ArrayList(java.util.ArrayList) MatchInPort(org.opendaylight.genius.mdsalutil.matches.MatchInPort) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Example 14 with VlanId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId in project genius by opendaylight.

the class TepCommandHelperTest method testCreateLocalCacheWithoutcheckExistingSubnet.

@Test
public void testCreateLocalCacheWithoutcheckExistingSubnet() {
    IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
    IpPrefix subnetMaskObj = ipPrefixTest;
    SubnetsKey subnetsKey = new SubnetsKey(subnetMaskObj);
    SubnetObject subObCli = new SubnetObject(gatewayIpObj, subnetsKey, subnetMaskObj, vlanId);
    Map<SubnetObject, List<Vteps>> subVtepMapTemp = new HashMap<>();
    subVtepMapTemp.put(subObCli, vtepsList);
    transportZoneNew = new TransportZoneBuilder().setZoneName(transportZone1).setTunnelType(tunnelType2).build();
    doReturn(Futures.immediateCheckedFuture(Optional.of(transportZoneNew))).when(mockReadTx).read(LogicalDatastoreType.CONFIGURATION, transportZoneIdentifier);
    doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(LogicalDatastoreType.CONFIGURATION, transportZonesIdentifier);
    try {
        tepCommandHelper.createLocalCache(dpId1, portName1, vlanId, tepIp1, subnetMask, gwyIp1, transportZone1, null);
        tepCommandHelper.createLocalCache(dpId2, portName1, vlanId, tepIp1, subnetMask, gwyIp1, transportZone1, null);
    } catch (TepException e) {
        LOG.error(e.getMessage());
    }
    verify(mockReadTx, times(2)).read(LogicalDatastoreType.CONFIGURATION, transportZoneIdentifier);
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) SubnetsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey) HashMap(java.util.HashMap) TransportZoneBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList) List(java.util.List) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 15 with VlanId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId in project genius by opendaylight.

the class TepCommandHelperTest method testDeleteOnCommit.

@Test
public void testDeleteOnCommit() {
    transportZoneList.add(transportZone);
    transportZoneList.add(transportZoneNew);
    transportZones = new TransportZonesBuilder().setTransportZone(transportZoneList).build();
    optionalTransportZones = Optional.of(transportZones);
    doReturn(Futures.immediateCheckedFuture(optionalTransportZones)).when(mockReadTx).read(LogicalDatastoreType.CONFIGURATION, transportZonesIdentifier);
    try {
        tepCommandHelper.deleteVtep(dpId1, portName1, vlanId, tepIp1, subnetMask, gwyIp1, transportZone1, null);
    } catch (TepException e) {
        LOG.error(e.getMessage());
    }
    tepCommandHelper.deleteOnCommit();
    verify(mockReadTx).read(LogicalDatastoreType.CONFIGURATION, transportZonesIdentifier);
    verify(mockReadTx).read(LogicalDatastoreType.CONFIGURATION, vtepsIdentifier);
    verify(mockReadTx).read(LogicalDatastoreType.CONFIGURATION, subnetsIdentifier);
    verify(mockWriteTx).delete(LogicalDatastoreType.CONFIGURATION, vtepsIdentifierNew);
    verify(mockWriteTx).delete(LogicalDatastoreType.CONFIGURATION, subnetsIdentifier);
    verify(mockWriteTx).delete(LogicalDatastoreType.CONFIGURATION, transportZoneIdentifier);
}
Also used : TransportZonesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZonesBuilder) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)27 VlanId (org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId)26 BigInteger (java.math.BigInteger)14 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)12 IfL2vlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)12 List (java.util.List)11 Test (org.junit.Test)11 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)10 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)10 VlanMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder)10 VlanIdBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder)10 SetVlanIdActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder)9 SubnetsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey)9 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)8 SetVlanIdActionCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder)6 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)6 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)6 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)6 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)6 VtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey)6