Package org.onosproject.netconf
Interface NetconfSession
-
- All Known Implementing Classes:
AbstractNetconfSession,NetconfSessionAdapter
public interface NetconfSessionNETCONF session object that allows NETCONF operations on top with the physical device on top of an SSH connection.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated 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.default voidcheckAndReestablish()Checks the state of the underlying SSH session and connection and if necessary it reestablishes it.booleanclose()Closes the Netconf session with the device.default 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.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)Deprecated.in 1.13.0 use async version instead.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.default booleanlock()Locks the running configuration.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)Deprecated.- 1.10.0 do not remove needs reworkingjava.lang.StringrequestSync(java.lang.String request)Executes an synchronous RPC to the server.default java.lang.StringrequestSync(java.lang.String request, int timeout)Executes an synchronous RPC to the server with specific reply TIMEOUT.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.default voidsetOnosCapabilities(java.lang.Iterable<java.lang.String> capabilities)Sets the ONOS side capabilities.voidstartSubscription()Starts subscription to the device's notifications.voidstartSubscription(java.lang.String filterSchema)Starts subscription to the device's notifications.default inttimeoutConnectSec()Read the connect timeout that this session was created with.default inttimeoutIdleSec()Read the idle timeout that this session was created with.default inttimeoutReplySec()Read the reply timeout that this session was created with.default booleanunlock()Unlocks the running configuration.booleanunlock(DatastoreId datastore)Unlocks the specified configuration.
-
-
-
Method Detail
-
request
@Deprecated java.util.concurrent.CompletableFuture<java.lang.String> request(java.lang.String request) throws NetconfExceptionDeprecated.- 1.10.0 do not remove needs reworkingExecutes 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- 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
java.util.concurrent.CompletableFuture<java.lang.String> rpc(java.lang.String request) throws NetconfExceptionExecutes an asynchronous RPC request to the server and obtains a future for it's response.- 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 connectionNetconfTransportException- on secure transport-layer error
-
asyncGetConfig
java.util.concurrent.CompletableFuture<java.lang.CharSequence> asyncGetConfig(DatastoreId datastore) throws NetconfException
Retrieves the specified configuration.- 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
java.util.concurrent.CompletableFuture<java.lang.CharSequence> asyncGet() throws NetconfExceptionRetrieves running configuration and device state.- Returns:
- running configuration and device state
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
get
java.lang.String get(java.lang.String request) throws NetconfExceptionRetrieves the requested configuration, different from get-config.- 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
java.lang.String get(java.lang.String filterSchema, java.lang.String withDefaultsMode) throws NetconfExceptionRetrieves the requested data.- 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
java.lang.String doWrappedRpc(java.lang.String request) throws NetconfExceptionExecutes an synchronous RPC to the server and wrap the request in RPC header.- 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
java.lang.String requestSync(java.lang.String request) throws NetconfExceptionExecutes an synchronous RPC to the server.- 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
-
requestSync
default java.lang.String requestSync(java.lang.String request, int timeout) throws NetconfExceptionExecutes an synchronous RPC to the server with specific reply TIMEOUT.- Parameters:
request- the XML containing the RPC for the server.timeout- the reply timeout.- Returns:
- Server response or ERROR
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
getConfig
@Deprecated java.lang.String getConfig(DatastoreId netconfTargetConfig) throws NetconfException
Deprecated.in 1.13.0 use async version instead.Retrieves the specified configuration.- 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
java.lang.String getConfig(DatastoreId netconfTargetConfig, java.lang.String configurationFilterSchema) throws NetconfException
Retrieves part of the specified configuration based on the filterSchema.- 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
boolean editConfig(java.lang.String newConfiguration) throws NetconfExceptionRetrieves part of the specified configuration based on the filterSchema.- 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
boolean editConfig(DatastoreId netconfTargetConfig, java.lang.String mode, java.lang.String newConfiguration) throws NetconfException
Retrieves part of the specified configuration based on the filterSchema.- 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
boolean copyConfig(DatastoreId destination, DatastoreId source) throws NetconfException
Copies the configuration between configuration datastores.The target configuration can't be the running one
- 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
boolean copyConfig(DatastoreId netconfTargetConfig, java.lang.String newConfiguration) throws NetconfException
Copies the new configuration, an Url or a complete configuration xml tree to the target configuration. The target configuration can't be the running one- 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
boolean copyConfig(java.lang.String netconfTargetConfig, java.lang.String newConfiguration) throws NetconfExceptionCopies the new configuration, an Url or a complete configuration xml tree to the target configuration. The target configuration can't be the running one- 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
boolean deleteConfig(DatastoreId netconfTargetConfig) throws NetconfException
Deletes part of the specified configuration based on the filterSchema.- 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
void startSubscription() throws NetconfExceptionStarts subscription to the device's notifications.- Throws:
NetconfException- when there is a problem starting the subscription
-
startSubscription
@Beta void startSubscription(java.lang.String filterSchema) throws NetconfExceptionStarts subscription to the device's notifications.- Parameters:
filterSchema- XML subtrees to indicate specific notification- Throws:
NetconfException- when there is a problem starting the subscription
-
endSubscription
void endSubscription() throws NetconfExceptionEnds subscription to the device's notifications.- Throws:
NetconfException- when there is a problem ending the subscription
-
lock
boolean lock(DatastoreId datastore) throws NetconfException
Locks the specified configuration.- 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
boolean unlock(DatastoreId datastore) throws NetconfException
Unlocks the specified configuration.- 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
-
lock
default boolean lock() throws NetconfExceptionLocks the running configuration.- Returns:
- true if successful.
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
unlock
default boolean unlock() throws NetconfExceptionUnlocks the running configuration.- Returns:
- true if successful.
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
commit
default boolean commit() throws NetconfExceptionCommits the candidate configuration the running configuration.- Returns:
- true if successful.
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
close
boolean close() throws NetconfExceptionCloses the Netconf session with the device. the first time it tries gracefully, then kills it forcefully- Returns:
- true if closed
- Throws:
NetconfException- when there is a problem in the communication process on the underlying connection
-
getSessionId
java.lang.String getSessionId()
Gets the session ID of the Netconf session.- Returns:
- Session ID as a string.
-
getDeviceCapabilitiesSet
java.util.Set<java.lang.String> getDeviceCapabilitiesSet()
Gets the capabilities of the remote Netconf device associated to this session.- Returns:
- Network capabilities as strings in a Set.
- Since:
- 1.10.0
-
checkAndReestablish
default void checkAndReestablish() throws NetconfExceptionChecks the state of the underlying SSH session and connection and if necessary it reestablishes it. Should be implemented, providing a default here for retrocompatibility.- Throws:
NetconfException- when there is a problem in reestablishing the connection or the session to the device.
-
setOnosCapabilities
default void setOnosCapabilities(java.lang.Iterable<java.lang.String> capabilities)
Sets the ONOS side capabilities.- Parameters:
capabilities- list of capabilities ONOS has.- Since:
- 1.10.0
-
addDeviceOutputListener
void addDeviceOutputListener(NetconfDeviceOutputEventListener listener) throws NetconfException
Add a listener to the underlying stream handler implementation.- Parameters:
listener- event listener.- Throws:
NetconfException- when this method will be called by STANDBY or NONE node.
-
removeDeviceOutputListener
void removeDeviceOutputListener(NetconfDeviceOutputEventListener listener) throws NetconfException
Remove a listener from the underlying stream handler implementation.- Parameters:
listener- event listener.- Throws:
NetconfException- when this method will be called by STANDBY or NONE node.
-
timeoutConnectSec
default int timeoutConnectSec()
Read the connect timeout that this session was created with.- Returns:
- timeout in seconds
-
timeoutReplySec
default int timeoutReplySec()
Read the reply timeout that this session was created with.- Returns:
- timeout in seconds
-
timeoutIdleSec
default int timeoutIdleSec()
Read the idle timeout that this session was created with.- Returns:
- timeout in seconds
-
-