@Override public void delete(PathArgument child) { try { output.write("\nDELETE -> ".getBytes()); output.write(current().node(child).toString().getBytes()); output.writeByte('\n'); } catch(IOException e) { Throwables.propagate(e); } }
private void outputPathAndNode(String name, PathArgument child, NormalizedNode<?, ?> data) { try { output.writeByte('\n'); output.write(name.getBytes()); output.write(" -> ".getBytes()); output.write(current().node(child).toString().getBytes()); output.write(": \n".getBytes()); NormalizedNodeXMLOutput.toStream(output, data); output.writeByte('\n'); } catch(IOException | XMLStreamException e) { Throwables.propagate(e); } } }
@Override public void onComplete(Throwable failure, Object result) { if(failure != null) { LOG.error("Failed to register DataChangeListener {} at path {}", listener, path.toString(), failure); } else { RegisterChangeListenerReply reply = (RegisterChangeListenerReply) result; setListenerRegistrationActor(actorContext.actorSelection( reply.getListenerRegistrationPath())); } } }, actorContext.getClientDispatcher());
private BmpRibInWriter(final YangInstanceIdentifier tablesRoot, final DOMTransactionChain chain, final RIBExtensionConsumerContext ribExtensions, final Set<TablesKey> tableTypes, final BindingCodecTree tree) { this.chain = chain; final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction(); this.tables = createTableInstance(tableTypes, tablesRoot, tx, ribExtensions, tree).build(); LOG.debug("New RIB table {} structure installed.", tablesRoot.toString()); tx.submit(); }
@Override public void onComplete(final Throwable failure, final Object result) { if (failure != null) { LOG.error("Failed to register DataTreeChangeListener {} at path {}", getInstance(), path.toString(), failure); } else { RegisterDataTreeChangeListenerReply reply = (RegisterDataTreeChangeListenerReply) result; setListenerRegistrationActor(actorContext.actorSelection( reply.getListenerRegistrationPath())); } } }, actorContext.getClientDispatcher());
/** * Search if the routing table route String contains routeName. */ private static Map<String,String> getRpcMemberMapByRoute(final RoutingTable table, final String routeName, final String address) { Set<DOMRpcIdentifier> routes = table.getRoutes(); Map<String, String> rpcMap = new HashMap<>(routes.size()); for (DOMRpcIdentifier route : routes) { if (!route.getContextReference().isEmpty()) { String routeString = route.getContextReference().toString(); if (routeString.contains(routeName)) { rpcMap.put(ROUTE_CONSTANT + routeString + NAME_CONSTANT + route.getType(), address); } } } return rpcMap; }
private static AuthorizationResponseType checkAuthorization(ActionType actionType, Authentication authentication, LogicalDatastoreType logicalDatastoreType, YangInstanceIdentifier yangInstanceIdentifier) { for (Policies policy : AuthzServiceImpl.listPolicies) { // Action type is compared as string, since its type is string in // the config yang. Comparison is case insensitive if (authentication.roles().contains(policy.getRole().getValue()) && (policy.getResource().getValue().equals(WILDCARD_TOKEN) || policy .getResource().getValue().equals(yangInstanceIdentifier.toString())) && (policy.getAction().toLowerCase() .equals(ActionType.Any.name().toLowerCase()) || actionType.name() .toLowerCase().equals(policy.getAction().toLowerCase()))) { return AuthorizationResponseType.Authorized; } } // For helium release we unauthorize other requests. return AuthorizationResponseType.NotAuthorized; }
private static int countNodes(final NormalizedNode<?,?> normalizedNode, final String namespaceFilter) { if (normalizedNode == null) { return 0; } final AtomicInteger count = new AtomicInteger(); new NormalizedNodeNavigator((level, parentPath, normalizedNode1) -> { if (!(normalizedNode1.getIdentifier() instanceof AugmentationIdentifier)) { if (normalizedNode1.getIdentifier().getNodeType().getNamespace().toString().contains(namespaceFilter)) { count.incrementAndGet(); } } }).navigate(YangInstanceIdentifier.EMPTY.toString(), normalizedNode); return count.get(); }