public Optional<DataBroker> getDataBrokerForMountPoint(@Nonnull InstanceIdentifier<?> iidToMountPoint) { Optional<MountPoint> potentialMountPoint = mountService.getMountPoint(iidToMountPoint); if (!potentialMountPoint.isPresent()) { LOG.debug("Mount point does not exist for {}", iidToMountPoint); return Optional.absent(); } return potentialMountPoint.get().getService(DataBroker.class); } }
private DataBroker getNodeMountPoint(InstanceIdentifier<Node> mountPointIid) { Optional<MountPoint> optionalObject = mountService.getMountPoint(mountPointIid); MountPoint mountPoint; if (optionalObject.isPresent()) { mountPoint = optionalObject.get(); if (mountPoint != null) { Optional<DataBroker> optionalDataBroker = mountPoint.getService(DataBroker.class); if (optionalDataBroker.isPresent()) { return optionalDataBroker.get(); } else { LOG.debug("Cannot obtain data broker from mountpoint {}", mountPoint); } } else { LOG.debug("Cannot obtain mountpoint with IID {}", mountPointIid); } } return null; }
public HydrogenMountInstanceAdapter(final MountPoint key) { this.identifier = key.getIdentifier(); final ImmutableClassToInstanceMap.Builder<BindingAwareService> builder = ImmutableClassToInstanceMap.builder(); final Optional<DataBroker> dataBroker = key.getService(DataBroker.class); if(dataBroker.isPresent()) { builder.put(DataBrokerService.class, new HydrogenDataBrokerAdapter(dataBroker.get())); } final Optional<org.opendaylight.controller.md.sal.binding.api.NotificationService> notificationService = key.getService(org.opendaylight.controller.md.sal.binding.api.NotificationService.class); if(notificationService.isPresent()) { builder.put(NotificationService.class, new HeliumNotificationServiceAdapter(notificationService.get())); } final Optional<RpcConsumerRegistry> rpcRegistry = key.getService(RpcConsumerRegistry.class); if(rpcRegistry.isPresent()) { builder.put(RpcConsumerRegistry.class, rpcRegistry.get()); } services = builder.build(); }
private ServiceFunctionDescriptionMonitorReportService getSfDescriptionMonitorService(String nodeName) { InstanceIdentifier<?> nodeIID = NETCONF_TOPO_IID.child(Node.class, new NodeKey(new NodeId(nodeName))); MountPointService mountService = SfcNetconfDataProvider.GetNetconfDataProvider().getMountService(); if (mountService == null) { LOG.error("Mount service is null"); return null; } Optional<MountPoint> mountPoint = mountService.getMountPoint(nodeIID); if (!mountPoint.isPresent()) { LOG.error("Mount point for node {} doesn't exist", nodeName); return null; } final Optional<RpcConsumerRegistry> service = mountPoint.get().getService(RpcConsumerRegistry.class); if (!service.isPresent()) { LOG.error("Failed to get RpcService for node {}", nodeName); return null; } return service.get().getRpcService(ServiceFunctionDescriptionMonitorReportService.class); }
public BGPOpenConfigListener(final DataBroker dataBroker, final MountPoint mountPoint, final BGPConfigStateStore configStateHolders) { final DataBroker mpDataBroker = Preconditions.checkNotNull(mountPoint).getService(DataBroker.class).get(); final BGPConfigModuleProvider configModuleWriter = new BGPConfigModuleProvider(); this.ribImplProvider = new BGPRibImplProvider(configStateHolders, configModuleWriter, mpDataBroker); this.peerProvider = new BGPPeerProvider(configStateHolders, configModuleWriter, mpDataBroker); this.appPeerProvider = new BGPAppPeerProvider(configStateHolders, configModuleWriter, mpDataBroker); this.registerDataTreeChangeListener = dataBroker.registerDataTreeChangeListener( new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, OpenConfigUtil.BGP_IID), this); }
final Optional<NotificationService> service1 = mountPoint.get().getService(NotificationService.class); LOG.info("Registering notification listener on {} for node: {}", VrfRouteNotification.QNAME, nodeId); final ListenerRegistration<ExampleNotificationsListener> accessTopologyListenerListenerRegistration = final Optional<RpcConsumerRegistry> service = mountPoint.get().getService(RpcConsumerRegistry.class); final NotificationsService rpcService = service.get().getRpcService(NotificationsService.class); final CreateSubscriptionInputBuilder createSubscriptionInputBuilder = new CreateSubscriptionInputBuilder();
/** * Find a node's NETCONF mount point and then retrieve its DataBroker. * e.g. * http://localhost:8080/restconf/config/network-topology:network-topology/ * topology/topology-netconf/node/{nodeName}/yang-ext:mount/ */ public static Optional<DataBroker> getDataBroker(MountPointService mountService, String nodeName) { NodeId nodeId = new NodeId(nodeName); InstanceIdentifier<Node> nodeInstanceId = InstanceIdentifier.builder(NetworkTopology.class) .child(Topology.class, new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName()))) .child(Node.class, new NodeKey(nodeId)) .build(); final Optional<MountPoint> nodeOptional = mountService.getMountPoint(nodeInstanceId); if (!nodeOptional.isPresent()) { return Optional.absent(); } MountPoint nodeMountPoint = nodeOptional.get(); return Optional.of(nodeMountPoint.getService(DataBroker.class).get()); }
final DataBroker xrNodeBroker = xrNode.getService(DataBroker.class).get();
final DataBroker dataBroker = mountPoint.get().getService(DataBroker.class).get(); final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();