use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node in project netvirt by opendaylight.
the class HwvtepPhysicalSwitchListener method updated.
/**
* Upon update checks if the tunnels Ip was null earlier and it got newly added.
* In that case simply call add.
* If not then check if Tunnel Ip has been updated from an old value to new value.
* If yes. delete old ITM tunnels of odl Tunnel Ipand add new ITM tunnels with new Tunnel
* IP then call added ().
*
* @param identifier iid
* @param phySwitchBefore ps Node before update
* @param phySwitchAfter ps Node after update
*/
@Override
protected void updated(InstanceIdentifier<PhysicalSwitchAugmentation> identifier, PhysicalSwitchAugmentation phySwitchBefore, PhysicalSwitchAugmentation phySwitchAfter) {
NodeId nodeId = getNodeId(identifier);
LOG.trace("Received PhysicalSwitch Update Event for node {}: PhysicalSwitch Before: {}, " + "PhysicalSwitch After: {}", nodeId.getValue(), phySwitchBefore, phySwitchAfter);
String psName = getPsName(identifier);
if (psName == null) {
LOG.error("Could not find the physical switch name for node {}", nodeId.getValue());
return;
}
L2GatewayDevice existingDevice = l2GatewayCache.get(psName);
LOG.info("Received physical switch {} update event for node {}", psName, nodeId.getValue());
InstanceIdentifier<Node> globalNodeIid = getManagedByNodeIid(identifier);
if (DEVICE_NOT_CACHED_OR_PARENT_CONNECTED.test(existingDevice, globalNodeIid)) {
if (TUNNEL_IP_AVAILABLE.test(phySwitchAfter)) {
added(identifier, phySwitchAfter);
}
} else {
if (!Objects.equals(phySwitchAfter.getTunnelIps(), phySwitchBefore.getTunnelIps()) && TUNNEL_IP_CHANGED.test(phySwitchAfter, existingDevice)) {
final String hwvtepId = existingDevice.getHwvtepNodeId();
elanClusterUtils.runOnlyInOwnerNode(existingDevice.getDeviceName(), "handling Physical Switch add create itm tunnels ", () -> {
LOG.info("Deleting itm tunnels for device {}", existingDevice.getDeviceName());
L2GatewayUtils.deleteItmTunnels(itmRpcService, hwvtepId, existingDevice.getDeviceName(), existingDevice.getTunnelIp());
// TODO remove these sleeps
Thread.sleep(10000L);
LOG.info("Creating itm tunnels for device {}", existingDevice.getDeviceName());
ElanL2GatewayUtils.createItmTunnels(dataBroker, itmRpcService, hwvtepId, psName, phySwitchAfter.getTunnelIps().get(0).getTunnelIpsKey());
return Collections.emptyList();
});
try {
// TODO remove the sleep by using better itm api to detect finish of prev op
Thread.sleep(20000L);
} catch (InterruptedException e) {
LOG.error("Interrupted ");
}
existingDevice.setTunnelIps(new HashSet<>());
added(identifier, phySwitchAfter);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node in project netvirt by opendaylight.
the class HwvtepTerminationPointListener method handlePortAdded.
private List<ListenableFuture<Void>> handlePortAdded(TerminationPoint portAdded, NodeId psNodeId) {
Node psNode = HwvtepUtils.getHwVtepNode(broker, LogicalDatastoreType.OPERATIONAL, psNodeId);
if (psNode != null) {
String psName = psNode.getAugmentation(PhysicalSwitchAugmentation.class).getHwvtepNodeName().getValue();
L2GatewayDevice l2GwDevice = l2GatewayCache.get(psName);
if (l2GwDevice != null) {
if (isL2GatewayConfigured(l2GwDevice)) {
List<L2gatewayConnection> l2GwConns = L2GatewayConnectionUtils.getAssociatedL2GwConnections(broker, l2GwDevice.getL2GatewayIds());
String newPortId = portAdded.getTpId().getValue();
NodeId hwvtepNodeId = new NodeId(l2GwDevice.getHwvtepNodeId());
List<VlanBindings> vlanBindings = getVlanBindings(l2GwConns, hwvtepNodeId, psName, newPortId);
return Collections.singletonList(elanL2GatewayUtils.updateVlanBindingsInL2GatewayDevice(hwvtepNodeId, psName, newPortId, vlanBindings));
}
} else {
LOG.error("{} details are not present in L2Gateway Cache", psName);
}
} else {
LOG.error("{} entry not in config datastore", psNodeId);
}
return Collections.emptyList();
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node in project netvirt by opendaylight.
the class L2GatewayConnectionListener method loadL2GwDeviceCache.
private void loadL2GwDeviceCache(List<Node> nodes) {
if (nodes == null) {
LOG.debug("No config topology nodes are present");
return;
}
Map<InstanceIdentifier<Node>, Node> allNodes = nodes.stream().collect(toMap(TO_NODE_PATH, Function.identity()));
LOG.trace("Loading all config nodes");
Set<InstanceIdentifier<Node>> allIids = allNodes.keySet();
Map<String, List<InstanceIdentifier<Node>>> psNodesByDeviceName = allIids.stream().filter(IS_PS_NODE).collect(groupingBy(GET_DEVICE_NAME, toList()));
// Process HA nodes
allNodes.values().stream().filter(IS_HA_PARENT_NODE).forEach(parentNode -> {
allIids.stream().filter(IS_PS_NODE).filter(psIid -> PS_NODE_OF_PARENT_NODE.test(psIid, parentNode)).forEach(psIid -> {
addL2DeviceToCache(psIid, parentNode, allNodes.get(psIid));
});
});
// Process non HA nodes there will be only one ps node iid for each device for non ha nodes
psNodesByDeviceName.values().stream().filter(psIids -> psIids.size() == 1).map(psIids -> psIids.get(0)).forEach(psIid -> {
Node psNode = allNodes.get(psIid);
Node globalNode = allNodes.get(TO_GLOBAL_PATH.apply(psNode));
if (globalNode != null) {
addL2DeviceToCache(psIid, globalNode, psNode);
}
});
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node in project netvirt by opendaylight.
the class LocalUcastMacListener method getChildMod.
@Override
protected Map<InstanceIdentifier<LocalUcastMacs>, DataObjectModification<LocalUcastMacs>> getChildMod(final InstanceIdentifier<Node> parentIid, final DataObjectModification<Node> mod) {
Map<InstanceIdentifier<LocalUcastMacs>, DataObjectModification<LocalUcastMacs>> result = new HashMap<>();
DataObjectModification<HwvtepGlobalAugmentation> aug = mod.getModifiedAugmentation(HwvtepGlobalAugmentation.class);
if (aug != null && getModificationType(aug) != null) {
Collection<DataObjectModification<? extends DataObject>> children = aug.getModifiedChildren();
children.stream().filter(childMod -> getModificationType(childMod) != null).filter(childMod -> childMod.getDataType() == LocalUcastMacs.class).forEach(childMod -> {
LocalUcastMacs afterMac = (LocalUcastMacs) childMod.getDataAfter();
LocalUcastMacs mac = afterMac != null ? afterMac : (LocalUcastMacs) childMod.getDataBefore();
InstanceIdentifier<LocalUcastMacs> iid = parentIid.augmentation(HwvtepGlobalAugmentation.class).child(LocalUcastMacs.class, mac.getKey());
result.put(iid, (DataObjectModification<LocalUcastMacs>) childMod);
});
}
return result;
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node in project netvirt by opendaylight.
the class ElanBridgeManager method buildBridgeOtherConfigs.
private List<BridgeOtherConfigs> buildBridgeOtherConfigs(Node ovsdbNode, String bridgeName, String mac) {
// First attempt to extract the bridge augmentation from operational...
Node bridgeNode = southboundUtils.getBridgeNode(ovsdbNode, bridgeName);
OvsdbBridgeAugmentation bridgeAug = null;
if (bridgeNode != null) {
bridgeAug = southboundUtils.extractBridgeAugmentation(bridgeNode);
}
// ...if present, it means this bridge already exists and we need to take
// care not to change the datapath id. We do this by explicitly setting
// other_config:datapath-id to the value reported in the augmentation.
List<BridgeOtherConfigs> otherConfigs;
if (bridgeAug != null) {
DatapathId dpId = bridgeAug.getDatapathId();
if (dpId != null) {
otherConfigs = bridgeAug.getBridgeOtherConfigs();
if (otherConfigs == null) {
otherConfigs = Lists.newArrayList();
}
if (otherConfigs.stream().noneMatch(otherConfig -> otherConfig.getBridgeOtherConfigKey().equals(OTHER_CONFIG_DATAPATH_ID))) {
String dpIdVal = dpId.getValue().replace(":", "");
otherConfigs.add(new BridgeOtherConfigsBuilder().setBridgeOtherConfigKey(OTHER_CONFIG_DATAPATH_ID).setBridgeOtherConfigValue(dpIdVal).build());
}
} else {
otherConfigs = Lists.newArrayList();
}
} else {
otherConfigs = Lists.newArrayList();
if (mac != null) {
otherConfigs.add(new BridgeOtherConfigsBuilder().setBridgeOtherConfigKey(OTHER_CONFIG_HWADDR).setBridgeOtherConfigValue(mac).build());
}
}
if (otherConfigs.stream().noneMatch(otherConfig -> otherConfig.getBridgeOtherConfigKey().equals(OTHER_CONFIG_DISABLE_IN_BAND))) {
otherConfigs.add(new BridgeOtherConfigsBuilder().setBridgeOtherConfigKey(OTHER_CONFIG_DISABLE_IN_BAND).setBridgeOtherConfigValue("true").build());
}
return otherConfigs;
}
Aggregations