Package org.onosproject.netconf
Class NetconfSessionAdapter
- java.lang.Object
-
- org.onosproject.netconf.AbstractNetconfSession
-
- org.onosproject.netconf.NetconfSessionAdapter
-
- All Implemented Interfaces:
NetconfSession
public class NetconfSessionAdapter extends AbstractNetconfSession implements NetconfSession
Adapter mainly intended for usage in tests.
-
-
Constructor Summary
Constructors Constructor Description NetconfSessionAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDeviceOutputListener(NetconfDeviceOutputEventListener listener)Add a listener to the underlying stream handler implementation.booleanclose()Closes the Netconf session with the device.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.voidendSubscription()Ends subscription to the device's notifications.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.java.util.Set<java.lang.String>getDeviceCapabilitiesSet()Gets the capabilities of the remote Netconf device associated to this session.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.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.java.lang.StringrequestSync(java.lang.String request)Executes an synchronous RPC to the server.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.voidstartSubscription(java.lang.String filterSchema)Starts subscription to the device's notifications.booleanunlock(DatastoreId datastore)Unlocks the specified configuration.-
Methods inherited from class org.onosproject.netconf.AbstractNetconfSession
asyncGet, asyncGetConfig, checkReply, commit, executeRpc
-
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
asyncGet, asyncGetConfig, checkAndReestablish, commit, lock, requestSync, setOnosCapabilities, timeoutConnectSec, timeoutIdleSec, timeoutReplySec, unlock
-
-
-
-
Method Detail
-
startSubscription
public void startSubscription(java.lang.String filterSchema) throws NetconfExceptionDescription copied from interface:NetconfSessionStarts subscription to the device's notifications.- Specified by:
startSubscriptionin interfaceNetconfSession- Specified by:
startSubscriptionin classAbstractNetconfSession- Parameters:
filterSchema- XML subtrees to indicate specific notification- Throws:
NetconfException- when there is a problem starting the subscription
-
startSubscription
public void startSubscription() throws NetconfExceptionDescription copied from interface:NetconfSessionStarts subscription to the device's notifications.- Specified by:
startSubscriptionin interfaceNetconfSession- Overrides:
startSubscriptionin classAbstractNetconfSession- Throws:
NetconfException- when there is a problem starting the subscription
-
requestSync
public java.lang.String requestSync(java.lang.String request) throws NetconfExceptionDescription copied from interface:NetconfSessionExecutes an synchronous RPC to the server.- Specified by:
requestSyncin interfaceNetconfSession- Specified by:
requestSyncin classAbstractNetconfSession- 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
-
request
public 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- Specified by:
requestin classAbstractNetconfSession- 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 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- Specified by:
rpcin classAbstractNetconfSession- 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
-
removeDeviceOutputListener
public void removeDeviceOutputListener(NetconfDeviceOutputEventListener listener)
Description copied from interface:NetconfSessionRemove a listener from the underlying stream handler implementation.- Specified by:
removeDeviceOutputListenerin interfaceNetconfSession- Overrides:
removeDeviceOutputListenerin classAbstractNetconfSession- Parameters:
listener- event listener.
-
getSessionId
public java.lang.String getSessionId()
Description copied from interface:NetconfSessionGets the session ID of the Netconf session.- Specified by:
getSessionIdin interfaceNetconfSession- Specified by:
getSessionIdin classAbstractNetconfSession- Returns:
- Session ID as a string.
-
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- Overrides:
getin classAbstractNetconfSession- 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
-
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- Overrides:
getin classAbstractNetconfSession- 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
-
endSubscription
public void endSubscription() throws NetconfExceptionDescription copied from interface:NetconfSessionEnds subscription to the device's notifications.- Specified by:
endSubscriptionin interfaceNetconfSession- Specified by:
endSubscriptionin classAbstractNetconfSession- Throws:
NetconfException- when there is a problem ending the subscription
-
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- Overrides:
editConfigin classAbstractNetconfSession- 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
-
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- Overrides:
doWrappedRpcin classAbstractNetconfSession- 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
-
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- Overrides:
copyConfigin classAbstractNetconfSession- 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- Overrides:
copyConfigin classAbstractNetconfSession- 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- Overrides:
copyConfigin classAbstractNetconfSession- 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
-
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- Overrides:
closein classAbstractNetconfSession- Returns:
- true if closed
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
addDeviceOutputListener
public void addDeviceOutputListener(NetconfDeviceOutputEventListener listener)
Description copied from interface:NetconfSessionAdd a listener to the underlying stream handler implementation.- Specified by:
addDeviceOutputListenerin interfaceNetconfSession- Overrides:
addDeviceOutputListenerin classAbstractNetconfSession- Parameters:
listener- event listener.
-
getConfig
public java.lang.String getConfig(DatastoreId netconfTargetConfig) throws NetconfException
Description copied from interface:NetconfSessionRetrieves the specified configuration.- Specified by:
getConfigin interfaceNetconfSession- Overrides:
getConfigin classAbstractNetconfSession- 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- Overrides:
getConfigin classAbstractNetconfSession- 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(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- Overrides:
editConfigin classAbstractNetconfSession- 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
-
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- Overrides:
deleteConfigin classAbstractNetconfSession- 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
-
lock
public boolean lock(DatastoreId datastore) throws NetconfException
Description copied from interface:NetconfSessionLocks the specified configuration.- Specified by:
lockin interfaceNetconfSession- Overrides:
lockin classAbstractNetconfSession- 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- Overrides:
unlockin classAbstractNetconfSession- 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
-
getDeviceCapabilitiesSet
public 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- Specified by:
getDeviceCapabilitiesSetin classAbstractNetconfSession- Returns:
- Network capabilities as strings in a Set.
-
-