use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.port.id.subport.data.PortIdToSubportKey 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, () -> {
/*
* Build Port-to-Subport details first, irrespective of port being available or not.
*/
PortIdToSubportBuilder portIdToSubportBuilder = new PortIdToSubportBuilder();
Uuid subPortUuid = subPort.getPortId();
portIdToSubportBuilder.withKey(new PortIdToSubportKey(subPortUuid)).setPortId(subPortUuid).setTrunkPortId(trunk.getPortId()).setVlanId(subPort.getSegmentationId());
List<ListenableFuture<?>> futures = new ArrayList<>();
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
tx.merge(NeutronvpnUtils.buildPortIdSubportMappingIdentifier(subPortUuid), portIdToSubportBuilder.build());
LOG.trace("Creating PortIdSubportMapping for port{}", portName);
}));
Interface iface = ifMgr.getInterfaceInfoFromConfigDataStore(portName);
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).addAugmentation(parentRefs).addAugmentation(splitHorizon);
Interface newIface = interfaceBuilder.build();
/*
* Interface is already created for parent NeutronPort. We're updating parent refs
* and VLAN Information
*/
ListenableFuture<?> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, txn -> txn.merge(interfaceIdentifier, newIface));
LoggingFutures.addErrorLogging(future, LOG, "createSubPortInterface: Failed for portName {}, parentName {}", portName, parentName);
futures.add(future);
return futures;
});
}
Aggregations