public synchronized InstanceIdentifier<NodeConnector> getNodeConnectorIidForPortName(Name portName) { for (SwitchState sw : switches.values()) { if (sw.fcncByNcIid == null) { continue; } for (Entry<InstanceIdentifier<NodeConnector>, FlowCapableNodeConnector> fcncByNcIidEntry : sw.fcncByNcIid .entrySet()) { FlowCapableNodeConnector fcnc = fcncByNcIidEntry.getValue(); if (portName.getValue().equals(fcnc.getName())) { return fcncByNcIidEntry.getKey(); } } } return null; }
@Override protected void onSubtreeModified(DataObjectModification<OfOverlayL3Context> rootNode, InstanceIdentifier<OfOverlayL3Context> rootIdentifier) { Name newPortName = rootNode.getDataAfter().getPortName(); Name oldPortName = rootNode.getDataBefore().getPortName(); LOG.trace("on update: \n old OfOverlayL3Context: {} \n new OfOverlayL3Context: {} \n rootIdentifier: {}", rootNode.getDataBefore(), rootNode.getDataAfter(), rootIdentifier); if (oldPortName == null && newPortName == null) { LOG.debug("Cannot update location for L3EP {} because port-name is missing.", rootIdentifier.firstKeyOf(EndpointL3.class)); return; } if (oldPortName != null && newPortName != null && oldPortName.equals(newPortName)) { LOG.debug("No need to update location for L3EP {} because port-name {} was not changed.", rootIdentifier.firstKeyOf(EndpointL3.class), oldPortName.getValue()); return; } updateLocationBasedOnPortName(newPortName, rootIdentifier); }
@Override protected void onSubtreeModified(DataObjectModification<OfOverlayContext> rootNode, InstanceIdentifier<OfOverlayContext> rootIdentifier) { Name newPortName = rootNode.getDataAfter().getPortName(); Name oldPortName = rootNode.getDataBefore().getPortName(); LOG.trace("on update: \n old OfOverlayContext: {} \n new OfOverlayContext: {} \n rootIdentifier: {}", rootNode.getDataBefore(), rootNode.getDataAfter(), rootIdentifier); if (oldPortName == null && newPortName == null) { LOG.debug("Cannot update location for EP {} because port-name is missing.", rootIdentifier.firstKeyOf(Endpoint.class)); return; } if (oldPortName != null && newPortName != null && oldPortName.equals(newPortName)) { LOG.debug("No need to update location for EP {} because port-name {} was not changed.", rootIdentifier.firstKeyOf(Endpoint.class), oldPortName.getValue()); return; } updateLocationBasedOnPortName(newPortName, rootIdentifier); }
private static @Nonnull ForwardingContext createL3ContextFromRouter( Router router) { Name l3ContextName = null; if (!Strings.isNullOrEmpty(router.getName())) { l3ContextName = new Name(router.getName()); } return new ForwardingContextBuilder().setContextId(new ContextId(router.getUuid().getValue())) .setContextType(MappingUtils.L3_CONTEXT) .setName(new Name(l3ContextName.getValue())) .build(); }
private OfOverlayContextBuilder checkAugmentation(RegisterEndpointInput input) { OfOverlayContextInput ictx = input.getAugmentation(OfOverlayContextInput.class); if (ictx == null) { return null; } OfOverlayContextBuilder ictxBuilder = new OfOverlayContextBuilder(ictx); if (ictx.getPortName() != null && ictx.getNodeId() != null && ictx.getNodeConnectorId() != null) { return ictxBuilder; } /* * In the case where they've provided just the port name, go see if * we can find the NodeId and NodeConnectorId from inventory. */ if (ictx.getPortName() != null) { NodeInfo augmentation = fetchAugmentation(ictx.getPortName().getValue()); if (augmentation != null) { ictxBuilder.setNodeId(augmentation.getNode().getId()); ictxBuilder.setNodeConnectorId(augmentation.getNodeConnector().getId()); } } return ictxBuilder; }