use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project openflowplugin by opendaylight.
the class ReconcileUtil method resolveAndDivideGroupDiffs.
/**
* Returns a list of safe synchronization steps.
*
* @param nodeId target node
* @param installedGroupsArg groups resent on device
* @param pendingGroups groups configured for device
* @param gatherUpdates check content of pending item if present on device (and create update task eventually)
* @return list of safe synchronization steps
*/
public static List<ItemSyncBox<Group>> resolveAndDivideGroupDiffs(final NodeId nodeId, final Map<Long, Group> installedGroupsArg, final Collection<Group> pendingGroups, final boolean gatherUpdates) {
final Map<Long, Group> installedGroups = new HashMap<>(installedGroupsArg);
final List<ItemSyncBox<Group>> plan = new ArrayList<>();
while (!Iterables.isEmpty(pendingGroups)) {
final ItemSyncBox<Group> stepPlan = new ItemSyncBox<>();
final Iterator<Group> iterator = pendingGroups.iterator();
final Map<Long, Group> installIncrement = new HashMap<>();
while (iterator.hasNext()) {
final Group group = iterator.next();
final Group existingGroup = installedGroups.get(group.getGroupId().getValue());
if (existingGroup != null) {
if (!gatherUpdates) {
iterator.remove();
} else {
// check buckets and eventually update
if (group.equals(existingGroup)) {
iterator.remove();
} else {
if (checkGroupPrecondition(installedGroups.keySet(), group)) {
iterator.remove();
LOG.trace("Group {} on device {} differs - planned for update", group.getGroupId(), nodeId);
stepPlan.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(existingGroup, group));
}
}
}
} else if (checkGroupPrecondition(installedGroups.keySet(), group)) {
iterator.remove();
installIncrement.put(group.getGroupId().getValue(), group);
stepPlan.getItemsToPush().add(group);
}
}
if (!stepPlan.isEmpty()) {
// atomic update of installed flows in order to keep plan portions clean of local group dependencies
installedGroups.putAll(installIncrement);
plan.add(stepPlan);
} else if (!pendingGroups.isEmpty()) {
LOG.warn("Failed to resolve and divide groups into preconditions-match based ordered plan: {}, " + "resolving stuck at level {}", nodeId.getValue(), plan.size());
throw new IllegalStateException("Failed to resolve and divide groups when matching preconditions");
}
}
return plan;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project openflowplugin by opendaylight.
the class ReconcileUtil method resolveFlowDiffsInAllTables.
/**
* Resolves flow differences in all tables.
*
* @param nodeId target node
* @param tableOperationalMap flow-tables resent on device
* @param tablesConfigured flow-tables configured for device
* @param gatherUpdates check content of pending item if present on device (and create update task eventually)
* @return map : key={@link TableKey}, value={@link ItemSyncBox} of safe synchronization steps
*/
public static Map<TableKey, ItemSyncBox<Flow>> resolveFlowDiffsInAllTables(final NodeId nodeId, final Map<Short, Table> tableOperationalMap, final List<Table> tablesConfigured, final boolean gatherUpdates) {
LOG.trace("resolving flows in tables for {}", nodeId.getValue());
final Map<TableKey, ItemSyncBox<Flow>> tableFlowSyncBoxes = new HashMap<>();
for (final Table tableConfigured : tablesConfigured) {
final List<Flow> flowsConfigured = tableConfigured.getFlow();
if (flowsConfigured == null || flowsConfigured.isEmpty()) {
continue;
}
// lookup table (on device)
final Table tableOperational = tableOperationalMap.get(tableConfigured.getId());
// wrap existing (on device) flows in current table into map
final Map<FlowDescriptor, Flow> flowOperationalMap = FlowCapableNodeLookups.wrapFlowsToMap(tableOperational != null ? tableOperational.getFlow() : null);
final ItemSyncBox<Flow> flowsSyncBox = resolveFlowDiffsInTable(flowsConfigured, flowOperationalMap, gatherUpdates);
if (!flowsSyncBox.isEmpty()) {
tableFlowSyncBoxes.put(tableConfigured.getKey(), flowsSyncBox);
}
}
return tableFlowSyncBoxes;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project openflowplugin by opendaylight.
the class ReconcileUtil method resolveMeterDiffs.
/**
* Resolves meter differences.
*
* @param nodeId target node
* @param meterOperationalMap meters present on device
* @param metersConfigured meters configured for device
* @param gatherUpdates check content of pending item if present on device (and create update task eventually)
* @return synchronization box
*/
public static ItemSyncBox<Meter> resolveMeterDiffs(final NodeId nodeId, final Map<MeterId, Meter> meterOperationalMap, final List<Meter> metersConfigured, final boolean gatherUpdates) {
LOG.trace("resolving meters for {}", nodeId.getValue());
final ItemSyncBox<Meter> syncBox = new ItemSyncBox<>();
for (Meter meter : metersConfigured) {
final Meter existingMeter = meterOperationalMap.get(meter.getMeterId());
if (existingMeter == null) {
syncBox.getItemsToPush().add(meter);
} else {
// compare content and eventually update
if (gatherUpdates && !meter.equals(existingMeter)) {
syncBox.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(existingMeter, meter));
}
}
}
return syncBox;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project netvirt by opendaylight.
the class ElanMacEntryListener method add.
// Using mac entry clustered listener instead of elan interface listener to avoid race conditions
// always use clustered listener to programme l2gw device
@Override
public void add(InstanceIdentifier<MacEntry> identifier, MacEntry add) {
LOG.trace("ElanMacEntryListener add : {}", add);
elanClusterUtils.runOnlyInOwnerNode("Adding dpn macs to remote ucast mac tables", () -> {
String elanName = identifier.firstKeyOf(MacTable.class).getElanInstanceName();
ElanInstance elanInstance = elanInstanceCache.get(elanName).orElse(null);
if (ElanUtils.isVxlanNetworkOrVxlanSegment(elanInstance)) {
Uint64 dpId = elanL2GatewayUtils.getDpidFromInterface(add.getInterface());
elanL2GatewayUtils.scheduleAddDpnMacInExtDevices(elanName, dpId, Lists.newArrayList(add.getMacAddress()));
}
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project netvirt by opendaylight.
the class HwvtepPhysicalSwitchListener method handleAdd.
/**
* Handle add.
*
* @param l2GwDevice
* the l2 gw device
*/
private void handleAdd(L2GatewayDevice l2GwDevice, InstanceIdentifier<PhysicalSwitchAugmentation> identifier, PhysicalSwitchAugmentation phySwitchAdded) {
LOG.info("PhysicalSwitchListener Handle add of tunnel ips {} psNode {} device {}", phySwitchAdded.getTunnelIps(), identifier.firstKeyOf(Node.class).getNodeId(), l2GwDevice);
final String psName = l2GwDevice.getDeviceName();
final String hwvtepNodeId = l2GwDevice.getHwvtepNodeId();
Set<IpAddress> tunnelIps = l2GwDevice.getTunnelIps();
if (tunnelIps != null) {
// TODO add logical switch and mcast put itm tep event and update mcast
hwvtepHACache.addDebugEvent(new MdsalEvent("ps add provision", l2GwDevice.getHwvtepNodeId()));
for (final IpAddress tunnelIpAddr : tunnelIps) {
if (L2GatewayConnectionUtils.isGatewayAssociatedToL2Device(l2GwDevice)) {
LOG.info("PhysicalSwitchListener L2Gateway {} associated for {} physical switch " + " creating ITM tunnels for {}", l2GwDevice.getL2GatewayIds(), psName, tunnelIpAddr);
l2gwServiceProvider.provisionItmAndL2gwConnection(l2GwDevice, psName, hwvtepNodeId, tunnelIpAddr);
} else {
LOG.info("l2gw.provision.skip hwvtepNodeId: {} psName : {}", hwvtepNodeId, psName);
}
}
InstanceIdentifier<Node> globalNodeIid = HwvtepSouthboundUtils.createInstanceIdentifier(new NodeId(hwvtepNodeId));
HwvtepHACache.getInstance().setTepIpOfNode(globalNodeIid, tunnelIps.iterator().next());
elanClusterUtils.runOnlyInOwnerNode(psName, "Stale entry cleanup", () -> {
InstanceIdentifier<Node> psIid = HwvtepSouthboundUtils.createInstanceIdentifier(HwvtepSouthboundUtils.createManagedNodeId(new NodeId(hwvtepNodeId), psName));
staleVlanBindingsCleaner.scheduleStaleCleanup(psName, globalNodeIid, psIid);
transportZoneListener.createL2gwZeroDayConfig();
return Collections.emptyList();
});
}
}
Aggregations