public class NetconfSession
extends java.lang.Object
get-config, edit-config and
commit.
The NETCONF session class is data model agnostic. Manipulation of data is
done via the Element class.
Example 1: Read and manipulate data locally
A get-config operation with an XPATH filter is sent to the agent (the agent
must implement the :xpath capability). When the configuration
tree is received it is edited locally and written back with an
edit-config operation. The read and write is done towards the
RUNNING datastore.
// Start NETCONF session towards devices
SSHConnection c = new SSHConnection("127.0.0.1", 5678);
c.authenticateWithPassword("admin", "pass");
SSHSession ssh = new SSHSession(c);
NetconfSession dev1 = new NetconfSession(ssh);
// Get system configuration from dev1 (RUNNING datastore)
// Read is done using Xpath expression
Element sys1 = dev1.getConfig("/system").first();
// Manipulate the config tree locally
sys1.setValue("dns", "83.100.1.1");
sys1.setValue("gateway", "10.0.0.1");
// Write back the updated element tree to the device
dev1.editConfig(sys1);
Example 2: Read config using subtree filtering
A subtree filter is built using the Element.create method. The
matching configuration is received and one of the elements is deleted. It is
"marked" for deletion and an edit-config operation is used to
actually delete the element on the agent.
// Start NETCONF session toward our device
SSHConnection c = new SSHConnection("127.0.0.1", 5678);
c.authenticateWithPassword("admin", "pass");
SSHSession ssh = new SSHSession(c);
NetconfSession dev1 = new NetconfSession(ssh);
// Create subtree filter
Element filter = Element.create("/hosts/host[name='kalle']");
// Read from RUNNING datastore
Element hosts = dev1.getConfig(filter).first();
// delete host 'kalle'
// that is... mark the node for deletion
sys1.markDelete("hosts/host[name='kalle']");
// edit-config. The deleted node has the operation="delete"
// marked on it.
dev1.editConfig(sys1);
Example 3: Transaction using candidates
try {
// Start (NETCONF) sessions towards devices
SSHConnection c1 = new SSHConnection("127.0.0.1", 3456);
SSHConnection c2 = new SSHConnection("10.4.5.6", 3456);
c1.authenticateWithPassword("admin", "pass");
c2.authenticateWithPassword("admin", "pass");
SSHSession ssh1 = new SSHSession(c1);
SSHSession ssh2 = new SSHSession(c2);
NetconfSession dev1 = new NetconfSession(ssh1);
NetconfSession dev2 = new NetconfSession(ssh2);
// take locks on CANDIDATE datastore so that we are not interrupted
dev1.lock(NetconfSession.CANDIDATE);
dev2.lock(NetconfSession.CANDIDATE);
// reset candidates so that CANDIDATE is an exact copy of running
dev1.copyConfig(NetconfSession.RUNNING, NetconfSession.CANDIDATE);
dev2.copyConfig(NetconfSession.RUNNING, NetconfSession.CANDIDATE);
// Get system configuration from dev1
Element sys1 = dev1.getConfig("/system").first();
// Manipulate element trees locally
sys1.setValue("dns", "83.100.1.1");
sys1.setValue("gateway", "10.0.0.1");
// Write back the updated element tree to both devices
dev1.editConfig(NetconfSession.CANDIDATE, sys1);
dev2.editConfig(NetconfSession.CANDIDATE, sys1);
// candidates are now updated
dev1.confirmedCommit(60);
dev2.confirmedCommit(60);
// now commit them
dev1.commit();
dev2.commit();
dev1.unlock(NetconfSession.CANDIDATE);
dev2.unlock(NetconfSession.CANDIDATE);
} catch (Exception e) {
// Devices will rollback within 1 min
}
Element| Modifier and Type | Field and Description |
|---|---|
static int |
CANDIDATE
The
CANDIDATE datastore. |
protected Capabilities |
capabilities
The capability elements for the session.
|
static java.lang.String |
CONFIG_GT |
static int |
CONTINUE_ON_ERROR
Value for error option.
|
static java.lang.String |
COPY_CONFIG_GT |
static java.lang.String |
EDIT_CONFIG_GT |
static java.lang.String |
FILTER |
static java.lang.String |
FILTER_GT |
static java.lang.String |
GET_CONFIG_GT |
static java.lang.String |
GET_GT |
static int |
MERGE
Value for default operation.
|
static int |
NONE
Value for default operation.
|
static int |
NOT_SET
Value is not set.
|
static int |
REPLACE
Value for default operation.
|
static int |
ROLLBACK_ON_ERROR
Value for error option.
|
static int |
RUNNING
The
RUNNING datastore. |
int |
sessionId
Session identifier.
|
static int |
SET
Value for test option.
|
static java.lang.String |
SOURCE_GT |
static java.lang.String |
START_TIME_GT |
static int |
STARTUP
The
STARTUP datastore. |
static int |
STOP_ON_ERROR
Value for error option.
|
static java.lang.String |
STOP_TIME_GT |
static java.lang.String |
STREAM_GT |
static java.lang.String |
TARGET_GT |
static int |
TEST_ONLY
Value for test option.
|
static int |
TEST_THEN_SET
Value for test option.
|
static java.lang.String |
VALIDATE_GT |
| Constructor and Description |
|---|
NetconfSession()
Creates a new session object.
|
NetconfSession(Transport transport)
Creates a new session object using the given transport object.
|
NetconfSession(Transport transport,
XMLParser parser)
Creates a new session object using the given transport object.
|
| Modifier and Type | Method and Description |
|---|---|
Element |
action(Element data)
Action capability.
|
NodeSet |
callRpc(Element data)
Calls rpc method.
|
void |
closeSession()
Requests graceful termination of a NETCONF session.
|
void |
commit()
When a candidate configuration's content is complete, the configuration
data can be committed, publishing the data set to the rest of the device
and requesting the device to conform to the behavior described in the
new configuration.
|
void |
confirmedCommit(int timeout)
The
:confirmed-commit capability indicates that the server
supports the confirmed commit. |
void |
copyConfig(Element sourceTree,
int target)
Creates or replace an entire configuration datastore with the contents
of another complete configuration datastore.
|
void |
copyConfig(Element sourceTree,
java.lang.String targetUrl)
Same as
copyConfig(Element,int) but uses an url as target. |
void |
copyConfig(int source,
int target)
Creates or replace an entire configuration datastore with the contents
of another complete configuration datastore.
|
void |
copyConfig(int source,
java.lang.String targetUrl)
Same as
copyConfig(int,int) but uses an url as target. |
void |
copyConfig(NodeSet sourceTrees,
int target)
variant of copyConfig() that takes a NodeSet as param
|
void |
copyConfig(NodeSet sourceTrees,
java.lang.String targetUrl) |
void |
copyConfig(java.lang.String sourceUrl,
int target)
Same as
copyConfig(int,int) but uses an url as the source. |
void |
copyConfig(java.lang.String sourceUrl,
java.lang.String targetUrl)
Same as
copyConfig(int,int) but uses an url as target and an
url as a source. |
void |
createSubscription()
The notification capability makes it possible to receive notifications
specified in a subscription.
|
void |
createSubscription(java.lang.String stream)
The notification capability makes it possible to receive notifications
specified in a subscription.
|
void |
createSubscription(java.lang.String streamName,
NodeSet eventFilter,
java.lang.String startTime,
java.lang.String stopTime)
The notification capability makes it possible to receive notifications
specified in a subscription.
|
void |
createSubscription(java.lang.String streamName,
java.lang.String eventFilter,
java.lang.String startTime,
java.lang.String stopTime)
Same as
createSubscription(String,NodeSet,String,String) except
a filter in xpath format can be given instead of a subtree filter. |
void |
deleteConfig(int datastore)
Deletes a configuration datastore.
|
void |
deleteConfig(java.lang.String targetUrl)
Deletes a configuration target url.
|
void |
discardChanges()
If the client decides that the candidate configuration should not be
committed, the <discard-changes> operation can be used to revert the
candidate configuration to the current running configuration.
|
void |
editConfig(Element configTree)
Edits the configuration.
|
void |
editConfig(int datastore,
Element configTree)
Edits the configuration.
|
void |
editConfig(int datastore,
NodeSet configTrees) |
void |
editConfig(int datastore,
java.lang.String url)
Edits the configuration.
|
void |
editConfig(NodeSet configTrees)
Edits the configuration.
|
protected int |
encode_rpc_begin(Transport out)
Encodes the RPC header and writes it to the provided output transport.
|
protected int |
encode_rpc_begin(Transport out,
Attribute attr)
Encodes the RPC header and writes it to the provided output transport.
|
protected void |
encode_rpc_end(Transport out)
Closes the rpc tag.
|
NodeSet |
get()
Retrieves running configuration and device state information.
|
NodeSet |
get(Element subtreeFilter)
Retrieves running configuration and device state information.
|
NodeSet |
get(java.lang.String xpath)
Retrieves running configuration and device state information.
|
Capabilities |
getCapabilities()
Return a Capabilities object with the NETCONF capabilities for this
session.
|
NodeSet |
getConfig()
Gets the device configuration data.
|
NodeSet |
getConfig(Element subtreeFilter)
Gets the device configuration data specified by subtree filtering.
|
NodeSet |
getConfig(int datastore)
Gets the device configuration data.
|
NodeSet |
getConfig(int datastore,
Element subtreeFilter)
Gets the device configuration data specified by subtree filtering.
|
NodeSet |
getConfig(int datastore,
java.lang.String xpath)
Gets the device configuration data specified by an xpath filter.
|
NodeSet |
getConfig(java.lang.String xpath)
Gets the device configuration data specified by an xpath expression.
|
NodeSet |
getStreams()
Method to get the available streams from the agent.
|
Transport |
getTransport()
Returns the transport object used by this session.
|
boolean |
hasCapability(java.lang.String uri)
Check if a specific named capability is supported.
|
protected void |
hello()
Capabilities are advertised in messages sent by each peer during session
establishment.
|
void |
killSession(int sessionId)
Force the termination of a NETCONF session.
|
void |
lock(int datastore)
The lock operation allows the client to lock the configuration system of
a device.
|
int |
lockPartial(java.lang.String select)
Same as
#lockPartial(int,String[]) except it only takes one
selection as argument. |
int |
lockPartial(java.lang.String[] select)
The partial-lock operation allows the client to lock a portion of a data
store.
|
Element |
readReply()
Reads a rpc reply from NETCONF.
|
Element |
receiveNotification()
Receive one notification.
|
protected Element |
recv_rpc_reply_ok(java.lang.String mid)
Receive from session
|
Element |
rpc(Element request)
The NETCONF protocol uses a remote procedure call (RPC) paradigm.
|
Element |
rpc(java.lang.String request)
The NETCONF protocol uses a remote procedure call (RPC) paradigm.
|
int |
sendRequest(Element request)
Sends rpc request and return.
|
int |
sendRequest(java.lang.String request)
Sends rpc request and return.
|
protected void |
setCapability(java.lang.String capability)
Set a proprietary capability.
|
void |
setDefaultOperation(int op)
Specifies the default operation for all edit-config operations for the
session.
|
void |
setErrorOption(int erroroption)
Specifies the error-option for the edit-config operations for the
session.
|
void |
setTestOption(int testoption)
Specifies the test-option parameter for the edit-config operations for
the session.
|
void |
setTransport(Transport transport)
Sets the transport used by this session.
|
void |
unlock(int datastore)
The unlock operation is used to release a configuration lock, previously
obtained with the
lock(int) operation. |
void |
unlockPartial(int lockId)
The unlock operation is used to release a configuration lock, previously
obtained with the
lock(int) operation. |
void |
validate(Element configTree)
This protocol operation validates the contents of the specified
configuration.
|
void |
validate(int datastore)
This protocol operation validates the given datastore.
|
void |
validate(java.lang.String url)
This protocol operation validates the given URL.
|
public static final java.lang.String GET_CONFIG_GT
public static final java.lang.String SOURCE_GT
public static final java.lang.String FILTER_GT
public static final java.lang.String FILTER
public static final java.lang.String GET_GT
public static final java.lang.String EDIT_CONFIG_GT
public static final java.lang.String TARGET_GT
public static final java.lang.String CONFIG_GT
public static final java.lang.String COPY_CONFIG_GT
public static final java.lang.String VALIDATE_GT
public static final java.lang.String STREAM_GT
public static final java.lang.String START_TIME_GT
public static final java.lang.String STOP_TIME_GT
public static final int RUNNING
RUNNING datastore.public static final int STARTUP
STARTUP datastore.public static final int CANDIDATE
CANDIDATE datastore.public int sessionId
hello
message.protected Capabilities capabilities
hello message upon connect.public static final int NOT_SET
public static final int MERGE
setDefaultOperation(int),
Constant Field Valuespublic static final int REPLACE
setDefaultOperation(int),
Constant Field Valuespublic static final int NONE
setDefaultOperation(int),
Constant Field Valuespublic static final int SET
setTestOption(int),
Constant Field Valuespublic static final int TEST_THEN_SET
setTestOption(int),
Constant Field Valuespublic static final int TEST_ONLY
setTestOption(int),
Constant Field Valuespublic static final int STOP_ON_ERROR
setErrorOption(int),
Constant Field Valuespublic static final int CONTINUE_ON_ERROR
setErrorOption(int),
Constant Field Valuespublic static final int ROLLBACK_ON_ERROR
setErrorOption(int),
Constant Field Valuespublic NetconfSession(Transport transport) throws JNCException, java.io.IOException
transport - Transport objectJNCExceptionjava.io.IOExceptionSSHSessionpublic NetconfSession(Transport transport, XMLParser parser) throws JNCException, java.io.IOException
transport - Transport objectparser - XML parser object
If we are using the confm package to create and manipulate
objects we must instantiate the parser as an
com.tailf.confm.XMLParser() If we fail to do that, we get the
XMLParser class from the inm package which always only
returns Element objects as opposed to the XMLParser from the
confm package which can return objects matching the confm
generated classes. If we use the confm Device class to create
our netconf sessions, this is all done automatically, whereas
if we create our netconf sessions ourselves, _and_ also want
to retrieve real confm objects we must:
SSHConnection ssh = new SSHConnection("127.0.0.1", 2022);
ssh.authenticateWithPassword("admin", "admin");
Transport tr = new SSHSession(ssh);
NetconfSession sess = new NetconfSession(tr, new com.tailf.confm.XMLParser());
JNCExceptionjava.io.IOExceptionSSHSessionpublic NetconfSession()
throws JNCException
setTransport(Transport) and an initial hello needs
to be sent to advertise capabilities.JNCExceptionpublic Capabilities getCapabilities()
hello
message from the server.public boolean hasCapability(java.lang.String uri)
uri - Name of capability to checkpublic void setTransport(Transport transport)
transport - Transport object, for example SSHSessionpublic Transport getTransport()
SSHSessionprotected void hello()
throws JNCException,
java.io.IOException
hello element containing a
list of that peer's capabilities. Each peer must send at least the base
NETCONF capability, "urn:ietf:params:netconf:base:1.0".
This method will send an initial hello to the output stream
and await the hello from the server.
Used from the constructor NetconfSession(Transport).
JNCExceptionjava.io.IOExceptionpublic Element rpc(java.lang.String request) throws java.io.IOException, JNCException
This method may be used for sending an XML string over the connected session and receiving a reply.
The reply is parsed into an element tree.
request - XML encoded NETCONF requestjava.io.IOExceptionJNCExceptionpublic Element rpc(Element request) throws java.io.IOException, JNCException
This method may be used for sending an XML element tree the connected session and receiving a reply.
The reply is parsed into an element tree.
request - XML element treejava.io.IOExceptionJNCExceptionpublic int sendRequest(java.lang.String request)
throws java.io.IOException
readReply() should be used.
Note that the return value reflects the last request-id generated by the NetconfSession methods, and is not checked against the request-id in the request parameter.
request - XML encoded NETCONF requestjava.io.IOExceptionpublic int sendRequest(Element request) throws java.io.IOException, JNCException
readReply() should be used.
Note that the return value reflects the last request-id generated by the NetconfSession methods, and is not checked against the request-id in the request parameter.
request - Element treejava.io.IOExceptionJNCExceptionpublic Element readReply() throws java.io.IOException, JNCException
The reply is parsed into an element tree.
java.io.IOExceptionJNCExceptionsendRequest(Element)public NodeSet getConfig(Element subtreeFilter) throws JNCException, java.io.IOException
subtreeFilter - A subtree filterJNCExceptionjava.io.IOExceptionpublic NodeSet getConfig() throws JNCException, java.io.IOException
JNCExceptionjava.io.IOExceptionpublic NodeSet getConfig(int datastore) throws JNCException, java.io.IOException
JNCExceptionjava.io.IOExceptionpublic NodeSet callRpc(Element data) throws JNCException, java.io.IOException
JNCExceptionjava.io.IOExceptionpublic NodeSet getConfig(java.lang.String xpath) throws JNCException, java.io.IOException
:xpath capability must be supported by the server.xpath - XPath expressionJNCExceptionjava.io.IOExceptionpublic NodeSet getConfig(int datastore, Element subtreeFilter) throws JNCException, java.io.IOException
datastore - The datastore. One of RUNNING,
CANDIDATE, STARTUPsubtreeFilter - A subtree filterJNCExceptionjava.io.IOExceptionpublic NodeSet getConfig(int datastore, java.lang.String xpath) throws JNCException, java.io.IOException
datastore - The datastore. One of RUNNING,
CANDIDATE, STARTUPxpath - XPath expressionJNCExceptionjava.io.IOExceptionpublic NodeSet get() throws JNCException, java.io.IOException
JNCExceptionjava.io.IOExceptionpublic NodeSet get(Element subtreeFilter) throws JNCException, java.io.IOException
subtreeFilter - A subtree filterJNCExceptionjava.io.IOExceptionpublic NodeSet get(java.lang.String xpath) throws JNCException, java.io.IOException
:xpath capability must be supported by the server.xpath - An xpath epxression.JNCExceptionjava.io.IOExceptionpublic void editConfig(Element configTree) throws JNCException, java.io.IOException
edit-config operation loads
all or part of a specified configuration to the RUNNING target
datatore.configTree - Configuration treeJNCExceptionjava.io.IOExceptionpublic void editConfig(NodeSet configTrees) throws JNCException, java.io.IOException
JNCExceptionjava.io.IOExceptionpublic void editConfig(int datastore,
Element configTree)
throws JNCException,
java.io.IOException
edit-config operation loads
all or part of a specified configuration to the specified target
configuration.datastore - The target datastore. One of RUNNING,
CANDIDATE, STARTUPconfigTree - The config tree to edit.JNCExceptionjava.io.IOExceptionpublic void editConfig(int datastore,
NodeSet configTrees)
throws JNCException,
java.io.IOException
JNCExceptionjava.io.IOExceptionpublic void editConfig(int datastore,
java.lang.String url)
throws JNCException,
java.io.IOException
datastore - The target datastore. One of RUNNING,
CANDIDATE, STARTUPurl - The source url.JNCExceptionjava.io.IOExceptionpublic void setDefaultOperation(int op)
The default-operation parameter is optional, but if provided, it must have one of the following values:
MERGE: The configuration data is merged with the configuration
at the corresponding level in the target datastore.
REPLACE: The configuration data completely replaces the
configuration in the target datastore. This is useful for loading
previously saved configuration data.
NONE: The target datastore is unaffected by the configuration
parameter, unless and until the incoming configuration data uses the
"operation" attribute to request a different operation. If the
configuration parameter contains data for which there is not a
corresponding level in the target datastore, an "rpc-error" is returned
with an "error-tag" value of data-missing. Using "none" allows
operations like "delete" to avoid unintentionally creating the parent
hierarchy of the element to be deleted.
public void setTestOption(int testoption)
:validate capability.
The test-option element has one of the following values:
TEST_THEN_SET: Perform a validation test before attempting to
set. If validation errors occur, do not perform the "edit-config"
operation. This is the default test-option.
SET: Perform a set without a validation test first.
TEST_ONLY: Only test. (Option is not supported in the
standard.)
testoption - One of SET, TEST_THEN_SET,
TEST_ONLYpublic void setErrorOption(int erroroption)
STOP_ON_ERROR: Abort the edit-config operation on first error.
This is the default error-option.
CONTINUE_ON_ERROR: Continue to process configuration data on
error; error is recorded, and negative response is generated if any
errors occur.
ROLLBACK_ON_ERROR: If an error condition occurs such that an
error severity "rpc-error" element is generated, the server will stop
processing the edit-config operation and restore the specified
configuration to its complete state at the start of this edit-config
operation. This option requires the server to support the
:rollback-on-error capability.
erroroption - One of STOP_ON_ERROR,
CONTINUE_ON_ERROR, ROLLBACK_ON_ERRORpublic void copyConfig(Element sourceTree, int target) throws JNCException, java.io.IOException
sourceTree - A config treetarget - The target datastoreJNCExceptionjava.io.IOExceptionpublic void copyConfig(NodeSet sourceTrees, int target) throws JNCException, java.io.IOException
JNCExceptionjava.io.IOExceptionpublic void copyConfig(Element sourceTree, java.lang.String targetUrl) throws JNCException, java.io.IOException
copyConfig(Element,int) but uses an url as target. Only
possible if :url capability is supported.sourceTree - A config treetargetUrl - The target URL.JNCExceptionjava.io.IOExceptionpublic void copyConfig(NodeSet sourceTrees, java.lang.String targetUrl) throws JNCException, java.io.IOException
JNCExceptionjava.io.IOExceptionpublic void copyConfig(int source,
int target)
throws JNCException,
java.io.IOException
source - The source datastoretarget - The target datastoreJNCExceptionjava.io.IOExceptionpublic void copyConfig(int source,
java.lang.String targetUrl)
throws JNCException,
java.io.IOException
copyConfig(int,int) but uses an url as target. Only
possible if :url capability is supported.source - The datastore to be used as sourcetargetUrl - The target URL.JNCExceptionjava.io.IOExceptionpublic void copyConfig(java.lang.String sourceUrl,
java.lang.String targetUrl)
throws JNCException,
java.io.IOException
copyConfig(int,int) but uses an url as target and an
url as a source. Only possible if :url capability is
supported.sourceUrl - The source URL.targetUrl - The target URL.JNCExceptionjava.io.IOExceptionpublic void copyConfig(java.lang.String sourceUrl,
int target)
throws JNCException,
java.io.IOException
copyConfig(int,int) but uses an url as the source. Only
possible if :url capability is supported.sourceUrl - The source URL.target - The target datastoreJNCExceptionjava.io.IOExceptionpublic void deleteConfig(int datastore)
throws JNCException,
java.io.IOException
datastore - Datastore to be deletedJNCExceptionjava.io.IOExceptionpublic void deleteConfig(java.lang.String targetUrl)
throws JNCException,
java.io.IOException
targetUrl - Name of configuration target url to be deleted.JNCExceptionjava.io.IOExceptionpublic void lock(int datastore)
throws JNCException,
java.io.IOException
An attempt to lock the configuration must fail if an existing session or other entity holds a lock on any portion of the lock target.
datastore - The datastore to lockJNCExceptionjava.io.IOExceptionpublic void unlock(int datastore)
throws JNCException,
java.io.IOException
lock(int) operation.datastore - The target datastore to unlockJNCExceptionjava.io.IOExceptionpublic int lockPartial(java.lang.String[] select)
throws JNCException,
java.io.IOException
If the selection filters are XPath expressions they are evaluated only once at lock time, thereafter the scope of the lock is maintained as a set of nodes. If the configuration data is later altered in a way that would make the original XPath filter expressions evaluate to a different set of nodes, this does not affect the scope of the partial lock. XPath is only used for the creation of the partial lock. Conceptually the scope of the lock is defined by the returned nodeset and not by the XPath expression.
If a node is locked by a session, only that same session will be able to modify that node or any node in the subtree underneath it.
If a top level node of a locked subtree is deleted, any other session can recreate it, as it is not covered by the lock anymore. The lock operation allows the client to lock the configuration system of a device. Such locks are intended to be short-lived and allow a client to make a change without fear of interaction with other NETCONF clients, non-NETCONF clients (e.g., SNMP and command line interface (CLI) scripts), and human users.
An attempt to lock the configuration must fail if an existing session or other entity holds a lock on any portion of the lock target.
datastore - datastore of which a part will be lockedselect - An array of selection filtersJNCExceptionjava.io.IOExceptionpublic int lockPartial(java.lang.String select)
throws JNCException,
java.io.IOException
#lockPartial(int,String[]) except it only takes one
selection as argument.JNCExceptionjava.io.IOException#lockPartial(int,String[])public void unlockPartial(int lockId)
throws JNCException,
java.io.IOException
lock(int) operation.lockId - Previously received lock identifier from
#lockPartial(int,String[])JNCExceptionjava.io.IOExceptionpublic void commit()
throws JNCException,
java.io.IOException
To commit the candidate configuration as the device's new current
configuration, use the commit operation.
The commit operation instructs the device to implement the
configuration data contained in the candidate configuration. If the
device is unable to commit all of the changes in the candidate
configuration datastore, then the running configuration must remain
unchanged. If the device does succeed in committing, the running
configuration must be updated with the contents of the candidate
configuration.
If the system does not have the :candidate capability, the
commit operation is not available.
JNCExceptionjava.io.IOExceptionpublic void confirmedCommit(int timeout)
throws JNCException,
java.io.IOException
:confirmed-commit capability indicates that the server
supports the confirmed commit.
A confirmed commit operation must be reverted if a follow-up commit (called the "confirming commit") is not issued within 600 seconds (10 minutes). The timeout period can be adjusted with the timeout parameter.
If the session issuing the confirmed commit is terminated for any reason before the confirm timeout expires, the server must restore the configuration to its state before the confirmed commit was issued.
If the device reboots for any reason before the confirm timeout expires, the server must restore the configuration to its state before the confirmed commit was issued.
If a confirming commit is not issued, the device will revert its configuration to the state prior to the issuance of the confirmed commit. Note that any commit operation, including a commit which introduces additional changes to the configuration, will serve as a confirming commit. Thus to cancel a confirmed commit and revert changes without waiting for the confirm timeout to expire, the manager can explicitly restore the configuration to its state before the confirmed commit was issued.
For shared configurations, this feature can cause other configuration changes (for example, via other NETCONF sessions) to be inadvertently altered or removed, unless the configuration locking feature is used (in other words, the lock is obtained before the edit-config operation is started). Therefore, it is strongly suggested that in order to use this feature with shared configuration databases, configuration locking should also be used.
timeout - Time that server will wait for confirming commit before
reverting configJNCExceptionjava.io.IOExceptionpublic void discardChanges()
throws JNCException,
java.io.IOException
JNCExceptionjava.io.IOExceptionpublic void closeSession()
throws JNCException,
java.io.IOException
When a NETCONF server receives a close-session request, it
will gracefully close the session. The server will release any locks and
resources associated with the session and gracefully close any
associated connections.
JNCExceptionjava.io.IOExceptionpublic void killSession(int sessionId)
throws JNCException,
java.io.IOException
When a NETCONF entity receives a kill-session request for
an open session, it will abort any operations currently in process,
release any locks and resources associated with the session, and close
any associated connections.
Session identifier of the NETCONF session to be terminated, if this value is the current session ID a JNCException will be thrown.
sessionId - The id of the session to terminateJNCExceptionjava.io.IOExceptionpublic void validate(Element configTree) throws JNCException, java.io.IOException
configTree - configuration tree to validateJNCExceptionjava.io.IOExceptionpublic void validate(int datastore)
throws java.io.IOException,
JNCException
CANDIDATE datastore.datastore - The datastore to validatejava.io.IOExceptionJNCExceptionpublic void validate(java.lang.String url)
throws java.io.IOException,
JNCException
"file://incoming.conf" then file must be
supported by the :url capability.url - The source url to validatejava.io.IOExceptionJNCExceptionpublic void createSubscription()
throws java.io.IOException,
JNCException
:notification capability
must be supported by the server.java.io.IOExceptionJNCExceptioncreateSubscription(String,String,String,String)public void createSubscription(java.lang.String stream)
throws java.io.IOException,
JNCException
:notification capability
must be supported by the server.
Subscribe on specified stream name.
stream - The name of the stream or null if all streams
of events are of interest.java.io.IOExceptionJNCExceptioncreateSubscription(String,String,String,String)public void createSubscription(java.lang.String streamName,
NodeSet eventFilter,
java.lang.String startTime,
java.lang.String stopTime)
throws java.io.IOException,
JNCException
:notification capability
must be supported by the server.
An optional parameter, stream, that indicates which stream
of events is of interest. If not present, events in the default NETCONF
stream will be sent.
An optional parameter, filter, that indicates which subset
of all possible events is of interest. If not present, all events not
precluded by other parameters will be sent.
A parameter, startTime, used to trigger the replay feature
and indicate that the replay should start at the time specified. If
startTime is not present, this is not a replay
subscription. It is not valid to specify start times that are later than
the current time. If the startTime specified is earlier
than the log can support, the replay will begin with the earliest
available notification. The time is specified in dateTime format.
An optional parameter, stopTime, used with the optional
replay feature to indicate the newest notifications of interest. If stop
time is not present, the notifications will continue until the
subscription is terminated. Must be used with and be later than
startTime. Values of stopTime in the future
are valid. The time is specified in dateTime format.
streamName - The name of the stream or nulleventFilter - a subtree filter - list of events, or
nullstartTime - a dateTime string specifying the replay start, or
null if the subscription is not a replay
subscriptionstopTime - a dateTime string specifying the stop of replay, or
null if the subscription is not a replay
subscription or infinite subscription is desiredjava.io.IOExceptionJNCExceptionreceiveNotification()public void createSubscription(java.lang.String streamName,
java.lang.String eventFilter,
java.lang.String startTime,
java.lang.String stopTime)
throws java.io.IOException,
JNCException
createSubscription(String,NodeSet,String,String) except
a filter in xpath format can be given instead of a subtree filter.streamName - The name of the stream or nulleventFilter - a filter xpath expression, or nullstartTime - a dateTime string specifying the replay start, or
nullstopTime - a dateTime string specifying the stop of replay, or
nulljava.io.IOExceptionJNCExceptionreceiveNotification()public NodeSet getStreams() throws JNCException, java.io.IOException
Element subtree = Element.create(
"urn:ietf:params:xml:ns:netmod:notification", "netconf/streams");
return session.get(subtree);
The available streams are returned.JNCExceptionjava.io.IOExceptionpublic Element receiveNotification() throws java.io.IOException, JNCException
java.io.IOExceptionJNCExceptionpublic Element action(Element data) throws JNCException, java.io.IOException
data - element tree with action-dataJNCExceptionjava.io.IOExceptionprotected Element recv_rpc_reply_ok(java.lang.String mid) throws JNCException, java.io.IOException
JNCExceptionjava.io.IOExceptionprotected void setCapability(java.lang.String capability)
hello() method to have any effect.capability - Add a capablity string for this client sessionprotected int encode_rpc_begin(Transport out)
out - Transport output streamprotected int encode_rpc_begin(Transport out, Attribute attr)
out - Transport output streamattr - Extra attribute to be added to rpc headerprotected void encode_rpc_end(Transport out)
out - Transport output stream