Package com.tailf.ned
Class NedWorker
The NedWorker is used by the NedMux for running a worker thread
for executing NedConnection tasks.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic enumIndicates the mode of Transaction ID supported by the NED.Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThis method is called by the NED to indicate that the abort method has been successfully completed.voidThis method is called by the NED to indicate that the command method has been successfully completed.voidcommandResponse(ConfXMLParam[] reply) This method is called by the NED to indicate that the command method has been successfully completed when the NED also has a reply.voidThis method should be invoked by a NedConnection instance when it has completed a commit operation to indicate a successful completion of the commit.voidconnectError(NedErrorCode code) voidconnectError(NedErrorCode code, String info) This method should be invoked if the NED fails to perform the connect() operation.voidThis method is invoked by a NedConnection instance when it has completed to create a notification subsription.voiderror(int op, NedErrorCode errCode, String reason) This function should be called when a callback like abort,persist, etc cannot be completed.voidThis function should be called when a callback like abort,persist, etc cannot be completed.voidThis error report function is kept for backward compatible reasons and should if possible be avoided.This method returns the commit comment.This method returns the current path associated with the action being processed.Get the phase of the device.intThis method returns an integer that represents the transaction we are going from.This method returns the ssh public key directory as defined in the auth map.getLabel()This method returns the commit label.intThis method returns the load operation that should be used when populating the transaction in any of the show methods.getNedId()This method returns the ned-id for the ned associated with this worker.This method returns the backend password as defined in the auth map.This method returns the backend user name as defined in the auth map.This method returns the backend secondary password as defined in the auth map.This method returns the source IP address if such an address is configured in the ncs configuration.intThis method returns an integer that represents the transaction we are going to, i.e the proposed new system state.voidThis method is called by the NED to send a response to the getTransId request.intgetUsid()This method returns an integer that represents the user session that initiated this NedWorker.voidThis method is called by the NED to send a response to the initialize request.voidisAliveResponse(boolean alive) booleanThe initialize call can request the trans_id response to be suppressed.booleanThis method helps the NED determine whether an action has been invoked with the verbose parameter.voidSend log messages to NCS.voidnotification(String data) Send notification to NCS once subsciption has been created.voidThis method is called by the NED to indicate that the persist method has been successfully completed.voidprepareDryResponse(String output) This method should be invoked by a NedConnection instance when it has completed a prepare dry operation to indicate a successful completion of and the result of the dry run.voidThis method should be invoked by a NedConnection instance when a prepare dry operation is invoked and the NED is not able to support such an operation.voidThis method should be invoked by a NedConnection instance when it has completed a prepare operation to indicate a successful completion of the prepare.voidThis method should be invoked by a NedConnection instance when it has completed a revert operation to indicate a successful completion of the revert.voidrun()voidsetAdditionalInfo(String info) Set information to be passed back to the caller, typically parse information if the user invokes a show action with the verbose parameter.voidThis method allows the NED to set transaction ID provisionally fromNedCliBase.show(NedWorker, String)orNedGenericBase.show(NedWorker, int)NED callback.voidsetTimeout(int ms) When the NED worker gets invoked, it gets passed three timeout values, connect/read/write timeouts.voidshowCliResponse(String config) This method is invoked by a NedCli instance in response to a show method invocation.voidvoidThis method is invoked by a NedGeneric when it has completed populating the transaction with the requested configuration sub-tree.voidThis method is invoked during the showStatsFilter() request to indicate that the NED has successfully populated the requested transaction.voidshowStatsPathResponse(NedTTL[] ttls) This method is invoked during the showStatsPath() request to indicate that the NED has successfully populated the requested subtree.voidSend trace message to the NCS.voidThis method should be invoked by a NedConnection instance when it has completed a uninitialize operation to indicate a successful uninitializationMethods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Constructor Details
-
NedWorker
Deprecated. -
NedWorker
-
-
Method Details
-
log
Send log messages to NCS. The log messages will end up at... FIXME- Parameters:
msg-- Throws:
Exception
-
trace
Send trace message to the NCS. The message will end up at... FIXME -
setTimeout
public void setTimeout(int ms) When the NED worker gets invoked, it gets passed three timeout values, connect/read/write timeouts. The NED code shall try to honor these timeouts. However, if the NED code fails to do that, the NCS itself has a timeout. The timeouts are config parameters under /devices/device/connect-timeout, /devices/device/read-timeout, and /devices/device/write-timeout. NCS will add 3 seconds to that timeout, and if the NED doesn't honor the timeouts, NCS will internally timeout the request. This method can be used to increase the timeout. I.e a NED that knows it is doing useful work, can prolong the configured timeouts.- Parameters:
ms- the number of milliseconds to set the new timeout to.
-
setAdditionalInfo
Set information to be passed back to the caller, typically parse information if the user invokes a show action with the verbose parameter.- Parameters:
info-
-
getDevicePhase
Get the phase of the device. -
run
public void run() -
commitResponse
This method should be invoked by a NedConnection instance when it has completed a commit operation to indicate a successful completion of the commit.- Throws:
IOExceptionNedException
-
prepareResponse
This method should be invoked by a NedConnection instance when it has completed a prepare operation to indicate a successful completion of the prepare.- Throws:
IOExceptionNedException
-
prepareDryResponse
This method should be invoked by a NedConnection instance when it has completed a prepare dry operation to indicate a successful completion of and the result of the dry run.- Throws:
IOExceptionNedException
-
prepareDryUnsupportedResponse
This method should be invoked by a NedConnection instance when a prepare dry operation is invoked and the NED is not able to support such an operation.- Throws:
IOExceptionNedException
-
revertResponse
This method should be invoked by a NedConnection instance when it has completed a revert operation to indicate a successful completion of the revert.- Throws:
IOExceptionNedException
-
showCliResponse
This method is invoked by a NedCli instance in response to a show method invocation. The config string should consist the relevant parts of the output from issuing the equivalent of 'show running-config' in a Cisco like CLI. The output must correspond to the data model provided in the capabilities sent as a response to the (re)connect request.- Parameters:
config-- Throws:
IOExceptionNedException
-
showCliResponse
- Throws:
IOExceptionNedException
-
showGenericResponse
This method is invoked by a NedGeneric when it has completed populating the transaction with the requested configuration sub-tree. It indicates that the operation was successful.- Throws:
IOExceptionNedException
-
showStatsPathResponse
This method is invoked during the showStatsPath() request to indicate that the NED has successfully populated the requested subtree.- Parameters:
ttls- an array of ttls for different paths. The NED may optionally provide different cache timeouts for different paths.- Throws:
IOExceptionNedException
-
showStatsFilterResponse
This method is invoked during the showStatsFilter() request to indicate that the NED has successfully populated the requested transaction.- Throws:
IOExceptionNedException
-
abortResponse
This method is called by the NED to indicate that the abort method has been successfully completed. If the NED is unable to complete the abort the error method should be invoked instead.- Throws:
IOExceptionNedException
-
persistResponse
This method is called by the NED to indicate that the persist method has been successfully completed. If the NED is unable to complete the persist the error method should be invoked instead.- Throws:
IOExceptionNedException
-
commandResponse
This method is called by the NED to indicate that the command method has been successfully completed. If the NED is unable to complete the command the error method should be invoked instead.- Throws:
IOExceptionNedException
-
commandResponse
This method is called by the NED to indicate that the command method has been successfully completed when the NED also has a reply. If the NED is unable to complete the command the error method should be invoked instead.- Parameters:
reply- is the return value from executing the command- Throws:
IOExceptionNedException
-
getCurrentPath
This method returns the current path associated with the action being processed. This method only returns valid data when called during an action invokation.- Returns:
- a ConfPath to the node which contains the action.
-
getFromTransactionId
public int getFromTransactionId()This method returns an integer that represents the transaction we are going from. In the normal case this is normally just 'running', but not always. It's possible to use Maapi.attach() on this transaction Id.Maapi.attach(int,int,int)Some complicated NEDs may require to read data from the system the way it looked like before the current transaction arrived.- Returns:
- a transaction integer.
-
getToTransactionId
public int getToTransactionId()This method returns an integer that represents the transaction we are going to, i.e the proposed new system state. It's possible to use Maapi.attach() on this transaction Id.Maapi.attach(int,int,int)Some complicated NEDs may require to read data from the system the way it is going to look like once the current transaction is committed.- Returns:
- a transaction integer.
-
getUsid
public int getUsid()This method returns an integer that represents the user session that initiated this NedWorker. If we wish to do Maapi.attach() to any of the from/to transactions we need the user session id- Returns:
- a user session id
-
getNedId
This method returns the ned-id for the ned associated with this worker.- Returns:
- the ned-id of the ned associated with this worker
-
getRemoteUser
This method returns the backend user name as defined in the auth map.- Returns:
- name of user to connect to backend as
-
getPassword
This method returns the backend password as defined in the auth map.- Returns:
- password to connect to backend with
-
getSecondaryPassword
This method returns the backend secondary password as defined in the auth map.- Returns:
- secondary password to connect to backend with
-
getKeyDir
This method returns the ssh public key directory as defined in the auth map.- Returns:
- null or a directory containing ssh public keys
-
getLoadOp
public int getLoadOp()This method returns the load operation that should be used when populating the transaction in any of the show methods. -
getLabel
This method returns the commit label.- Returns:
- null or the commit label
-
getComment
This method returns the commit comment.- Returns:
- null or a comment describing the commit
-
getTransIdResponse
This method is called by the NED to send a response to the getTransId request. If the NED is unable to complete the command the error method should be invoked instead.- Parameters:
id- is a string representing a transaction id- Throws:
IOExceptionNedException
-
isAliveResponse
- Throws:
IOExceptionNedException
-
getSourceAddress
This method returns the source IP address if such an address is configured in the ncs configuration. If not configured this method returns null.- Returns:
- the source IP address or null if not configured
-
initializeResponse
This method is called by the NED to send a response to the initialize request. If the NED is unable to complete the command the error method should be invoked instead.- Parameters:
id- is a string representing a transaction id- Throws:
IOExceptionNedException
-
uninitializeResponse
This method should be invoked by a NedConnection instance when it has completed a uninitialize operation to indicate a successful uninitialization- Throws:
IOExceptionNedException
-
createSubscriptionResponse
This method is invoked by a NedConnection instance when it has completed to create a notification subsription. If the NED is unable to create the subscription the error method should be invoked instead.- Throws:
IOExceptionNedException
-
notification
Send notification to NCS once subsciption has been created.- Parameters:
data-
-
isSuppressTransId
public boolean isSuppressTransId()The initialize call can request the trans_id response to be suppressed. This method must be called to check if that is the case. -
isVerbose
public boolean isVerbose()This method helps the NED determine whether an action has been invoked with the verbose parameter. If an action has been invoked with the verbose parameter, then the NED may choose to report additional information usingsetAdditionalInfo(String). -
setProvisionalTransId
This method allows the NED to set transaction ID provisionally fromNedCliBase.show(NedWorker, String)orNedGenericBase.show(NedWorker, int)NED callback. If NSO needs to fetch the transaction ID immediately after the show() callback, it will first check whether the show() callback has indicated any provisional transaction ID and in such case use this value. If no provisional transaction ID has been supplied, then NSO will call getTransId() as needed. If a CLI NED has multiple top tags, then show() callback may be called multiple times as a part of single operation. In such case the NSO will only use the provisional transaction ID if show() has been called on all top tags as a part of such logical operation, and the last provisional transaction ID set by the NED will be used. -
currentCommand
-
error
This function should be called when a callback like abort,persist, etc cannot be completed.- Parameters:
op- is the command originally issued from NCS, ie a NedCmd.getCommand() integer like NedCmd.CONNECT_CLI, NedCmd.CONNECT_GENERIC, NedCmd.PREPARE_CLI, ...reason- is the reason for the error
-
error
This error report function is kept for backward compatible reasons and should if possible be avoided. The "error" string parameter is expected to be the string representation of on of the NedErrorCode values. If this is not the case this function will fallback to NED_EXTERNAL_ERROR code and concatenate the original error string together with the reason.- Parameters:
op- is the command originally issued from NCS, ie a NedCmd.getCommand() integer like NedCmd.CONNECT_CLI, NedCmd.CONNECT_GENERIC, NedCmd.PREPARE_CLI, ...error- string representation of a NedErrorCodereason- textual description of the reason for the error
-
error
This function should be called when a callback like abort,persist, etc cannot be completed.- Parameters:
op- is the command originally issued from NCS, ie a NedCmd.getCommand() integer like NedCmd.CONNECT_CLI, NedCmd.CONNECT_GENERIC, NedCmd.PREPARE_CLI, ...errCode- NedErrorCode for the errorreason- textual description of the reason for the error
-
connectError
- Throws:
NedException
-
connectError
This method should be invoked if the NED fails to perform the connect() operation.- Parameters:
code- is the reason for the connect to fail. SeeNedErrorCode.CONNECT_CONNECTION_REFUSED,NedErrorCode.CONNECT_TIMEOUT, etc.info- is a string describing the connect error. Normally this parameter is not needed. If it is given, it will be appended to the error message all the way to the northbound agent invoking the NED connect call- Throws:
NedException
-