Пример #1
0
  private void handleSlaveMountPoint(final DataObjectModification<Node> rootNode) {
    @SuppressWarnings("ConstantConditions")
    final NetconfNode netconfNodeAfter = rootNode.getDataAfter().getAugmentation(NetconfNode.class);

    if (NetconfNodeConnectionStatus.ConnectionStatus.Connected.equals(
        netconfNodeAfter.getConnectionStatus())) {
      createActorRef();
      final String masterAddress =
          netconfNodeAfter.getClusteredConnectionStatus().getNetconfMasterNode();
      final String path =
          NetconfTopologyUtils.createActorPath(
              masterAddress,
              NetconfTopologyUtils.createMasterActorName(
                  id.getName(),
                  netconfNodeAfter.getClusteredConnectionStatus().getNetconfMasterNode()));
      setup.getActorSystem().actorSelection(path).tell(new AskForMasterMountPoint(), slaveActorRef);
    } else {;
      closeActor();
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see org.opendaylight.controller.md.sal.binding.api.DataChangeListener#onDataChanged(org.
   * opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent)
   */
  @Override
  public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
    LOG.info("OnDataChange, change: {}", change);
    try {
      // create
      for (Entry<InstanceIdentifier<?>, DataObject> entry : change.getCreatedData().entrySet()) {
        if (entry.getKey().getTargetType() == NetconfNode.class) {
          NodeId nodeId = helper.getNodeId(entry.getKey());

          // To determine whether the equipment is support ofconfig
          helper.createOfconfigNode(nodeId);
        }
      }
      // update
      for (Entry<InstanceIdentifier<?>, DataObject> entry : change.getUpdatedData().entrySet()) {
        if (entry.getKey().getTargetType() == NetconfNode.class) {
          NodeId nodeId = helper.getNodeId(entry.getKey());

          // To determine whether it is device ofconfig
          Optional<OfconfigTopoHandler> handlerOptional =
              helper.getOfconfigInventoryTopoHandler(nodeId);
          if (handlerOptional.isPresent()) {

            // We have a ofconfig device
            NetconfNode nnode = (NetconfNode) entry.getValue();
            ConnectionStatus csts = nnode.getConnectionStatus();

            switch (csts) {
              case Connected:
                {
                  if (helper.isOfconfigDeviceNode(nnode)) {
                    LOG.info("ofconfig device: {} is fully connected", nodeId.getValue());
                  }
                  break;
                }
              case Connecting:
                {
                  if (helper.isOfconfigDeviceNode(nnode)) {

                    LOG.info("ofconfig device: {} was disconnected", nodeId.getValue());
                  }
                  break;
                }
              case UnableToConnect:
                {
                  if (helper.isOfconfigDeviceNode(nnode)) {
                    LOG.info("ofconfig device: {} connection failed", nodeId.getValue());
                    helper.destroyOfconfigNode(nodeId);
                  }
                  break;
                }
              default:
                break;
            }
          }
        }
      }
    } catch (Exception e) {
      LOG.error("OnDataChange, change: {} fail", change, e);
    }
  }