public class Maapi extends Object
This class implements the Management Agent API (MAAPI).
The purpose of the class is twofold:
Maapi can be used to implement our own proprietary management agent.
This class implements the Management Agent API (MAAPI).
The purpose of the class is twofold:
MAAPI can be used to implement our own proprietary management agent.
Example:
// int port = Conf.PORT for ConfD or Conf.NCS_PORT for NCS
// Setup socket to server
Socket s = new Socket("localhost", port);
// Start MAAPI session for admin user, originating from localhost
Maapi maapi = new Maapi(s);
maapi.startUserSession("admin",
InetAddress.getByName("localhost"),
"maapi",
new String[] { "admin" },
MaapiUserSessionFlag.PROTO_TCP);
// Start a read transaction towards the running configuration.
int tid = maapi.startTrans(Conf.DB_RUNNING, Conf.MODE_READ);
// Set the namespace for the upcoming data operations
maapi.setNamespace(tid, "http://tail-f.com/test/mtest/1.0");
// Read the maxLeaseTime setting in the running configuration.
ConfObject r = maapi.getElem(tid, "/mtest/servers/server{www}/ip");
// Done, the transaction and user session is automatically
// ended when the socket is closed.
s.close();
| Modifier and Type | Class and Description |
|---|---|
static class |
Maapi.Progress |
static class |
Maapi.Verbosity
To be used in:
Maapi.reportProgress(int,Verbosity,String)
Maapi.reportProgress(int,Verbosity,String,String)
Maapi.reportProgressStart(int,Verbosity,String,String)
Maapi.reportNedProgress(Verbosity,String,String,String)
Maapi.reportNedProgressStart(Verbosity,String,String,String)
Maapi.reportServiceProgress(int,Verbosity,String,ConfPath)
#reportServiceProgress(int,Verbosity,String,ConfPath,String)
#reportServiceProgressStart(int,Verbosity,String,ConfPath,String) |
| Constructor and Description |
|---|
Maapi(Socket socket)
Creates a new instance of
Maapi supplying a established
open socket to ConfD/NCS daemon. |
| Modifier and Type | Method and Description |
|---|---|
void |
aaaReload(boolean synchronous)
When the ConfD/NCS AAA tree is populated by an external data provider,
this method can be used by the data provider to notify ConfD/NCS when
there is a change to the AAA data.
|
void |
abortTrans(int tid)
Abort a transaction specified by transaction handle tid.
|
void |
abortUpgrade()
Note, This method is only applicable for Confd.
|
void |
applyTrans(int tid,
boolean keepOpen)
Apply a current transaction with transaction handle tid.
|
void |
applyTrans(int tid,
boolean keepOpen,
int flags)
Apply a current transaction with transaction handle tid
with additional flags (NCS Specific).
|
ApplyResult |
applyTransParams(int tid,
boolean keepOpen,
CommitParams params)
Apply a current transaction with transaction handle tid
with additional NCS specific parameters.
|
void |
attach(int tid,
int nsi)
Same as
Maapi.attach(int, int, int) with the exception
that the User session id is implicit for the attached transaction. |
void |
attach(int tid,
int nsi,
int usid)
Attach to a current transaction.
|
void |
attach(int tid,
String ns)
Same as
Maapi.attach(int, String, int) with the exception
that the User session id is implicit for the attached transaction. |
void |
attach(int tid,
String ns,
int usid)
Attach to a current transaction.
|
int |
attachInit()
Attach to transaction available in phase0.
|
MaapiAuthentication |
authenticate(String user,
String passwd)
If we are implementing a proprietary Management Agent with MAAPI API,
the method
Maapi.startUserSession(String,InetAddress,String,String[],
MaapiUserSessionFlag) requires the application to tell ConfD/NCS
which groups the user are member of. |
MaapiAuthentication |
authenticate2(String user,
String passwd,
InetAddress src_addr,
int src_port,
String context,
MaapiUserSessionFlag proto)
If we are implementing a proprietary Management Agent with MAAPI API, the
method
Maapi.startUserSession(String,InetAddress,String,String[],
MaapiUserSessionFlag) requires the application to tell ConfD/NCS
which groups the user are member of. |
void |
candidateAbortCommit()
This function cancels a pending confirmed commit.
|
void |
candidateAbortCommitPersistent(String persistId)
Cancel an ongoing persistent commit with the cookie given by persistId.
|
void |
candidateCommit()
This function copies the candidate to running.
|
void |
candidateCommitInfo(String label,
String comment)
This method can be used to set the "Label" and/or "Comment"
that is stored in the rollback file when the candidate is committed
to running.
|
void |
candidateCommitInfo(String persistId,
String label,
String comment)
This method can be used to set the "Label" and/or "Comment"
that is stored in the rollback file when the candidate is committed
to running.
|
void |
candidateCommitPersistent(String persistId)
Confirm an ongoing persistent commit with the cookie given by persistId.
|
void |
candidateConfirmedCommit(int t)
This method also copies the candidate into running.
|
void |
candidateConfirmedCommitInfo(int timeoutsecs,
String label,
String comment)
This method does the same as
Maapi.candidateConfirmedCommitPersistent(int, java.lang.String, java.lang.String), but allows for
setting the "Label" and/or "Comment" that is stored in the
rollback file when the candidate is committed to running. |
void |
candidateConfirmedCommitInfo(int timeoutsecs,
String persist,
String persistId,
String label,
String comment)
This method does the same as
Maapi.candidateConfirmedCommitPersistent(int, java.lang.String, java.lang.String), but allows for
setting the "Label" and/or "Comment" that is stored in the
rollback file when the candidate is committed to running. |
void |
candidateConfirmedCommitPersistent(int timeoutsecs,
String persist,
String persistId)
This method can be used to start or extend a persistent confirmed
commit, see the Tail-f Commit Capability section in the NETCONF Server
chapter in the User Guide.
|
void |
candidateReset()
This function copies running into candidate.
|
void |
candidateValidate()
This function validates the candidate.
|
void |
cd(int tid,
String fmt,
Object... arguments)
This function mimics the behavior of the UNIX "cd" command.
|
void |
clearOpCache()
Same as
Maapi.clearOpCache(ConfPath), with the only difference that
if clears all cached data from "/" and down. |
void |
clearOpCache(ConfPath path)
Request clearing of the operational data cache (see the Operational Data
the User Guide).
|
void |
CLIAccounting(String user,
int usid,
String cmd)
Generate an audit log entry in the CLI audit log.
|
CLICmdToPathResult |
CLICmdToPath(int th,
String cmd)
Given a C- or I-style command, this method tries to determine the
corresponding namespace and path in the schema.
|
CLICmdToPathResult |
CLICmdToPath(String cmd)
Equivalent to
Maapi.CLICmdToPath(int, String) with the first
parameter set to -1 (ie, the command is not interpreted in the
context of any particular transaction) |
String |
CLIDiffCmd(int thandle,
int thandleOld,
ConfPath path)
Get the diff between two transactions as C-/I-style CLI commands.
|
String |
CLIPathCmd(int th,
EnumSet<CLIPathCmdFlag> flags,
String fmt,
Object... args)
Returns a string representing the C/I style CLI command that can be
associated with the given path.
|
String |
CLIPrompt(int usid,
String prompt,
boolean echo)
Prompts user for a string.
|
String |
CLIPrompt(int usid,
String prompt,
boolean echo,
int timeout)
Prompts user for a string.
|
String |
CLIPromptOneOf(int usid,
String prompt,
String[] choice)
Prompt user for one of the strings given in the choice parameter.
|
String |
CLIPromptOneOf(int usid,
String prompt,
String[] choice,
int timeout)
Prompt user for one of the strings given in the choice parameter.
|
String |
CLIReadEOF(int usid,
boolean echo)
Read a multi line string from the CLI.
|
String |
CLIReadEOF(int usid,
boolean echo,
int timeout)
Read a multi line string from the CLI.
|
void |
CLIWrite(int usid,
String buf)
Write to the CLI.
|
CommitQueueResult |
commitQueueResult(int tid,
int timeout)
Deprecated.
Use
Maapi.applyTransParams(int, boolean, CommitParams) instead.
This method must be called if applyTrans() or prepareTrans() was
called, and one of the flags Maapi.COMMIT_NCS_COMMIT_QUEUE_ASYNC or
Maapi.COMMIT_NCS_COMMIT_QUEUE_SYNC was set, and must not be called
otherwise.
If the transaction did not result in a commit queue entry (e.g.,
it didn't involve any devices) the function returns a
CommitQueueResult with its status set to NCS_COMMIT_QUEUE_NONE.
Otherwise, if Maapi.COMMIT_NCS_COMMIT_QUEUE_ASYNC was set, the
function returns a CommitQueueResult with its status set to
NCS_COMMIT_QUEUE_ASYNC, and its queue_id set to the commit queue id.
Otherwise, if Maapi.COMMIT_NCS_COMMIT_QUEUE_SYNC was set, the
function waits at most timeout seconds for the commit queue
item to be sent to the devices. If the result was successful,
it returns a CommitQueueResult with its status set to
NCS_COMMIT_QUEUE_SYNC. If the timer expires, it returns a
CommitQueueResult with its status set to
NCS_COMMIT_QUEUE_TIMEOUT, and its queue_id set to the commit
queue id. If the result was unsuccessful, an exception is raised.
If any of the devices in the queue item returns an error
the status is set to NCS_COMMIT_QUEUE_FAILED. If the queue item
is deleted before execution the status is set to
NCS_COMMIT_QUEUE_DELETED. |
void |
commitTrans(int tid)
Commit a transaction specified by transaction handle tid.
|
void |
commitUpgrade()
Note, This method is only applicable for Confd.
|
int |
confirmedCommitInProgress()
Checks whether a confirmed commit is pending.
|
void |
copy_tree(int tid,
boolean useSharedCreate,
ConfPath from,
ConfPath to)
Deprecated.
Use
Maapi.copyTree(int, boolean, ConfPath, ConfPath) instead. |
void |
copy_tree(int tid,
ConfPath from,
ConfPath to)
Deprecated.
Use
Maapi.copyTree(int, ConfPath, ConfPath) instead. |
void |
copy(int thfrom,
int thto)
If we open two transactions from the same user sessions but towards
different data stores, such as one transaction towards the candidate and
one towards running, we can copy all data from one data store to the
other with this method.
|
void |
copyPath(int fromTh,
int toTh,
ConfPath path)
Similar to
Maapi.copy(int, int), but does a replacing copy only
of the subtree rooted at the path given by path |
void |
copyRunningToStartup()
Copies running to startup.
|
void |
copyTree(int tid,
boolean useSharedCreate,
ConfPath from,
ConfPath to)
This function is used to copy an entire subtree in the configuration from
one point to another.
|
void |
copyTree(int tid,
ConfPath from,
ConfPath to)
Equivalent to
Maapi#copyTree(int, false, ConfPath, ConfPath)
ie., for use outside fastmap, without 'shared' create/set |
void |
create(int tid,
ConfPath path)
Create an entity in the XML tree.
|
void |
create(int tid,
String fmt,
Object... arguments)
Create a new list entry in the XML tree.
|
void |
delete(int tid,
ConfPath path)
Deletes a node and all its children from the XML data tree.
|
void |
delete(int tid,
String fmt,
Object... arguments)
Deletes a node and all its children from the XML data tree.
|
void |
deleteAll(int th,
MaapiDeleteAllFlag how)
This function can be used to delete "all" configuration data within
a transaction.
|
void |
deleteConfig(int db)
This function empties a data store.
|
ConfObject[][] |
deref(int tid,
String fmt,
Object... arguments)
This method dereferences a leafref and returns a list of the objects the
leafref "points" to.
|
void |
detach(int tid)
Detaches an attached MAAPI socket.
|
void |
diffIterate(int tid,
MaapiDiffIterate iter)
Iterates through the transaction diff.
|
void |
diffIterate(int tid,
MaapiDiffIterate iter,
Object initstate,
String fmt,
Object... args)
Iterates through the transaction diff.
|
void |
diffIterate(int tid,
MaapiDiffIterate iter,
String fmt,
Object... args)
Iterates through the transaction diff.
|
void |
diffIterate(int tid,
Object initstate,
EnumSet<DiffIterateFlags> flags,
MaapiDiffIterate iter,
ConfPath path)
Iterates through the transaction diff.
|
void |
disconnectRemote(String address)
Disconnect all remote connections between CONFD_IPC_PORT (see the IPC
section in the Advanced Topics chapter in the User Guide) and address.
|
void |
disconnectSockets(int[] sockets)
This function is an alternative to
disconnectRemote()
that can be useful in particular when using the "External IPC"
functionality (see "Using a different IPC mechanism" in the ConfD IPC
section in the Advanced Topics chapter in the User Guide). |
boolean |
doDisplay(int tid,
String fmt,
Object... args)
If the data model uses the YANG 'when' or 'tailf:display-when'
statement, this function can be used to determine if the item
given by the path in fmt should be displayed or not.
|
void |
endUserSession()
Ends the current user session on this
Maapi instance. |
boolean |
exists(int tid,
ConfPath path)
Boolean function which return 1 or 0 if a path defines an existing
element in the XML data tree.
|
boolean |
exists(int tid,
String fmt,
Object... arguments) |
ConfKey |
findNext(MaapiCursor c,
ConfFindNextType type,
ConfKey key)
The findNext method makes it possible to jump forward to an element
in the model at a position defined by the MaapiCursor
After the findNext call the same MaapiCursor can be used in subsequent
getNext calls.
|
void |
finishTrans(int tid)
Finish the transaction specified by transaction handle tid.
|
ConfAttributeValue[] |
getAttrs(int tid,
ConfAttributeType[] attribs,
String fmt,
Object... args)
Retrieve attributes for a configuration node.
|
String[] |
getAuthorizationInfo(int usid)
This method retrieves authorization info for a user session, i.e.
|
static ArrayList<ConfNamespace> |
getAutoNsList() |
static ArrayList<ConfNamespace> |
getAutoNsList(ArrayList<ConfNamespace> defaultNsList) |
ConfTag |
getCase(int tid,
String choice,
ConfPath path) |
ConfTag |
getCase(int tid,
String choice,
String fmt,
Object... arguments)
This returns the current 'case' for a 'choice' construct.
|
CLIInteraction |
getCLIInteraction(int usid)
Get CLIInteraction object which enables communication with the user via
the CLI.
|
String |
getCwd(int tid)
Returns the current position as previously set by Maapi.cd(),
Maapi.pushd(), or Maapi.popd() as a String.
|
ConfPath |
getCwdPath(int tid)
Returns the current position like Maapi.getCwd(), but as a ConfPath
instead of as a String.
|
ConfValue |
getElem(int tid,
ConfPath path) |
ConfValue |
getElem(int tid,
String fmt,
Object... arguments)
This reads a value from the path in fmt and returns the result.
|
List<String> |
getMountId(int tid,
ConfPath path) |
int |
getMyUserSession()
Returns the usid associated with this
Maapi |
ConfKey |
getNext(MaapiCursor c)
Iterates and gets the keys for the next element pinpointed by the
MaapiCursor initially retrieved by
Maapi.newCursor(int, String, Object...). |
ArrayList<ConfNamespace> |
getNsList()
Get a list of the installed namespaces retrieved from the loaded
MaapiSchemas. |
int |
getNumberOfInstances(int tid,
ConfPath path) |
int |
getNumberOfInstances(int tid,
String fmt,
Object... arguments)
Return the number of instances in a list.
|
ConfObject[] |
getObject(int tid,
String fmt,
Object... arguments)
This reads a container object or a list entry object from the path in fmt
and returns the result.
|
List<ConfObject[]> |
getObjects(MaapiCursor c,
int numOfObjects,
int numOfInstances)
Get several list instances with one request.
|
int |
getRollbackId(int tid)
Get rollback id for committed transaction specified by
transaction handle tid.
|
int |
getRunningDbStatus()
Query ConfD/NCS for its consistency state.
|
static MaapiSchemas |
getSchemas()
Returns the currently loaded schema.
|
Socket |
getSocket() |
CommitParams |
getTransParams(int tid)
Get commit parameters for a transaction.
|
MaapiUserSession |
getUserSession(int usid)
Return a
MaapiUserSession given by the usid. |
MaapiUserSessionId |
getUserSessionIdentification(int usid)
This method can be used to retrieve additional identification
information for a user session (if available - ie., if it has been
provided by the northbound client).
|
String |
getUserSessionOpaque(int usid)
If the user session has "opaque" information provided by the
northbound client (see the -O option in
confd_cli),
the opaque information can be retrieved using this method. |
int[] |
getUserSessions()
Return all user sessions id's currently connected to ConfD/NCS.
|
<T extends ConfXMLParam> |
getValues(int tid,
T[] params,
ConfPath path)
Read an arbitrary set of sub-elements of a container element.
|
<T extends ConfXMLParam> |
getValues(int tid,
T[] params,
String fmt,
Object... arguments)
Read an arbitrary set of sub-elements of a container element.
|
<T extends List<ConfXMLParam>> |
getValues(int tid,
T params,
ConfPath path)
Read an arbitrary set of sub-elements of a container element.
|
<T extends List<ConfXMLParam>> |
getValues(int tid,
T params,
String fmt,
Object... arguments)
Read an arbitrary set of sub-elements of a container element.
|
void |
initUpgrade(int timeoutsecs,
int flags)
Note, This method is only applicable for Confd.
|
void |
insert(int tid,
boolean createBackPointer,
String fmt,
Object... arguments)
This function inserts a new element in an ordered list of elements.
|
void |
insert(int tid,
String fmt,
Object... arguments) |
boolean |
isCandidateModified()
Returns true if candidate has been modified, i.e if there are pending non
committed changes to the candidate data store.
|
int |
isLockSet(int db)
This methods checks if a lock is taken or not.
|
boolean |
isRunningModified()
Returns true if running has been modified since the last copy to startup,
false if it has not been modified.
|
void |
iterate(int tid,
Object initstate,
EnumSet<ConfIterateFlags> flags,
MaapiIterate iter,
ConfPath path)
Iterates through all the data in a transaction.
|
void |
killUserSession(int usid)
Ends another users session, effectively logging out that user.
|
MaapiRollback[] |
listRollback()
Get list of available rollback files.
|
void |
loadConfig(int tid,
EnumSet<MaapiConfigFlag> flags,
String filename)
This function loads a configuration from filename into the server.
|
void |
loadConfigCmds(int tid,
EnumSet<MaapiConfigFlag> flags,
String cmds,
String fmt,
Object... arguments)
This function loads a configuration from a string into the server.
|
MaapiOutputStream |
loadConfigStream(int tid,
EnumSet<MaapiConfigFlag> flags)
Load configuration from a
OuputStream into ConfD/NCS. |
void |
loadRollback(int tid,
int nr)
Load rollback file into a given transaction.
|
void |
loadRollbackFixed(int tid,
int fixed_nr)
Load rollback file into a given transaction using the fixed
number.
|
MaapiSchemas |
loadSchemas()
Load Schemas method that downloads all schemas from server into a
MaapiSchemas container, from which specified schemas can be accessed and
traversed.
|
MaapiSchemas |
loadSchemas(String[] namespaceURIs)
Load Schemas method that downloads a specified number of schemas
the server into a MaapiSchemas container, from which specified schemas
can be accessed and transversed.
|
void |
lock(int db)
This function is used to take a lock on one of the databases.
|
int |
lockPartial(int db,
String xpath)
Same as
Maapi.lockPartial(int,String[]) except only one xpath
expression is given. |
int |
lockPartial(int db,
String[] xpaths)
It is possible to manipulate partial locks on the databases, i.e.
|
void |
move(int tid,
ConfKey tokey,
String fmt,
Object... arguments)
This function moves an existing object.
|
void |
move(int tid,
String tokey,
String fmt,
Object... arguments)
This function moves an existing object
|
void |
moveOrdered(int tid,
MoveWhereFlag where,
ConfKey tokey,
String fmt,
Object... arguments)
For a list with the YANG ordered-by user statement, this function can be
used to change the order of entries, by moving one entry to a new
position.
|
void |
ncsApplyTemplate(int tid,
String template,
ConfPath rootIKP,
Properties variables,
boolean createShared,
boolean createBackpointer) |
void |
ncsApplyTemplate(int tid,
String template,
ConfPath rootIKP,
Properties variables,
String document,
boolean createShared,
boolean createBackpointer) |
String[] |
ncsGetTemplateVariables(String template) |
void |
ncsMovePrivateData(int initTid,
ConfPath from,
ConfPath to)
Used in service data migrations, after config data has been moved in
the data upgrade, also the service ncs specific private data has to be
moved.
|
Set<String> |
ncsTemplates() |
void |
netconfSSHCallHome(ConfObject host,
int port)
Request that ConfD daemon initiates a NETCONF SSH Call Home
connection (see RFC 8071) to the NETCONF client running on
host.
|
void |
netconfSSHCallHomeOpaque(ConfObject host,
String opaque,
int port)
Request that ConfD daemon initiates a NETCONF SSH Call Home
connection (see RFC 8071) to the NETCONF client running on
host.
|
MaapiCursor |
newCursor(int tid,
ConfPath path)
Creates a cursor for a list specified by
path |
MaapiCursor |
newCursor(int tid,
String fmt,
Object... arguments)
Creates a cursor for a list specified by
fmt. |
MaapiCursor |
newCursorWithFilter(int tid,
String filter,
ConfPath path)
Creates a cursor for a list specified by
path with an XPath
filter specified by filter. |
MaapiCursor |
newCursorWithFilter(int tid,
String filter,
String fmt,
Object... arguments)
Creates a cursor for a list specified by
fmt with an XPath
filter specified by filter. |
void |
performUpgrade(String[] loadpathdirs)
Note, This method is only applicable for Confd.
|
void |
popd(int tid)
Pops the top position of the directory stack and changes directory
|
void |
prepareTrans(int tid)
Prepares the transaction specified by transaction handle tid.
|
void |
prepareTrans(int tid,
int flags)
Prepares the transaction specified by transaction handle tid.
|
void |
prioMessage(String to,
String message)
Send a high priority message to a specific user, a specific user session
or all users depending on the to parameter.
|
void |
pushd(int tid,
String fmt,
Object... arguments)
Behaves like cd() with the exception that we can subsequently call popd()
and return to the previous position in the XML data tree.
|
<T extends ResultType> |
queryStart(int tid,
String expr,
String context,
int chunkSize,
int offset,
List<String> select,
Class<T> cls)
Initiate (or starts) a new XPath query attached to the
transaction given in
tid. |
<T extends ResultType> |
queryStart(int tid,
String expr,
String context,
int chunkSize,
int offset,
List<String> select,
List<String> sort,
boolean reverseSortOrder,
Class<T> cls)
Initiate (or starts) a new XPath query attached to the
transaction given in
th. |
void |
reloadConfig()
Request that the daemon reloads its configuration files.
|
MaapiSchemas |
reloadSchemas()
This method throws away any old MaapiSchemas container and downloads a
new from the server.
|
MaapiSchemas |
reloadSchemas(String[] namespaceURIs)
This method throws away any old MaapiSchemas container and downloads a
new from the server.
|
void |
reopenLogs()
Request that the daemon closes and re-opens its log files
|
void |
reportProgress(int tid,
Maapi.Verbosity verbosity,
String msg)
Report progress of an action or transaction.
|
void |
reportProgress(int tid,
Maapi.Verbosity verbosity,
String msg,
String packageName)
Report progress of an action or transaction.
|
Maapi.Progress |
reportProgressStart(int tid,
Maapi.Verbosity verbosity,
String msg,
String packageName)
Report progress of an action or transaction.
|
void |
reportProgressStop(Maapi.Progress progress)
Report progress of an action or transaction.
|
void |
reportProgressStop(Maapi.Progress progress,
String annotation)
Report progress of an action or transaction.
|
void |
reportServiceProgress(int tid,
Maapi.Verbosity verbosity,
String msg,
String packageName,
ConfPath servicePath)
Report transaction progress events for a FASTMAP service.
|
Maapi.Progress |
reportServiceProgressStart(int tid,
Maapi.Verbosity verbosity,
String msg,
String packageName,
ConfPath servicePath)
Report transaction progress events for a FASTMAP service.
|
void |
reportServiceProgressStop(Maapi.Progress progress)
Report transaction progress events for a FASTMAP service.
|
void |
reportServiceProgressStop(Maapi.Progress progress,
String annotation)
Report transaction progress events for a FASTMAP service.
|
ConfXMLParam[] |
requestAction(ConfXMLParam[] params,
int nshash,
String fmt,
Object... arguments)
Same as
Maapi.requestAction(ConfXMLParam[], String, Object...)
Since actions are not associated with transactions, the
namespace hash nshash must be provided and the path
to the action, i.e. |
ConfXMLParam[] |
requestAction(ConfXMLParam[] params,
String fmt,
Object... arguments)
Invokes an action defined in the data model annotated with
tailf:action (see tailf_yang_extensions(5)). |
ConfXMLParam[] |
requestAction(List<ConfXMLParam> params,
int nshash,
String fmt,
Object... arguments) |
ConfXMLParam[] |
requestAction(List<ConfXMLParam> params,
String fmt,
Object... arguments)
Same as
Maapi.requestAction(ConfXMLParam[], String, Object...)
with the difference that the params is List
instead of ConfXMLParam array. |
ConfXMLParam[] |
requestActionTh(int tid,
ConfXMLParam[] params,
String fmt,
Object... arguments)
Same as
Maapi.requestAction(ConfXMLParam[], String, Object...)
with the difference that the fmt is not required to have a namespace
prefix in the root tag. |
ConfXMLParam[] |
requestActionTh(int tid,
List<ConfXMLParam> params,
String fmt,
Object... arguments) |
void |
revert(int tid)
Remove all changes in the transaction.
|
MaapiInputStream |
rollbackConfig(int tid,
String fmt,
String... args)
This function can be used to save the equivalent of a rollback file for a
given configuration before it is committed (or a subtree thereof) in
curly bracket format.
|
void |
safeCreate(int tid,
ConfPath path)
Create a new list entity in the XML tree.
|
void |
safeCreate(int tid,
String fmt,
Object... arguments)
Create a new entity in the XML tree.
|
void |
safeDelete(int tid,
String fmt,
Object... arguments)
Deletes a node and all its children from the XML data tree.
|
ConfValue |
safeGetElem(int tid,
ConfPath path)
Reads a value from the
path specified |
ConfValue |
safeGetElem(int tid,
String fmt,
Object... arguments)
This reads a value from the path in fmt and returns the result.
|
ConfObject[] |
safeGetObject(int tid,
String fmt,
Object... arguments)
This is a variant of getObject() that returns null if the object doesn't
exist
|
MaapiInputStream |
saveConfig(int tid,
EnumSet<MaapiConfigFlag> flags)
Save the entire config in different formats.
|
MaapiInputStream |
saveConfig(int tid,
EnumSet<MaapiConfigFlag> flags,
ConfPath path)
Save the subtree in different formats.
|
MaapiInputStream |
saveConfig(int tid,
EnumSet<MaapiConfigFlag> flags,
String fmt,
Object... args)
Save the subtree in different formats, with ability to XPath Filtering.
|
void |
setAttr(int tid,
ConfAttributeValue attr,
String fmt,
Object... args)
Set an attribute for a configuration node.
|
void |
setComment(int tid,
String comment)
Set the "Comment" that is stored in the rollback file when a
transaction towards running is committed.
|
boolean |
setDelayedWhen(int tid,
boolean on)
This function enables/disables the "delayed when" mode of a transaction.
|
void |
setElem(int tid,
ConfObject value,
ConfPath path)
Set value to a leaf node.
|
void |
setElem(int tid,
ConfObject value,
String fmt,
Object... arguments)
Set value to a leaf node.
|
void |
setElem(int tid,
String value,
ConfPath path)
Set value to a leaf node.
|
void |
setElem(int tid,
String value,
String fmt,
Object... arguments)
Set value to a leaf node.
|
void |
setFlags(int tid,
EnumSet<MaapiFlag> flags)
This method can modify some aspects of the read/write session, see
MaapiFlag The flags are an Enumset of
MaapiFlag |
void |
setLabel(int tid,
String label)
Set the "Label" that is stored in the rollback file when a
transaction towards running is committed.
|
void |
setNamespace(int tid,
int nsid) |
void |
setNamespace(int tid,
String ns)
Before can invoke any of read or write functions, we must indicate which
namespace we are going to use.
|
void |
setNextUserSessionId(int usid)
Set the user session id that will be assigned to the next user session
started.
|
void |
setObject(int tid,
ConfObject[] values,
String fmt,
Object... arguments)
This writes a container object or a list entry object from the path in
fmt and returns the result.
|
void |
setReadOnlyMode(boolean flag)
Control if the node should accept write transactions
|
void |
setRunningDbStatus(int status)
Explicitly sets the systems notion of the consistency
state.
|
void |
setUserSession(int usid)
Associate this Maapi instance with an already existing user session.
|
void |
setValues(int tid,
ConfXMLParam[] params,
ConfPath path)
Set arbitrary sub-elements of a container element in one bulk operation.
|
void |
setValues(int tid,
ConfXMLParam[] params,
String fmt,
Object... arguments)
Set arbitrary sub-elements of a container element in one bulk operation.
|
void |
setValues(int tid,
List<ConfXMLParam> params,
ConfPath path)
Set arbitrary sub-elements of a container element in one bulk operation.
|
void |
setValues(int tid,
List<ConfXMLParam> params,
String fmt,
Object... arguments)
Set arbitrary sub-elements of a container element in one bulk operation.
|
void |
sharedCreate(int tid,
boolean createBackpointer,
ConfPath path)
Deprecated.
|
void |
sharedCreate(int tid,
ConfPath path) |
void |
sharedCreate(int tid,
String fmt,
Object... arguments) |
void |
sharedSetElem(int tid,
ConfObject value,
ConfPath path)
Set value to a leaf node from NCS FastMap code.
|
void |
sharedSetElem(int tid,
ConfObject value,
String fmt,
Object... arguments)
Set value to a leaf node from NCS FastMap code
This method is the equivalent of setElem() except that it
can only be called from NCS FastMap service code.
|
void |
sharedSetElem(int tid,
String value,
String fmt,
Object... arguments)
Set value to a leaf node from NCS FastMap code.
|
void |
sharedSetValues(int tid,
ConfXMLParam[] params,
boolean createBackpointer,
ConfPath path)
|
void |
sharedSetValues(int tid,
ConfXMLParam[] params,
ConfPath path)
Set arbitrary sub-elements of a container element in one bulk operation
from NCS FastMap code.
|
void |
sharedSetValues(int tid,
ConfXMLParam[] params,
String fmt,
Object... arguments)
Set arbitrary sub-elements of a container element in one bulk operation
from NCS FastMap code.
|
void |
sharedSetValues(int tid,
List<ConfXMLParam> params,
ConfPath path)
Set arbitrary sub-elements of a container element in one bulk operation
from NCS FastMap code.
|
void |
sharedSetValues(int tid,
List<ConfXMLParam> params,
String fmt,
Object... arguments)
Set arbitrary sub-elements of a container element in one bulk operation
from NCS FastMap code.
|
void |
snmpaReload(boolean synchronous)
When the ConfD/NCS SNMP Agent config tree is implemented by an external
data provider, this method can be used by the data provider to notify
ConfD/NCS when there is a change to the data.
|
void |
snmpSendNotification(String notifName,
String notifyTarget,
String ctxName,
SnmpVarbind[] varbinds)
Send SNMP notification.
|
void |
startPhase(int phase)
Once the ConfD/NCS daemon has been started in phase0 it is possible to
use this function to tell the daemon to proceed to startPhase 1 or 2.
|
void |
startPhase(int phase,
boolean synchronous)
Once the ConfD/NCS daemon has been started in phase0 it is possible to
use this function to tell the daemon to proceed to start phase 1 or 2.
|
int |
startTrans(int dbname,
int mode)
Start a new transaction towards the specified database
dbname with a transaction mode mode. |
int |
startTrans(int dbname,
int mode,
String vendor,
String product,
String version,
String clientId) |
int |
startTrans2(int dbname,
int mode,
int usid)
Start a new transaction towards database within an existing
user session specified by
usid. |
int |
startTransFlags(int dbname,
int mode,
int usid,
EnumSet<MaapiFlag> flags)
Start a new transaction towards the specified database
dbname with a transaction mode mode with
additional flags to control read/write sessions. |
int |
startTransInTrans(int mode,
int usid,
int tid)
Start a new transaction within an existing user session and another
transaction as backend
|
void |
startUserSession(String user,
InetAddress srcip,
String context,
String[] groups,
MaapiUserSessionFlag proto)
Establish a new user session on this
Maapi instance. |
void |
startUserSession(String user,
InetAddress srcip,
String context,
String[] groups,
MaapiUserSessionFlag proto,
String vendor,
String product,
String version,
String clientId) |
void |
stop()
Requests that the daemon stops, returns when daemon has stopped.
|
void |
stop(boolean synchronous)
Stops the daemon.
|
void |
sysMessage(String to,
String message)
Send a message to a specific user, a specific user session or all users
depending on the to parameter.
|
String |
toString() |
void |
unlock(int db)
This function releases a lock previously acquired using the lock()
method.
|
void |
unlockPartial(int lockId)
This methods releases a lock previously acquired using the lockPartial()
method.
|
void |
userMessage(String to,
String message,
String sender)
Send a message to a specific user, a specific user session or all users
depending on the to parameter.
|
String[] |
validateToken(String token,
InetAddress srcAddr,
int srcPort,
String context,
MaapiUserSessionFlag proto)
If external token validation (see /confdConfig/aaa/externalValidation)
is in use, this method can be used to ask ConfD/NSO to validate such
a token.
|
void |
validateTrans(int tid,
boolean unlock,
boolean force)
Validates a transaction specified by transaction handle tid
|
void |
waitStart(int phase)
Wait until the daemon has completed a certain start phase.
|
void |
waitStarted()
Wait until the daemon is fully started, i.e.
|
ConfPath |
xpath2kpath_th(int tid,
String xpath) |
ConfPath |
xpath2kpath(String xpath)
Convert a XPath path to a ConfPath object.
|
void |
xpathEval(int tid,
MaapiXPathEvalResult xpatheval,
MaapiXPathEvalTrace xpathtrace,
String expr,
Object initstate,
String fmt,
Object... arguments)
Evaluated the xpath expression as supplied in by
expr. |
String |
xpathEvalExpr(int tid,
String expr,
MaapiXPathEvalTrace xpathtrace,
String fmt,
Object... arg)
Evaluate the xpath expression given in
expr parameter
and return the result as a string. |
public static final int IA_CLIENT_MAAPI
public static final int MAAPI_UPGRADE_KILL_ON_TIMEOUT
@Deprecated public static final int COMMIT_NCS_BYPASS_COMMIT_QUEUE
public static final int COMMIT_NCS_ASYNC_COMMIT_QUEUE
public static final int COMMIT_NCS_SYNC_COMMIT_QUEUE
@Deprecated public static final int COMMIT_NCS_NO_FASTMAP
public static final int COMMIT_NCS_NO_REVISION_DROP
Maapi.applyTrans(int,boolean,int)
Maapi.prepareTrans(int,int)public static final int COMMIT_NCS_NO_DEPLOY
public static final int COMMIT_NCS_NO_NETWORKING
public static final int COMMIT_NCS_NO_OUT_OF_SYNC_CHECK
public static final int COMMIT_NCS_COMMIT_QUEUE_BYPASS
public static final int COMMIT_NCS_COMMIT_QUEUE_ASYNC
public static final int COMMIT_NCS_COMMIT_QUEUE_SYNC
public static final int COMMIT_NCS_NO_OVERWRITE
public static final int COMMIT_NCS_COMMIT_QUEUE_LOCK
public static final int COMMIT_NCS_COMMIT_QUEUE_BLOCK_OTHERS
public static final int COMMIT_NCS_COMMIT_QUEUE_ATOMIC
public static final int COMMIT_NCS_COMMIT_QUEUE_NONATOMIC
public static final int COMMIT_NCS_COMMIT_QUEUE_CONTINUE_ON_ERROR
public static final int COMMIT_NCS_COMMIT_QUEUE_ROLLBACK_ON_ERROR
public static final int COMMIT_NCS_COMMIT_QUEUE_STOP_ON_ERROR
public static final int COMMIT_NCS_USE_LSA
public static final int COMMIT_NCS_NO_LSA
public static final int COMMIT_NCS_RECONCILE_KEEP_NON_SERVICE_CONFIG
public static final int COMMIT_NCS_RECONCILE_DISCARD_NON_SERVICE_CONFIG
public Maapi(Socket socket) throws IOException, ConfException
Maapi supplying a established
open socket to ConfD/NCS daemon.
Since the ConfD/NCS daemon expects initialization within
5 seconds after a new socket is established this constructor should be
called directly for a new socket. For instance:
// int port = Conf.PORT for ConfD or Conf.NCS_PORT for NCS
Maapi maapi = new Maapi(new Socket("localhost", port));
When establishing a connection to ConfD/NCS the
MaapiSchemas will be loaded once automatically
by the library.
If encrypted communication towards ConfD/NCS is desired, an environment variable "CONFD_IPC_ACCESS_FILE" or "NCS_IPC_ACCESS_FILE" need to be set. This variable is expected to point to a file containing a secret salt. example: export CONFD_IPC_ACCESS_FILE=./secret_file.txt An alternative to the environment variable is to set an java system property with the same name pointing to the file.
socket - A socket connected to ConfD/NCS.ConfException - If ConfD/NCS refuses to establish
connection the reason could be obtained through
Throwable.getMessage()IOException - signals I/O exception on the underlying socketpublic ArrayList<ConfNamespace> getNsList()
MaapiSchemas. The underlying socket is not required to
be open for this operation.public void startUserSession(String user, InetAddress srcip, String context, String[] groups, MaapiUserSessionFlag proto) throws IOException, ConfException
Maapi instance.
Once we have created a Maapi communication instance,
we must also establish a user session.
It is up to the user of the Maapi class to
authenticate users.
Maapi can be used to to perform the actual
authentication through a call to Maapi.authenticate(String,String)
but authentication may very well occur through some other
external means.
Thus, when we use this function to create a user session, we must provide all relevant information about the user. If we wish to execute read/write transactions over the MAAPI interface, we must first have an established user session.
A user session corresponds to a NETCONF manager who has just established an authenticated SSH connection, but not yet sent any NETCONF commands on the SSH connection.
The user string is the login name of the user.
The user name is used when setting up the AAA environment for the
session.
The srcip address specifies from where
did the session originate.
The context parameter can be any string which is
precisely the context string which will be
used to authorize all data access through the AAA system.
Each AAA rule has a context string which must match in order for a
AAA rule to match. (See the AAA chapter in the User Guide).
Using the string "system" for context has special significance:
'confd --status' or
'ncs --status', nor 'show users' in CLI etc.
It is not possible to create new user sessions until the system has reached start phase 2 with the above exception of a session with the context set to "system".
The photo parameter specifies the protocol used
by the user for connecting to the device. Can be
one of MaapiUserSessionFlag.PROTO_SSH,
MaapiUserSessionFlag.PROTO_CONSOLE,
MaapiUserSessionFlag.PROTO_TCP, and
MaapiUserSessionFlag.PROTO_SSL
user - Login name of usersrcip - Source ip where the user session originatecontext - The context string parameter stated discussed above.groups - An array of AAA groups that the user belongs to.proto - Protocol used by the user for connecting to the device..MaapiException - If ConfD/NCS could not create a new
session based on the parameters. To get detailed message
use Throwable.getMessage()Signals - I/O exception on the underlying socketIOExceptionConfExceptionpublic void startUserSession(String user, InetAddress srcip, String context, String[] groups, MaapiUserSessionFlag proto, String vendor, String product, String version, String clientId) throws IOException, ConfException
IOExceptionConfExceptionpublic void endUserSession()
throws IOException,
ConfException
Maapi instance.
If the Maapi socket is closed, the user
session is automatically ended.
MaapiException - If there is no current session on this
Maapi instanceIOException - Signals I/O exception on the underlying
socketConfExceptionpublic void killUserSession(int usid)
throws IOException,
ConfException
usid - ID of session to terminateMaapiException - If the session with the ID
did not existsIOException - Signals I/O exception on the underlying
socketConfExceptionpublic MaapiUserSession getUserSession(int usid) throws IOException, ConfException
MaapiUserSession given by the usid.usid - ID of session to retrieveMaapiException - If the user session with the given
ID does not exitsIOException - Signals I/O exception on the underlying
socketConfExceptionpublic int[] getUserSessions()
throws IOException,
ConfException
MaapiException - -IOException - Signals I/O exception on the underlying
socketConfExceptionpublic int getMyUserSession()
throws IOException,
ConfException
MaapiMaapiException - If no user session exists on this
Maapi socketIOException - Signals some I/O exception on the underlying
socketConfExceptionpublic MaapiUserSessionId getUserSessionIdentification(int usid) throws ConfException, IOException
usid - Session idMaapiUserSessionId object with the fields
vendor, product, version and clientId.ConfExceptionIOExceptionMaapiExceptionpublic String getUserSessionOpaque(int usid) throws ConfException, IOException
confd_cli),
the opaque information can be retrieved using this method.usid - User session idConfExceptionIOExceptionpublic void setNextUserSessionId(int usid)
throws ConfException,
IOException
usid - The session id to assign for the next user sessionConfExceptionIOExceptionpublic String[] validateToken(String token, InetAddress srcAddr, int srcPort, String context, MaapiUserSessionFlag proto) throws ConfException, IOException
token - The token to validatesrcAddr, - @param srcPort, @param context @param proto
extra information passed to the token validation executable
(see /confdConfig/aaa/externalValidation/includeExtra)ConfExceptionIOExceptionpublic int startTrans(int dbname,
int mode)
throws IOException,
ConfException
dbname with a transaction mode mode.
The main purpose of MAAPI is to provide read and write access into the transaction manager. Regardless of whether data is kept in CDB or in some* (or several) external data bases, the same API is used to access data.
ConfD/NCS acts as a mediator and multiplexes the different commands to the code which is responsible for each individual data element.
This function creates a new transaction towards a specified data
base. If successful, it returns a new transaction identifier,
a tid which must be used as a parameter in most of the
Maapi methods which manipulate the transaction.
We will drive this transaction forward through the different states a
transaction goes through. If an external database is used, and it has
registered callback functions for the different transaction states, those
callbacks will be called when we in MAAPI invoke the different MAAPI
transaction manipulation functions. For example when we call
startTrans the init callback will be invoked
in all external databases. If data is kept in CDB, the system will
handle everything internally.
The parameter dbname is supplied using on of
Conf.DB_STARTUP,Conf.DB_RUNNING,Conf.DB_CANDIDATE
Transaction mode mode is supplied using
Conf.MODE_READ, to start a read only transaction
Conf.MODE_READ_WRITE to start a read write transaction.
A read only transaction will incur less resource usage, thus if no
writes will be done (e.g. the purpose of the transaction is only
to read operational data), it is best to use
Conf.MODE_READ.
There are also some cases where starting a read-write transaction is not allowed, e.g. if we start a transaction towards the running data store is set to "writable-through-candidate" in confd.conf/ncs.conf, or if ConfD/NCS is running in HA slave mode.
dbname - Database that the transaction should operate on.mode - Read or write mode.MaapiException - If the transaction could not be started
see the Throwable.getMessage()IOException - Signals I/O exception on the underlying socketConfExceptionpublic int startTrans(int dbname,
int mode,
String vendor,
String product,
String version,
String clientId)
throws IOException,
ConfException
IOExceptionConfExceptionpublic int startTrans2(int dbname,
int mode,
int usid)
throws IOException,
ConfException
usid.
If we want to start new transactions inside actions, we can use this function to execute the new transaction within the existing user session.
See Maapi.startTrans(int,int) for available
options on dbname and mode mode.
dbname - Database that the transaction should operate onmode - Read or write modeusid - The user session idMaapiException - If the transaction could not be started
see the Throwable.getMessage()IOException - Signals I/O exception on the underlying socketConfExceptionpublic int startTransFlags(int dbname,
int mode,
int usid,
EnumSet<MaapiFlag> flags)
throws IOException,
ConfException
dbname with a transaction mode mode with
additional flags to control read/write sessions.
This method makes it possible to provide flags that can otherwise be
used with Maapi.setFlags(int,EnumSet) already when starting a
transaction, as well as setting the MaapiFlag.HIDE_INACTIVE
flag that can only be used with this function.
Otherwise its has functionality equivalent to Maapi.startTrans2().
dbname - Database that the transaction should operate on. Possible
values are STARTUP, RUNNING, CANDIDATEmode - Read or write mode. Possible values are READ and READ_WRITEusid - User session idflags - EnumSet of MaapiFlag values.IOExceptionConfExceptionpublic int startTransInTrans(int mode,
int usid,
int tid)
throws IOException,
ConfException
mode - Read or write mode. Possible values are READ and READ_WRITEusid - User session idtid - Backend transaction idMaapiExceptionIOExceptionConfExceptionpublic void finishTrans(int tid)
throws IOException,
ConfException
If the transaction is implemented by an
external database, this will invoke the finish callback.
tid - Transaction id of transaction to terminate.MaapiExceptionIOExceptionConfExceptionpublic void attach(int tid,
int nsi,
int usid)
throws IOException,
ConfException
While a transaction is executing, we have a number of situations where we wish to invoke user Java code which can interact in the transaction. One such situation is when we wish to write semantic validation code which is invoked in the validation phase of a transaction.
This code needs to execute within the context of the executing transaction, it must thus have access to the "shadow" storage where all not-yet-committed data is kept.
This method attaches to a existing transaction. See user guide chapter "Semantic Validation" for example code.
Another situation where we wish to attach to the executing transaction is when we are using the notifications API and subscribe to notification of type NOTIF_COMMIT_DIFF and wish to read the committed diffs from the transaction.
tid - Transaction identifiernsi - Namespace identifier. Use 0 if we don't care which
namespace is the default to choose if path elements
are not properly prefixed.usid - UsidMaapiExceptionIOExceptionConfExceptionpublic void attach(int tid,
int nsi)
throws IOException,
ConfException
Maapi.attach(int, int, int) with the exception
that the User session id is implicit for the attached transaction.tid - Transaction identifiernsi - Namespace identifier. Use 0 if we don't care which
namespace is the default to choose if path elements
are not properly prefixed.IOExceptionConfExceptionpublic void attach(int tid,
String ns,
int usid)
throws IOException,
ConfException
While a transaction is executing, we have a number of situations where we wish to invoke user Java code which can interact in the transaction. One such situation is when we wish to write semantic validation code which is invoked in the validation phase of a transaction.
This code needs to execute within the context of the executing transaction, it must thus have access to the "shadow" storage where all not-yet-committed data is kept.
This method attaches to a existing transaction. See user guide chapter "Semantic Validation" for example code.
Another situation where we wish to attach to the executing transaction is when we are using the notifications API and subscribe to notification of type NOTIF_COMMIT_DIFF and wish to read the committed diffs from the transaction.
tid - Transaction identifierns - Namespace identifierusid - UsidMaapiExceptionIOExceptionConfExceptionpublic void attach(int tid,
String ns)
throws IOException,
ConfException
Maapi.attach(int, String, int) with the exception
that the User session id is implicit for the attached transaction.tid - Transaction identifierns - Namespace identifierIOExceptionConfExceptionpublic int attachInit()
throws IOException,
ConfException
This method is used to attach the Maapi socket to the special transaction available in phase0 used for CDB initialization and upgrade.
IOExceptionConfExceptionpublic void detach(int tid)
throws IOException,
ConfException
finish phase in validation code.
An attached MAAPI socket will be
automatically detached when the transaction terminates.
This method performs an explicit detach.tid - Transaction IdentifierMaapiExceptionIOExceptionConfExceptionpublic void applyTrans(int tid,
boolean keepOpen)
throws IOException,
ConfException
Invoking the transaction methods in exactly the right order can be a bit complicated.
The right order to invoke the methods is:
Maapi.validateTrans(int,boolean,boolean)Maapi.prepareTrans(int)Maapi.commitTrans(int)Maapi.abortTrans(int)Usually we do not require this fine grained control
over the two-phase commit protocol. It is easier to use
applyTrans
which validates, prepares and eventually aborts or commits.
A call to applyTrans must also eventually be
followed by a call to Maapi.finishTrans(int) which will terminate
the transaction.
For a readonly transaction, i.e. one started with
Conf.MODE_READ, or for a read-write transaction where we
haven't actually done any writes, we do not
need to call any of the validate/prepare/commit/abort or apply methods,
since there is nothing for them to do.
Calling finishTrans to terminate the
transaction is sufficient.
The parameter keepopen can optionally be set to true, then the changes to the transaction are not discarded if validation fails. This feature is typically used by management applications that wish to present the validation errors to an operator and allow the operator to fix the validation errors and then later retry the apply sequence.
tid - Transaction id of transaction to commitkeepOpen - If validation fails should the transaction be kept
open or notConfException - If the transaction is in badstate, for
example if applyTrans is called twice.IOExceptionpublic void applyTrans(int tid,
boolean keepOpen,
int flags)
throws IOException,
ConfException
Some NCS specific flags can be used:
Maapi.COMMIT_NCS_NO_REVISION_DROP means that NCS will not
run its data model revision algorithm, thus requiring all participating
managed devices to have all parts of the data models for all data
contained in this transaction, i.e., this flag forces NCS to never
silently drop any data set operations towards a device.
Maapi.COMMIT_NCS_NO_DEPLOY means that NCS will commit without
running the FASTMAP algorithm, i.e, write the
service instance data without activating the service(s).
The service(s) can later be re-deployed to write the
changes of the service(s) to the network.
Maapi.COMMIT_NCS_NO_NETWORKING means that the NCS device
manager will not see these changes. Even if transaction manipulates
data below /devices/device/config, nothing will be sent to the
managed devices. Thus this is a way to manipulate CDB in NCS without
generating any southbound traffic.
Maapi.COMMIT_NCS_NO_OUT_OF_SYNC_CHECK means that NCS will
continue with the transaction even if NCS detects that a device's
configuration is out of sync. The device's sync state is assumed
to be unknown after such commit and the stored transaction id
value is cleared.
Maapi.COMMIT_NCS_NO_OVERWRITE means that NCS will check
that the data that should be modified has not changed on the
device compared to NCS's view of the data. This is
fine-granular sync check; NCS verifies that NCS and the
device is in sync regarding the data that will be modified.
If they are not in sync, the transaction is aborted.
Maapi.COMMIT_NCS_ASYNC_COMMIT_QUEUE means that if some device
is non-operational or has data waiting in the commit queue, the data
in this transaction will be placed in the queue. If this flag is set
and the function returns ok, the function commitQueueResult() must
be called. commitQueueResult() will return the commit queue id for
the transaction, if any device was involved in the commit.
Maapi.COMMIT_NCS_SYNC_COMMIT_QUEUE means that if some device
is non-operational or has data waiting in the commit queue, the data
in this transaction will be placed in the queue. If this flag is set
and the function returns ok, the function commitQueueResult() must
be called. commitQueueResult() will wait for the transaction to be
committed to the devices, if any device was involved in the commit.
Maapi.COMMIT_NCS_BYPASS_COMMIT_QUEUE means that if
/devices/commit-queue/enabled-by-default is 'true' the
data in this transaction will bypass the commit queue.
The data will be written directly to the devices.
Maapi.COMMIT_NCS_COMMIT_QUEUE_LOCK means that NCS will place a
lock on the resulting queue item. The queue item will not be processed
until it has been unlocked, see the actions 'unlock' and 'lock' in
/devices/commit-queue/queue-item'.
No following queue items, using the same devices, will be
allowed to execute as long as the lock is in place.
Maapi.COMMIT_NCS_COMMIT_QUEUE_BLOCK_OTHERS means that the
resulting queue item will block subsequent queue items, which use any
of the devices in this queue item, from being queued.
Maapi.COMMIT_NCS_COMMIT_QUEUE_ATOMIC means that the atomic
behaviour of the resulting queue item is preserved.
Maapi.COMMIT_NCS_COMMIT_QUEUE_NONATOMIC means that the
devices contained in the resulting queue item can start executing
if the same devices in other non-atomic queue items ahead of it in
the queue are completed.
Maapi.COMMIT_NCS_COMMIT_QUEUE_CONTINUE_ON_ERROR means that the
commit queue will continue on errors. No rollback data will be created.
This is the preferred choice when re-deploying a service as a re-deploy
doesn't have a transaction intent.
Maapi.COMMIT_NCS_COMMIT_QUEUE_ROLLBACK_ON_ERROR means that the
commit queue item will roll back on errors. The commit queue will place a
lock with 'block-others' on the devices and services in the failed queue
item. The rollback action will then automatically be invoked when the
queue item has finished its execution. The lock will be removed as
part of the rollback.
Maapi.COMMIT_NCS_COMMIT_QUEUE_STOP_ON_ERROR means that the
commit queue will place a lock with 'block-others' on the devices and
services in the failed queue item. The lock must then either manually be
released or the rollback action under /devices/commit-queue/completed
be invoked.
Maapi.COMMIT_NCS_USE_LSA means that NCS will force handling LSA
nodes as such.
Maapi.COMMIT_NCS_NO_LSA means that NCS will not handle any of
the LSA nodes as such. These nodes will be handled as any other device.
Maapi.COMMIT_NCS_RECONCILE_KEEP_NON_SERVICE_CONFIG means that all
data which existed before the service was created will now be owned by
the service. When the service is removed that data will also be removed.
In technical terms the reference count will be decreased by one for
everything which existed. Note that this flag has no effect on initial
service creation. Any manually configured data that exists below in the
configuration tree will be kept.
Maapi.COMMIT_NCS_RECONCILE_DISCARD_NON_SERVICE_CONFIG means that
all data which existed before the service was created will now be owned
by the service. When the service is removed that data will also be
removed. In technical terms the reference count will be decreased by one
for everything which existed. Note that this flag has no effect on
initial service creation. Any manually configured data that exists below
in the configuration tree will be discarded.
The flags are bits and can be ORed together.
tid - Transaction id of transaction to commitkeepOpen - If validation fails should the transaction be kept
open or notflags - Bitwise ORed flagsMaapiExceptionIOExceptionConfExceptionpublic ApplyResult applyTransParams(int tid, boolean keepOpen, CommitParams params) throws IOException, ConfException
tid - Transaction id of transaction to commitkeepOpen - If validation fails should the transaction be kept
open or notparams - Commit parameters, see CommitParamsDryRunResult if dry-run was requested.
An instance of CommitQueueResult if commit through
commit queue was requested. Otherwise an instance of
ApplyResult.IOExceptionConfExceptionpublic CommitParams getTransParams(int tid) throws IOException, ConfException
tid - Transaction id of transaction to get commit parameters forIOExceptionConfException@Deprecated public CommitQueueResult commitQueueResult(int tid, int timeout) throws IOException, ConfException
Maapi.applyTransParams(int, boolean, CommitParams) instead.
This method must be called if applyTrans() or prepareTrans() was
called, and one of the flags Maapi.COMMIT_NCS_COMMIT_QUEUE_ASYNC or
Maapi.COMMIT_NCS_COMMIT_QUEUE_SYNC was set, and must not be called
otherwise.
If the transaction did not result in a commit queue entry (e.g.,
it didn't involve any devices) the function returns a
CommitQueueResult with its status set to NCS_COMMIT_QUEUE_NONE.
Otherwise, if Maapi.COMMIT_NCS_COMMIT_QUEUE_ASYNC was set, the
function returns a CommitQueueResult with its status set to
NCS_COMMIT_QUEUE_ASYNC, and its queue_id set to the commit queue id.
Otherwise, if Maapi.COMMIT_NCS_COMMIT_QUEUE_SYNC was set, the
function waits at most timeout seconds for the commit queue
item to be sent to the devices. If the result was successful,
it returns a CommitQueueResult with its status set to
NCS_COMMIT_QUEUE_SYNC. If the timer expires, it returns a
CommitQueueResult with its status set to
NCS_COMMIT_QUEUE_TIMEOUT, and its queue_id set to the commit
queue id. If the result was unsuccessful, an exception is raised.
If any of the devices in the queue item returns an error
the status is set to NCS_COMMIT_QUEUE_FAILED. If the queue item
is deleted before execution the status is set to
NCS_COMMIT_QUEUE_DELETED.tid - Transaction id of committed transactiontimeout - Timeout in seconds. -1 means infinity. Only
applicable if the sync flag was set.ConfExceptionIOExceptionpublic int getRollbackId(int tid)
throws IOException,
ConfException
This methods returns the fixed rollback id of the rollback file created during commit of the transaction. If rollbacks are disabled or no rollback was created this returns -1.
tid - Transaction IdentifierMaapiExceptionIOExceptionConfExceptionpublic void validateTrans(int tid,
boolean unlock,
boolean force)
throws IOException,
ConfException
This method validates all data written in the transaction. This includes all XML checks, checking for uniqueness and dangling pointers. It also includes all defined semantic validation, i.e. user programs that have registered functions under validation points. (See user manual chapter Semantic Validation).
If this method throws an exception due to a validation error, the
transaction is still open for further editing. If unlock is true, the
transaction is open for further editing even if validation succeeds. If
unlock is false and the method returns, the next method to be called
MUST be Maapi.prepareTrans(int) or
Maapi.finishTrans(int).
unlock = true can be used to implement a 'validate' command which can be
given in the middle of an editing session. The first thing that happens
is that a lock is set. If unlock = true, the lock is released on success.
The lock is always released on failure.
The force parameter should normally be false.
It has no effect for a transaction towards the running or
startup data stores, validation is always performed.
For a transaction towards the candidate data store, validation will
not be done unless force true. Avoiding this validation is preferable if
we are going to commit the candidate to running
e.g with Maapi.candidateCommit(), since otherwise the validation
will be done twice. However if we are implementing a 'validate' command,
we should set force = true
tid - Transaction Identifierunlock - if true the transaction is open for further editingforce - if true validation will performed also for
candidate data storeMaapiExceptionIOExceptionConfExceptionpublic void prepareTrans(int tid)
throws IOException,
ConfException
commitTrans or
abortTrans must be
called.
It will invoke the prepare callback in all participants in the transaction. If all participants reply with OK, the second phase of the two-phase commit procedure is commenced.
tid - Transaction IdentifierMaapiExceptionIOExceptionConfExceptionpublic void prepareTrans(int tid,
int flags)
throws IOException,
ConfException
commitTrans or
abortTrans must be
called.
It will invoke the prepare callback in all participants in the transaction. If all participants reply with OK, the second phase of the two-phase commit procedure is commenced.
For a definition of the flags, see Maapi.applyTrans(int,boolean)
tid - Transaction Identifierflags - Bitwise ORed flagsMaapiExceptionIOExceptionConfExceptionpublic void commitTrans(int tid)
throws IOException,
ConfException
Maapi.validateTrans(int,boolean,boolean) and
prepareTrans must be called prior to
commitTranstid - Transaction IdentifierMaapiExceptionIOExceptionConfExceptionpublic void abortTrans(int tid)
throws IOException,
ConfException
validateTrans or prepareTrans.tid - Transaction IdentifierMaapiExceptionIOExceptionConfExceptionpublic void diffIterate(int tid,
MaapiDiffIterate iter)
throws IOException,
ConfException
For all diffs in the transaction
the supplied
MaapiDiffIterate.iterate(ConfObject[],DiffIterateOperFlag,
ConfObject,ConfObject,Object) (callback) method will be called.
This method can be called from an attached MAAPI session. The purpose of the function is to iterate through the transaction diff. It can typically be used in conjunction with the notification API when we subscribe to NOTIF_COMMIT_DIFF events.
For all diffs in the transaction the supplied callback function
iterate will be called. The iterate callback
receives the keypath which uniquely identifies which element in the
XML tree that is affected, the operation, and an optional value.
iterate is called for each modified list entry, and for each
modified leaf node. If the node is a list entry, op is one of
MOP_CREATED, MOP_DELETED or
MOP_MODIFIED If the node is a leaf node, op
is one of MOP_DELETED or MOP_VALUE_SET.
If iterate returns ITER_STOP, no more
iteration is done. If
iterate returns ITER_RECURSE iteration
continues with all children
to the node. If iterate returns
ITER_CONTINUE iteration ignores
the children to the node (if any), and continues with the node's sibling.
The different commit messages are not subjected to AAA checks, i.e. regardless of which path we have and which context was used to create the MAAPI socket, all changed values are sent on the socket.
tid - Transaction handleiter - A MaapiDiffIterate objectMaapiException - Failed diffIterateIOException - Failed to read/write maapi socketConfExceptionpublic void diffIterate(int tid,
MaapiDiffIterate iter,
String fmt,
Object... args)
throws IOException,
ConfException
For all diffs in the transaction
the supplied
MaapiDiffIterate.iterate(ConfObject[],DiffIterateOperFlag,
ConfObject,ConfObject,Object) (callback) method will be called.
This method can be called from an attached MAAPI session. The purpose of the function is to iterate through the transaction diff. It can typically be used in conjunction with the notification API when we subscribe to NOTIF_COMMIT_DIFF events.
For all diffs in the transaction the supplied callback function
iterate will be called. The iterate callback
receives the keypath which uniquely identifies which element in the
XML tree that is affected, the operation, and an optional value.
iterate is called for each modified list entry, and for each
modified leaf node. If the node is a list entry, op is one of
MOP_CREATED, MOP_DELETED or
MOP_MODIFIED If the node is a leaf node, op
is one of MOP_DELETED or MOP_VALUE_SET.
If iterate returns ITER_STOP, no more
iteration is done. If
iterate returns ITER_RECURSE iteration
continues with all children
to the node. If iterate returns
ITER_CONTINUE iteration ignores
the children to the node (if any), and continues with the node's sibling.
The different commit messages are not subjected to AAA checks, i.e. regardless of which path we have and which context was used to create the MAAPI socket, all changed values are sent on the socket.
tid - Transaction handleiter - A MaapiDiffIterate objectMaapiException - Failed diffIterateIOException - Failed to read/write maapi socketConfExceptionpublic void diffIterate(int tid,
MaapiDiffIterate iter,
Object initstate,
String fmt,
Object... args)
throws IOException,
ConfException
For all diffs in the transaction
the supplied
MaapiDiffIterate.iterate(ConfObject[],DiffIterateOperFlag,
ConfObject,ConfObject,Object) (callback) method will be called.
This method can be called from an attached MAAPI session. The purpose of the function is to iterate through the transaction diff. It can typically be used in conjunction with the notification API when we subscribe to NOTIF_COMMIT_DIFF events.
For all diffs in the transaction the supplied callback function
iterate will be called. The iterate callback
receives the keypath which uniquely identifies which element in the
XML tree that is affected, the operation, and an optional value.
iterate is called for each modified list entry, and for each
modified leaf node. If the node is a list entry, op is one of
MOP_CREATED, MOP_DELETED or
MOP_MODIFIED If the node is a leaf node, op
is one of MOP_DELETED or MOP_VALUE_SET.
If iterate returns ITER_STOP, no more
iteration is done. If
iterate returns ITER_RECURSE iteration
continues with all children
to the node. If iterate returns
ITER_CONTINUE iteration ignores
the children to the node (if any), and continues with the node's sibling.
The different commit messages are not subjected to AAA checks, i.e. regardless of which path we have and which context was used to create the MAAPI socket, all changed values are sent on the socket.
tid - Transaction handleiter - A MaapiDiffIterate objectMaapiException - Failed diffIterateIOException - Failed to read/write maapi socketConfExceptionpublic void diffIterate(int tid,
Object initstate,
EnumSet<DiffIterateFlags> flags,
MaapiDiffIterate iter,
ConfPath path)
throws IOException,
ConfException
For all diffs in the transaction
the supplied
MaapiDiffIterate.iterate(ConfObject[],DiffIterateOperFlag,
ConfObject,ConfObject,Object) (callback) method will be called.
This method can be called from an attached MAAPI session. The purpose of the function is to iterate through the transaction diff. It can typically be used in conjunction with the notification API when we subscribe to NOTIF_COMMIT_DIFF events.
For all diffs in the transaction the supplied callback function
iterate will be called. The iterate callback
receives the keypath which uniquely identifies which element in the
XML tree that is affected, the operation, and an optional value.
iterate is called for each modified list entry, and for each
modified leaf node. If the node is a list entry, op is one of
MOP_CREATED, MOP_DELETED or
MOP_MODIFIED If the node is a leaf node, op
is one of MOP_DELETED or MOP_VALUE_SET.
If the flags argument is set to DiffIterateFlags.ITER_WANT_ATTR
also attribute changes will be iterated over with op
MOP_ATTR_SET and new and old values as
ConfAttributeValue
If iterate returns ITER_STOP, no more
iteration is done. If
iterate returns ITER_RECURSE iteration
continues with all children
to the node. If iterate returns
ITER_CONTINUE iteration ignores
the children to the node (if any), and continues with the node's sibling.
The different commit messages are not subjected to AAA checks, i.e. regardless of which path we have and which context was used to create the MAAPI socket, all changed values are sent on the socket.
tid - Transaction handleinitstate - arbitrary object passed to the iteratorflags - set of DiffIterateFlags flags that controls the
iteration, for Maapi only DiffIterateFlags.ITER_WANT_ATTR
is supportediter - A MaapiDiffIterate objectpath - ConfPathMaapiException - Failed diffIterateIOException - Failed to read/write maapi socketConfExceptionpublic void iterate(int tid,
Object initstate,
EnumSet<ConfIterateFlags> flags,
MaapiIterate iter,
ConfPath path)
throws IOException,
ConfException
For all data elements in the transaction the supplied
MaapiIterate.iterate(ConfObject[],ConfObject,
ConfAttributeValue[],Object) (callback) method will be called.
This method can be called from an attached MAAPI session.
The iterate callback
receives the keypath which uniquely identifies which element in the
XML tree that is affected, the operation, and an optional value.
iterate is called for each list entry, and for each
leaf node. If the node is a list entry, op is one of
MOP_CREATED, MOP_DELETED or
MOP_MODIFIED If the node is a leaf node, op
is one of MOP_DELETED or MOP_VALUE_SET.
If the flags argument is set to ConfIterateFlags.ITER_WANT_ATTR
also attribute changes will be iterated over with op
MOP_ATTR_SET and new and old values as
ConfAttributeValue
If iterate returns ITER_STOP, no more
iteration is done. If
iterate returns ITER_RECURSE iteration
continues with all children
to the node. If iterate returns
ITER_CONTINUE iteration ignores
the children to the node (if any), and continues with the node's sibling.
The different commit messages are not subjected to AAA checks, i.e. regardless of which path we have and which context was used to create the MAAPI socket, all changed values are sent on the socket.
tid - Transaction handleinitstate - arbitrary object passed to the iteratorflags - set of ConfIterateFlags flags that controls the
iteration, for Maapi only ConfIterateFlags.ITER_WANT_ATTR
is supportediter - A MaapiIterate objectpath - ConfPathIOExceptionConfExceptionpublic void setLabel(int tid,
String label)
throws IOException,
ConfException
Maapi.candidateCommitInfo(java.lang.String, java.lang.String)
method. For a confirmed commit, the "Label" must also be given via the
Maapi.candidateConfirmedCommitInfo(int, java.lang.String, java.lang.String) method.tid - Transaction Identifierlabel - LabelMaapiExceptionIOExceptionConfExceptionpublic void setComment(int tid,
String comment)
throws IOException,
ConfException
Maapi.candidateCommitInfo(java.lang.String, java.lang.String)
method. For a confirmed commit, the "Comment" must also be given via the
Maapi.candidateConfirmedCommitInfo(int, java.lang.String, java.lang.String) method.tid - Transaction Identifiercomment - CommentMaapiExceptionIOExceptionConfExceptionpublic void setNamespace(int tid,
String ns)
throws IOException,
ConfException
The ns string is the namespace URL
tid - Transaction Identifierns - Namespace uriMaapiExceptionIOExceptionConfExceptionpublic void setNamespace(int tid,
int nsid)
throws IOException,
ConfException
IOExceptionConfExceptionpublic void cd(int tid,
String fmt,
Object... arguments)
throws ConfException,
IOException
The cd() function is also very useful when writing generic code for accessing parts of the configuration tree.
tid - Transaction Identifierfmt - path stringarguments - optional parameters for substitution in fmtMaapiExceptionIOExceptionConfExceptionpublic void pushd(int tid,
String fmt,
Object... arguments)
throws ConfException,
IOException
tid - Transaction Identifierfmt - path stringarguments - optional parameters for substitution in fmtMaapiExceptionIOExceptionConfExceptionpublic void popd(int tid)
throws ConfException,
IOException
tid - Transaction IdentifierMaapiExceptionIOExceptionConfExceptionpublic boolean exists(int tid,
ConfPath path)
throws IOException,
ConfException
tid - Transaction Identifierpath - ConfPath instanceMaapiExceptionIOExceptionConfExceptionpublic boolean exists(int tid,
String fmt,
Object... arguments)
throws IOException,
ConfException
IOExceptionConfExceptionpublic int getNumberOfInstances(int tid,
String fmt,
Object... arguments)
throws IOException,
ConfException
tid - Transaction Identifierfmt - path stringarguments - optional parameters for substitution in fmtMaapiExceptionIOExceptionConfExceptionpublic int getNumberOfInstances(int tid,
ConfPath path)
throws IOException,
ConfException
IOExceptionConfExceptionpublic ConfValue getElem(int tid, String fmt, Object... arguments) throws IOException, ConfException
tid - Transaction Identifierfmt - path stringarguments - optional parameters for substitution in fmtMaapiExceptionIOExceptionConfExceptionpublic ConfValue getElem(int tid, ConfPath path) throws IOException, ConfException
IOExceptionConfExceptionpublic ConfValue safeGetElem(int tid, ConfPath path) throws IOException, ConfException
Reads a value from the path specified
The path must lead to a leaf element in the data tree.
This is a equivalent method ofMaapi.getElem(int,String,Object[])
method which returns null if the element doesn't exist instead
of throwing a exception.
tid - transaction handlepath - leaf element in data treeConfExceptionIOExceptionpublic ConfValue safeGetElem(int tid, String fmt, Object... arguments) throws IOException, ConfException
tid - Transaction Identifierfmt - path stringarguments - optional parameters for substitution in fmtMaapiExceptionIOExceptionConfExceptionpublic ConfObject[] getObject(int tid, String fmt, Object... arguments) throws IOException, ConfException
tid - Transaction Identifierfmt - path stringarguments - optional parameters for substitution in fmtMaapiExceptionIOExceptionConfExceptionpublic ConfObject[] safeGetObject(int tid, String fmt, Object... arguments) throws IOException, ConfException
tid - Transaction Identifierfmt - path stringarguments - optional parameters for substitution in fmtMaapiExceptionIOExceptionConfExceptionpublic void setObject(int tid,
ConfObject[] values,
String fmt,
Object... arguments)
throws IOException,
ConfException
tid - Transaction Identifiervalues - fmt - path stringarguments - optional parameters for substitution in fmtMaapiExceptionIOExceptionConfExceptionpublic void setValues(int tid,
List<ConfXMLParam> params,
ConfPath path)
throws IOException,
ConfException
tid - params - path - IOExceptionConfExceptionpublic void setValues(int tid,
List<ConfXMLParam> params,
String fmt,
Object... arguments)
throws IOException,
ConfException
params - fmt - arguments - IOExceptionConfExceptionpublic void setValues(int tid,
ConfXMLParam[] params,
String fmt,
Object... arguments)
throws IOException,
ConfException
tid - params - fmt - arguments - IOExceptionConfExceptionpublic void setValues(int tid,
ConfXMLParam[] params,
ConfPath path)
throws IOException,
ConfException
tid - params - path - IOExceptionConfExceptionpublic void sharedSetValues(int tid,
List<ConfXMLParam> params,
ConfPath path)
throws IOException,
ConfException
tid - params - path - IOExceptionConfExceptionpublic void sharedSetValues(int tid,
List<ConfXMLParam> params,
String fmt,
Object... arguments)
throws IOException,
ConfException
tid - params - fmt - arguments - IOExceptionConfExceptionpublic void sharedSetValues(int tid,
ConfXMLParam[] params,
String fmt,
Object... arguments)
throws IOException,
ConfException
tid - params - fmt - arguments - IOExceptionConfExceptionpublic void sharedSetValues(int tid,
ConfXMLParam[] params,
ConfPath path)
throws IOException,
ConfException
tid - params - path - IOExceptionConfExceptionpublic void sharedSetValues(int tid,
ConfXMLParam[] params,
boolean createBackpointer,
ConfPath path)
throws IOException,
ConfException
tid - params - createBackpointer - path - IOExceptionConfExceptionpublic <T extends List<ConfXMLParam>> T getValues(int tid, T params, String fmt, Object... arguments) throws IOException, ConfException
The params list must be pre-populated
based on the specification of the ConfXMLParam array
structure format. Where ConfXMLParamValue value element set by
ConfXMLParamValue.setValue(ConfObject) method is given as follow:
ConfNoExists means that the value should be read from the
transaction and stored in the array.
ConfXMLParamStart,ConfXMLParamStop
are used as per the specification.
All elements have the same position in the array after the call,
In order to simplify extraction of the values -
this means that optional elements that were requested but didn't
exist will have ConfNoExists (as a the
ConfXMLParam.getValue() return value in
the corresponding position in a ConfXMLParamValue)
rather than being omitted from the array.
However requesting a list entry that doesn't exist will throw
a exception indicating that the instance does not exits.
T - the type list holding the structuretid - transaction handlearguments - optional parameter for substitution in fmtparams - pre-populated structure of the elements to be extractedMaapiException - If the the call failed for some reason
see the Throwable.getMessage() for details.IOException - Signals I/O exception of some kindConfExceptionConfXMLParam,
ConfXMLParamValuepublic <T extends List<ConfXMLParam>> T getValues(int tid, T params, ConfPath path) throws IOException, ConfException
The params list must be pre-populated
based on the specification of the ConfXMLParam array
structure format. Where ConfXMLParamValue value element set by
ConfXMLParamValue.setValue(ConfObject) method is given as follow:
ConfNoExists means that the value should be read from the
transaction and stored in the array.
ConfXMLParamStart,ConfXMLParamStop
are used as per the specification.
All elements have the same position in the array after the call,
In order to simplify extraction of the values -
this means that optional elements that were requested but didn't
exist will have ConfNoExists (as a the
ConfXMLParam.getValue() return value in
the corresponding position in a ConfXMLParamValue)
rather than being omitted from the array.
However requesting a list entry that doesn't exist will throw
a exception indicating that the instance does not exits.
T - the type list holding the structuretid - transaction handlepath - the path pointing to the location of extractionparams - pre-populated structure of the elements to be extractedMaapiException - If the the call failed for some reason
see the Throwable.getMessage() for details.IOException - Signals I/O exception of some kindConfExceptionConfXMLParam,
ConfXMLParamValuepublic <T extends ConfXMLParam> T[] getValues(int tid, T[] params, String fmt, Object... arguments) throws IOException, ConfException
The params array must be pre-populated
based on the specification of the ConfXMLParam array
structure format. Where ConfXMLParamValue value element set by
ConfXMLParamValue.setValue(ConfObject) method is given as follow:
ConfNoExists means that the value should be read from the
transaction and stored in the array.
ConfXMLParamStart,ConfXMLParamStop
are used as per the specification.
All elements have the same position in the array after the call,
In order to simplify extraction of the values -
this means that optional elements that were requested but didn't
exist will have ConfNoExists (as a the
ConfXMLParam.getValue() return value in
the corresponding position in a ConfXMLParamValue)
rather than being omitted from the array.
However requesting a list entry that doesn't exist will throw
a exception indicating that the instance does not exits.
T - type of the elements contained in the structuretid - transaction handleparams - pre-populated structure of the elements to be extractedfmt - path stringarguments - optional parameter for substitution in fmtMaapiException - If the the call failed for some reason
see the Throwable.getMessage() for details.IOException - Signals I/O exception of some kindConfExceptionConfXMLParam,
ConfXMLParamValuepublic <T extends ConfXMLParam> T[] getValues(int tid, T[] params, ConfPath path) throws IOException, ConfException
The params array must be pre-populated
based on the specification of the ConfXMLParam array
structure format. Where ConfXMLParamValue value element set by
ConfXMLParamValue.setValue(ConfObject) method is given as follow:
ConfNoExists means that the value should be read from the
transaction and stored in the array.
ConfXMLParamStart,ConfXMLParamStop
are used as per the specification.
All elements have the same position in the array after the call,
In order to simplify extraction of the values -
this means that optional elements that were requested but didn't
exist will have ConfNoExists (as a the
ConfXMLParam.getValue() return value in
the corresponding position in a ConfXMLParamValue)
rather than being omitted from the array.
However requesting a list entry that doesn't exist will throw
a exception indicating that the instance does not exits.
T - type of the elements contained in the structuretid - transaction handleparams - pre-populated structure of the elements to be extractedpath - the path pointing to the location of extractionMaapiException - If the the call failed for some reason
see the Throwable.getMessage() for details.IOException - Signals I/O exception of some kindConfExceptionConfXMLParam,
ConfXMLParamValuepublic MaapiCursor newCursor(int tid, String fmt, Object... arguments) throws IOException, ConfException
Creates a cursor for a list specified by fmt.
The MaapiCursor is used to iterate over the keys of a list.
When we wish to iterate over key entries we must first create a cursor.
The cursor instance is subsequently used in
Maapi.getNext(MaapiCursor) to retrieve the next key instance in
the list. When the cursor retrieves null the whole list has been
iterated.
An exhausted cursor cannot be reset.
For example, if we have the following YANG model:
module mtest { namespace "http://tail-f.com/test/mtest/1.0"; prefix mtest; import ietf-inet-types { prefix inet; } container servers { list server { key name; max-elements 64; leaf name { type string; } leaf ip { type inet:ip-address; mandatory true; } leaf port { type inet:port-number; mandatory true; } } } }
Example usage:
MaapiCursor c = maapi.newCursor(tid, "/mtest:mtest/servers/server"); ConfKey x; while ((x = maapi.getNext(c)) != null) { ConfValue nameValue = maapi.getElem(tid, "/mtest:mtest/servers/server{%x}/name", x); ConfValue ipValue = maapi.getElem(tid, "/mtest:mtest/servers/server{%x}/ip", x); ConfValue portValue = maapi.getElem(tid, "/mtest:mtest/servers/server{%x}/port",x); }
tid - current transaction idfmt - path of the list to be iteratedarguments - optional parameters for substitution in fmtIOExceptionConfExceptionpublic MaapiCursor newCursor(int tid, ConfPath path) throws IOException, ConfException
Creates a cursor for a list specified by path
The MaapiCursor is used to iterate over the keys of a list.
When we wish to iterate over key entries we must first create a cursor.
The cursor instance is subsequently used in
Maapi.getNext(MaapiCursor) to retrieve the next key instance in
the list. When the cursor retrieves null the whole list has been
iterated and the cursor can not be reset.
tid - current transaction idpath - path of the list to be iteratedIOExceptionConfExceptionpublic MaapiCursor newCursorWithFilter(int tid, String filter, String fmt, Object... arguments) throws IOException, ConfException
Creates a cursor for a list specified by fmt with an XPath
filter specified by filter.
The MaapiCursor is used to iterate over the keys a list.
When we wish to iterate over key entries we must first create a cursor.
The cursor instance is subsequently used in
Maapi.getNext(MaapiCursor) to retrieve the next key instance in
the list. When the cursor retrieves null the whole list has been
iterated and the cursor can not be reset.
If filter is not null, only keys of elements
matching the filter will be included in the iteration.
If filter is null, this method behaves just as
Maapi.newCursor(int, String, Object...)
Given the same example model as in
Maapi.newCursor(int, String, Object...) one could iterate over
servers on the 10.x.x.x network with port numbers above 8000 using
the following cursor call:
MaapiCursor c = maapi.newCursorWithFilter(tid, "starts-with(ip, \"10.\") and port > 8000", "/mtest:mtest/servers/server");
tid - current transaction idfilter - XPath filter for filtering the listfmt - path of the list to be iteratedarguments - optional parameters for substitution in fmtIOExceptionConfExceptionpublic MaapiCursor newCursorWithFilter(int tid, String filter, ConfPath path) throws IOException, ConfException
Creates a cursor for a list specified by path with an XPath
filter specified by filter.
The MaapiCursor is used to iterate over the keys of a list.
When we wish to iterate over key entries we must first create a cursor.
The cursor instance is subsequently used in
Maapi.getNext(MaapiCursor) to retrieve the next key instance in
the list. When the cursor retrieves null the whole list has been
iterated and the cursor can not be reset.
If filter is not null, only keys of elements
matching the filter will be included in the iteration.
If filter is null, this method behaves just as
Maapi.newCursor(int, ConfPath)
tid - current transaction idfilter - XPath filter for filtering the listpath - path of the list to be iteratedIOExceptionConfExceptionpublic ConfKey getNext(MaapiCursor c) throws IOException, ConfException
MaapiCursor initially retrieved by
Maapi.newCursor(int, String, Object...).
With the key(s) it is possible to navigate further down the model.
For example, to read the port element from the 'server' example model, we would do:
MaapiCursor c = maapi.newCursor(tid, "/mtest:mtest/servers/server"); ConfKey x = maapi.getNext(c); while (x != null) { ConfObject p; p = maapi.getElem(tid, "/mtest:mtest/servers/server{%x}/port", x); // .... x = maapi.getNext(c); }
c - MaapiCursorIOExceptionConfExceptionpublic ConfKey findNext(MaapiCursor c, ConfFindNextType type, ConfKey key) throws IOException, ConfException
c - MaapiCursor for pathtype - ConfFindNextType if same element as key or element
after key should be retrievedkey - ConfKey for the searched elementIOExceptionConfExceptionpublic List<ConfObject[]> getObjects(MaapiCursor c, int numOfObjects, int numOfInstances) throws IOException, ConfException
c - MaapiCursor on current listnumOfObjects - Number of object retrieved from a list instancenumOfInstances - Number of list instances retrieved in this callIOExceptionConfExceptionpublic void setElem(int tid,
ConfObject value,
String fmt,
Object... arguments)
throws IOException,
ConfException
There two different methods to set a value to a leaf node.
One where the value is a string and one where the value to set is a
ConfObject. The string version
is useful when we have implemented a management agent where the user
enters values as strings.
The version with ConfObject is useful when we
are setting values which we have just read from various API methods
that returns ConfObject.
tid - Transaction Identifiervalue - fmt - path stringarguments - optional parameters for substitution in fmtIOExceptionConfExceptionpublic void setElem(int tid,
ConfObject value,
ConfPath path)
throws IOException,
ConfException
There two different methods to set a value to a leaf node.
One where the value is a string and one where the value to set is a
ConfObject. The string version
is useful when we have implemented a management agent where the user
enters values as strings.
The version with ConfObject is useful when we
are setting values which we have just read from various API methods
that returns ConfObject.
tid - Transaction Identifiervalue - path - IOExceptionConfExceptionpublic void setElem(int tid,
String value,
String fmt,
Object... arguments)
throws IOException,
ConfException
There two different methods to set a value to a leaf node.
One where the value is a string and one where the value to set is a
ConfObject. The string version
is useful when we have implemented a management agent where the user
enters values as strings.
The version with ConfObject is useful when we
are setting values which we have just read from various API methods
that returns ConfObject.
tid - Transaction Identifiervalue - fmt - path stringarguments - optional parameters for substitution in fmtIOExceptionConfExceptionpublic void setElem(int tid,
String value,
ConfPath path)
throws IOException,
ConfException
There two different methods to set a value to a leaf node.
One where the value is a string and one where the value to set is a
ConfObject. The string version
is useful when we have implemented a management agent where the user
enters values as strings.
The version with ConfObject is useful when we
are setting values which we have just read from various API methods
that returns ConfObject.
tid - Transaction Identifiervalue - path - ConfPath instanceIOExceptionConfExceptionpublic void sharedSetElem(int tid,
ConfObject value,
String fmt,
Object... arguments)
throws IOException,
ConfException
tid - Transaction Identifiervalue - fmt - path stringarguments - optional parameters for substitution in fmtIOExceptionConfExceptionpublic void sharedSetElem(int tid,
ConfObject value,
ConfPath path)
throws IOException,
ConfException
tid - Transaction Identifiervalue - path - IOExceptionConfExceptionpublic void sharedSetElem(int tid,
String value,
String fmt,
Object... arguments)
throws IOException,
ConfException
tid - Transaction Identifiervalue - fmt - path stringarguments - optional parameters for substitution in fmtIOExceptionConfExceptionpublic void create(int tid,
String fmt,
Object... arguments)
throws IOException,
ConfException
maapi.create(tid, "/servers/server{www}");
If we are creating a new server element as above, we must also populate
all other XML elements below, which do not have a default value in the
YANG model. Thus we must also:
maapi.setElem(tid, "80",
"/servers/server{www}/port");
before we try to commit the data.tid - Transaction Identifierfmt - path stringarguments - optional parameters for substitution in fmtConfException - if the object already existsIOExceptionpublic void create(int tid,
ConfPath path)
throws IOException,
ConfException
maapi.create(tid, "/servers/server{www}");
If we are creating a new server element as above, we must also populate
all other XML elements below which do not have a default value in the
YANG model. Thus, assuming 'port' is mandatory we must also:
maapi.setElem(tid, "80",
"/servers/server{www}/port");
before we try to commit the data.tid - Transaction Identifierpath - ConfException - if the object already existsIOExceptionpublic void safeCreate(int tid,
String fmt,
Object... arguments)
throws IOException,
ConfException
tid - Transaction Identifierfmt - path stringarguments - optional parameters for substitution in fmtConfExceptionIOExceptionpublic void safeCreate(int tid,
ConfPath path)
throws IOException,
ConfException
tid - Transaction Identifierpath - ConfExceptionIOExceptionpublic void sharedCreate(int tid,
String fmt,
Object... arguments)
throws IOException,
ConfException
IOExceptionConfExceptionpublic void sharedCreate(int tid,
ConfPath path)
throws IOException,
ConfException
IOExceptionConfExceptionpublic void sharedCreate(int tid,
boolean createBackpointer,
ConfPath path)
throws IOException,
ConfException
Maapi.sharedCreate(int tid, ConfPath path)tid - Transaction IdentifiercreateBackpointer - path - ConfExceptionIOExceptionpublic void delete(int tid,
String fmt,
Object... arguments)
throws IOException,
ConfException
tid - Transaction Identifierfmt - path stringarguments - optional parameters for substitution in fmtConfExceptionIOExceptionpublic void delete(int tid,
ConfPath path)
throws IOException,
ConfException
tid - Transaction Identifierpath - ConfExceptionIOExceptionpublic void deleteAll(int th,
MaapiDeleteAllFlag how)
throws ConfException,
IOException
how specifies the extent of "all":
MAAPI_DEL_SAFE
Delete everything except namespaces that were exported to none
(with tailf:export none). Toplevel nodes that cannot be deleted due
to AAA rules are silently left in place, but descendant nodes will
still be deleted if the AAA rules allow it.
MAAPI_DEL_EXPORTED
Delete everything except namespaces that were exported to none
(with tailf:export none). AAA rules are ignored, i.e. nodes are
deleted even if the AAA rules don't allow it.
MAAPI_DEL_ALL
Delete everything. AAA rules are ignored.
th - Transaction handlehow - One of the flags in MaapiDeleteAllFlag,
specifying 'how' to delete allConfExceptionIOExceptionpublic void safeDelete(int tid,
String fmt,
Object... arguments)
throws IOException,
ConfException
Version of
delete that doesn't throw an exception if the
element doesn't exist
tid - Transaction Identifierfmt - path stringarguments - optional parameters for substitution in fmtConfExceptionIOExceptionpublic void insert(int tid,
String fmt,
Object... arguments)
throws IOException,
ConfException
IOExceptionConfExceptionpublic void insert(int tid,
boolean createBackPointer,
String fmt,
Object... arguments)
throws IOException,
ConfException
tid - Transaction IdentifiercreateBackPointer - When we insert items into lists that are
managed by FastMap code, we always want to set this parameter to
true. Since we insert into the list, effectively changing the keys
the FastMap diff-sets must be updated accordingly.fmt - path stringarguments - optional parameters for substitution in fmtConfExceptionIOExceptionpublic void move(int tid,
ConfKey tokey,
String fmt,
Object... arguments)
throws IOException,
ConfException
tid - Transaction Identifiertokey - fmt - path stringarguments - optional parameters for substitution in fmtConfExceptionIOExceptionpublic void move(int tid,
String tokey,
String fmt,
Object... arguments)
throws IOException,
ConfException
Renames the object using the new instance key tokey represented as a string.
tid - Transaction Identifiertokey - fmt - path stringarguments - optional parameters for substitution in fmtConfExceptionIOExceptionpublic void moveOrdered(int tid,
MoveWhereFlag where,
ConfKey tokey,
String fmt,
Object... arguments)
throws IOException,
ConfException
tid - current transactionwhere - MoveWhereFlag movement flagtokey - key as base for relative movementsfmt - path stringarguments - optional parameters for substitution in fmtIOExceptionConfExceptionpublic ConfTag getCase(int tid, String choice, String fmt, Object... arguments) throws IOException, ConfException
When we use the YANG choice statement in the data model, this method
can be used to find the currently selected case,
avoiding useless getElem() etc requests for nodes that belong
to other cases. The fmt arguments give the path to
the list entry or container where the choice is defined,
and choice is the name of the choice.The case value is returned as
ConfTag.
For a choice without a mandatory true statement where no case is
currently selected, the function will fail with
ERR_NOEXISTS if the choice doesn't have a default case.
If it has a default case, it will be returned
unless the MaapiFlag.NO_DEFAULTS flag is in effect @see
MaapiFlag if the flag is set, the value returned will have type
ConfTagDefault.
NOTE: The method will suppress all ERR_NOEXISTS errors this means that the method will not throw exception when ERR_NOEXISTS occurs it will print a warning message and return null.
tid - current transaction handlechoice - name of the choicefmt - path string to the container or list where the
choice is definedarguments - optional parameters for substitution in fmtMaapiExceptionIOExceptionConfExceptionpublic ConfTag getCase(int tid, String choice, ConfPath path) throws IOException, ConfException
IOExceptionConfExceptionpublic void revert(int tid)
throws IOException,
ConfException
tid - IOExceptionConfException@Deprecated public void copy_tree(int tid, ConfPath from, ConfPath to) throws IOException, ConfException
Maapi.copyTree(int, ConfPath, ConfPath) instead.IOExceptionConfException@Deprecated public void copy_tree(int tid, boolean useSharedCreate, ConfPath from, ConfPath to) throws IOException, ConfException
Maapi.copyTree(int, boolean, ConfPath, ConfPath) instead.IOExceptionConfExceptionpublic void copyTree(int tid,
ConfPath from,
ConfPath to)
throws IOException,
ConfException
Maapi#copyTree(int, false, ConfPath, ConfPath)
ie., for use outside fastmap, without 'shared' create/setIOExceptionConfExceptionpublic void copyTree(int tid,
boolean useSharedCreate,
ConfPath from,
ConfPath to)
throws IOException,
ConfException
tid - Transaction IdentifieruseSharedCreate - from - to - ConfExceptionIOExceptionpublic void lock(int db)
throws IOException,
ConfException
Only one entity may own the lock at any given time.
You do not have to acquire the lock before you read or write to a transaction.
This lock is also taken by the CLI when the user enters exclusive mode. Depending on the configuration different locks will be taken, ie, if the system has been configured to have a candidate, and a writable running configuration then both a lock on running and a lock on the candidate database will be acquired.
The following locks are acquired when you enter configure exclusive mode in the CLI:
If the system is configured with a startup db, and no writable running or candidate: lock startup
If the system is configured with a writable running and no startup or candidate db: lock running
If the system is configured with a writable running and a startup db, and no candidate: lock running and startup.
If the system is configured with a writable running and a candidate db, and no startup: lock running and candidate.
db - Database to lock. Possible values are STARTUP, RUNNING, and
CANDIDATEConfExceptionIOExceptionpublic void unlock(int db)
throws IOException,
ConfException
db - Database to unlock. Possible values are STARTUP, RUNNING, and
CANDIDATEConfExceptionIOExceptionpublic int lockPartial(int db,
String[] xpaths)
throws IOException,
ConfException
db - Databasexpaths - Array of xpath expressions to lockConfExceptionIOExceptionpublic int lockPartial(int db,
String xpath)
throws IOException,
ConfException
Maapi.lockPartial(int,String[]) except only one xpath
expression is given.IOExceptionConfExceptionpublic void unlockPartial(int lockId)
throws IOException,
ConfException
lockId - The previously specified lock identifierConfExceptionIOExceptionpublic ConfObject[][] deref(int tid, String fmt, Object... arguments) throws IOException, ConfException
tid - Transaction Identifierfmt - path stringarguments - optional parameters for substitution in fmtMaapiExceptionIOExceptionConfExceptionpublic int isLockSet(int db)
throws IOException,
ConfException
db - Database to check. Possible values are
Conf.DB_STARTUP, Conf.DB_RUNNING, and
Conf.DB_CANDIDATEConfExceptionIOExceptionpublic void candidateValidate()
throws IOException,
ConfException
ConfExceptionIOExceptionpublic void deleteConfig(int db)
throws IOException,
ConfException
ConfExceptionIOExceptionpublic void candidateCommit()
throws IOException,
ConfException
ConfExceptionIOExceptionpublic void candidateConfirmedCommit(int t)
throws IOException,
ConfException
t - Timeout in secondsConfExceptionIOExceptionpublic void candidateReset()
throws IOException,
ConfException
ConfExceptionIOExceptionpublic void candidateAbortCommit()
throws IOException,
ConfException
ConfExceptionIOExceptionpublic int confirmedCommitInProgress()
throws IOException,
ConfException
ConfExceptionIOExceptionpublic void candidateConfirmedCommitPersistent(int timeoutsecs,
String persist,
String persistId)
throws IOException,
ConfException
persist parameter sets the cookie for the
persistent confirmed commit, while the persistId gives
the cookie for an already ongoing persistent confirmed commit.
This gives the following
possibilities:
persist = "cookie", persistId = null
Start a persistent confirmed commit
with the cookie "cookie", or extend an already ongoing non-persistent
confirmed commit and turn it into a persistent confirmed commit.
persist = "newcookie", persistId = "oldcookie"
Extend an ongoing
persistent confirmed commit that uses the cookie "oldcookie" and change
the cookie to "newcookie".
persist = null, persistId = "cookie"
Extend an ongoing persistent confirmed commit that uses the cookie
"oldcookie" and turn it into a non-persistent confirmed commit.
persist = null, persistId = null Does the same as
Maapi.candidateConfirmedCommit(int).
persist = "cookie", persistId = null, and to extend it
with persist = "cookie", persistId = "cookie".
Throws ConfExceptiontimeoutsecs - timeout for the confirmed commitpersist - value for a new persistent confirmed commitpersistId - value for an already ongoing persistent confirmed commitIOExceptionConfException - If error. If the errorCode for the
ConfException is ConfException.ERR_NOEXISTS
it means that there is an ongoing persistent
confirmed commit, but persistId did not give the right
cookie for it.public void candidateConfirmedCommitInfo(int timeoutsecs,
String label,
String comment)
throws IOException,
ConfException
Maapi.candidateConfirmedCommitPersistent(int, java.lang.String, java.lang.String), but allows for
setting the "Label" and/or "Comment" that is stored in the
rollback file when the candidate is committed to running. To set
only the "Label", give comment as null, and to set only the
"Comment", give label as null.
Note: To ensure that the "Label" and/or "Comment" are stored in the
rollback file in all cases when doing a confirmed commit, they must
be given both with the confirmed commit (using this method) and
with the confirming commit (using Maapi.candidateCommitInfo(java.lang.String, java.lang.String)).timeoutsecs - timeout for the confirmed commitlabel - value for "Label" in the rollback filecomment - value for "Comment" in the rollback fileIOExceptionConfException - If error. If the errorCode for the
ConfException is ConfException.ERR_NOEXISTS
it means that there is an ongoing persistent
confirmed commit, but persistId did not give the right
cookie for it.public void candidateConfirmedCommitInfo(int timeoutsecs,
String persist,
String persistId,
String label,
String comment)
throws IOException,
ConfException
Maapi.candidateConfirmedCommitPersistent(int, java.lang.String, java.lang.String), but allows for
setting the "Label" and/or "Comment" that is stored in the
rollback file when the candidate is committed to running. To set
only the "Label", give comment as null, and to set only the
"Comment", give label as null.
Note: To ensure that the "Label" and/or "Comment" are stored in the
rollback file in all cases when doing a confirmed commit, they must
be given both with the confirmed commit (using this method) and
with the confirming commit (using Maapi.candidateCommitInfo(java.lang.String, java.lang.String)).timeoutsecs - timeout for the confirmed commitpersist - value for a new persistent confirmed commitpersistId - value for an already ongoing persistent confirmed commitlabel - value for "Label" in the rollback filecomment - value for "Comment" in the rollback fileIOExceptionConfException - If error. If the errorCode for the
ConfException is ConfException.ERR_NOEXISTS
it means that there is an ongoing persistent
confirmed commit, but persistId did not give the right
cookie for it.public void candidateAbortCommitPersistent(String persistId) throws IOException, ConfException
Maapi.candidateAbortCommit().persistId - cookie for ongoing persistent confirmed commitIOExceptionConfException - If error. If the errorCode for the
ConfException is ConfException.ERR_NOEXISTS
it means that there is an ongoing persistent
confirmed commit, but persistId did not give the
right cookie for it.public void candidateCommitPersistent(String persistId) throws IOException, ConfException
Maapi.candidateCommit().
Throws ConfException if error. If the errorCode for the ConfException is
ConfException.ERR_NOEXISTS it means that there is an ongoing persistent
confirmed commit, but persist_id did not give the right cookie for it.persistId - IOExceptionConfException - If error. If the errorCode for the
ConfException is ConfException.ERR_NOEXISTS
it means that there is an ongoing persistent confirmed commit,
but persistId did not give the
right cookie for it.public void candidateCommitInfo(String label, String comment) throws IOException, ConfException
Maapi.candidateCommit(). Otherwise the
method will confirm the ongoing confirmed commit. For a persistent
confirmed commit, the cookie can be given by persistId if needed.
Note: To ensure that the "Label" and/or "Comment" are stored
in the rollback file in all cases when doing a confirmed commit,
they must be given both with the confirmed commit (using
Maapi.candidateConfirmedCommitInfo(int, java.lang.String, java.lang.String)) and
with the confirming commit (using this method).label - value for "Label" in the rollback filecomment - value for "Comment" in the rollback fileIOExceptionConfException - If error. If the errorCode for the
ConfException is ConfException.ERR_NOEXISTS
it means that there is an ongoing persistent confirmed commit,
but persistId did not give the
right cookie for it.public void candidateCommitInfo(String persistId, String label, String comment) throws IOException, ConfException
Maapi.candidateCommit(). Otherwise the
method will confirm the ongoing confirmed commit. For a persistent
confirmed commit, the cookie can be given by persistId if needed.
Note: To ensure that the "Label" and/or "Comment" are stored
in the rollback file in all cases when doing a confirmed commit,
they must be given both with the confirmed commit (using
Maapi.candidateConfirmedCommitInfo(int, java.lang.String, java.lang.String)) and
with the confirming commit (using this method).persistId - value for an already ongoing persistent confirmed commitlabel - value for "Label" in the rollback filecomment - value for "Comment" in the rollback fileIOExceptionConfException - If error. If the errorCode for the
ConfException is ConfException.ERR_NOEXISTS
it means that there is an ongoing persistent confirmed commit,
but persistId did not give the
right cookie for it.public void loadRollback(int tid,
int nr)
throws IOException,
ConfException
tid - Transaction Identifiernr - Rollback numberIOExceptionConfExceptionpublic void loadRollbackFixed(int tid,
int fixed_nr)
throws IOException,
ConfException
tid - Transaction Identifierfixed_nr - fixed rollback numberIOExceptionConfExceptionpublic MaapiRollback[] listRollback() throws IOException, ConfException
IOExceptionConfExceptionpublic void copyRunningToStartup()
throws IOException,
ConfException
ConfExceptionIOExceptionpublic void copy(int thfrom,
int thto)
throws IOException,
ConfException
thfrom - thto - ConfExceptionIOExceptionpublic void copyPath(int fromTh,
int toTh,
ConfPath path)
throws IOException,
ConfException
Maapi.copy(int, int), but does a replacing copy only
of the subtree rooted at the path given by pathfromTh - toTh - path - ConfExceptionIOExceptionpublic MaapiAuthentication authenticate(String user, String passwd) throws IOException, ConfException
Maapi.startUserSession(String,InetAddress,String,String[],
MaapiUserSessionFlag) requires the application to tell ConfD/NCS
which groups the user are member of.
ConfD/NCS itself has the capability to authenticate users. It is possible for a MAAPI application to let ConfD/NCS authenticate the user, as per the AAA configuration in the system configuration file
user - passwd - ConfExceptionIOExceptionpublic MaapiAuthentication authenticate2(String user, String passwd, InetAddress src_addr, int src_port, String context, MaapiUserSessionFlag proto) throws IOException, ConfException
Maapi.startUserSession(String,InetAddress,String,String[],
MaapiUserSessionFlag) requires the application to tell ConfD/NCS
which groups the user are member of.
ConfD/NCS itself has the capability to authenticate users. It is possible for a MAAPI application to let ConfD/NCS authenticate the user, as per the AAA configuration in the system configuration file
user - passwd - src_addr - src_port - context - proto - ConfExceptionIOExceptionpublic String[] getAuthorizationInfo(int usid) throws IOException, ConfException
IOExceptionConfExceptionpublic int getRunningDbStatus()
throws IOException,
ConfException
If a transaction fails in the commit phase, the
configuration database is in in a possibly inconsistent state.
This method queries ConfD/NCS on the consistency state.ConfExceptionIOExceptionpublic void setRunningDbStatus(int status)
throws IOException,
ConfException
ConfExceptionIOExceptionpublic ConfXMLParam[] requestAction(ConfXMLParam[] params, String fmt, Object... arguments) throws IOException, ConfException
tailf:action (see tailf_yang_extensions(5)).
The input parameters is specified as ConfXMLParam
as the input array param which corresponds to
the input section of the action.
The output parameters returned from the method call returns
a array of ConfXMLParam which corresponds to
the output section of the action.
Consider the following yang model:
module cs {
namespace "http://example.com/test/cs/1.0";
prefix cs;
import tailf-common {
prefix tailf;
}
typedef math_op {
type enumeration {
enum add;
enum sub;
enum mul;
enum div;
enum square;
}
}
container system {
list computer {
key name;
leaf name {
type string;
}
tailf:action math {
tailf:actionpoint math_cs;
input {
list operation {
min-elements 1;
max-elements 3;
leaf number {
type int32;
mandatory true;
}
leaf type {
type math_op;
mandatory true;
}
leaf-list operands {
type int16;
}
}
}
output {
container result {
presence "";
leaf number {
type int32;
mandatory true;
}
leaf type {
type math_op;
mandatory true;
}
leaf value {
type int16;
mandatory true;
}
}
}
}
}
}
}
The following is a example of how to assemble the action parameters into
and array of ConfXMLParam and its subclasses:
ConfNamespace n = new cs();
ConfXMLParam[] params =
new ConfXMLParam[] {
new ConfXMLParamStart(n, cs.cs_operation_),
new ConfXMLParamValue(n, cs.cs_number_, new ConfInt32(13)),
new ConfXMLParamValue(n, cs.cs_type_, new ConfEnumeration(0)),
new ConfXMLParamValue(n, cs.cs_operands_,
new ConfList(new ConfObject[] {
new ConfInt16(13),
new ConfInt16(25) })),
new ConfXMLParamStop(n, cs.cs_operation_)};
Using this we can call the action:
Maapi maapi = Maapi(socket);
maapi.setNamespace(
maapi.startUserSession("admin",
InetAddress.getByName("localhost"),
"maapi",
new String[] { "admin" },
MaapiUserSessionFlag.PROTO_TCP);
//Invokes the specified action with input arguments params
//and returns the output parameters
ConfXMLParam[] res = maapi.requestAction(params,
"/system/computer{fred}/math");
The path given by fmt and the varargs list
is the full path to the action, i.e. the final element must be the
name of the action element in the YANG model.
Since actions are not associated with transactions, the namespace
must be provided and the path must be absolute
transactions, the namespace must be provided and the path must be
absolute - but see
Maapi.requestActionTh(int,ConfXMLParam[],String,Object...).
The Maapi instance must have an established user
session before issue this method call.
params - action input parametersfmt - path string, this must be an absolute path with its
root element prefixed .i.e "/prefix:tagname/...."arguments - optional parameters for substitution in fmtConfException - If the methods invocation fails for some
reason. The errorCode or message could be obtain
through getErrorCode, getMessage()IOException - Signals that a I/O
exception has occurred on the stream to ConfD/NCSpublic ConfXMLParam[] requestAction(List<ConfXMLParam> params, String fmt, Object... arguments) throws IOException, ConfException
Maapi.requestAction(ConfXMLParam[], String, Object...)
with the difference that the params is List
instead of ConfXMLParam array.
The Maapi instance must have an established user
session before issue this method call.
params - action input parameters as Listfmt - path string, this must be an absolute path with its
root element prefixed .i.e "/prefix:tagname/...."arguments - optional parameters for substitution in fmtConfXMLParam as the output parametersConfException - If the methods invocation fails for some
reason. The errorCode or message could be obtain
through getErrorCode, getMessage()IOException - Signals that a I/O
exception has occurred on the stream to ConfD/NCSpublic ConfXMLParam[] requestAction(ConfXMLParam[] params, int nshash, String fmt, Object... arguments) throws IOException, ConfException
Maapi.requestAction(ConfXMLParam[], String, Object...)
Since actions are not associated with transactions, the
namespace hash nshash must be provided and the path
to the action, i.e. the final element must be the name of the
action in the data model.
absolute - but see
Maapi.requestActionTh(int,ConfXMLParam[],String,Object...).params - action parametersnshash - hashvalue for root namespace for the path represented by
the fmt argumentfmt - path stringarguments - optional parameters for substitution in fmtConfExceptionIOExceptionpublic ConfXMLParam[] requestAction(List<ConfXMLParam> params, int nshash, String fmt, Object... arguments) throws IOException, ConfException
IOExceptionConfExceptionpublic ConfXMLParam[] requestActionTh(int tid, ConfXMLParam[] params, String fmt, Object... arguments) throws IOException, ConfException
Maapi.requestAction(ConfXMLParam[], String, Object...)
with the difference that the fmt is not required to have a namespace
prefix in the root tag. The root namespace is instead retrieved from
the transaction indicated by the tid argument.
Also, the user session of the transaction owner is used for the action
invocation.
This function may be convenient in some cases where actions are invoked
in conjunction with a transaction, and it must be used if the action
needs to access the transaction store.tid - current transaction handleparams - action parametersfmt - path stringarguments - optional parameters for substitution in fmtIOExceptionConfExceptionpublic ConfXMLParam[] requestActionTh(int tid, List<ConfXMLParam> params, String fmt, Object... arguments) throws IOException, ConfException
IOExceptionConfExceptionpublic void snmpSendNotification(String notifName, String notifyTarget, String ctxName, SnmpVarbind[] varbinds) throws ConfException
Sends a notification to the management targets defined for 'notifyTarget' in the snmpNotifyTable in SNMP-NOTIFICATION-MIB from the specified context. If no NotifyName is specified (or if it is ""), the notification is sent to all management targets.
notifName - Notification namenotifyTarget - Notification target namectxName - Context name.varbinds - An array of variable bindingsConfExceptionpublic String CLIPrompt(int usid, String prompt, boolean echo) throws ConfException, IOException
The echo parameter is used to control if the input should be echoed or not. If set to 'true' all input will be visible and if set to 'false' only stars will be shown instead of the actual characters entered by the user. The resulting string will be returned.
This function is intended to be called from inside an action callback when invoked from the CLI.
usid - ID of sessionprompt - Prompt stringecho - If the answer should be echoed or notConfExceptionIOExceptionpublic String CLIPrompt(int usid, String prompt, boolean echo, int timeout) throws ConfException, IOException
The echo parameter is used to control if the input should be echoed or not. If set to 'true' all input will be visible and if set to 'false' only stars will be shown instead of the actual characters entered by the user. The resulting string will be returned.
This function is intended to be called from inside an action callback when invoked from the CLI.
usid - ID of sessionprompt - Prompt stringecho - If the answer should be echoed or nottimeout - Idle timeout in secondsConfExceptionIOExceptionpublic String CLIPromptOneOf(int usid, String prompt, String[] choice) throws ConfException, IOException
For example:
String res =
maapi.CLIPromptOneOf(usid,
"Do you want to proceed (yes/no): ",
new String[] { "yes", "no" });
For example:
Do you want to proceed (yes/no): maybe
The value must be one of: yes,no.
Do you want to proceed (yes/no):
This function is intended to be called from inside an action callback
when invoked from the CLI.usid - ID of sessionprompt - Prompt stringchoice - An array of choices to accept from userConfExceptionIOExceptionpublic String CLIPromptOneOf(int usid, String prompt, String[] choice, int timeout) throws ConfException, IOException
For example:
String res =
maapi.CLIPromptOneOf(usid,
"Do you want to proceed (yes/no): ",
new String[] { "yes", "no" },
60);
For example:
Do you want to proceed (yes/no): maybe
The value must be one of: yes,no.
Do you want to proceed (yes/no):
This function is intended to be called from inside an action callback
when invoked from the CLI.usid - ID of sessionprompt - Prompt stringchoice - An array of choices to accept from usertimeout - Idle timeout in secondsConfExceptionIOExceptionpublic String CLIReadEOF(int usid, boolean echo) throws ConfException, IOException
The user has to end the input using ctrl-D. The entered characters will be returned. The echo parameters controls if the entered characters should be echoed or not. If set to 'true' the answer will be visible and if set to 'false' stars will be echoed instead.
This method is intended to be called from inside an action call- back when invoked from the CLI.
ConfExceptionIOExceptionpublic String CLIReadEOF(int usid, boolean echo, int timeout) throws ConfException, IOException
The user has to end the input using ctrl-D. The entered characters will be returned. The echo parameters controls if the entered characters should be echoed or not. If set to 'true' the answer will be visible and if set to 'false' stars will be echoed instead.
This function is intended to be called from inside an action call- back when invoked from the CLI.
ConfExceptionIOExceptionpublic void CLIWrite(int usid,
String buf)
throws ConfException,
IOException
This method is intended to be called from inside an action callback when invoked from the CLI.
usid - ID of sessionbuf - Text to write to CLIConfExceptionIOExceptionpublic void CLIAccounting(String user, int usid, String cmd) throws ConfException, IOException
user - username of sessionusid - ID of sessioncmd - Text to write to the audit logConfExceptionIOExceptionpublic String CLIDiffCmd(int thandle, int thandleOld, ConfPath path) throws ConfException, IOException
thandle - Transaction attached to MaapithandleOld - Another transactionpath - pathConfExceptionIOExceptionpublic CLICmdToPathResult CLICmdToPath(String cmd) throws ConfException, IOException
Maapi.CLICmdToPath(int, String) with the first
parameter set to -1 (ie, the command is not interpreted in the
context of any particular transaction)ConfExceptionIOExceptionpublic CLICmdToPathResult CLICmdToPath(int th, String cmd) throws ConfException, IOException
CLICmdToPathResult object, containing the resulting
namespace and the data-model path.
If the string cannot be interpreted as a path an exception is thrown, indicating that the string is either an operational mode command, a configuration mode command, or just badly formatted. The string is interpreted in the context of the current running configuration.
th - transaction handlecmd - The command to interpretConfExceptionIOExceptionpublic String CLIPathCmd(int th, EnumSet<CLIPathCmdFlag> flags, String fmt, Object... args) throws ConfException, IOException
th - Transaction handleflags - Flags can be given as:
EMIT_PARENTS to enable the commands to reach the submode for the path
to be emitted.
DELETE to emit the command to delete the given path.
NON_RECURSIVE to prevent that all children to a container or list item
are displayed.path - path to be formatted as CLI commandConfExceptionIOExceptionpublic void setReadOnlyMode(boolean flag)
throws ConfException,
IOException
flag - ModeConfExceptionIOExceptionpublic MaapiSchemas loadSchemas() throws ConfException
When loaded the MaapiSchemas object is stored
locally and new calls to this method will return the same instance.
MaapiException - if loading failsConfExceptionpublic MaapiSchemas loadSchemas(String[] namespaceURIs) throws ConfException
When loaded the MaapiSchemas object is stored locally and new calls to this method will return the same instance.
namespaceURIs - string array of URIs for the schemas to loadMaapiException - if loading failsConfExceptionpublic static MaapiSchemas getSchemas()
public MaapiSchemas reloadSchemas() throws ConfException
Hence each call of this method will interact with the server.
MaapiExceptionConfExceptionpublic MaapiSchemas reloadSchemas(String[] namespaceURIs) throws ConfException
Which namespaces are loaded is specified and do not need to be the same as the earlier loaded that is viped out. This method can therefore unload old schemas and add loading of new schemas.
namespaceURIs - string array of URIs for the schemas to loadMaapiExceptionConfExceptionpublic void setUserSession(int usid)
throws ConfException,
IOException
This can be used instead
Maapi.startUserSession(String,InetAddress, String, String[],
MaapiUserSessionFlag)
when we really do not want to start a new user session, e.g. if we want
to call an action on behalf of a given user session
usid - user session idMaapiExceptionConfExceptionIOExceptionpublic MaapiOutputStream loadConfigStream(int tid, EnumSet<MaapiConfigFlag> flags) throws ConfException, IOException
OuputStream into ConfD/NCS.
This method loads a configuration from a OutputStream
into the server.
The tid parameter is a transaction id. Thus the application must create and also apply the transaction. By default the complete configuration (as allowed by the user of the current transaction) is deleted before the file is loaded.
To merge the contents of the file use the
MaapiConfigFlag.MAAPI_CONFIG_MERGE flag.
The MaapiConfigFlag.MAAPI_CONFIG_WITH_OPER flag can be used
together with MaapiConfigFlag.MAAPI_CONFIG_XML to mean that
any operational data in the file should be ignored
(instead of producing an error).
The other flags parameters are the same as for
Maapi.saveConfig(int, EnumSet, String, Object...)
tid - transaction id for started transactionflags - One of
MAAPI_CONFIG_XML,
MAAPI_CONFIG_J ,
MAAPI_CONFIG_C,
MAAPI_CONFIG_WITH_DEFAULTS,
MAAPI_CONFIG_SHOW_DEFAULTS,
MAAPI_CONFIG_C_IOS,
MAAPI_CONFIG_MERGE or
MAAPI_CONFIG_WITH_OPERMaapiExceptionConfExceptionIOExceptionpublic void loadConfig(int tid,
EnumSet<MaapiConfigFlag> flags,
String filename)
throws ConfException,
IOException
Maapi.saveConfig(int, EnumSet, String, Object...)tid - transaction id for started transactionflags - One of MAAPI_CONFIG_XML,
MAAPI_CONFIG_J ,
MAAPI_CONFIG_C,
MAAPI_CONFIG_WITH_DEFAULTS,
MAAPI_CONFIG_SHOW_DEFAULTS,
MAAPI_CONFIG_C_IOS,
MAAPI_CONFIG_MERGE or
MAAPI_CONFIG_WITH_OPERfilename - name of the configuration file relative directory where
ConfD/NCS started.MaapiExceptionConfExceptionIOExceptionpublic void loadConfigCmds(int tid,
EnumSet<MaapiConfigFlag> flags,
String cmds,
String fmt,
Object... arguments)
throws IOException,
ConfException
Maapi.saveConfig(int, EnumSet, String, Object...)tid - transaction id for started transactionflags - One of MAAPI_CONFIG_XML,
MAAPI_CONFIG_J, MAAPI_CONFIG_C,
MAAPI_CONFIG_WITH_DEFAULTS,
MAAPI_CONFIG_SHOW_DEFAULTS,
MAAPI_CONFIG_C_IOS,
MAAPI_CONFIG_MERGE or
MAAPI_CONFIG_WITH_OPERcmds - string representing the configuration to be loadedfmt - path relative to which the configuration should be loadedConfExceptionIOExceptionpublic MaapiInputStream saveConfig(int tid, EnumSet<MaapiConfigFlag> flags, ConfPath path) throws ConfException, IOException
Retrieves an InputStream from a given path
specified by fmt with flags parameter
which controls the format as follows:
| Flag | Description | |
| Raw-XML | MaapiConfigFlag.XML_FORMAT,
MaapiConfigFlag.MAAPI_CONFIG_XML
|
The configuration format is XML |
| Pretty-XML | MaapiConfigFlag.XML_PRETTY,
MaapiConfigFlag.MAAPI_CONFIG_XML_PRETTY
|
The configuration format is pretty printed XML |
| Juniper CLI format | MaapiConfigFlag.MAAPI_CONFIG_J,
MaapiConfigFlag.JUNIPER_CLI_FORMAT
|
The configuration is in curly brace Juniper CLI format |
| Cisco XR CLI format | MaapiConfigFlag.MAAPI_CONFIG_C_IOS,
MaapiConfigFlag.CISCO_XR_FORMAT
|
The configuration is in Cisco XR style format |
| Cisco IOS CLI format | MaapiConfigFlag.MAAPI_CONFIG_C_IOS,
MaapiConfigFlag.CISCO_IOS_FORMAT
|
The configuration is in Cisco IOS style format |
The provided path indicates from where the configuration is to be rooted. If for example fmt is "/aaa:aaa/authentication/users" we only dump a part of the AAA data. It must be a prefix pre pended keypath.
By default, the treatment of nodes with a tailf:hidden
statement depends on the state of the transaction. For a transaction
started via MAAPI, no nodes are hidden, while for a transaction started
by another northbound agent (e.g. CLI) and attached to, the nodes that
are hidden are the same as in that agent session. The default can be
overridden by using one of the flags
MaapiConfigFlag.MAAPI_CONFIG_HIDE_ALL and
MaapiConfigFlag.MAAPI_CONFIG_UNHIDE_ALL.
By default, the NCS service-meta-data attributes (refcounter,
backpointer, and original-value) are not included in the configuration.
The flag MaapiConfigFlag.MAAPI_CONFIG_WITH_SERVICE_META can
be used to request that these attributes should be included.
The library will initialize a new socket to the end point specified by the initial socket (which was created during initialization of this Maapi instance) thus it is up to the use
tid - transaction id of the current transactionflags - format parameters (see the table above ) with additional
MAAPI_CONFIG_WITH_DEFAULTS,
MAAPI_CONFIG_SHOW_DEFAULTS for controlling
the defaults
MAAPI_CONFIG_READ_WRITE_ACCESS_ONLY for saving
only nodes for which the user has read_write accesspath - path indicating where the configuration to be rootedConfException - If the methods invocation fails for some
reason. The errorCode or message could be obtain
through getErrorCode, getMessage()IOException - Signals that a I/O
exception has occurred on the stream to ConfD/NCSpublic MaapiInputStream saveConfig(int tid, EnumSet<MaapiConfigFlag> flags) throws ConfException, IOException
Retrieves an InputStream with flags
parameter which controls the format as follows:
| Flag | Description | |
| Raw-XML | MaapiConfigFlag.XML_FORMAT,
MaapiConfigFlag.MAAPI_CONFIG_XML
|
The configuration format is XML |
| Pretty-XML | MaapiConfigFlag.XML_PRETTY,
MaapiConfigFlag.MAAPI_CONFIG_XML_PRETTY
|
The configuration format is pretty printed XML |
| Juniper CLI format | MaapiConfigFlag.MAAPI_CONFIG_J,
MaapiConfigFlag.JUNIPER_CLI_FORMAT
|
The configuration is in curly brace Juniper CLI format |
| Cisco XR CLI format | MaapiConfigFlag.MAAPI_CONFIG_C_IOS,
MaapiConfigFlag.CISCO_XR_FORMAT
|
The configuration is in Cisco XR style format |
| Cisco IOS CLI format | MaapiConfigFlag.MAAPI_CONFIG_C_IOS,
MaapiConfigFlag.CISCO_IOS_FORMAT
|
The configuration is in Cisco IOS style format |
By default, the treatment of nodes with a tailf:hidden
statement depends on the state of the transaction. For a transaction
started via MAAPI, no nodes are hidden, while for a transaction started
by another northbound agent (e.g. CLI) and attached to, the nodes that
are hidden are the same as in that agent session. The default can be
overridden by using one of the flags
MaapiConfigFlag.MAAPI_CONFIG_HIDE_ALL and
MaapiConfigFlag.MAAPI_CONFIG_UNHIDE_ALL.
Entire configuration is dumped, except that namespaces with restricted export (from 'confdc/ncsc --export') are treated as follows:
When the MAAPI_CONFIG_XML or MAAPI_CONFIG_XML_PRETTY formats are used, the context of the user session that started the transaction is used to select namespaces with restricted export. If the "system" context is used, all namespaces are selected, regardless of export restriction.
When one of the CLI formats is used, the context used to select namespaces with restricted export is always "CLI".
The library will initialize a new socket to the end point specified by the initial socket (which was created during initialization of this Maapi instance) thus it is up to the use
tid - transaction id of the current transactionflags - format parameters (see the table above ) with additional
MAAPI_CONFIG_WITH_DEFAULTS,
MAAPI_CONFIG_SHOW_DEFAULTS for controlling
the defaultsConfException - If the methods invocation fails for some
reason. The errorCode or message could be obtain
through getErrorCode, getMessage()IOException - Signals that a I/O
exception has occurred on the stream to ConfD/NCSMaapi.saveConfig(int,EnumSet,ConfPath)public MaapiInputStream saveConfig(int tid, EnumSet<MaapiConfigFlag> flags, String fmt, Object... args) throws ConfException, IOException
Retrieves an InputStream from a given path
specified by fmt with flags parameter
which controls the format as follows:
| Flag | Description | |
| Raw-XML | MaapiConfigFlag.XML_FORMAT,
MaapiConfigFlag.MAAPI_CONFIG_XML
|
The configuration format is XML |
| Pretty-XML | MaapiConfigFlag.XML_PRETTY,
MaapiConfigFlag.MAAPI_CONFIG_XML_PRETTY
|
The configuration format is pretty printed XML |
| Juniper CLI format | MaapiConfigFlag.MAAPI_CONFIG_J,
MaapiConfigFlag.JUNIPER_CLI_FORMAT
|
The configuration is in curly brace Juniper CLI format |
| Cisco XR CLI format | MaapiConfigFlag.MAAPI_CONFIG_C_IOS,
MaapiConfigFlag.CISCO_XR_FORMAT
|
The configuration is in Cisco XR style format |
| Cisco IOS CLI format | MaapiConfigFlag.MAAPI_CONFIG_C_IOS,
MaapiConfigFlag.CISCO_IOS_FORMAT
|
The configuration is in Cisco IOS style format |
The provided path indicates from where the configuration is to be rooted. If for example fmt is "/aaa:aaa/authentication/users" we only dump a part of the AAA data. It must be a prefix pre pended keypath.
By default, the treatment of nodes with a tailf:hidden
statement depends on the state of the transaction. For a transaction
started via MAAPI, no nodes are hidden, while for a transaction started
by another northbound agent (e.g. CLI) and attached to, the nodes that
are hidden are the same as in that agent session. The default can be
overridden by using one of the flags
MaapiConfigFlag.MAAPI_CONFIG_HIDE_ALL and
MaapiConfigFlag.MAAPI_CONFIG_UNHIDE_ALL.
For MAAPI_CONFIG_XML and MAAPI_CONFIG_XML_PRETTY
it is alternatively possible to give an XPath filter, by
including the flag MaapiConfigFlag.MAAPI_CONFIG_XPATH.
The library will initialize a new socket to the end point specified by the initial socket (which was created during initialization of this Maapi instance) thus it is up to the user to close the returning InputStream after reading the configuration.
tid - transaction id of the current transactionflags - format parameters (see the table above ) with additional
MAAPI_CONFIG_WITH_DEFAULTS,
MAAPI_CONFIG_SHOW_DEFAULTS for controlling
the defaultsfmt - path indicating where the configuration to be rootedargs - variable argument list for c-style parameters in fmtConfException - If the methods invocation fails for some
reason. The errorCode or message could be obtain
through getErrorCode, getMessage()IOException - Signals that a I/O
exception has occurred on the stream to ConfD/NCSMaapi.saveConfig(int,EnumSet,ConfPath)public MaapiInputStream rollbackConfig(int tid, String fmt, String... args) throws MaapiException
tid - transaction id for current transactionfmt - path indicating where the configuration to be rootedargs - variable argument list for c-style parameters in fmtPathMaapiExceptionpublic boolean isCandidateModified()
throws IOException,
ConfException
IOExceptionConfExceptionpublic void ncsMovePrivateData(int initTid,
ConfPath from,
ConfPath to)
throws IOException,
ConfException
initTid - the phase0 transaction retrieved by attachInitfrom - the path to move the private data fromto - the path to move the private data toIOExceptionConfExceptionpublic void reportProgress(int tid,
Maapi.Verbosity verbosity,
String msg)
throws IOException,
ConfException
tid - transaction handleverbosity - at which verbosity level the message should be reportedmsg - the message to reportIOExceptionConfExceptionpublic void reportProgress(int tid,
Maapi.Verbosity verbosity,
String msg,
String packageName)
throws IOException,
ConfException
tid - transaction handleverbosity - at which verbosity level the message should be reportedmsg - the message to reportpackageName - from what package the message is reportedIOExceptionConfExceptionpublic Maapi.Progress reportProgressStart(int tid, Maapi.Verbosity verbosity, String msg, String packageName) throws IOException, ConfException
tid - transaction handleverbosity - at which verbosity level the message should be reportedmsg - the message to reportpackageName - from what package the message is reported#Progress object to be passed to
Maapi.reportProgressStop(Progress) or
Maapi.reportProgressStop(Progress,String) once the event
has finished.IOExceptionConfExceptionpublic void reportProgressStop(Maapi.Progress progress) throws IOException, ConfException
progress - the #Progress object returned by the call to
Maapi.reportProgressStart(int,Verbosity,String,String)IOExceptionConfExceptionpublic void reportProgressStop(Maapi.Progress progress, String annotation) throws IOException, ConfException
progress - the #Progress object returned by the call to
Maapi.reportProgressStart(int,Verbosity,String,String)annotation - metadata about the event, indicating error, explains
latency or shows result etc.IOExceptionConfExceptionpublic void reportServiceProgress(int tid,
Maapi.Verbosity verbosity,
String msg,
String packageName,
ConfPath servicePath)
throws IOException,
ConfException
tid - transaction handleverbosity - at which verbosity level the message should be reportedmsg - the message to reportpackageName - from what package the message is reportedservicePath - the path to the serviceIOExceptionConfExceptionpublic Maapi.Progress reportServiceProgressStart(int tid, Maapi.Verbosity verbosity, String msg, String packageName, ConfPath servicePath) throws IOException, ConfException
tid - transaction handleverbosity - at which verbosity level the message should be reportedmsg - the message to reportpackageName - from what package the message is reportedservicePath - the path to the service#Progress object to be passed to
Maapi.reportServiceProgressStop(Progress) or
Maapi.reportServiceProgressStop(Progress,String) once the
event has finished.IOExceptionConfExceptionpublic void reportServiceProgressStop(Maapi.Progress progress) throws IOException, ConfException
progress - the #Progress object returned by the call to
#reportServiceProgressStart(tid,Verbosity,String,String,ConfPath)IOExceptionConfExceptionpublic void reportServiceProgressStop(Maapi.Progress progress, String annotation) throws IOException, ConfException
progress - the #Progress object returned by the call to
#reportServiceProgressStart(tid,Verbosity,String,String,ConfPath)annotation - metadata about the event, indicating error, explains
latency or shows result etc.IOExceptionConfExceptionpublic Set<String> ncsTemplates() throws IOException, ConfException
IOExceptionConfExceptionpublic void ncsApplyTemplate(int tid,
String template,
ConfPath rootIKP,
Properties variables,
boolean createShared,
boolean createBackpointer)
throws IOException,
ConfException
IOExceptionConfExceptionpublic void ncsApplyTemplate(int tid,
String template,
ConfPath rootIKP,
Properties variables,
String document,
boolean createShared,
boolean createBackpointer)
throws IOException,
ConfException
IOExceptionConfExceptionpublic String[] ncsGetTemplateVariables(String template) throws IOException, ConfException
IOExceptionConfExceptionpublic void initUpgrade(int timeoutsecs,
int flags)
throws IOException,
ConfException
timeoutsecs - specifies a maximum time to wait for users to exitflags - bitflags for control of upgrade behaviorIOExceptionConfExceptionpublic void performUpgrade(String[] loadpathdirs) throws IOException, ConfException
loadpathdirs - array of directoriesIOExceptionConfExceptionpublic void commitUpgrade()
throws IOException,
ConfException
IOExceptionConfExceptionpublic void abortUpgrade()
throws IOException,
ConfException
IOExceptionConfExceptionpublic ConfAttributeValue[] getAttrs(int tid, ConfAttributeType[] attribs, String fmt, Object... args) throws IOException, ConfException
tid - current transactionattribs - array of ConfAttributeType denoting attributes to retrievefmt - path indicating node to retrieve attributes fromargs - variable argument list for c-style parameters in fmtPathIOExceptionConfExceptionpublic void setAttr(int tid,
ConfAttributeValue attr,
String fmt,
Object... args)
throws IOException,
ConfException
tid - current transactionattr - ConfAttributeValue object denoting the attribute to setfmt - path indicating node to retrieve attributes fromargs - variable argument list for c-style parameters in fmtPathIOExceptionConfExceptionpublic void setFlags(int tid,
EnumSet<MaapiFlag> flags)
throws IOException,
ConfException
MaapiFlagtid - current transactionflags - Enumset of MaapiFlagIOExceptionConfExceptionpublic String getCwd(int tid) throws IOException, ConfException
tid - current transactionIOExceptionConfExceptionpublic ConfPath getCwdPath(int tid) throws IOException, ConfException
tid - current transactionIOExceptionConfExceptionpublic boolean isRunningModified()
throws IOException,
ConfException
IOExceptionConfExceptionpublic boolean doDisplay(int tid,
String fmt,
Object... args)
throws IOException,
ConfException
tid - current transactionfmt - path stringargs - optional parameters for substitution in fmtIOExceptionConfExceptionpublic void userMessage(String to, String message, String sender) throws IOException, ConfException
to - username, integer string session no or "all" for all usersmessage - string message to sendsender - stringIOExceptionConfExceptionpublic void sysMessage(String to, String message) throws IOException, ConfException
to - username, integer string session no or "all" for all usersmessage - string message to sendIOExceptionConfExceptionpublic void prioMessage(String to, String message) throws IOException, ConfException
to - username, integer string session no or "all" for all usersmessage - string message to sendIOExceptionConfExceptionpublic void disconnectRemote(String address) throws IOException, ConfException
address - IOExceptionConfExceptionpublic void disconnectSockets(int[] sockets)
throws IOException,
ConfException
disconnectRemote()
that can be useful in particular when using the "External IPC"
functionality (see "Using a different IPC mechanism" in the ConfD IPC
section in the Advanced Topics chapter in the User Guide).
In this case ConfD does not have any knowledge of the remote address of
the IPC connections, and thus disconnectRemote() is
not applicable. disconnectSockets() instead takes an
array of file descriptor numbers as the parameter.
ConfD will close all connected sockets whose local file descriptor
number is included that array.sockets - The array of socket file descriptors to closeIOExceptionMaapiExceptionConfExceptionpublic CLIInteraction getCLIInteraction(int usid)
usid - user session idpublic ConfPath xpath2kpath(String xpath) throws IOException, ConfException
xpath - IOExceptionConfExceptionpublic ConfPath xpath2kpath_th(int tid, String xpath) throws IOException, ConfException
IOExceptionConfExceptionpublic void xpathEval(int tid,
MaapiXPathEvalResult xpatheval,
MaapiXPathEvalTrace xpathtrace,
String expr,
Object initstate,
String fmt,
Object... arguments)
throws IOException,
ConfException
Evaluated the xpath expression as supplied in by
expr.
result(ConfObject[],ConfValue,Object)
method of @see MaapiXPathEvalResult
is called
with the keypath (as ConfObject[]) to the resulting
node as the first argument,
and, if the node is a leaf and has a
value (as ConfValue), the value of that node
as the second argument otherwise it will return the string "undefined".
The expression will be evaluated using the root node as the context node, unless a path to an existing node is given as the fmt argument.
For each invocation the
result method should return
ITER_CONTINUE to tell the
xpath evaluator to continue with the
next resulting node. To stop the evaluation the result
can return ITER_STOP instead.
The MaapiXPathEvalTrace implementation of
a method trace(String) that takes a
single string as argument.
If supplied (optional) it will be invoked when the xpath evaluator has trace output for the current expression.
Theinitstate parameter can be used for any user
supplied opaque
data (i.e. whatever is supplied as initstate is passed as state
to the result method for each invocation).tid - Transaction handlexpatheval - A implementation of MaapiXPathEvalResult
callback methodxpathtrace - A implementation of MaapiXPathEvalTrace or
null if no trace is wantedexpr - The XPath expressionfmt - Path string (context node) root if not suppliedarguments - Optional parameters for substitution in fmtMaapiException - Failed MaapiXPathEvaluateIOException - Failed to read/write maapi socketConfExceptionpublic String xpathEvalExpr(int tid, String expr, MaapiXPathEvalTrace xpathtrace, String fmt, Object... arg) throws IOException, ConfException
expr parameter
and return the result as a string.
It is possible to supply a path fmt (optional) which will
be treated as the initial context node when evaluating expr.
If the path is relative, this is treated as the starting point,
and this is also the node that current() will return
when used in the xpath expression.
If null is given, the current maapi position is used
(set by Maapi.cd(int,String,Object...))
The MaapiXPathEvalTrace implementation of
the method trace(String) which
takes a single string as argument (optional) will be
invoked if supplied (optional) when the xpath implementation has
trace output for the current expression.
tid - Transaction handleexpr - The xpath expressionxpathtrace - A implementation of MaapiXPathEvalTrace
or null if no trace is wanted
A implementation of MaapiXPathEvalTrace or null
if no trace is wantedfmt - Path string (context node) root if not suppliedarg - Optional parameters for substitution in fmtConfException - Failed MaapiXPathEvaluateIOException - Failed to read/write maapi socketpublic void netconfSSHCallHome(ConfObject host, int port) throws IOException, ConfException
host - The ip address or hostname of the clientport - The port the client listens toIOExceptionConfExceptionpublic void netconfSSHCallHomeOpaque(ConfObject host, String opaque, int port) throws IOException, ConfException
host - The ip address or hostname of the clientopaque - String passed to an external SSH Call Home sessionport - The port the client listens toIOExceptionConfExceptionpublic void aaaReload(boolean synchronous)
throws IOException,
ConfException
confd --clear-aaa-cache or ncs
--clear-aaa-cache.synchronous - Whether to wait for the daemon to complete reloading
the AAA data before returning.IOExceptionConfExceptionpublic void snmpaReload(boolean synchronous)
throws IOException,
ConfException
synchronous - Whether to wait for the daemon to complete reloading
the data before returning.IOExceptionConfExceptionpublic void startPhase(int phase,
boolean synchronous)
throws IOException,
ConfException
phase - Which start phase to proceed to, 1 or 2synchronous - Whether to wait for the daemon to complete the
transition to the requested start phase or return immediately.IOExceptionConfExceptionpublic void startPhase(int phase)
throws IOException,
ConfException
phase - Which start phase to proceed to, 1 or 2IOExceptionConfExceptionpublic void waitStart(int phase)
throws IOException,
ConfException
phase - Which start phase to wait for: 0, 1, or 2IOExceptionConfExceptionpublic void waitStarted()
throws IOException,
ConfException
IOExceptionConfExceptionpublic void reloadConfig()
throws IOException,
ConfException
IOExceptionConfExceptionpublic void reopenLogs()
throws IOException,
ConfException
IOExceptionConfExceptionpublic void stop(boolean synchronous)
throws IOException,
ConfException
synchronous - Whether to wait for the daemon to stopIOExceptionConfExceptionpublic void stop()
throws IOException,
ConfException
IOExceptionConfExceptionpublic Socket getSocket()
public static ArrayList<ConfNamespace> getAutoNsList()
public static ArrayList<ConfNamespace> getAutoNsList(ArrayList<ConfNamespace> defaultNsList)
public <T extends ResultType> QueryResult<T> queryStart(int tid, String expr, String context, int chunkSize, int offset, List<String> select, List<String> sort, boolean reverseSortOrder, Class<T> cls) throws IOException, ConfException
th.
If successful a
QueryResult is returned which represents a query result.
The XPath expr string parameter is a primary XPath
expression which must evaluate to a node-set, the "results".
For each node in the results node-set every "select" expression is
evaluated with the result node as its context. For example,
given the YANG snippet:
list interface {
key name;
unique number;
leaf name {
type string;
}
leaf number {
type uint32;
mandatory true;
}
leaf enabled {
type boolean;
default true;
}
...
}
and given that we want to find the name and number of all enabled
interfaces - the expr could be
"/interface[enabled='true']", and the select
expressions would be { "name","number" }.
Note that the select expressions can have any valid XPath expression,
so if you wanted to find out an interfaces name,
and whether its number is even or not, the expressions would be:
{ "name", "(number mod 2) == 0" } .
The select parameter determining what to
include in the result.
The chunksize is
the possibility to return the result in groups of a particular size.
This option determines the fetch frequency for a iterator.
The "chunk" retrieval is done by the QueryResult.iterator()
iterator which process result locally and when it needs more
data it retrieve the next chunk (if available).
The offset is the number of the first result in this
chunk (i.e. for the first chunk it will be 1).
If the underlying database supports multiple "tables" there is usually also support for "join" (the ability to make a filter span several tables), in ConfD/NCS this is usually not an issue - reference to "other" tables are naturally done using leafref, and thus it is possible to filter on "foreign keys" (to use SQL terminology).
tid - transaction handleexpr - XPath expressioncontext - A context nodechunkSize - Result chunksize to fetchoffset - The offset to start fetchselect - A list of XPath "select" expressionssort - A list of XPath exressions used for sortingreverseSortOrder - Set this to true to get items in the reverse
order (only if "sort" is specified)cls - Result typeIOException - if the underlying socket or input stream is
closed for some reasonConfException - if the XPath parser encounters error for some
reasonpublic <T extends ResultType> QueryResult<T> queryStart(int tid, String expr, String context, int chunkSize, int offset, List<String> select, Class<T> cls) throws IOException, ConfException
tid.
Runs an XPath query with default sort order
If successful a
QueryResult is returned which represents a query result.
tid - transaction handleexpr - XPath expressioncontext - A context nodechunkSize - Result chunksize to fetchoffset - The offset to start fetchselect - A list of XPath "select" expressionscls - Result typeIOException - if the underlying socket or input stream is
closed for some reasonConfException - if the XPath parser encounters error for some
reasonpublic boolean setDelayedWhen(int tid,
boolean on)
throws IOException,
ConfException
Maapi.applyTrans(int, boolean).tid - transaction idon - true if "delayed when" mode should be activated,
false if "delayed when" mode should be deactivated.IOExceptionConfExceptionpublic void clearOpCache()
throws IOException,
ConfException
Maapi.clearOpCache(ConfPath), with the only difference that
if clears all cached data from "/" and down.IOExceptionConfExceptionpublic void clearOpCache(ConfPath path) throws IOException, ConfException
path - ConfPath to the subtree for which cached data should be
clearedIOExceptionConfExceptionpublic List<String> getMountId(int tid, ConfPath path) throws IOException, ConfException
IOExceptionConfException