use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.order.tlv.Order 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.params.xml.ns.yang.pcep.types.rev181109.order.tlv.Order in project netvirt by opendaylight.
the class NeutronPortChangeListener method add.
@Override
public void add(InstanceIdentifier<Port> identifier, Port input) {
LOG.trace("Received port add event: port={}", input);
String portName = input.getUuid().getValue();
LOG.trace("Adding Port : key: {}, value={}", identifier, input);
Network network = neutronvpnUtils.getNeutronNetwork(input.getNetworkId());
if (network == null || !NeutronvpnUtils.isNetworkTypeSupported(network)) {
LOG.warn("neutron vpn received a port add() for a network without a provider extension augmentation " + "or with an unsupported network type for the port {} which is part of network {}", portName, network);
return;
}
neutronvpnUtils.addToPortCache(input);
String portStatus = NeutronUtils.PORT_STATUS_DOWN;
if (!Strings.isNullOrEmpty(input.getDeviceOwner()) && !Strings.isNullOrEmpty(input.getDeviceId())) {
if (NeutronConstants.DEVICE_OWNER_ROUTER_INF.equals(input.getDeviceOwner())) {
handleRouterInterfaceAdded(input);
NeutronUtils.createPortStatus(input.getUuid().getValue(), NeutronUtils.PORT_STATUS_ACTIVE, dataBroker);
return;
}
if (NeutronConstants.DEVICE_OWNER_GATEWAY_INF.equals(input.getDeviceOwner())) {
handleRouterGatewayUpdated(input, false);
portStatus = NeutronUtils.PORT_STATUS_ACTIVE;
} else if (NeutronConstants.DEVICE_OWNER_FLOATING_IP.equals(input.getDeviceOwner())) {
handleFloatingIpPortUpdated(null, input);
portStatus = NeutronUtils.PORT_STATUS_ACTIVE;
}
}
// in order to validate the supported vnic types from the hostconfig
if (input.getFixedIps() != null && !input.getFixedIps().isEmpty() && (!isPortTypeSwitchdev(input) || isPortBound(input))) {
handleNeutronPortCreated(input);
}
NeutronUtils.createPortStatus(input.getUuid().getValue(), portStatus, dataBroker);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.order.tlv.Order in project lispflowmapping by opendaylight.
the class MappingMergeUtil method getCommonLocatorRecords.
private static List<LocatorRecord> getCommonLocatorRecords(MappingRecord nbMapping, MappingRecord sbMapping) {
// Return null when NB is a negative mapping
if (nbMapping.getLocatorRecord() == null || nbMapping.getLocatorRecord().isEmpty()) {
return null;
}
List<LocatorRecord> sbLocators = sbMapping.getLocatorRecord();
// We assume locators are unique and don't show up several times (with different or identical p/w/mp/mw),
// so we create a HashMap of the locators from the SB mapping record, keyed by the Rloc
Map<Rloc, LocatorRecord> sbLocatorMap = new HashMap<Rloc, LocatorRecord>();
for (LocatorRecord locator : sbLocators) {
sbLocatorMap.put(locator.getRloc(), locator);
}
// Gradually building final list of common locators, in order that they appear in NB Mapping
List<LocatorRecord> commonLocators = new ArrayList<LocatorRecord>();
for (LocatorRecord nbLocator : nbMapping.getLocatorRecord()) {
Rloc nbRloc = nbLocator.getRloc();
if (sbLocatorMap.containsKey(nbRloc)) {
if (sbLocatorMap.get(nbRloc).getPriority() == (short) 255) {
// if SB locator has p == 255 then common locator takes all NB fields except for p
// which must be set to 255
LocatorRecordBuilder lrb = new LocatorRecordBuilder(nbLocator);
lrb.setPriority((short) 255);
commonLocators.add(lrb.build());
} else {
commonLocators.add(nbLocator);
}
}
}
return commonLocators;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.order.tlv.Order in project lispflowmapping by opendaylight.
the class MappingMergeUtil method mergeLocatorRecords.
private static void mergeLocatorRecords(MappingRecordBuilder mrb, MappingRecord newRecord) {
List<LocatorRecord> locators = mrb.getLocatorRecord();
// We assume locators are unique and sorted and don't show up several times (with different or identical
// p/w/mp/mw), so we create a LinkedHashMap (which preserves order) of the locators from the existing merged
// record, keyed by the Rloc
Map<Rloc, LocatorRecord> locatorMap = new LinkedHashMap<Rloc, LocatorRecord>();
// All locators to be added to the merge set are first stored in this list
List<LocatorRecord> newLocatorList = new ArrayList<LocatorRecord>();
for (LocatorRecord locator : locators) {
locatorMap.put(locator.getRloc(), locator);
}
for (LocatorRecord newLocator : newRecord.getLocatorRecord()) {
Rloc newRloc = newLocator.getRloc();
if (locatorMap.containsKey(newRloc)) {
// overlapping locator
if (!locatorMap.get(newRloc).equals(newLocator)) {
LocatorRecord mergedLocator = mergeLocators(locatorMap.get(newRloc), newLocator);
newLocatorList.add(mergedLocator);
}
} else {
// new locator
newLocatorList.add(newLocator);
}
}
// Build new merged and sorted locator set if need be
if (!newLocatorList.isEmpty()) {
List<LocatorRecord> mergedLocators = new ArrayList<LocatorRecord>();
int mlocIt = 0;
int locIt = 0;
while (mlocIt < newLocatorList.size() && locIt < locators.size()) {
int cmp = compareLocators(locators.get(locIt), newLocatorList.get(mlocIt));
if (cmp < 0) {
mergedLocators.add(locators.get(locIt));
locIt++;
} else if (cmp > 0) {
mergedLocators.add(newLocatorList.get(mlocIt));
mlocIt++;
} else {
// when a locator appears in both lists, keep the new (merged) one and skip the old
mergedLocators.add(newLocatorList.get(mlocIt));
mlocIt++;
locIt++;
}
}
while (locIt < locators.size()) {
mergedLocators.add(locators.get(locIt));
locIt++;
}
while (mlocIt < newLocatorList.size()) {
mergedLocators.add(newLocatorList.get(mlocIt));
mlocIt++;
}
mrb.setLocatorRecord(mergedLocators);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.order.tlv.Order in project genius by opendaylight.
the class InterfaceManagerConfigurationTest method rebuildTerminationPoint.
private TerminationPoint rebuildTerminationPoint(TerminationPoint tp) {
// The problem we're fixing here is that, in MD-SAL binding v1, YANG lists are represented
// as Java lists but they don't preserve order (unless they specify “ordered-by user”).
// YANG keyed lists in particular are backed by maps, so you can store such a list in the
// MD-SAL and get it back in a different order.
// When comparing beans involving such lists, we need to sort the lists before comparing
// them. Retrieving the augmentation gives a modifiable list, so it's tempting to just
// sort that — but the list is re-created every time the augmentation is retrieved, so
// the sort is lost.
// To avoid all this, we rebuild instances of TerminationPoint, and sort the affected lists
// in the augmentations, with full augmentation rebuilds too (since the lists in a built
// augmentation might be unmodifiable).
TerminationPointBuilder newTpBuilder = new TerminationPointBuilder(tp);
OvsdbTerminationPointAugmentation ovsdbTpAugmentation = tp.getAugmentation(OvsdbTerminationPointAugmentation.class);
if (ovsdbTpAugmentation != null) {
OvsdbTerminationPointAugmentationBuilder newOvsdbTpAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder(ovsdbTpAugmentation);
if (ovsdbTpAugmentation.getOptions() != null) {
List<Options> options = new ArrayList<>(ovsdbTpAugmentation.getOptions());
options.sort(Comparator.comparing(o -> o.getKey().toString()));
newOvsdbTpAugmentationBuilder.setOptions(options);
}
if (ovsdbTpAugmentation.getInterfaceBfd() != null) {
List<InterfaceBfd> interfaceBfd = new ArrayList<>(ovsdbTpAugmentation.getInterfaceBfd());
interfaceBfd.sort(Comparator.comparing(o -> o.getKey().toString()));
newOvsdbTpAugmentationBuilder.setInterfaceBfd(interfaceBfd);
}
newTpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, newOvsdbTpAugmentationBuilder.build());
}
return newTpBuilder.build();
}
Aggregations