use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunk.attributes.SubPorts 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;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunk.attributes.SubPorts 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<?>> 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);
Interface newIface = 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.
*/
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
tx.put(interfaceIdentifier, newIface);
LOG.trace("Resetting trunk member interface {}", newIface);
}));
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
tx.delete(NeutronvpnUtils.buildPortIdSubportMappingIdentifier(subPort.getPortId()));
LOG.trace("Deleting PortIdSubportMapping for portName {}", portName);
}));
return futures;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunk.attributes.SubPorts in project netvirt by opendaylight.
the class NeutronPortChangeListener method createOfPortInterface.
private String createOfPortInterface(Port port, TypedWriteTransaction<Datastore.Configuration> wrtConfigTxn) {
Interface inf = createInterface(port);
String infName = inf.getName();
InstanceIdentifier<Interface> interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(infName);
try {
Optional<Interface> optionalInf = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, interfaceIdentifier);
if (!optionalInf.isPresent()) {
wrtConfigTxn.put(interfaceIdentifier, inf);
} else if (isInterfaceUpdated(inf, optionalInf.get())) {
/*
Case where an update DTCN wasn't received by this class due to node going down
upon cluster reboot or any other unknown reason
In such a case, updates contained in the missed DTCN won't be processed and have to be handled
explicitly
Update of subports (vlanId, splithorizon tag) is handled here
Update of portSecurity (PortSecurityEnabled, SecurityGroups, AllowedAddressPairs) add is handled
Update of portSecurity update/removed is not handled
Update of parentrefs is not handled as parentrefs updation is handled by IFM Oxygen onwards
*/
wrtConfigTxn.put(interfaceIdentifier, inf);
LOG.error("Interface {} is already present and is updated", infName);
} else {
LOG.warn("Interface {} is already present", infName);
}
} catch (ExecutionException | InterruptedException e) {
LOG.error("failed to create interface {}", infName, e);
}
return infName;
}
Aggregations