Package com.tailf.ned
Class NedGenericBase
Object
com.tailf.ned.NedConnectionBase
com.tailf.ned.NedGenericBase
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
Is invoked by NCS to abort the current transaction and bring the configuration back to the state before the previousprepare()
invocation.initNoConnect
(String deviceId, NedMux mux, NedWorker w) Make a new instance of Ned object without establishing a connection towards the device.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.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.abstract void
Is invoked by NCS to take the configuration to a new state.void
prepareDry
(NedWorker w, NedEditOp[] ops) Is invoked by NCS to ask the NED what actions it would take towards the device if it would do a prepare.abstract void
Is invoked by NCS to undo the changes introduced in the last commit operation (communicated to the NED in the prepare method invocation).abstract void
Read parts of the configuration and applies it to the transaction provided in the method invocation.void
showOffline
(NedWorker w, int th, String data) Read parts of the configuration and applies it to the transaction, both provided in the method invocation.void
showPartial
(NedWorker w, int th, ConfPath[] paths) Read parts of the configuration and applies it to the transaction provided in the method invocation.Methods inherited from class com.tailf.ned.NedConnectionBase
close, close, command, commit, connection_id, createSubscription, device_id, getCapas, getConnectionId, getStatsCapas, getSystemStateData, getTimeInPool, getTransactionIdMode, getTransId, getUseStoredCapas, getWantRevertDiff, identity, initialize, isAlive, isAlive, keepAlive, modules, persist, reconnect, setCapabilities, setConnectionData, setPlatformData, showStatsFilter, showStatsFilter, showStatsFilter, showStatsPath, type, uninitialize, useStoredCapabilities
-
Constructor Details
-
NedGenericBase
public NedGenericBase()
-
-
Method Details
-
prepare
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 methodprepareResponse()
inNedWorker 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 theNedTracer
API and can be used in, for example, theSSHSession
as a tracer.ops
- Edit operations representing the changes to the configuration.- Throws:
Exception
-
prepareDry
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 toprepareDryResponse()
The Ned should invoke the methodprepareDryResponse()
inNedWorker w
when the operation is completed. If the functionality is not supported this method need not be implemented. Alternatively the NED can respond with aNedWorker.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 theNedTracer
API and can be used in, for example, theSSHSession
as a tracer.ops
- Edit operations representing the changes to the configuration.- Throws:
Exception
-
abort
Is invoked by NCS to abort the current transaction and bring the configuration back to the state before the previousprepare()
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 methodabortResponse()
in inNedWorker 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 theNedTracer
API and can be used in, for example, theSSHSession
as a tracer.ops
- is the edit operations needed for taking the config back to the previous state.- Throws:
Exception
-
revert
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 betweenabort()
and revert() is that revert() is invoked aftercommit()
(but before persist), whereas abort() is invoked before the commit(). Once the configuration has been made persistent bypersist()
it can no longer be restored to any previous (potentially saved) state. When the revert operation has been completed the methodrevertResponse
inNedWorker 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 theNedTracer
API and can be used in, for example, theSSHSession
as a tracer.ops
- is the edit operations for taking the config back to the previous state.- Throws:
Exception
-
show
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 methodshowGenericResponse()
in in theNedWorker 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 theNedTracer
API and can be used in, for example, theSSHSession
as a tracer.th
- is a transaction id that can be used with the Maapi library for accessing a transaction.- Throws:
Exception
-
showPartial
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 methodshowGenericResponse()
in in theNedWorker 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 theNedTracer
API and can be used in, for example, theSSHSession
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
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 methodshowGenericResponse()
in in theNedWorker 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 theNedTracer
API and can be used in, for example, theSSHSession
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 deviceip
- address to connect to deviceport
- port to connect toluser
- name of user to connect astrace
- indicates if raw trace messages should be generated or notconnectTimeout
- in millisecondsreadTimeout
- in millisecondswriteTimeout
- 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 deviceip
- address to connect to deviceport
- port to connect toluser
- name of user to connect astrace
- indicates if raw trace messages should be generated or notconnectTimeout
- in millisecondsreadTimeout
- in millisecondswriteTimeout
- in millisecondsmux
-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 theNedTracer
API and can be used in, for example, theSSHSession
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 devicemux
-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
-