Package org.onosproject.netconf
Class AbstractNetconfSession
- java.lang.Object
-
- org.onosproject.netconf.AbstractNetconfSession
-
- All Implemented Interfaces:
NetconfSession
- Direct Known Subclasses:
NetconfSessionAdapter
public abstract class AbstractNetconfSession extends java.lang.Object implements NetconfSession
Abstract netconf session implements methods common for different implementations of netconf session.
-
-
Constructor Summary
Constructors Constructor Description AbstractNetconfSession()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddDeviceOutputListener(NetconfDeviceOutputEventListener listener)Add a listener to the underlying stream handler implementation.java.util.concurrent.CompletableFuture<java.lang.CharSequence>asyncGet()Retrieves running configuration and device state.java.util.concurrent.CompletableFuture<java.lang.CharSequence>asyncGetConfig(DatastoreId datastore)Retrieves the specified configuration.protected booleancheckReply(java.lang.String reply)Checks errors in reply from the session.booleanclose()Closes the Netconf session with the device.booleancommit()Commits the candidate configuration the running configuration.booleancopyConfig(java.lang.String netconfTargetConfig, java.lang.String newConfiguration)Copies the new configuration, an Url or a complete configuration xml tree to the target configuration.booleancopyConfig(DatastoreId netconfTargetConfig, java.lang.String newConfiguration)Copies the new configuration, an Url or a complete configuration xml tree to the target configuration.booleancopyConfig(DatastoreId destination, DatastoreId source)Copies the configuration between configuration datastores.booleandeleteConfig(DatastoreId netconfTargetConfig)Deletes part of the specified configuration based on the filterSchema.java.lang.StringdoWrappedRpc(java.lang.String request)Executes an synchronous RPC to the server and wrap the request in RPC header.booleaneditConfig(java.lang.String newConfiguration)Retrieves part of the specified configuration based on the filterSchema.booleaneditConfig(DatastoreId netconfTargetConfig, java.lang.String mode, java.lang.String newConfiguration)Retrieves part of the specified configuration based on the filterSchema.abstract voidendSubscription()Ends subscription to the device's notifications.protected java.util.concurrent.CompletableFuture<java.lang.CharSequence>executeRpc(java.lang.String rpcString)java.lang.Stringget(java.lang.String request)Retrieves the requested configuration, different from get-config.java.lang.Stringget(java.lang.String filterSchema, java.lang.String withDefaultsMode)Retrieves the requested data.java.lang.StringgetConfig(DatastoreId netconfTargetConfig)Retrieves the specified configuration.java.lang.StringgetConfig(DatastoreId netconfTargetConfig, java.lang.String configurationFilterSchema)Retrieves part of the specified configuration based on the filterSchema.abstract java.util.Set<java.lang.String>getDeviceCapabilitiesSet()Gets the capabilities of the remote Netconf device associated to this session.abstract java.lang.StringgetSessionId()Gets the session ID of the Netconf session.booleanlock(DatastoreId datastore)Locks the specified configuration.voidremoveDeviceOutputListener(NetconfDeviceOutputEventListener listener)Remove a listener from the underlying stream handler implementation.abstract java.util.concurrent.CompletableFuture<java.lang.String>request(java.lang.String request)Executes an asynchronous RPC to the server and obtains a future to be completed.abstract java.lang.StringrequestSync(java.lang.String request)Executes an synchronous RPC to the server.abstract java.util.concurrent.CompletableFuture<java.lang.String>rpc(java.lang.String request)Executes an asynchronous RPC request to the server and obtains a future for it's response.voidstartSubscription()Starts subscription to the device's notifications.abstract voidstartSubscription(java.lang.String filterSchema)Starts subscription to the device's notifications.booleanunlock(DatastoreId datastore)Unlocks the specified configuration.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.onosproject.netconf.NetconfSession
checkAndReestablish, lock, requestSync, setOnosCapabilities, timeoutConnectSec, timeoutIdleSec, timeoutReplySec, unlock
-
-
-
-
Method Detail
-
request
public abstract java.util.concurrent.CompletableFuture<java.lang.String> request(java.lang.String request) throws NetconfExceptionDescription copied from interface:NetconfSessionExecutes an asynchronous RPC to the server and obtains a future to be completed. The caller must ensure that the message-id in any request is unique for the session- Specified by:
requestin interfaceNetconfSession- Parameters:
request- the XML containing the RPC for the server.- Returns:
- Server response or ERROR
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
rpc
public abstract java.util.concurrent.CompletableFuture<java.lang.String> rpc(java.lang.String request) throws NetconfExceptionDescription copied from interface:NetconfSessionExecutes an asynchronous RPC request to the server and obtains a future for it's response.- Specified by:
rpcin interfaceNetconfSession- Parameters:
request- the XML containing the RPC request for the server.- Returns:
- Server response or ERROR
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
executeRpc
protected java.util.concurrent.CompletableFuture<java.lang.CharSequence> executeRpc(java.lang.String rpcString) throws NetconfException- Throws:
NetconfException
-
asyncGetConfig
public java.util.concurrent.CompletableFuture<java.lang.CharSequence> asyncGetConfig(DatastoreId datastore) throws NetconfException
Description copied from interface:NetconfSessionRetrieves the specified configuration.- Specified by:
asyncGetConfigin interfaceNetconfSession- Parameters:
datastore- to retrieve configuration from- Returns:
- specified configuration
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
asyncGet
public java.util.concurrent.CompletableFuture<java.lang.CharSequence> asyncGet() throws NetconfExceptionDescription copied from interface:NetconfSessionRetrieves running configuration and device state.- Specified by:
asyncGetin interfaceNetconfSession- Returns:
- running configuration and device state
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
get
public java.lang.String get(java.lang.String request) throws NetconfExceptionDescription copied from interface:NetconfSessionRetrieves the requested configuration, different from get-config.- Specified by:
getin interfaceNetconfSession- Parameters:
request- the XML containing the request to the server.- Returns:
- device running configuration
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
get
public java.lang.String get(java.lang.String filterSchema, java.lang.String withDefaultsMode) throws NetconfExceptionDescription copied from interface:NetconfSessionRetrieves the requested data.- Specified by:
getin interfaceNetconfSession- Parameters:
filterSchema- XML subtrees to include in the replywithDefaultsMode- with-defaults mode- Returns:
- Server response
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
doWrappedRpc
public java.lang.String doWrappedRpc(java.lang.String request) throws NetconfExceptionDescription copied from interface:NetconfSessionExecutes an synchronous RPC to the server and wrap the request in RPC header.- Specified by:
doWrappedRpcin interfaceNetconfSession- Parameters:
request- the XML containing the request to the server.- Returns:
- Server response or ERROR
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
requestSync
public abstract java.lang.String requestSync(java.lang.String request) throws NetconfExceptionDescription copied from interface:NetconfSessionExecutes an synchronous RPC to the server.- Specified by:
requestSyncin interfaceNetconfSession- Parameters:
request- the XML containing the RPC for the server.- Returns:
- Server response or ERROR
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
getConfig
public java.lang.String getConfig(DatastoreId netconfTargetConfig) throws NetconfException
Description copied from interface:NetconfSessionRetrieves the specified configuration.- Specified by:
getConfigin interfaceNetconfSession- Parameters:
netconfTargetConfig- the type of configuration to retrieve.- Returns:
- specified configuration.
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
getConfig
public java.lang.String getConfig(DatastoreId netconfTargetConfig, java.lang.String configurationFilterSchema) throws NetconfException
Description copied from interface:NetconfSessionRetrieves part of the specified configuration based on the filterSchema.- Specified by:
getConfigin interfaceNetconfSession- Parameters:
netconfTargetConfig- the type of configuration to retrieve.configurationFilterSchema- XML schema to filter the configuration elements we are interested in- Returns:
- device running configuration.
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
editConfig
public boolean editConfig(java.lang.String newConfiguration) throws NetconfExceptionDescription copied from interface:NetconfSessionRetrieves part of the specified configuration based on the filterSchema.- Specified by:
editConfigin interfaceNetconfSession- Parameters:
newConfiguration- configuration to set- Returns:
- true if the configuration was edited correctly
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
editConfig
public boolean editConfig(DatastoreId netconfTargetConfig, java.lang.String mode, java.lang.String newConfiguration) throws NetconfException
Description copied from interface:NetconfSessionRetrieves part of the specified configuration based on the filterSchema.- Specified by:
editConfigin interfaceNetconfSession- Parameters:
netconfTargetConfig- the targetConfiguration to changemode- default-operation modenewConfiguration- configuration to set- Returns:
- true if the configuration was edited correctly
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
copyConfig
public boolean copyConfig(DatastoreId destination, DatastoreId source) throws NetconfException
Description copied from interface:NetconfSessionCopies the configuration between configuration datastores.The target configuration can't be the running one
- Specified by:
copyConfigin interfaceNetconfSession- Parameters:
destination- configuration datastoresource- configuration datastore- Returns:
- true if the configuration was copied correctly
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
copyConfig
public boolean copyConfig(DatastoreId netconfTargetConfig, java.lang.String newConfiguration) throws NetconfException
Description copied from interface:NetconfSessionCopies the new configuration, an Url or a complete configuration xml tree to the target configuration. The target configuration can't be the running one- Specified by:
copyConfigin interfaceNetconfSession- Parameters:
netconfTargetConfig- the type of configuration to retrieve.newConfiguration- configuration XML to set or URL tag to the configuration- Returns:
- true if the configuration was copied correctly
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
copyConfig
public boolean copyConfig(java.lang.String netconfTargetConfig, java.lang.String newConfiguration) throws NetconfExceptionDescription copied from interface:NetconfSessionCopies the new configuration, an Url or a complete configuration xml tree to the target configuration. The target configuration can't be the running one- Specified by:
copyConfigin interfaceNetconfSession- Parameters:
netconfTargetConfig- the type of configuration to retrieve.newConfiguration- configuration to set- Returns:
- true if the configuration was copied correctly
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
deleteConfig
public boolean deleteConfig(DatastoreId netconfTargetConfig) throws NetconfException
Description copied from interface:NetconfSessionDeletes part of the specified configuration based on the filterSchema.- Specified by:
deleteConfigin interfaceNetconfSession- Parameters:
netconfTargetConfig- the name of the configuration to delete- Returns:
- true if the configuration was copied correctly
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
startSubscription
public void startSubscription() throws NetconfExceptionDescription copied from interface:NetconfSessionStarts subscription to the device's notifications.- Specified by:
startSubscriptionin interfaceNetconfSession- Throws:
NetconfException- when there is a problem starting the subscription
-
startSubscription
public abstract void startSubscription(java.lang.String filterSchema) throws NetconfExceptionDescription copied from interface:NetconfSessionStarts subscription to the device's notifications.- Specified by:
startSubscriptionin interfaceNetconfSession- Parameters:
filterSchema- XML subtrees to indicate specific notification- Throws:
NetconfException- when there is a problem starting the subscription
-
endSubscription
public abstract void endSubscription() throws NetconfExceptionDescription copied from interface:NetconfSessionEnds subscription to the device's notifications.- Specified by:
endSubscriptionin interfaceNetconfSession- Throws:
NetconfException- when there is a problem ending the subscription
-
lock
public boolean lock(DatastoreId datastore) throws NetconfException
Description copied from interface:NetconfSessionLocks the specified configuration.- Specified by:
lockin interfaceNetconfSession- Parameters:
datastore- configuration datastore to be locked- Returns:
- true if successful.
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
unlock
public boolean unlock(DatastoreId datastore) throws NetconfException
Description copied from interface:NetconfSessionUnlocks the specified configuration.- Specified by:
unlockin interfaceNetconfSession- Parameters:
datastore- configuration datastore to be unlocked- Returns:
- true if successful.
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
commit
public boolean commit() throws NetconfExceptionDescription copied from interface:NetconfSessionCommits the candidate configuration the running configuration.- Specified by:
commitin interfaceNetconfSession- Returns:
- true if successful.
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
close
public boolean close() throws NetconfExceptionDescription copied from interface:NetconfSessionCloses the Netconf session with the device. the first time it tries gracefully, then kills it forcefully- Specified by:
closein interfaceNetconfSession- Returns:
- true if closed
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
getSessionId
public abstract java.lang.String getSessionId()
Description copied from interface:NetconfSessionGets the session ID of the Netconf session.- Specified by:
getSessionIdin interfaceNetconfSession- Returns:
- Session ID as a string.
-
getDeviceCapabilitiesSet
public abstract java.util.Set<java.lang.String> getDeviceCapabilitiesSet()
Description copied from interface:NetconfSessionGets the capabilities of the remote Netconf device associated to this session.- Specified by:
getDeviceCapabilitiesSetin interfaceNetconfSession- Returns:
- Network capabilities as strings in a Set.
-
addDeviceOutputListener
public void addDeviceOutputListener(NetconfDeviceOutputEventListener listener) throws NetconfException
Description copied from interface:NetconfSessionAdd a listener to the underlying stream handler implementation.- Specified by:
addDeviceOutputListenerin interfaceNetconfSession- Parameters:
listener- event listener.- Throws:
NetconfException- when this method will be called by STANDBY or NONE node.
-
removeDeviceOutputListener
public void removeDeviceOutputListener(NetconfDeviceOutputEventListener listener) throws NetconfException
Description copied from interface:NetconfSessionRemove a listener from the underlying stream handler implementation.- Specified by:
removeDeviceOutputListenerin interfaceNetconfSession- Parameters:
listener- event listener.- Throws:
NetconfException- when this method will be called by STANDBY or NONE node.
-
checkReply
@Beta protected boolean checkReply(java.lang.String reply)
Checks errors in reply from the session.- Parameters:
reply- reply string- Returns:
- true if no error, else false
-
-