use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan in project netvirt by opendaylight.
the class NeutronTrunkChangeListener method createSubPortInterface.
private void createSubPortInterface(Trunk trunk, SubPorts subPort) {
if (!NetworkTypeVlan.class.equals(subPort.getSegmentationType())) {
LOG.warn("SegmentationType other than VLAN not supported for Trunk:SubPorts");
return;
}
String portName = subPort.getPortId().getValue();
String parentName = trunk.getPortId().getValue();
InstanceIdentifier<Interface> interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(portName);
// Should we use parentName?
jobCoordinator.enqueueJob("PORT- " + portName, () -> {
Interface iface = ifMgr.getInterfaceInfoFromConfigDataStore(portName);
List<ListenableFuture<Void>> futures = new ArrayList<>();
if (iface == null) {
/*
* Trunk creation requires NeutronPort to be present, by this time interface
* should've been created. In controller restart use case Interface would already be present.
* Clustering consideration:
* This being same shard as NeutronPort, interface creation will be triggered on the same
* node as this one. Use of DSJC helps ensure the order.
*/
LOG.warn("Interface not present for Trunk SubPort: {}", subPort);
return futures;
}
InterfaceBuilder interfaceBuilder = new InterfaceBuilder();
IfL2vlan ifL2vlan = new IfL2vlanBuilder().setL2vlanMode(IfL2vlan.L2vlanMode.TrunkMember).setVlanId(new VlanId(subPort.getSegmentationId().intValue())).build();
ParentRefs parentRefs = new ParentRefsBuilder().setParentInterface(parentName).build();
SplitHorizon splitHorizon = new SplitHorizonBuilder().setOverrideSplitHorizonProtection(true).build();
interfaceBuilder.setName(portName).setType(L2vlan.class).addAugmentation(IfL2vlan.class, ifL2vlan).addAugmentation(ParentRefs.class, parentRefs).addAugmentation(SplitHorizon.class, splitHorizon);
iface = interfaceBuilder.build();
/*
* Interface is already created for parent NeutronPort. We're updating parent refs
* and VLAN Information
*/
WriteTransaction txn = dataBroker.newWriteOnlyTransaction();
txn.merge(LogicalDatastoreType.CONFIGURATION, interfaceIdentifier, iface);
LOG.trace("Creating trunk member interface {}", iface);
futures.add(txn.submit());
return futures;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan 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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan in project genius by opendaylight.
the class IfmUtil method getVlanInterfaceInfo.
public static VlanInterfaceInfo getVlanInterfaceInfo(Interface iface, BigInteger dpId) {
short vlanId = 0;
String portName = null;
IfL2vlan vlanIface = iface.getAugmentation(IfL2vlan.class);
ParentRefs parentRefs = iface.getAugmentation(ParentRefs.class);
if (parentRefs != null && parentRefs.getParentInterface() != null) {
portName = parentRefs.getParentInterface();
} else {
LOG.warn("Portname set to null since parentRef is Null");
}
VlanInterfaceInfo vlanInterfaceInfo = new VlanInterfaceInfo(dpId, portName, vlanId);
if (vlanIface != null) {
vlanId = vlanIface.getVlanId() == null ? 0 : vlanIface.getVlanId().getValue().shortValue();
L2vlanMode l2VlanMode = vlanIface.getL2vlanMode();
if (l2VlanMode == L2vlanMode.Transparent) {
vlanInterfaceInfo.setVlanTransparent(true);
}
if (l2VlanMode == L2vlanMode.NativeUntagged) {
vlanInterfaceInfo.setUntaggedVlan(true);
}
vlanInterfaceInfo.setVlanId(vlanId);
}
return vlanInterfaceInfo;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan in project genius by opendaylight.
the class IfmUtil method getEgressActionInfosForInterface.
/**
* Returns the list of egress actions for a given interface.
*
* @param interfaceInfo the interface to look up
* @param portNo port number
* @param ifaceType the type of the interface
* @param tunnelKey the tunnel key
* @param actionKeyStart the start for the first key assigned for the new actions
* @param isDefaultEgress if it is the default egress
* @param ifIndex interface index
* @param groupId group Id
* @return list of actions for the interface
*/
// The following suppression is for javac, not for checkstyle
@SuppressWarnings("fallthrough")
@SuppressFBWarnings("SF_SWITCH_FALLTHROUGH")
public static List<ActionInfo> getEgressActionInfosForInterface(Interface interfaceInfo, String portNo, InterfaceInfo.InterfaceType ifaceType, Long tunnelKey, int actionKeyStart, boolean isDefaultEgress, int ifIndex, long groupId) {
List<ActionInfo> result = new ArrayList<>();
switch(ifaceType) {
case MPLS_OVER_GRE:
// fall through
case GRE_TRUNK_INTERFACE:
if (!isDefaultEgress) {
// stores the value coming from a VXLAN tunnel
if (tunnelKey == null) {
tunnelKey = 0L;
}
}
// fall through
case VXLAN_TRUNK_INTERFACE:
if (!isDefaultEgress) {
if (tunnelKey != null) {
result.add(new ActionSetFieldTunnelId(actionKeyStart++, BigInteger.valueOf(tunnelKey)));
}
} else {
// For OF Tunnels default egress actions need to set tunnelIps
IfTunnel ifTunnel = interfaceInfo.getAugmentation(IfTunnel.class);
if (BooleanUtils.isTrue(ifTunnel.isTunnelRemoteIpFlow() && ifTunnel.getTunnelDestination() != null)) {
result.add(new ActionSetTunnelDestinationIp(actionKeyStart++, ifTunnel.getTunnelDestination()));
}
if (BooleanUtils.isTrue(ifTunnel.isTunnelSourceIpFlow() && ifTunnel.getTunnelSource() != null)) {
result.add(new ActionSetTunnelSourceIp(actionKeyStart++, ifTunnel.getTunnelSource()));
}
}
// fall through
case VLAN_INTERFACE:
if (isDefaultEgress) {
IfL2vlan vlanIface = interfaceInfo.getAugmentation(IfL2vlan.class);
LOG.trace("get egress actions for l2vlan interface: {}", vlanIface);
boolean isVlanTransparent = false;
int vlanVid = 0;
if (vlanIface != null) {
vlanVid = vlanIface.getVlanId() == null ? 0 : vlanIface.getVlanId().getValue();
isVlanTransparent = vlanIface.getL2vlanMode() == IfL2vlan.L2vlanMode.Transparent;
}
if (vlanVid != 0 && !isVlanTransparent) {
result.add(new ActionPushVlan(actionKeyStart++));
result.add(new ActionSetFieldVlanVid(actionKeyStart++, vlanVid));
}
result.add(new ActionOutput(actionKeyStart++, new Uri(portNo)));
} else {
addEgressActionInfosForInterface(ifIndex, actionKeyStart, result);
}
break;
case LOGICAL_GROUP_INTERFACE:
if (isDefaultEgress) {
result.add(new ActionGroup(groupId));
} else {
addEgressActionInfosForInterface(ifIndex, actionKeyStart, result);
}
break;
default:
LOG.warn("Interface Type {} not handled yet", ifaceType);
break;
}
return result;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan in project genius by opendaylight.
the class OvsInterfaceConfigUpdateHelper method handleInterfaceAdminStateUpdates.
private void handleInterfaceAdminStateUpdates(WriteTransaction transaction, Interface interfaceNew, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState) {
IfL2vlan ifL2vlan = interfaceNew.getAugmentation(IfL2vlan.class);
if (ifL2vlan == null || IfL2vlan.L2vlanMode.Trunk != ifL2vlan.getL2vlanMode() && IfL2vlan.L2vlanMode.Transparent != ifL2vlan.getL2vlanMode()) {
return;
}
LOG.info("admin-state modified for interface {}", interfaceNew.getName());
OperStatus operStatus = interfaceManagerCommonUtils.updateStateEntry(interfaceNew, transaction, ifState);
InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(interfaceNew.getName());
InterfaceParentEntry interfaceParentEntry = interfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryKey);
if (interfaceParentEntry == null || interfaceParentEntry.getInterfaceChildEntry() == null) {
return;
}
VlanMemberStateUpdateWorker vlanMemberStateUpdateWorker = new VlanMemberStateUpdateWorker(txRunner, operStatus, interfaceParentEntry.getInterfaceChildEntry());
coordinator.enqueueJob(interfaceNew.getName(), vlanMemberStateUpdateWorker, IfmConstants.JOB_MAX_RETRIES);
}
Aggregations