use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder 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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder in project genius by opendaylight.
the class OvsdbSouthboundTestUtil method updateTerminationPoint.
public static void updateTerminationPoint(DataBroker dataBroker, String interfaceName, Class<? extends InterfaceTypeBase> type) throws TransactionCommitFailedException {
final OvsdbBridgeName ovsdbBridgeName = new OvsdbBridgeName("s2");
final InstanceIdentifier<Node> bridgeIid = createInstanceIdentifier("192.168.56.101", 6640, ovsdbBridgeName);
InstanceIdentifier<TerminationPoint> tpId = createTerminationPointInstanceIdentifier(InstanceIdentifier.keyOf(bridgeIid.firstIdentifierOf(Node.class)), interfaceName);
TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
tpBuilder.setKey(InstanceIdentifier.keyOf(tpId));
OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder();
tpAugmentationBuilder.setName(interfaceName);
if (type != null) {
tpAugmentationBuilder.setInterfaceType(type);
}
List<InterfaceBfdStatus> interfaceBfdStatuses = Arrays.asList(new InterfaceBfdStatusBuilder().setBfdStatusKey("state").setBfdStatusValue("down").build());
tpAugmentationBuilder.setInterfaceBfdStatus(interfaceBfdStatuses);
tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, tpAugmentationBuilder.build());
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
tx.merge(OPERATIONAL, tpId, tpBuilder.build(), true);
tx.submit().checkedGet();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder in project genius by opendaylight.
the class OvsdbSouthboundTestUtil method createTerminationPoint.
public static void createTerminationPoint(DataBroker dataBroker, String interfaceName, Class<? extends InterfaceTypeBase> type, String externalId) throws TransactionCommitFailedException {
final OvsdbBridgeName ovsdbBridgeName = new OvsdbBridgeName("s2");
final InstanceIdentifier<Node> bridgeIid = createInstanceIdentifier("192.168.56.101", 6640, ovsdbBridgeName);
InstanceIdentifier<TerminationPoint> tpId = createTerminationPointInstanceIdentifier(InstanceIdentifier.keyOf(bridgeIid.firstIdentifierOf(Node.class)), interfaceName);
TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
tpBuilder.setKey(InstanceIdentifier.keyOf(tpId));
OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder();
tpAugmentationBuilder.setName(interfaceName);
if (type != null) {
tpAugmentationBuilder.setInterfaceType(type);
}
if (externalId != null) {
List<InterfaceExternalIds> interfaceExternalIds = new ArrayList<>();
InterfaceExternalIds interfaceExternalIds1 = new InterfaceExternalIdsBuilder().setExternalIdKey("iface-id").setExternalIdValue(externalId).build();
interfaceExternalIds.add(interfaceExternalIds1);
tpAugmentationBuilder.setInterfaceExternalIds(interfaceExternalIds);
}
tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, tpAugmentationBuilder.build());
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
tx.put(OPERATIONAL, tpId, tpBuilder.build(), true);
tx.submit().checkedGet();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder in project netvirt by opendaylight.
the class ElanBridgeManager method copyBridgeToConfig.
private void copyBridgeToConfig(Node brIntNode) {
NodeBuilder bridgeNodeBuilder = new NodeBuilder(brIntNode);
// termination points need to be masssaged to remove the ifindex field
// which are not allowed in the config data store
List<TerminationPoint> terminationPoints = brIntNode.getTerminationPoint();
if (terminationPoints != null) {
List<TerminationPoint> newTerminationPoints = new ArrayList<>();
for (TerminationPoint tp : terminationPoints) {
OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation = tp.getAugmentation(OvsdbTerminationPointAugmentation.class);
TerminationPointBuilder tpBuilder = new TerminationPointBuilder(tp);
if (ovsdbTerminationPointAugmentation != null) {
OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder(ovsdbTerminationPointAugmentation);
tpAugmentationBuilder.setIfindex(null);
tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, tpAugmentationBuilder.build());
}
newTerminationPoints.add(tpBuilder.build());
}
bridgeNodeBuilder.setTerminationPoint(newTerminationPoints);
}
InstanceIdentifier<Node> brNodeIid = SouthboundUtils.createInstanceIdentifier(brIntNode.getNodeId());
this.mdsalUtils.put(LogicalDatastoreType.CONFIGURATION, brNodeIid, bridgeNodeBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder in project netvirt by opendaylight.
the class TestInterfaceManager method getTunnelPortsOnBridge.
@Override
public List<OvsdbTerminationPointAugmentation> getTunnelPortsOnBridge(BigInteger dpnId) {
if (dpnId == GeniusProviderTestParams.DPN_ID_NO_EXIST) {
// Unfortunately, the getTunnelPortsOnBridge() method may return null
return null;
}
if (dpnId == GeniusProviderTestParams.DPN_ID_NO_PORTS) {
return Collections.emptyList();
}
OvsdbTerminationPointAugmentationBuilder tpAug = new OvsdbTerminationPointAugmentationBuilder();
tpAug.setOfport(GeniusProviderTestParams.OF_PORT);
if (dpnId == GeniusProviderTestParams.DPN_ID_NO_VXGPE_PORTS) {
// Tunnel Termination Point that is NOT of type VXGPE
tpAug.setInterfaceType(InterfaceTypeGre.class);
} else {
// Tunnel Termination Point that IS of type VXGPE
tpAug.setInterfaceType(InterfaceTypeVxlan.class);
}
List<Options> opsList = new ArrayList<>();
if (dpnId != GeniusProviderTestParams.DPN_ID_NO_OPTIONS) {
OptionsBuilder opsBuilder = new OptionsBuilder();
opsBuilder.setKey(new OptionsKey(GeniusProvider.OPTION_KEY_EXTS));
opsBuilder.setValue(GeniusProvider.OPTION_VALUE_EXTS_GPE);
opsList.add(opsBuilder.build());
}
tpAug.setOptions(opsList);
List<OvsdbTerminationPointAugmentation> tpAugList = new ArrayList<>();
tpAugList.add(tpAug.build());
return tpAugList;
}
Aggregations