Package com.tailf.ned

Class NedGenericBase

Object
com.tailf.ned.NedConnectionBase
com.tailf.ned.NedGenericBase

public abstract class NedGenericBase extends NedConnectionBase
This interface must be adhered to by code that talks to a generic device that is modeled in YANG. The configuration is sent to the Ned as a set of create/delete/set operations that has to be mapped to configuration operation on the actual device by the NedGeneric code.
  • Constructor Details

    • NedGenericBase

      public NedGenericBase()
  • Method Details

    • prepare

      public abstract void prepare(NedWorker w, NedEditOp[] ops) throws Exception
      Is invoked by NCS to take the configuration to a new state. The Ned may choose to apply the changes directly to the device, preferably to a candidate configuration, but if the device lacks candidate support it may choose to apply the changes directly to the running config. If the configuration changes are later aborted, or reverted, the NCS will provide the necessary changes for restoring the configuration to its previous state. The Ned should invoke the method prepareResponse() in NedWorker w when the operation is completed. initialize (prepare transaction) / \ / uninitialize (undo preparations) v prepare (send data to device) / \ v v abort | commit(send confirmed commit (ios would do noop)) / \ v v revert | persist (send confirming commit)
      Parameters:
      w - The NedWorker instance currently responsible for driving the communication between NCS and the device. This NedWorker instance should be used when communicating with the NCS, ie for sending responses, errors, and trace messages. It is also implements the NedTracer API and can be used in, for example, the SSHSession as a tracer.
      ops - Edit operations representing the changes to the configuration.
      Throws:
      Exception
    • prepareDry

      public void prepareDry(NedWorker w, NedEditOp[] ops) throws Exception
      Is invoked by NCS to ask the NED what actions it would take towards the device if it would do a prepare. The NED can send the preformatted output back to NCS through the call to prepareDryResponse() The Ned should invoke the method prepareDryResponse() in NedWorker w when the operation is completed. If the functionality is not supported this method need not be implemented. Alternatively the NED can respond with a NedWorker.prepareDryUnsupportedResponse().
      Parameters:
      w - The NedWorker instance currently responsible for driving the communication between NCS and the device. This NedWorker instance should be used when communicating with the NCS, ie for sending responses, errors, and trace messages. It is also implements the NedTracer API and can be used in, for example, the SSHSession as a tracer.
      ops - Edit operations representing the changes to the configuration.
      Throws:
      Exception
    • abort

      public abstract void abort(NedWorker w, NedEditOp[] ops) throws Exception
      Is invoked by NCS to abort the current transaction and bring the configuration back to the state before the previous prepare() invocation. The NCS has calculated the changes needed to reach that state from the current state. The instance may choose to use these commands, or use some other mechanism to reach the same state. When the operation is completed it should invoke the method abortResponse() in in NedWorker w.
      Parameters:
      w - The NedWorker instance currently responsible for driving the communication between NCS and the device. This NedWorker instance should be used when communicating with the NCS, ie for sending responses, errors, and trace messages. It is also implements the NedTracer API and can be used in, for example, the SSHSession as a tracer.
      ops - is the edit operations needed for taking the config back to the previous state.
      Throws:
      Exception
    • revert

      public abstract void revert(NedWorker w, NedEditOp[] ops) throws Exception
      Is invoked by NCS to undo the changes introduced in the last commit operation (communicated to the NED in the prepare method invocation). The difference between abort() and revert() is that revert() is invoked after commit() (but before persist), whereas abort() is invoked before the commit(). Once the configuration has been made persistent by persist() it can no longer be restored to any previous (potentially saved) state. When the revert operation has been completed the method revertResponse in NedWorker w should be called.
      Parameters:
      w - The NedWorker instance currently responsible for driving the communication between NCS and the device. This NedWorker instance should be used when communicating with the NCS, ie for sending responses, errors, and trace messages. It is also implements the NedTracer API and can be used in, for example, the SSHSession as a tracer.
      ops - is the edit operations for taking the config back to the previous state.
      Throws:
      Exception
    • show

      public abstract void show(NedWorker w, int th) throws Exception
      Read parts of the configuration and applies it to the transaction provided in the method invocation. It may choose to write more into the transaction than is actually requested. The response is sent by invoking the method showGenericResponse() in in the NedWorker w.
      Parameters:
      w - The NedWorker instance currently responsible for driving the communication between NCS and the device. This NedWorker instance should be used when communicating with the NCS, ie for sending responses, errors, and trace messages. It is also implements the NedTracer API and can be used in, for example, the SSHSession as a tracer.
      th - is a transaction id that can be used with the Maapi library for accessing a transaction.
      Throws:
      Exception
    • showPartial

      public void showPartial(NedWorker w, int th, ConfPath[] paths) throws Exception
      Read parts of the configuration and applies it to the transaction provided in the method invocation. It may choose to write more into the transaction than is actually requested. The response is sent by invoking the method showGenericResponse() in in the NedWorker w.
      Parameters:
      w - The NedWorker instance currently responsible for driving the communication between NCS and the device. This NedWorker instance should be used when communicating with the NCS, ie for sending responses, errors, and trace messages. It is also implements the NedTracer API and can be used in, for example, the SSHSession as a tracer.
      th - is a transaction id that can be used with the Maapi library for accessing a transaction.
      paths - are paths to filter the various parts of the configuration tree that are relevant to write into the transaction.
      Throws:
      Exception
    • showOffline

      public void showOffline(NedWorker w, int th, String data) throws Exception
      Read parts of the configuration and applies it to the transaction, both provided in the method invocation. It may choose to write more into the transaction than is actually requested. The response is sent by invoking the method showGenericResponse() in in the NedWorker w.
      Parameters:
      w - The NedWorker instance currently responsible for driving the communication between NCS and the device. This NedWorker instance should be used when communicating with the NCS, ie for sending responses, errors, and trace messages. It is also implements the NedTracer API and can be used in, for example, the SSHSession as a tracer.
      th - is a transaction id that can be used with the Maapi library for accessing a transaction.
      data - are the configuration in native format.
      Throws:
      Exception
    • isConnection

      public abstract boolean isConnection(String deviceId, InetAddress ip, int port, String luser, boolean trace, int connectTimeout, int readTimeout, int writeTimeout)
      Used by the connection pool to find a matching connection. If the current connection is has the same parameters it should return true, otherwise false.
      Parameters:
      deviceId - name of device
      ip - address to connect to device
      port - port to connect to
      luser - name of user to connect as
      trace - indicates if raw trace messages should be generated or not
      connectTimeout - in milliseconds
      readTimeout - in milliseconds
      writeTimeout - in milliseconds
    • newConnection

      public abstract NedGenericBase newConnection(String deviceId, InetAddress ip, int port, String luser, boolean trace, int connectTimeout, int readTimeout, int writeTimeout, NedMux mux, NedWorker worker)
      Establish a new connection to a device and send response to NCS with information about the device using the method setConnectionData() A new instance representing the new connection should be returned. The returned instance will be used for further communication with the device. Different worker instances may be used for the communication and the instance cannot assume the worker used in this invocation will be the same used in the future invocations of the prepare(), abort(), revert(), persist(), show(), etc methods.
      Parameters:
      deviceId - name of device
      ip - address to connect to device
      port - port to connect to
      luser - name of user to connect as
      trace - indicates if raw trace messages should be generated or not
      connectTimeout - in milliseconds
      readTimeout - in milliseconds
      writeTimeout - in milliseconds
      mux -
      worker - The NedWorker instance currently responsible for driving the communication between NCS and the device. This NedWorker instance should be used when communicating with the NCS, ie for sending responses, errors, and trace messages. It is also implements the NedTracer API and can be used in, for example, the SSHSession as a tracer.
      Returns:
      the connection instance
    • initNoConnect

      public NedGenericBase initNoConnect(String deviceId, NedMux mux, NedWorker w) throws NedWorker.NotEnoughDataException
      Make a new instance of Ned object without establishing a connection towards the device. The NED should use previously stored information about the device to initialize its state if needed or throw NedWorker.NotEnoughDataException. It should then send the information about the device using the setConnectionData() method. A new instance representing the new connection should be returned. That instance can only be used for invoking prepareDry() callback and not for actual communication with the device. close() callback will be invoked before destroying the NED instance, so the implementation of the close() callback should handle cleanup both for instances created with newConnection() and instanced created with initNoConnect()
      Parameters:
      deviceId - name of device
      mux -
      w - The NedWorker instance currently responsible for driving the communication between NCS and the device. This NedWorker instance should be used when communicating with the NCS, ie for sending responses, errors, and trace messages.
      Returns:
      the NED instance
      Throws:
      NedWorker.NotEnoughDataException