use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan.L2vlanMode in project netvirt by opendaylight.
the class NeutronPortChangeListener method createInterface.
private Interface createInterface(Port port) {
String interfaceName = port.getUuid().getValue();
IfL2vlan.L2vlanMode l2VlanMode = IfL2vlan.L2vlanMode.Trunk;
InterfaceBuilder interfaceBuilder = new InterfaceBuilder();
IfL2vlanBuilder ifL2vlanBuilder = new IfL2vlanBuilder();
ifL2vlanBuilder.setL2vlanMode(l2VlanMode);
interfaceBuilder.setEnabled(true).setName(interfaceName).setType(L2vlan.class).addAugmentation(IfL2vlan.class, ifL2vlanBuilder.build());
if (NeutronvpnUtils.getPortSecurityEnabled(port)) {
InterfaceAclBuilder interfaceAclBuilder = new InterfaceAclBuilder();
interfaceAclBuilder.setPortSecurityEnabled(true);
NeutronvpnUtils.populateInterfaceAclBuilder(interfaceAclBuilder, port);
interfaceBuilder.addAugmentation(InterfaceAcl.class, interfaceAclBuilder.build());
neutronvpnUtils.populateSubnetIpPrefixes(port);
}
return interfaceBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan.L2vlanMode 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.L2vlanMode 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.genius.interfacemanager.rev160406.IfL2vlan.L2vlanMode 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.genius.interfacemanager.rev160406.IfL2vlan.L2vlanMode in project genius by opendaylight.
the class InterfaceManagerTestUtil method putVlanInterfaceConfig.
static void putVlanInterfaceConfig(DataBroker dataBroker, String ifaceName, String parentRefs, IfL2vlan.L2vlanMode l2vlanMode) throws TransactionCommitFailedException {
Interface interfaceInfo = InterfaceManagerTestUtil.buildInterface(ifaceName, ifaceName, true, L2vlan.class, parentRefs, l2vlanMode);
InstanceIdentifier<Interface> interfaceInstanceIdentifier = IfmUtil.buildId(ifaceName);
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
tx.put(CONFIGURATION, interfaceInstanceIdentifier, interfaceInfo, true);
tx.submit().checkedGet();
}
Aggregations