use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId 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.model.match.types.rev131026.vlan.match.fields.VlanId in project genius by opendaylight.
the class InterfacemgrProvider method createVLANInterface.
@Override
public ListenableFuture<Void> createVLANInterface(String interfaceName, String portName, Integer vlanId, String description, IfL2vlan.L2vlanMode l2vlanMode, boolean isExternal) throws InterfaceAlreadyExistsException {
LOG.info("Create VLAN interface : {}", interfaceName);
Interface interfaceOptional = interfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(interfaceName));
if (interfaceOptional != null) {
LOG.debug("VLAN interface already exists {} ", interfaceOptional.getDescription());
throw new InterfaceAlreadyExistsException(interfaceOptional.getName());
}
IfL2vlanBuilder l2vlanBuilder = new IfL2vlanBuilder().setL2vlanMode(l2vlanMode);
if (vlanId != null && vlanId > 0) {
l2vlanBuilder.setVlanId(new VlanId(vlanId));
}
ParentRefs parentRefs = new ParentRefsBuilder().setParentInterface(portName).build();
InterfaceBuilder interfaceBuilder = new InterfaceBuilder().setEnabled(true).setName(interfaceName).setType(L2vlan.class).addAugmentation(IfL2vlan.class, l2vlanBuilder.build()).addAugmentation(ParentRefs.class, parentRefs).setDescription(description);
if (isExternal) {
interfaceBuilder.addAugmentation(IfExternal.class, new IfExternalBuilder().setExternal(true).build());
}
InstanceIdentifier<Interface> interfaceIId = interfaceManagerCommonUtils.getInterfaceIdentifier(new InterfaceKey(interfaceName));
ListenableFuture<Void> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> tx.put(CONFIGURATION, interfaceIId, interfaceBuilder.build(), CREATE_MISSING_PARENTS));
ListenableFutures.addErrorLogging(future, LOG, "Failed to (async) write {}", interfaceIId);
return future;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId in project genius by opendaylight.
the class InterfaceManagerTestUtil method buildInterface.
static Interface buildInterface(String ifName, String desc, boolean enabled, Object ifType, String parentInterface, IfL2vlan.L2vlanMode l2vlanMode) {
InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(ifName)).setName(ifName).setDescription(desc).setEnabled(enabled).setType((Class<? extends InterfaceType>) ifType);
ParentRefs parentRefs = new ParentRefsBuilder().setParentInterface(parentInterface).build();
builder.addAugmentation(ParentRefs.class, parentRefs);
if (ifType.equals(L2vlan.class)) {
IfL2vlanBuilder ifL2vlanBuilder = new IfL2vlanBuilder().setL2vlanMode(l2vlanMode);
if (IfL2vlan.L2vlanMode.TrunkMember.equals(l2vlanMode)) {
ifL2vlanBuilder.setVlanId(new VlanId(100));
} else {
ifL2vlanBuilder.setVlanId(VlanId.getDefaultInstance("0"));
}
builder.addAugmentation(IfL2vlan.class, ifL2vlanBuilder.build());
} else if (ifType.equals(IfTunnel.class)) {
IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(null).setTunnelGateway(null).setTunnelSource(null).setTunnelInterfaceType(null).build();
builder.addAugmentation(IfTunnel.class, tunnel);
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId in project genius by opendaylight.
the class IfmCLIUtil method showVlanOutput.
static void showVlanOutput(InterfaceInfo ifaceInfo, Interface iface, CommandSession session) {
StringBuilder sb = new StringBuilder();
Formatter fmt = new Formatter(sb);
IfL2vlan l2vlan = iface.getAugmentation(IfL2vlan.class);
int vlanId = l2vlan != null ? l2vlan.getVlanId() != null ? l2vlan.getVlanId().getValue() : 0 : 0;
session.getConsole().println(fmt.format(VLAN_OUTPUT_FORMAT_LINE1, iface.getName()));
sb.setLength(0);
session.getConsole().println(fmt.format(VLAN_OUTPUT_FORMAT, "", ifaceInfo == null ? UNSET : ifaceInfo.getDpId(), ifaceInfo == null ? UNSET : ifaceInfo.getPortName(), vlanId));
sb.setLength(0);
session.getConsole().println(fmt.format(VLAN_OUTPUT_FORMAT, ifaceInfo == null ? UNSET : ifaceInfo.getInterfaceTag(), ifaceInfo == null ? UNSET : ifaceInfo.getPortNo(), ifaceInfo == null ? UNSET : ifaceInfo.getAdminState(), ifaceInfo == null ? UNSET : ifaceInfo.getOpState()));
sb.setLength(0);
session.getConsole().println(fmt.format(VLAN_OUTPUT_FORMAT + "%n", iface.getDescription(), "", "", ""));
sb.setLength(0);
fmt.close();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId in project openflowplugin by opendaylight.
the class VlanVidEntryDeserializer method deserializeEntry.
@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
final boolean hasMask = processHeader(message);
final VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
final int vlanVidValue = message.readUnsignedShort();
if (hasMask) {
// Skip mask
message.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
vlanIdBuilder.setVlanId(new VlanId(0)).setVlanIdPresent(true);
} else {
final boolean vidPresent = (vlanVidValue & (1 << 12)) != 0;
vlanIdBuilder.setVlanId(new VlanId((vidPresent ? vlanVidValue & ((1 << 12) - 1) : vlanVidValue))).setVlanIdPresent(vidPresent);
}
if (Objects.isNull(builder.getVlanMatch())) {
builder.setVlanMatch(new VlanMatchBuilder().setVlanId(vlanIdBuilder.build()).build());
} else if (Objects.isNull(builder.getVlanMatch().getVlanId())) {
builder.setVlanMatch(new VlanMatchBuilder(builder.getVlanMatch()).setVlanId(vlanIdBuilder.build()).build());
} else {
throwErrorOnMalformed(builder, "vlanMatch", "vlanVid");
}
}
Aggregations