use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder in project netvirt by opendaylight.
the class TerminationPointCmd method transform.
@Override
public TerminationPoint transform(InstanceIdentifier<Node> nodePath, TerminationPoint src) {
HwvtepPhysicalPortAugmentation augmentation = src.getAugmentation(HwvtepPhysicalPortAugmentation.class);
if (augmentation == null) {
return new TerminationPointBuilder(src).build();
}
String nodeIdVal = nodePath.firstKeyOf(Node.class).getNodeId().getValue();
int idx = nodeIdVal.indexOf("/physicalswitch");
if (idx > 0) {
nodeIdVal = nodeIdVal.substring(0, idx);
nodePath = HwvtepHAUtil.convertToInstanceIdentifier(nodeIdVal);
}
final InstanceIdentifier<Node> path = nodePath;
TerminationPointBuilder tpBuilder = new TerminationPointBuilder(src);
tpBuilder.removeAugmentation(HwvtepPhysicalPortAugmentation.class);
HwvtepPhysicalPortAugmentationBuilder tpAugmentationBuilder = new HwvtepPhysicalPortAugmentationBuilder(augmentation);
if (augmentation.getVlanBindings() != null && augmentation.getVlanBindings().size() > 0) {
tpAugmentationBuilder.setVlanBindings(augmentation.getVlanBindings().stream().map(vlanBindings -> {
VlanBindingsBuilder vlanBindingsBuilder = new VlanBindingsBuilder(vlanBindings);
vlanBindingsBuilder.setLogicalSwitchRef(HwvtepHAUtil.convertLogicalSwitchRef(vlanBindings.getLogicalSwitchRef(), path));
return vlanBindingsBuilder.build();
}).collect(Collectors.toList()));
}
tpBuilder.addAugmentation(HwvtepPhysicalPortAugmentation.class, tpAugmentationBuilder.build());
return tpBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder in project netvirt by opendaylight.
the class ElanL2GatewayMulticastUtils method preapareRemoteMcastMacEntry.
/**
* Update remote mcast mac.
*
* @param elanName
* the elan name
* @param device
* the device
* @param dpnsTepIps
* the dpns tep ips
* @param l2GwDevicesTepIps
* the l2 gw devices tep ips
* @return the write transaction
*/
private void preapareRemoteMcastMacEntry(String elanName, L2GatewayDevice device, List<IpAddress> dpnsTepIps, List<IpAddress> l2GwDevicesTepIps) {
NodeId nodeId = new NodeId(device.getHwvtepNodeId());
ArrayList<IpAddress> remoteTepIps = new ArrayList<>(l2GwDevicesTepIps);
remoteTepIps.remove(device.getTunnelIp());
remoteTepIps.addAll(dpnsTepIps);
IpAddress dhcpDesignatedSwitchTepIp = getTepIpOfDesignatedSwitchForExternalTunnel(device, elanName);
if (dpnsTepIps.isEmpty()) {
// physical locator in l2 gw device
if (dhcpDesignatedSwitchTepIp != null) {
remoteTepIps.add(dhcpDesignatedSwitchTepIp);
HwvtepPhysicalLocatorAugmentation phyLocatorAug = HwvtepSouthboundUtils.createHwvtepPhysicalLocatorAugmentation(String.valueOf(dhcpDesignatedSwitchTepIp.getValue()));
InstanceIdentifier<TerminationPoint> iid = HwvtepSouthboundUtils.createPhysicalLocatorInstanceIdentifier(nodeId, phyLocatorAug);
TerminationPoint terminationPoint = new TerminationPointBuilder().setKey(HwvtepSouthboundUtils.getTerminationPointKey(phyLocatorAug)).addAugmentation(HwvtepPhysicalLocatorAugmentation.class, phyLocatorAug).build();
ResourceBatchingManager.getInstance().put(ResourceBatchingManager.ShardResource.CONFIG_TOPOLOGY, iid, terminationPoint);
LOG.info("Adding PhysicalLocator for node: {} with Dhcp designated switch Tep Ip {} " + "as physical locator, elan {}", device.getHwvtepNodeId(), String.valueOf(dhcpDesignatedSwitchTepIp.getValue()), elanName);
} else {
LOG.warn("Dhcp designated switch Tep Ip not found for l2 gw node {} and elan {}", device.getHwvtepNodeId(), elanName);
}
}
if (dhcpDesignatedSwitchTepIp != null && !remoteTepIps.contains(dhcpDesignatedSwitchTepIp)) {
remoteTepIps.add(dhcpDesignatedSwitchTepIp);
}
String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(elanName);
putRemoteMcastMac(nodeId, logicalSwitchName, remoteTepIps);
LOG.info("Adding RemoteMcastMac for node: {} with physical locators: {}", device.getHwvtepNodeId(), remoteTepIps);
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder in project netvirt by opendaylight.
the class TestBuilders method buildTerminationPoint.
public static TerminationPoint buildTerminationPoint(InstanceIdentifier<Node> nodeIid, String ip) {
TerminationPointKey tpKey = new TerminationPointKey(new TpId("vxlan_over_ipv4:" + ip));
TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
if (nodeIid != null && tpKey != null) {
tpBuilder.setKey(tpKey);
tpBuilder.setTpId(tpKey.getTpId());
InstanceIdentifier<TerminationPoint> tpPath = buildTpId(nodeIid, ip);
HwvtepPhysicalLocatorAugmentationBuilder tpAugmentationBuilder = new HwvtepPhysicalLocatorAugmentationBuilder();
tpAugmentationBuilder.setPhysicalLocatorUuid(getUUid(ip));
tpAugmentationBuilder.setEncapsulationType(createEncapsulationType("vxlan_over_ipv4"));
tpAugmentationBuilder.setDstIp(new IpAddress(ip.toCharArray()));
tpBuilder.addAugmentation(HwvtepPhysicalLocatorAugmentation.class, tpAugmentationBuilder.build());
}
return tpBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder in project bgpcep by opendaylight.
the class LinkstateTopologyBuilder method buildTp.
private static TerminationPoint buildTp(final TpId id, final TerminationPointType type) {
final TerminationPointBuilder stpb = new TerminationPointBuilder();
stpb.setKey(new TerminationPointKey(id));
stpb.setTpId(id);
if (type != null) {
stpb.addAugmentation(TerminationPoint1.class, new TerminationPoint1Builder().setIgpTerminationPointAttributes(new IgpTerminationPointAttributesBuilder().setTerminationPointType(type).build()).build());
}
return stpb.build();
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder 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