@Override public void deleteCurrentAttributes(@Nonnull InstanceIdentifier<Neighbor> id, @Nonnull Neighbor dataBefore, @Nonnull WriteContext writeContext) throws WriteFailedException { checkNotNull(dataBefore, "Cannot delete null neighbour"); checkArgument(id.firstKeyOf(Interface.class) != null, "No parent interface key found"); LOG.debug("Processing request for Neigbour delete"); String interfaceName = id.firstKeyOf(Interface.class).getName(); MappingContext mappingContext = writeContext.getMappingContext(); checkState(interfaceContext.containsIndex(interfaceName, mappingContext), "Mapping does not contains mapping for provider interface name %s", interfaceName); LOG.debug("Parent interface[{}] index found", interfaceName); try { addDelNeighbourAndReply(id, false, interfaceContext.getIndex(interfaceName, mappingContext), dataBefore); LOG.info("Neighbour {} successfully deleted", id); } catch (VppBaseCallException e) { throw new WriteFailedException.DeleteFailedException(id, e); } }
@Override public void writeCurrentAttributes(@Nonnull InstanceIdentifier<Neighbor> id, @Nonnull Neighbor dataAfter, @Nonnull WriteContext writeContext) throws WriteFailedException { checkNotNull(dataAfter, "Cannot write null neighbour"); checkArgument(id.firstKeyOf(Interface.class) != null, "No parent interface key found"); LOG.debug("Processing request for Neigbour write"); String interfaceName = id.firstKeyOf(Interface.class).getName(); MappingContext mappingContext = writeContext.getMappingContext(); checkState(interfaceContext.containsIndex(interfaceName, mappingContext), "Mapping does not contains mapping for provider interface name ".concat(interfaceName)); LOG.debug("Parent interface index found"); try { addDelNeighbourAndReply(id, true, interfaceContext.getIndex(interfaceName, mappingContext), dataAfter); LOG.info("Neighbour successfully written"); } catch (VppBaseCallException e) { throw new WriteFailedException.CreateFailedException(id, dataAfter, e); } }
@Override public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<NshEntry> id, @Nonnull final NshEntry dataBefore, @Nonnull final WriteContext writeContext) throws WriteFailedException { LOG.debug("Removing nsh entry: iid={} dataBefore={}", id, dataBefore); final String entryName = dataBefore.getName(); checkState(nshEntryContext.containsIndex(entryName, writeContext.getMappingContext()), "Removing nsh entry {}, but index could not be found in the nsh entry context", entryName); final int entryIndex = nshEntryContext.getIndex(entryName, writeContext.getMappingContext()); try { nshAddDelEntry(false, id, dataBefore, entryIndex, writeContext.getMappingContext()); // Remove deleted interface from interface context: nshEntryContext.removeName(dataBefore.getName(), writeContext.getMappingContext()); LOG.debug("Successfully removed nsh entry(id={]): iid={} dataAfter={}", entryIndex, id, dataBefore); } catch (VppBaseCallException e) { throw new WriteFailedException.DeleteFailedException(id, e); } }
@Override public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<NshMap> id, @Nonnull final NshMap dataBefore, @Nonnull final WriteContext writeContext) throws WriteFailedException { LOG.debug("Removing nsh map: iid={} dataBefore={}", id, dataBefore); final String mapName = dataBefore.getName(); checkState(nshMapContext.containsIndex(mapName, writeContext.getMappingContext()), "Removing nsh map {}, but index could not be found in the nsh map context", mapName); final int mapIndex = nshMapContext.getIndex(mapName, writeContext.getMappingContext()); try { nshAddDelMap(false, id, dataBefore, mapIndex, writeContext.getMappingContext()); // Remove deleted interface from interface context: nshMapContext.removeName(dataBefore.getName(), writeContext.getMappingContext()); LOG.debug("Successfully removed nsh map(id={]): iid={} dataAfter={}", mapIndex, id, dataBefore); } catch (VppBaseCallException e) { throw new WriteFailedException.DeleteFailedException(id, e); } }
private NshAddDelMap getNshAddDelMapRequest(final boolean isAdd, final int mapIndex, @Nonnull final NshMap map, @Nonnull final MappingContext ctx) { final NshAddDelMap request = new NshAddDelMap(); request.isAdd = booleanToByte(isAdd); request.nspNsi = (map.getNsp().intValue()<<8) | map.getNsi(); request.mappedNspNsi = (map.getMappedNsp().intValue()<<8) | map.getMappedNsi(); if (map.getEncapType() == VxlanGpe.class) { request.nextNode = 2; } checkState(interfaceContext.containsIndex(map.getEncapIfName(), ctx), "Mapping does not contains mapping for provider interface Name ".concat(map.getEncapIfName())); request.swIfIndex = interfaceContext.getIndex(map.getEncapIfName(), ctx); return request; } }
@Override public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<BridgeDomain> id, @Nonnull final BridgeDomain dataBefore, @Nonnull final WriteContext ctx) throws WriteFailedException { LOG.debug("writeCurrentAttributes: id={}, current={}, ctx={}", id, dataBefore, ctx); final String bdName = dataBefore.getName(); try { int index; if (bdContext.containsIndex(bdName, ctx.getMappingContext())) { index = bdContext.getIndex(bdName, ctx.getMappingContext()); } else { // FIXME we need the bd index to be returned by VPP or we should have a counter field // (maybe in context similar to artificial name) // Here we assign the next available ID from bdContext's perspective index = 1; while (bdContext.containsName(index, ctx.getMappingContext())) { index++; } } addOrUpdateBridgeDomain(id, index, dataBefore); bdContext.addName(index, bdName, ctx.getMappingContext()); } catch (VppBaseCallException e) { LOG.warn("Failed to create bridge domain", e); throw new WriteFailedException.CreateFailedException(id, dataBefore, e); } }
if (!nshMapContext.containsIndex(mapName, ctx.getMappingContext())) { LOG.debug("Could not find nsh map {} in the naming context", mapName); return;
if (!nshEntryContext.containsIndex(entryName, ctx.getMappingContext())) { LOG.debug("Could not find nsh entry {} in the naming context", entryName); return;