Package com.tailf.ned
Class NedCliBaseTemplate
Object
com.tailf.ned.NedConnectionBase
com.tailf.ned.NedCliBase
com.tailf.ned.NedCliBaseTemplate
This class implements NED CLI template
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionintstatic final org.apache.logging.log4j.LoggerDeprecated.intintbooleanint -
Constructor Summary
ConstructorsConstructorDescriptionNedCliBaseTemplate(String deviceId, InetAddress ip, int port, String proto, String ruser, String pass, String secpass, boolean trace, int connectTimeout, int readTimeout, int writeTimeout, NedMux mux, NedWorker worker) -
Method Summary
Modifier and TypeMethodDescriptionvoidIs invoked by NCS to abort the configuration to the state before the previous prepare() invocation.voidapplyConfig(NedWorker worker, int cmd, String data) voidclose()This method is invoked when a connection close is forced and no NedWorker is involved.voidThis method is invoked when the connection is terminated.voidcommand(NedWorker worker, String cmdname, ConfXMLParam[] p) This is for any optional commands on the device that are not part of the yang files config data, but is modeled as tailf:actions or rpcs in the device yang files.voidThis indicates that the current set of operations should be committed to the running configuration.The device id is originally provided by NCS to properly identify the device.voidgetTransId(NedWorker worker) When this method is invoked the NED should produce a transaction id that must be changed if any changes has been made to the configuration since the last time the transaction id was requested.voididentity()This should return the a unique (among registered NedConnection classes) identity.booleanThis method is invoked to check if a connection is still alive.booleanisConnection(String deviceId, InetAddress ip, int port, String proto, String ruser, String pass, String secpass, String keydir, boolean trace, int connectTimeout, int readTimeout, int writeTimeout) Used by the connection pool to find a matching connection.String[]modules()Which YANG modules are covered by the class instance.newConnection(String deviceId, InetAddress ip, int port, String proto, String ruser, String pass, String secpass, String publicKeyDir, 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.voidThis method is invoked when the currently committed change set should be made permanent.voidIs invoked by NCS to take the configuration to a new state.voidprepareDry(NedWorker worker, String data) Is invoked by NCS to tell the NED what actions it should take towards the device if it should do a prepare.voidUsed for resuming a connection found in the connection pool.voidIs invoked by NCS to undo the changes introduced in the last commit operation (communicated to the NED in the prepare method invocation).voidvoidsetupTelnet(NedWorker worker) voidExtract parts of the configuration and send it to NCS.string_dequote(String aText) Deprecated.string_quote(String aText) Deprecated.Usequote(String)instead.toString()voidtype()The type is one of "cli" and "generic".Methods inherited from class com.tailf.ned.NedCliBase
initNoConnect, showOffline, showPartial, showPartialMethods inherited from class com.tailf.ned.NedConnectionBase
connection_id, createSubscription, getCapas, getConnectionId, getPlatformData, getStatsCapas, getSystemStateData, getTimeInPool, getTransactionIdMode, getUseStoredCapas, getWantRevertDiff, initialize, keepAlive, setCapabilities, setConnectionData, setPlatformData, showStatsFilter, showStatsFilter, showStatsFilter, showStatsPath, uninitialize, useStoredCapabilities
-
Field Details
-
LOGGER
Deprecated. -
device_id
-
connection
-
session
-
ip
-
port
public int port -
proto
-
ruser
-
pass
-
secpass
-
trace
public boolean trace -
tracer
-
connectTimeout
public int connectTimeout -
readTimeout
public int readTimeout -
writeTimeout
public int writeTimeout -
mux
-
-
Constructor Details
-
NedCliBaseTemplate
public NedCliBaseTemplate() -
NedCliBaseTemplate
-
-
Method Details
-
setupSSH
- Throws:
Exception
-
setupTelnet
- Throws:
Exception
-
trace
-
handshake
- Throws:
Exception
-
reconnect
Description copied from class:NedConnectionBaseUsed for resuming a connection found in the connection pool.- Specified by:
reconnectin classNedConnectionBase- Parameters:
worker- The NedWorker instance currently responsible for driving the communication between NCS and the device. This NedWorker instance should be used when communicating with NCS, i.e, 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.
-
device_id
Description copied from class:NedConnectionBaseThe device id is originally provided by NCS to properly identify the device. It is the name used for the device by NCS in the list of devices.- Specified by:
device_idin classNedConnectionBase
-
type
Description copied from class:NedConnectionBaseThe type is one of "cli" and "generic". This information is sent to NCS when the NedMux is started to let NCS know how to communicate with each device.- Specified by:
typein classNedConnectionBase
-
modules
Description copied from class:NedConnectionBaseWhich YANG modules are covered by the class instance. This information is defined by the setConnectionData() call and is sent to NCS after initiating a new connection, or when re-establishing a connection. The modules() method is not actually used.- Specified by:
modulesin classNedConnectionBase
-
identity
Description copied from class:NedConnectionBaseThis should return the a unique (among registered NedConnection classes) identity. It will be used by NCS when creating new connections to control which of the registered NedConnection classes to use.- Overrides:
identityin classNedConnectionBase
-
applyConfig
public void applyConfig(NedWorker worker, int cmd, String data) throws NedException, IOException, SSHSessionException, NedCliBaseTemplate.ApplyException -
prepare
Description copied from class:NedCliBaseIs 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 (typically the case on IOS like boxes). If the configuration changes are later aborted, or reverted, the NCS will provide the necessary commands for restoring the configuration to its previous state. The device should invoke the w.prepareResponse() 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)- Specified by:
preparein classNedCliBase- Parameters:
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.data- is the CLI commands for transforming the configuration to a new state. The commands are generated using the YANG data model in combination with the tailf: extensions to guide the mapping.- Throws:
Exception
-
prepareDry
Description copied from class:NedCliBaseIs invoked by NCS to tell the NED what actions it should take towards the device if it should do a prepare. The NED should invoke the methodprepareDryResponse()when the operation is completed. If no changes needs to be done just answerprepareDryResponse(data)If an error is detected answer this through a call toerror()inNedWorker w.- Specified by:
prepareDryin classNedCliBase- Parameters:
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 theNedTracerAPI and can be used in, for example, theSSHSessionas a tracer.data- is the CLI commands for transforming the configuration to a new state. The commands are generated using the YANG data model in combination with the tailf: extensions to guide the mapping.- Throws:
Exception
-
abort
Description copied from class:NedCliBaseIs invoked by NCS to abort the configuration to the state before the previous prepare() invocation. The NCS has calculated the commands needed to reach that state from the current state. The instance may choose to use there commands, or use some other mechanism to reach the same state. When the operation is completed it should invoke the w.abortResponse() method in the NedWorker.- Specified by:
abortin classNedCliBase- Parameters:
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.data- is the commands for taking the config back to the previous state. The commands are generated using the YANG data model in combination with the tailf: extensions to guide the mapping.- Throws:
Exception
-
revert
Description copied from class:NedCliBaseIs 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 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 w.revertResponse() method should be called.- Specified by:
revertin classNedCliBase- Parameters:
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.data- is the commands for taking the config back to the previous state.- Throws:
Exception
-
commit
Description copied from class:NedConnectionBaseThis indicates that the current set of operations should be committed to the running configuration. When completed the w.commitResponse() method should be invoked. Devices that does not support commit() should invoke the w.commitResponse() method without delay. On error invoke the w.error(NedCmd.COMMIT, Error, Reason) method.- Specified by:
commitin classNedConnectionBase- Parameters:
worker- The NedWorker instance currently responsible for driving the communication between NCS and the device. This NedWorker instance should be used when communicating with NCS, i.e, 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.timeout- If the commit operation does not complete within 'timeout' seconds the operation should be aborted.- Throws:
Exception
-
persist
Description copied from class:NedConnectionBaseThis method is invoked when the currently committed change set should be made permanent. This corresponds to copying the running configuration to the startup configuration, on a running/startup device, or issuing the confirming commit operation on a device that supports that. When completed the w.persistResponse() should be invoked. On error invoke the w.error(NedCmd.PERSIST,Error, Reason) method.- Specified by:
persistin classNedConnectionBase- Parameters:
worker- The NedWorker instance currently responsible for driving the communication between NCS and the device. This NedWorker instance should be used when communicating with NCS, i.e, 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.- Throws:
Exception
-
close
Description copied from class:NedConnectionBaseThis method is invoked when the connection is terminated. It is not invoked when placing the connection in the connection pool. No response is required, but trace messages may be generated during the close down.- Specified by:
closein classNedConnectionBase- Parameters:
worker- The NedWorker instance currently responsible for driving the communication between NCS and the device. This NedWorker instance should be used when communicating with NCS, i.e, 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.- Throws:
NedExceptionIOException
-
close
public void close()Description copied from class:NedConnectionBaseThis method is invoked when a connection close is forced and no NedWorker is involved. This typically occurs when a connection is removed from the connection pool. No response or trace messages can be sent during the operation.- Specified by:
closein classNedConnectionBase
-
isAlive
Description copied from class:NedConnectionBaseThis method is invoked to check if a connection is still alive. When a connection is stored in the connection pool it will periodically be polled to see if it is alive. If false is returned the connection will be closed using the close() method invocation.- Overrides:
isAlivein classNedConnectionBase- Parameters:
worker- The NedWorker instance currently responsible for driving the communication between NCS and the device. This NedWorker instance should be used when communicating with NCS, i.e, 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.
-
getTransId
Description copied from class:NedConnectionBaseWhen this method is invoked the NED should produce a transaction id that must be changed if any changes has been made to the configuration since the last time the transaction id was requested. The transaction id can either be requested from the system, or calculated by the callback, for example by calculating an MD5 checksum of the configuration text. The method should indicate its return status by invoking the method w.error() or w.getTransIdResponse() The method should be implemented if the NED claimed a NedWorker.TransactionIdMode which is not NONE in setConnectionData().- Specified by:
getTransIdin classNedConnectionBase- Parameters:
worker- The NedWorker instance currently responsible for driving the communication between NCS and the device. This NedWorker instance should be used when communicating with NCS, i.e, 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.- Throws:
Exception
-
show
Description copied from class:NedCliBaseExtract parts of the configuration and send it to NCS. The response is sent by invoking the w.showCliResponse() method in the provided NedWorker.- Specified by:
showin classNedCliBase- Parameters:
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.toptag- is the top level tag indicating which part of the config should be extracted.- Throws:
Exception
-
isConnection
public boolean isConnection(String deviceId, InetAddress ip, int port, String proto, String ruser, String pass, String secpass, String keydir, boolean trace, int connectTimeout, int readTimeout, int writeTimeout) Description copied from class:NedCliBaseUsed by the connection pool to find a matching connection. If the current connection is has the same parameters it should return true, otherwise false.- Specified by:
isConnectionin classNedCliBase- Parameters:
deviceId- name of deviceip- address to connect to deviceport- port to connect toproto- ssh or telnetruser- name of user to connect aspass- password to use when connectingsecpass- secondary password to use when entering config mode, set to empty string if not configured in the authgrouptrace- indicates if raw trace messages should be generated or notconnectTimeout- in millisecondsreadTimeout- in millisecondswriteTimeout- in milliseconds
-
command
Description copied from class:NedConnectionBaseThis is for any optional commands on the device that are not part of the yang files config data, but is modeled as tailf:actions or rpcs in the device yang files.- Specified by:
commandin classNedConnectionBase- Parameters:
worker- The NedWorker instance currently responsible for driving the communication between NCS and the device. This NedWorker instance should be used when communicating with NCS, i.e, 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.cmdname- Name of the command (path to action?)- Throws:
Exception
-
newConnection
public NedCliBase newConnection(String deviceId, InetAddress ip, int port, String proto, String ruser, String pass, String secpass, String publicKeyDir, boolean trace, int connectTimeout, int readTimeout, int writeTimeout, NedMux mux, NedWorker worker) Description copied from class:NedCliBaseEstablish a new connection to a device and send response to NCS with information about the device. This information is set by using the setConnectionData() method. A new instance representing the new connection should be returned. That instance will then be used for further communication with the device. Different worker instances may be used for that communication and the instance cannot assume that the worker used in this invocation will be the same used for the invocations of the prepare, abort, revert, persist, show, etc methods.- Specified by:
newConnectionin classNedCliBase- Parameters:
deviceId- name of deviceip- address to connect to deviceport- port to connect toproto- ssh or telnetruser- name of user to connect aspass- password to use when connectingsecpass- secondary password to use when entering config mode, set to empty string if not configured in the authgrouppublicKeyDir- directory to read public keys. null if password is giventrace- indicates if raw trace messages should be generated or notconnectTimeout- in millisecondsreadTimeout- in millisecondswriteTimeout- in millisecondsworker- 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
-
toString
-
string_quote
Deprecated.Usequote(String)instead. -
quote
-
string_dequote
Deprecated.Useunquote(String)instead. -
unquote
-
unquote(String)instead.