use of org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId in project netvirt by opendaylight.
the class ExpectedObjects method newInterfaceConfig.
public static Interface newInterfaceConfig(final String interfaceName, final String parentName) {
InterfaceBuilder _interfaceBuilder = new InterfaceBuilder();
final Procedure1<InterfaceBuilder> _function = (InterfaceBuilder it) -> {
it.setDescription(interfaceName);
it.setName(interfaceName);
it.setType(L2vlan.class);
ParentRefsBuilder _parentRefsBuilder = new ParentRefsBuilder();
final Procedure1<ParentRefsBuilder> _function_1 = (ParentRefsBuilder it_1) -> {
it_1.setParentInterface(parentName);
};
ParentRefs _doubleGreaterThan = XtendBuilderExtensions.<ParentRefs, ParentRefsBuilder>operator_doubleGreaterThan(_parentRefsBuilder, _function_1);
it.addAugmentation(ParentRefs.class, _doubleGreaterThan);
IfL2vlanBuilder _ifL2vlanBuilder = new IfL2vlanBuilder();
final Procedure1<IfL2vlanBuilder> _function_2 = (IfL2vlanBuilder it_1) -> {
it_1.setL2vlanMode(IfL2vlan.L2vlanMode.Trunk);
VlanId _vlanId = new VlanId(Integer.valueOf(0));
it_1.setVlanId(_vlanId);
};
IfL2vlan _doubleGreaterThan_1 = XtendBuilderExtensions.<IfL2vlan, IfL2vlanBuilder>operator_doubleGreaterThan(_ifL2vlanBuilder, _function_2);
it.addAugmentation(IfL2vlan.class, _doubleGreaterThan_1);
};
return XtendBuilderExtensions.<Interface, InterfaceBuilder>operator_doubleGreaterThan(_interfaceBuilder, _function);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId in project netvirt by opendaylight.
the class PhysicalSwitchHelper method createVlanBinding.
public static VlanBindings createVlanBinding(Long key, String logicalSwitch) {
VlanBindingsBuilder vbBuilder = new VlanBindingsBuilder();
VlanBindingsKey vbKey = new VlanBindingsKey(new VlanId(key.intValue()));
vbBuilder.setKey(vbKey);
vbBuilder.setVlanIdKey(vbKey.getVlanIdKey());
HwvtepLogicalSwitchRef hwvtepLogicalSwitchRef = new HwvtepLogicalSwitchRef(createInstanceIdentifier(logicalSwitch));
vbBuilder.setLogicalSwitchRef(hwvtepLogicalSwitchRef);
return vbBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId in project netvirt by opendaylight.
the class NeutronTrunkChangeListener method deleteSubPortInterface.
private void deleteSubPortInterface(SubPorts subPort) {
String portName = subPort.getPortId().getValue();
InstanceIdentifier<Interface> interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(subPort.getPortId().getValue());
jobCoordinator.enqueueJob("PORT- " + portName, () -> {
Interface iface = ifMgr.getInterfaceInfoFromConfigDataStore(portName);
List<ListenableFuture<Void>> futures = new ArrayList<>();
if (iface == null) {
LOG.warn("Interface not present for SubPort {}", subPort);
return futures;
}
/*
* We'll reset interface back to way it was? Can IFM handle parentRef delete?
*/
InterfaceBuilder interfaceBuilder = new InterfaceBuilder(iface);
// Reset augmentations
interfaceBuilder.removeAugmentation(IfL2vlan.class).removeAugmentation(ParentRefs.class).removeAugmentation(SplitHorizon.class);
IfL2vlan ifL2vlan = new IfL2vlanBuilder().setL2vlanMode(IfL2vlan.L2vlanMode.Trunk).build();
interfaceBuilder.addAugmentation(IfL2vlan.class, ifL2vlan);
iface = interfaceBuilder.build();
/*
* There is no means to do an update to remove elements from a node.
* Our solution is to get existing iface, remove parentRef and VlanId,
* and do a put to replace existing entry. This works out better as put
* has better performance than merge.
* Only drawback is any in-flight changes might be lost, but that is a corner case
* and this being subport delete path, don't expect any significant changes to
* corresponding Neutron Port. Deletion of NeutronPort should follow soon enough.
*/
WriteTransaction txn = dataBroker.newWriteOnlyTransaction();
txn.put(LogicalDatastoreType.CONFIGURATION, interfaceIdentifier, iface);
LOG.trace("Resetting trunk member interface {}", iface);
futures.add(txn.submit());
return futures;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId 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.l2.types.rev130827.VlanId in project netvirt by opendaylight.
the class L2GatewayListener method update.
@Override
protected void update(InstanceIdentifier<L2gateway> identifier, L2gateway original, L2gateway update) {
LOG.trace("Updating L2gateway : key: {}, original value={}, update value={}", identifier, original, update);
List<L2gatewayConnection> connections = l2gwService.getAssociatedL2GwConnections(Sets.newHashSet(update.getUuid()));
if (connections == null) {
LOG.warn("There are no connections associated with l2 gateway uuid {} name {}", update.getUuid(), update.getName());
return;
}
if (original.getDevices() == null) {
connections.forEach((connection) -> l2gwService.addL2GatewayConnection(connection));
return;
}
jobCoordinator.enqueueJob("l2gw.update", () -> {
ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction();
DeviceInterfaces updatedDeviceInterfaces = new DeviceInterfaces(update);
List<ListenableFuture<Void>> fts = new ArrayList<>();
original.getDevices().stream().filter((originalDevice) -> originalDevice.getInterfaces() != null).forEach((originalDevice) -> {
String deviceName = originalDevice.getDeviceName();
L2GatewayDevice l2GwDevice = l2GatewayCache.get(deviceName);
NodeId physicalSwitchNodeId = HwvtepSouthboundUtils.createManagedNodeId(new NodeId(l2GwDevice.getHwvtepNodeId()), deviceName);
originalDevice.getInterfaces().stream().filter((intf) -> !updatedDeviceInterfaces.containsInterface(deviceName, intf.getInterfaceName())).forEach((intf) -> {
connections.forEach((connection) -> {
Integer vlanId = connection.getSegmentId();
if (intf.getSegmentationIds() != null && !intf.getSegmentationIds().isEmpty()) {
for (Integer vlan : intf.getSegmentationIds()) {
HwvtepUtils.deleteVlanBinding(transaction, physicalSwitchNodeId, intf.getInterfaceName(), vlan);
}
} else {
LOG.debug("Deleting vlan binding {} {} {}", physicalSwitchNodeId, intf.getInterfaceName(), vlanId);
HwvtepUtils.deleteVlanBinding(transaction, physicalSwitchNodeId, intf.getInterfaceName(), vlanId);
}
});
});
});
fts.add(transaction.submit());
Futures.addCallback(fts.get(0), new FutureCallback<Void>() {
@Override
public void onSuccess(Void success) {
LOG.debug("Successfully deleted vlan bindings for l2gw update {}", update);
connections.forEach((l2GwConnection) -> l2gwService.addL2GatewayConnection(l2GwConnection, null, update));
}
@Override
public void onFailure(Throwable throwable) {
LOG.error("Failed to delete vlan bindings as part of l2gw udpate {}", update);
}
}, MoreExecutors.directExecutor());
return fts;
}, SystemPropertyReader.getDataStoreJobCoordinatorMaxRetries());
}
Aggregations