Module _ncs.maapi
Low level module for connecting to NCS with a read/write interface inside transactions.
This module is used to connect to the NCS transaction manager. The API described here has several purposes. We can use MAAPI when we wish to implement our own proprietary management agent. We also use MAAPI to attach to already existing NCS transactions, for example when we wish to implement semantic validation of configuration data in Python, and also when we wish to implement CLI wizards in Python.
This documentation should be read together with the confd_lib_maapi(3) man page.
Functions
def aaa_reload(sock, synchronous)
-
Start a reload of aaa from external data provider.
Used by external data provider to notify that there is a change to the AAA data. Calling the function with the argument 'synchronous' set to 1 or True means that the call will block until the loading is completed.
Keyword arguments:
- sock – a python socket instance
- synchronous – if 1, will wait for the loading complete and return when the loading is complete; if 0, will only initiate the loading of AAA data and return immediately
def aaa_reload_path(sock, synchronous, path)
-
Start a reload of aaa from external data provider.
A variant of _maapi_aaa_reload() that causes only the AAA subtree given by path to be loaded.
Keyword arguments:
- sock – a python socket instance
- synchronous – if 1, will wait for the loading complete and return when the loading is complete; if 0, will only initiate the loading of AAA data and return immediately
- path – the subtree to be loaded
def abort_trans(sock, thandle)
-
Final phase of a two phase transaction, aborting the trans.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
def abort_upgrade(sock)
-
Can be called before committing upgrade in order to abort it.
Final step in an upgrade.
Keyword arguments:
- sock – a python socket instance
def apply_template(sock, thandle, template, variables, flags, rootpath)
-
Apply a template that has been loaded into NCS. The template parameter gives the name of the template. This is NOT a FASTMAP function, for that use shared_ncs_apply_template instead.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- template – template name
- variables – None or a list of variables in the form of tuples
- flags – should be 0
- rootpath – in what context to apply the template
def apply_trans(sock, thandle, keepopen)
-
Apply a transaction.
Validates, prepares and eventually commits or aborts the transaction. If the validation fails and the 'keep_open' argument is set to 1 or True, the transaction is left open and the developer can react upon the validation errors.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- keepopen – if true, transaction is not discarded if validation fails
def apply_trans_flags(sock, thandle, keepopen, flags)
-
A variant of apply_trans() that takes an additional 'flags' argument.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- keepopen – if true, transaction is not discarded if validation fails
- flags – flags to set in the transaction
def apply_trans_params(sock, thandle, keepopen, params) ‑> list
-
A variant of apply_trans() that takes commit parameters in form of a list ofTagValue objects and returns a list of TagValue objects depending on theparameters passed in.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- keepopen – if true, transaction is not discarded if validation fails
- params – list of TagValue objects
def attach(sock, hashed_ns, ctx)
-
Attach to a existing transaction.
Keyword arguments:
- sock – a python socket instance
- hashed_ns – the namespace to use
- ctx – transaction context
def attach2(sock, hashed_ns, usid, thandle)
-
Used when there is no transaction context beforehand, to attach to a existing transaction.
Keyword arguments:
- sock – a python socket instance
- hashed_ns – the namespace to use
- usid – user session id, can be set to 0 to use the owner of the transaction
- thandle – transaction handle
def attach_init(sock) ‑> int
-
Attach the _MAAPI socket to the special transaction available during phase0. Returns the thandle as an integer.
Keyword arguments:
- sock – a python socket instance
def authenticate(sock, user, password, n) ‑> tuple
-
Authenticate a user session. Use the 'n' to get a list of n-1 groups that the user is a member of. Use n=1 if the function is used in a context where the group names are not needed. Returns 1 if accepted without groups. If the authentication failed or was accepted a tuple with first element status code, 0 for rejection and 1 for accepted is returned. The second element either contains the reason for the rejection as a string OR a list groupnames.
Keyword arguments:
- sock – a python socket instance
- user – username
- pass – password
- n – number of groups to return
def authenticate2(sock, user, password, src_addr, src_port, context, prot, n) ‑> tuple
-
This function does the same thing as maapi.authenticate(), but allows for passing of the additional parameters src_addr, src_port, context, and prot, which otherwise are passed only to maapi_start_user_session()/ maapi_start_user_session2(). The parameters are passed on to an external authentication executable. Keyword arguments:
- sock – a python socket instance
- user – username
- pass – password
- src_addr – ip address
- src_port – port number
- context – context for the session
- prot – the protocol used by the client for connecting
- n – number of groups to return
def candidate_abort_commit(sock)
-
Cancel an ongoing confirmed commit.
Keyword arguments:
- sock – a python socket instance
def candidate_abort_commit_persistent(sock, persist_id)
-
Cancel an ongoing confirmed commit with the cookie given by persist_id.
Keyword arguments:
- sock – a python socket instance
- persist_id – gives the cookie for an already ongoing persistent confirmed commit
def candidate_commit(sock)
-
This function copies the candidate to running.
Keyword arguments:
- sock – a python socket instance
def candidate_commit_info(sock, persist_id, label, comment)
-
Commit the candidate to running, or confirm an ongoing confirmed commit, and set the Label and/or Comment that is stored in the rollback file when the candidate is committed to running.
Note:
To ensure the Label and/or Comment are stored in the rollback file in all cases when doing a confirmed commit, they must be given with both, the confirmed commit (using maapi_candidate_confirmed_commit_info()) and the confirming commit (using this function).
Keyword arguments:
- sock – a python socket instance
- persist_id – gives the cookie for an already ongoing persistent confirmed commit
- label – the Label
- comment – the Comment
def candidate_commit_persistent(sock, persist_id)
-
Confirm an ongoing persistent commit with the cookie given by persist_id.
Keyword arguments:
- sock – a python socket instance
- persist_id – gives the cookie for an already ongoing persistent confirmed commit
def candidate_confirmed_commit(sock, timeoutsecs)
-
This function also copies the candidate into running. However if a call to maapi_candidate_commit() is not done within timeoutsecs an automatic rollback will occur.
Keyword arguments:
- sock – a python socket instance
- timeoutsecs – timeout in seconds
def candidate_confirmed_commit_info(sock, timeoutsecs, persist, persist_id, label, comment)
-
Like candidate_confirmed_commit_persistent, but also allows for setting the Label and/or Comment that is stored in the rollback file when the candidate is committed to running.
Note:
To ensure the Label and/or Comment are stored in the rollback file in all cases when doing a confirmed commit, they must be given with both, the confirmed commit (using this function) and the confirming commit (using candidate_commit_info()).
Keyword arguments:
- sock – a python socket instance
- timeoutsecs – timeout in seconds
- persist – sets the cookie for the persistent confirmed commit
- persist_id – gives the cookie for an already ongoing persistent confirmed commit
- label – the Label
- comment – the Comment
def candidate_confirmed_commit_persistent(sock, timeoutsecs, persist, persist_id)
-
Start or extend a confirmed commit using persist id.
Keyword arguments:
- sock – a python socket instance
- timeoutsecs – timeout in seconds
- persist – sets the cookie for the persistent confirmed commit
- persist_id – gives the cookie for an already ongoing persistent confirmed commit
def candidate_reset(sock)
-
Copy running into candidate.
Keyword arguments:
- sock – a python socket instance
def candidate_validate(sock)
-
This function validates the candidate.
Keyword arguments:
- sock – a python socket instance
def cd(sock, thandle, path)
-
Change current position in the tree.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- path – position to change to
def clear_opcache(sock, path)
-
Clearing of operational data cache.
Keyword arguments:
- sock – a python socket instance
- path – the path to the subtree to clear
def cli_accounting(sock, user, usid, cmdstr)
-
Generates an audit log entry in the CLI audit log.
Keyword arguments:
- sock – a python socket instance
- user – user to generate the entry for
- thandle – transaction handle
def cli_cmd(sock, usess, buf)
-
Execute CLI command in the ongoing CLI session.
Keyword arguments:
- sock – a python socket instance
- usess – user session
- buf – string to write
def cli_cmd2(sock, usess, buf, flags)
-
Execute CLI command in a ongoing CLI session. With flags: CMD_NO_FULLPATH - Do not perform the fullpath check on show commands. CMD_NO_HIDDEN - Allows execution of hidden CLI commands.
Keyword arguments:
- sock – a python socket instance
- usess – user session
- buf – string to write
- flags – as above
def cli_cmd3(sock, usess, buf, flags, unhide)
-
Execute CLI command in a ongoing CLI session.
Keyword arguments:
- sock – a python socket instance
- usess – user session
- buf – string to write
- flags – as above
- unhide – The unhide parameter is used for passing a hide group which is unhidden during the execution of the command.
def cli_cmd4(sock, usess, buf, flags, unhide)
-
Execute CLI command in a ongoing CLI session.
Keyword arguments:
- sock – a python socket instance
- usess – user session
- buf – string to write
- flags – as above
- unhide – The unhide parameter is used for passing a hide group which is unhidden during the execution of the command.
def cli_cmd_to_path(sock, line, nsize, psize) ‑> tuple
-
Returns string of the C/I namespaced CLI path that can be associated with the given command. Returns a tuple ns and path.
Keyword arguments:
- sock – a python socket instance
- line – data model path as string
- nsize – limit length of namespace
- psize – limit length of path
def cli_cmd_to_path2(sock, thandle, line, nsize, psize) ‑> tuple
-
Returns string of the C/I namespaced CLI path that can be associated with the given command. In the context of the provided transaction handle. Returns a tuple ns and path.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- line – data model path as string
- nsize – limit length of namespace
- psize – limit length of path
def cli_diff_cmd(sock, thandle, thandle_old, flags, path, size) ‑> str
-
Get the diff between two sessions as a series C/I cli commands. Returns a string. If no changes exist between the two sessions for the given path a _ncs.error.Error will be thrown with the error set to ERR_BADPATH
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- thandle_old – transaction handle
- flags – as for cli_path_cmd
- path – as for cli_path_cmd
- size – limit diff
def cli_get(sock, usess, opt, size) ‑> str
-
Read CLI session parameter or attribute.
Keyword arguments:
- sock – a python socket instance
- usess – user session
- opt – option to get
- size – maximum response size (optional, default 1024)
def cli_path_cmd(sock, thandle, flags, path, size) ‑> str
-
Returns string of the C/I CLI command that can be associated with the given path. The flags can be given as FLAG_EMIT_PARENTS to enable the commands to reach the submode for the path to be emitted. The flags can be given as FLAG_DELETE to emit the command to delete the given path. The flags can be given as FLAG_NON_RECURSIVE to prevent that all children to a container or list item are displayed.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- flags – as above
- path – the path for the cmd
- size – limit cmd
def cli_prompt(sock, usess, prompt, echo, size) ‑> str
-
Prompt user for a string.
Keyword arguments:
- sock – a python socket instance
- usess – user session
- prompt – string to show the user
- echo – determines wether to control if the input should be echoed or not. ECHO shows the input, NOECHO does not
- size – maximum response size (optional, default 1024)
def cli_prompt_oneof(...)
-
Prompt user for a string.
def cli_prompt_oneof2(...)
-
Prompt user for a string.
def cli_read_eof(...)
-
Prompt user for a string.
def cli_read_eof2(...)
-
Prompt user for a string.
def cli_set(sock, usess, opt, value)
-
Set CLI session parameter.
Keyword arguments:
- sock – a python socket instance
- usess – user session
- opt – option to set
- value – the new value of the session parameter
def cli_write(sock, usess, buf)
-
Write to the cli.
Keyword arguments:
- sock – a python socket instance
- usess – user session
- buf – string to write
def close(sock)
-
Ends session and closes socket.
Keyword arguments:
- sock – a python socket instance
def commit_queue_result(sock, thandle, timeoutsecs) ‑> tuple
-
Get result from commit queue. Returns tuple(int, int) containing queue id and status.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- timeoutsecs – timeout in seconds
def commit_trans(sock, thandle)
-
Final phase of a two phase transaction, committing the trans.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
def commit_upgrade(sock)
-
Final step in an upgrade.
Keyword arguments:
- sock – a python socket instance
def confirmed_commit_in_progress(sock) ‑> int
-
Checks whether a confirmed commit is ongoing. Returns a positive integer being the usid of confirmed commit operation in progress or 0 if no confirmed commit is in progress.
Keyword arguments:
- sock – a python socket instance
def connect(sock, ip, port, path)
-
Connect to the system daemon.
Keyword arguments:
- sock – a python socket instance
- ip – the ip address
- port – the port
- path – the path if socket is AF_UNIX (optional)
def copy(sock, from_thandle, to_thandle)
-
Copy all data from one data store to another.
Keyword arguments:
- sock – a python socket instance
- from_thandle – transaction handle
- to_thandle – transaction handle
def copy_path(sock, from_thandle, to_thandle, path)
-
Copy subtree rooted at path from one data store to another.
Keyword arguments:
- sock – a python socket instance
- from_thandle – transaction handle
- to_thandle – transaction handle
- path – the subtree rooted at path is copied
def copy_running_to_startup(sock)
-
Copies running to startup.
Keyword arguments:
- sock – a python socket instance
def copy_tree(sock, thandle, frompath, topath)
-
Copy subtree rooted at frompath to topath.
Keyword arguments:
- sock – a python socket instance
- frompath – the subtree rooted at path is copied
- topath – to which path the subtree is copied
def create(sock, thandle, path)
-
Create a new list entry, a presence container or a leaf of type empty (unless in a union, if type empty is in a union use set_elem instead) in the data tree.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- path – path of item to create
def cs_node_cd(socket, thandle, path) ‑> Optional[CsNode]
-
Utility function which finds the resulting CsNode given a string keypath.
Does the same thing as _ncs.cs_node_cd(), but can handle paths that are ambiguous due to traversing a mount point, by sending a request to the daemon
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- path – the keypath
def cs_node_children(sock, thandle, mount_point, path) ‑> List[CsNode]
-
Retrieve a list of the children nodes of the node given by mount_point that are valid for path. The mount_point node must be a mount point (i.e. mount_point.is_mount_point() == True), and the path must lead to a specific instance of this node (including the final keys if mount_point is a list node). The thandle parameter is optional, i.e. it can be given as -1 if a transaction is not available.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- mount_point – a CsNode instance
- path – the path to the instance of the node
def delete(sock, thandle, path)
-
Delete an existing list entry, a presence container or a leaf of type empty from the data tree.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- path – path of item to delete
def delete_all(sock, thandle, how)
-
Delete all data within a transaction.
The how argument specifies how to delete: DEL_SAFE - Delete everything except namespaces that were exported with tailf:export none. Top-level nodes that cannot be deleted due to AAA rules are left in place (descendant nodes may be deleted if the rules allow it). DEL_EXPORTED - As DEL_SAFE, but AAA rules are ignored. DEL_ALL - Delete everything, AAA rules are ignored.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- how – DEL_SAFE, DEL_EXPORTED or DEL_ALL
def delete_config(sock, name)
-
Empties a datastore.
Keyword arguments:
- sock – a python socket instance
- name – name of the datastore to empty
def destroy_cursor(mc)
-
Deallocates memory which is associated with the cursor.
Keyword arguments:
- mc – maapiCursor
def detach(sock, ctx)
-
Detaches an attached _MAAPI socket.
Keyword arguments:
- sock – a python socket instance
- ctx – transaction context
def detach2(sock, thandle)
-
Detaches an attached _MAAPI socket when we do not have a transaction context available.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
def diff_iterate(sock, thandle, iter, flags)
-
Iterate through a transaction diff.
For each diff in the transaction the callback function 'iter' will be called. The iter function needs to have the following signature:
Where arguments are:
- keypath - the affected path (HKeypathRef)
- operation - one of MOP_CREATED, MOP_DELETED, MOP_MODIFIED, MOP_VALUE_SET, MOP_MOVED_AFTER, or MOP_ATTR_SET
- oldvalue - always None
- newvalue - see below
The 'newvalue' argument may be set for operation MOP_VALUE_SET and is a Value object in that case. For MOP_MOVED_AFTER it may be set to a list of key values identifying an entry in the list - if it's None the list entry has been moved to the beginning of the list. For MOP_ATTR_SET it will be set to a 2-tuple of Value's where the first Value is the attribute set and the second Value is the value the attribute was set to. If the attribute has been deleted the second value is of type C_NOEXISTS
The iter function should return one of:
- ITER_STOP - Stop further iteration
- ITER_RECURSE - Recurse further down the node children
- ITER_CONTINUE - Ignore node children and continue with the node's siblings
One could also define a class implementing the call function as:
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- iter – iterator function, will be called for every diff in the transaction
- flags – bitmask of ITER_WANT_ATTR and ITER_WANT_P_CONTAINER
def disconnect_remote(sock, address)
-
Disconnect all remote connections to 'address' except HA connections.
Keyword arguments:
- sock – a python socket instance
- address – ip address (string)
def disconnect_sockets(sock, sockets)
-
Disconnect 'sockets' which is a list of sockets (fileno).
Keyword arguments:
- sock – a python socket instance
- sockets – list of sockets (int)
def do_display(sock, thandle, path) ‑> int
-
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 'path' should be displayed or not.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- path – path to the 'display-when' statement
def end_progress_span(sock, span, annotation) ‑> int
-
Ends a progress span started from start_progress_span() or start_progress_span_th().
Keyword arguments: * sock – a python socket instance * span – span_id (string) or dict with key 'span_id' * annotation – metadata about the event, indicating error, explains latency or shows result etc
def end_user_session(sock)
-
End the MAAPI user session associated with the socket
Keyword arguments:
- sock – a python socket instance
def exists(sock, thandle, path) ‑> bool
-
Check wether a node in the data tree exists. Returns boolean.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- path – position to check
def find_next(mc, type, inkeys) ‑> Union[List[Value], bool]
-
Update the cursor mc with the key(s) for the list entry designated by the type and inkeys parameters. This function may be used to start a traversal from an arbitrary entry in a list. Keys for subsequent entries may be retrieved with the get_next() function. When no more keys are found, False is returned.
The strategy to use is defined by type:
Keyword arguments:
- mc – maapiCursor
- type – CONFD_FIND_NEXT or CONFD_FIND_SAME_OR_NEXT
- inkeys – where to start finding
def finish_trans(sock, thandle)
-
Finish a transaction.
If the transaction is implemented by an external database, this will invoke the finish() callback.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
def get_attrs(sock, thandle, attrs, keypath) ‑> list
-
Get attributes for a node. Returns a list of attributes.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- attrs – list of type of attributes to get
- keypath – path to choice
-
This function retrieves authorization info for a user session,i.e. the groups that the user has been assigned to.
Keyword arguments:
- sock – a python socket instance
- usessid – user session id
def get_case(sock, thandle, choice, keypath) ‑> Value
-
Get the case from a YANG choice statement.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- choice – choice name
- keypath – path to choice
def get_elem(sock, thandle, path) ‑> Value
-
Path must be a valid leaf node in the data tree. Returns a Value object.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- path – position of elem
def get_my_user_session_id(sock) ‑> int
-
Returns user session id
Keyword arguments:
- sock – a python socket instance
def get_next(mc) ‑> Union[List[Value], bool]
-
Iterates and gets the keys for the next entry in a list. When no more keys are found, False is returned.
Keyword arguments:
- mc – maapiCursor
def get_object(sock, thandle, n, keypath) ‑> List[Value]
-
Read at most n values from keypath in a list.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- path – position of list entry
def get_objects(mc, n, nobj) ‑> List[Value]
-
Read at most n values from each nobj lists starting at Cursor mc. Returns a list of Value's.
Keyword arguments:
- mc – maapiCursor
- n – at most n values will be read
- nobj – number of nobj lists which n elements will be taken from
def get_rollback_id(sock, thandle) ‑> int
-
Get rollback id from a committed transaction. Returns int with fixed id, where -1 indicates an error or no rollback id available.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
def get_running_db_status(sock) ‑> int
-
If a transaction fails in the commit() phase, the configuration database is in in a possibly inconsistent state. This function queries ConfD on the consistency state. Returns 1 if the configuration is consistent and 0 otherwise.
Keyword arguments:
- sock – a python socket instance
def get_schema_file_path(sock) ‑> str
-
If shared memory schema support has been enabled, this function will return the pathname of the file used for the shared memory mapping, which can then be passed to the mmap_schemas() function>
If creation of the schema file is in progress when the function is called, the call will block until the creation has completed.
Keyword arguments:
- sock – a python socket instance
def get_stream_progress(sock, id) ‑> int
-
Used in conjunction with a maapi stream to see how much data has been consumed.
This function allows us to limit the amount of data 'in flight' between the application and the system. The sock parameter must be the maapi socket used for a function call that required a stream socket for writing (currently the only such function is load_config_stream()), and the id parameter is the id returned by that function.
Keyword arguments:
- sock – a python socket instance
- id – the id returned from load_config_stream()
def get_templates(sock) ‑> list
-
Get the defined templates.
Keyword arguments:
- sock – a python socket instance
def get_trans_params(sock, thandle) ‑> list
-
Get the commit parameters for a transaction. The commit parameters are returned as a list of TagValue objects.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
def get_user_session(sock, usessid) ‑> UserInfo
-
Return user info.
Keyword arguments:
- sock – a python socket instance
- usessid – session id
def get_user_session_identification(sock, usessid) ‑> dict
-
Get user session identification data.
Get the user identification data related to a user session provided by the 'usessid' argument. The function returns a dict with the user identification data.
Keyword arguments:
- sock – a python socket instance
- usessid – user session id
def get_user_session_opaque(sock, usessid) ‑> str
-
Returns a string containing additional 'opaque' information, if additional 'opaque' information is available.
Keyword arguments:
- sock – a python socket instance
- usessid – user session id
def get_user_sessions(sock) ‑> list
-
Return a list of session ids.
Keyword arguments:
- sock – a python socket instance
def get_values(sock, thandle, values, keypath) ‑> list
-
Get values from keypath based on the Tag Value array values.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- values – list of tagValues
def getcwd(sock, thandle) ‑> str
-
Get the current position in the tree as a string.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
def getcwd_kpath(sock, thandle) ‑> HKeypathRef
-
Get the current position in the tree as a HKeypathRef.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
def hide_group(sock, thandle, group_name)
-
Hide all nodes belonging to a hide group in a transaction that started with flag FLAG_HIDE_ALL_HIDEGROUPS.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- group_name – the group name
def init_cursor(sock, thandle, path) ‑> Cursor
-
Whenever we wish to iterate over the entries in a list in the data tree, we must first initialize a cursor.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- path – position of elem
- secondary_index – name of secondary index to use (optional)
- xpath_expr – xpath expression used to filter results (optional)
def init_upgrade(sock, timeoutsecs, flags)
-
First step in an upgrade, initializes the upgrade procedure.
Keyword arguments:
- sock – a python socket instance
- timeoutsecs – maximum time to wait for user to voluntarily exit from 'configuration' mode
- flags – 0 or 'UPGRADE_KILL_ON_TIMEOUT' (will terminate all ongoing transactions
def insert(sock, thandle, path)
-
Insert a new entry in a list, the key of the list must be a integer.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- path – the subtree rooted at path is copied
def install_crypto_keys(sock)
-
Copy configured DES3 and AES keys into the memory in the library.
Keyword arguments:
- sock – a python socket instance
def is_candidate_modified(sock) ‑> bool
-
Checks if candidate is modified.
Keyword arguments:
- sock – a python socket instance
def is_lock_set(sock, name) ‑> int
-
Check if db name is locked. Return the 'usid' of the user holding the lock or 0 if not locked.
Keyword arguments:
- sock – a python socket instance
def is_running_modified(sock) ‑> bool
-
Checks if running is modified.
Keyword arguments:
- sock – a python socket instance
def iterate(sock, thandle, iter, flags, path)
-
Used to iterate over all the data in a transaction and the underlying data store as opposed to only iterate over changes like diff_iterate.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- iter – iterator function, will be called for every diff in the transaction
- flags – ITER_WANT_ATTR or 0
- path – receive only changes from this path and below
The iter callback function should have the following signature:
def keypath_diff_iterate(sock, thandle, iter, flags, path)
-
Like diff_iterate but takes an additional path argument.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- iter – iterator function, will be called for every diff in the transaction
- flags – bitmask of ITER_WANT_ATTR and ITER_WANT_P_CONTAINER
- path – receive only changes from this path and below
def kill_user_session(sock, usessid)
-
Kill MAAPI user session with session id.
Keyword arguments:
- sock – a python socket instance
- usessid – the MAAPI session id to be killed
def list_rollbacks(sock, rp_size) ‑> list
-
Get a list of rollbacks, at most rp_size big.
This function is deprecated and will be removed in a future release. Consult the /rollback-files list instead.
Keyword arguments:
- sock – a python socket instance
- rp_size – maximum number of rollback files to list
def load_config(sock, thandle, flags, filename)
-
Loads configuration from 'filename'. The caller of the function has to indicate which format the file has by using one of the following flags:
Keyword arguments:
- sock – a python socket instance
- thandle – a transaction handle
- flags – as above
- filename – to read the configuration from
def load_config_cmds(sock, thandle, flags, cmds, path)
-
Loads configuration from the string 'cmds'
Keyword arguments:
- sock – a python socket instance
- thandle – a transaction handle
- cmds – a string of cmds
- flags – as above
def load_config_stream(sock, th, flags) ‑> int
-
Loads configuration from the stream socket. The th and flags parameters are the same as for load_config(). Returns and id.
Keyword arguments:
- sock – a python socket instance
- thandle – a transaction handle
- flags – as for load_config()
def load_config_stream_result(sock, id) ‑> int
-
We use this function to verify that the configuration we wrote on the stream socket was successfully loaded.
Keyword arguments:
- sock – a python socket instance
- id – the id returned from load_config_stream()
def load_rollback(sock, thandle, rollback_num)
-
Install a rollback file with number 'rollback_num'.
This function is deprecated and will be removed in a future release. Use the action /rollback-files/apply-rollback-file instead.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- rollback_num – rollback file no
def load_rollback_fixed(sock, thandle, fixed_num)
-
Install a rollback file with fixed number 'fixed_num'.
This function is deprecated and will be removed in a future release. Use the action /rollback-files/apply-rollback-file instead.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- fixed_num – rollback fixed number
def load_schemas(sock)
-
Loads all schema information into the lib.
Keyword arguments:
- sock – a python socket instance
def load_schemas_list(sock, flags, nshash, nsflags)
-
Loads selected schema information into the lib.
Keyword arguments:
- sock – a python socket instance
- flags – the flags to set
- nshash – the listed namespaces that schema information should be loaded for
- nsflags – namespace specific flags
def lock(sock, name)
-
Lock database with name.
Keyword arguments:
- sock – a python socket instance
- name – name of the database to lock
def lock_partial(sock, name, xpaths) ‑> int
-
Lock a subset (xpaths) of database name. Returns lockid.
Keyword arguments:
- sock – a python socket instance
- xpaths – a list of strings
def move(sock, thandle, tokey, path)
-
Moves an existing list entry, i.e. renames the entry using the tokey parameter.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- tokey – confdValue list
- path – the subtree rooted at path is copied
def move_ordered(sock, thandle, where, tokey, path)
-
Moves an entry in an 'ordered-by user' statement to a new position.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- where – FIRST, LAST, BEFORE or AFTER
- tokey – confdValue list
- path – the subtree rooted at path is copied
def netconf_ssh_call_home(sock, host, port)
-
Initiates a NETCONF SSH Call Home connection.
Keyword arguments:
sock – a python socket instance host – an ipv4 addres, ipv6 address, or host name port – the port to connect to
def netconf_ssh_call_home_opaque(sock, host, opaque, port)
-
Initiates a NETCONF SSH Call Home connection.
Keyword arguments: sock – a python socket instance host – an ipv4 addres, ipv6 address, or host name opaque – opaque string passed to an external call home session port – the port to connect to
def num_instances(sock, thandle, path) ‑> int
-
Return the number of instances in a list in the tree.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- path – position to check
def perform_upgrade(sock, loadpathdirs)
-
Second step in an upgrade. Loads new data model files.
Keyword arguments:
- sock – a python socket instance
- loadpathdirs – list of directories that are searched for CDB 'init' files
def popd(sock, thandle)
-
Return to earlier saved (pushd) position in the tree.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
def prepare_trans(sock, thandle)
-
First phase of a two-phase trans.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
def prepare_trans_flags(sock, thandle, flags)
-
First phase of a two-phase trans with flags.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- flags – flags to set in the transaction
def prio_message(sock, to, message)
-
Like sys_message but will be output directly instead of delivered when the receiver terminates any ongoing command.
Keyword arguments:
- sock – a python socket instance
- to – user to send message to or 'all' to send to all users
- message – the message
def progress_info(sock, msg, verbosity, attrs, links, path)
-
While spans represents a pair of data points: start and stop; info events are instead singular events, one point in time. Call progress_info() to write a progress span info event to the progress trace. The info event will have the same span-id as the start and stop events of the currently ongoing progress span in the active user session or transaction. See start_progress_span() for more information.
Keyword arguments:
- sock – a python socket instance
- msg – message to report
- verbosity – VERBOSITY_*, default: VERBOSITY_NORMAL (optional)
- attrs – user defined attributes (dict)
- links – to existing traces or spans [{'trace_id':'…', 'span_id':'…'}]
- path – keypath to an action/leaf/service
def progress_info_th(sock, thandle, msg, verbosity, attrs, links, path)
-
progress_info_th(sock, thandle, msg, verbosity, attrs, links, path) -> None
While spans represents a pair of data points: start and stop; info events are instead singular events, one point in time. Call progress_info() to write a progress span info event to the progress trace. The info event will have the same span-id as the start and stop events of the currently ongoing progress span in the active user session or transaction. See start_progress_span() for more information.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- msg – message to report
- verbosity – VERBOSITY_*, default: VERBOSITY_NORMAL (optional)
- attrs – user defined attributes (dict)
- links – to existing traces or spans [{'trace_id':'…', 'span_id':'…'}]
- path – keypath to an action/leaf/service
def pushd(sock, thandle, path)
-
Like cd, but saves the previous position in the tree. This can later be used by popd to return.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- path – position to change to
def query_free_result(qrs)
-
Deallocates the struct returned by 'query_result()'.
Keyword arguments:
- qrs – the query result structure to free
def query_reset(sock, qh)
-
Reset the query to the beginning again.
Keyword arguments:
- sock – a python socket instance
- qh – query handle
def query_reset_to(sock, qh, offset)
-
Reset the query to offset.
Keyword arguments:
- sock – a python socket instance
- qh – query handle
- offset – offset counted from the beginning
def query_result(sock, qh) ‑> QueryResult
-
Fetches the next available chunk of results associated with query handle qh.
Keyword arguments:
- sock – a python socket instance
- qh – query handle
def query_result_count(sock, qh) ‑> int
-
Counts the number of query results
Keyword arguments:
- sock – a python socket instance
- qh – query handle
def query_start(sock, thandle, expr, context_node, chunk_size, initial_offset, result_as, select, sort) ‑> int
-
Starts a new query attached to the transaction given in 'th'. Returns a query handle.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- expr – the XPath Path expression to evaluate
- context_node – The context node (an ikeypath) for the primary expression, or None (which means that the context node will be /).
- chunk_size – How many results to return at a time. If set to 0, a default number will be used.
- initial_offset – Which result in line to begin with (1 means to start from the beginning).
- result_as – The format the results will be returned in.
- select – An array of XPath 'select' expressions.
- sort – An array of XPath expressions which will be used for sorting
def query_stop(sock, qh)
-
Stop the running query.
Keyword arguments:
- sock – a python socket instance
- qh – query handle
def rebind_listener(sock, listener)
-
Request that the subsystems specified by 'listeners' rebinds its listener socket(s).
Keyword arguments:
- sock – a python socket instance
- listener – One of the following parameters (ORed together if more than one)
def reload_config(sock)
-
Request that the system reloads its configuration files.
Keyword arguments:
- sock – a python socket instance
def reopen_logs(sock)
-
Request that the system closes and re-opens its log files.
Keyword arguments:
- sock – a python socket instance
def report_progress(sock, verbosity, msg)
-
Report progress events.
This function makes it possible to report transaction/action progress from user code.
This function is deprecated and will be removed in a future release. Use progress_info() instead.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- verbosity – at which verbosity level the message should be reported
- msg – message to report
def report_progress2(sock, verbosity, msg, package)
-
Report progress events.
This function makes it possible to report transaction/action progress from user code.
This function is deprecated and will be removed in a future release. Use progress_info() instead.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- verbosity – at which verbosity level the message should be reported
- msg – message to report
- package – from what package the message is reported
def report_progress_start(sock, verbosity, msg, package) ‑> int
-
Report progress events. Used for calculation of the duration between two events.
This function makes it possible to report transaction/action progress from user code.
This function is deprecated and will be removed in a future release. Use start_progress_span() instead.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- verbosity – at which verbosity level the message should be reported
- msg – message to report
- package – from what package the message is reported (only NCS)
def report_progress_stop(sock, verbosity, msg, annotation, package, timestamp) ‑> int
-
Report progress events. Used for calculation of the duration between two events.
This function makes it possible to report transaction/action progress from user code.
This function is deprecated and will be removed in a future release. Use end_progress_span() instead.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- verbosity – at which verbosity level the message should be reported
- msg – message to report
- annotation – metadata about the event, indicating error, explains latency or shows result etc
- package – from what package the message is reported (only NCS)
- timestamp – start of the event
def report_service_progress(sock, verbosity, msg, path)
-
Report progress events for a service.
This function makes it possible to report transaction progress from FASTMAP code.
This function is deprecated and will be removed in a future release. Use progress_info() instead.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- verbosity – at which verbosity level the message should be reported
- msg – message to report
- path – service instance path
def report_service_progress2(sock, verbosity, msg, package, path)
-
Report progress events for a service.
This function makes it possible to report transaction progress from FASTMAP code.
This function is deprecated and will be removed in a future release. Use progress_info() instead.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- verbosity – at which verbosity level the message should be reported
- msg – message to report
- package – from what package the message is reported
- path – service instance path
def report_service_progress_start(sock, verbosity, msg, package, path) ‑> int
-
Report progress events for a service. Used for calculation of the duration between two events.
This function makes it possible to report transaction progress from FASTMAP code.
This function is deprecated and will be removed in a future release. Use start_progress_span() instead.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- verbosity – at which verbosity level the message should be reported
- msg – message to report
- package – from what package the message is reported
- path – service instance path
def report_service_progress_stop(sock, verbosity, msg, annotation, package, path)
-
Report progress events for a service. Used for calculation of the duration between two events.
This function makes it possible to report transaction progress from FASTMAP code.
This function is deprecated and will be removed in a future release. Use end_progress_span() instead.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- verbosity – at which verbosity level the message should be reported
- msg – message to report
- annotation – metadata about the event, indicating error, explains latency or shows result etc
- package – from what package the message is reported
- path – service instance path
- timestamp – start of the event
def request_action(sock, params, hashed_ns, path) ‑> list
-
Invoke an action defined in the data model. Returns a list oftagValues.
Keyword arguments:
- sock – a python socket instance
- params – tagValue parameters for the action
- hashed_ns – namespace
- path – path to action
def request_action_str_th(sock, thandle, cmd, path) ‑> str
-
The same as request_action_th but takes the parameters as a string and returns the result as a string.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- cmd – string parameters
- path – path to action
def request_action_th(sock, thandle, params, path) ‑> list
-
Same as for request_action() but uses the current namespace.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- params – tagValue parameters for the action
- path – path to action
def revert(sock, thandle)
-
Removes all changes done to the transaction.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
def roll_config(sock, thandle, path) ‑> int
-
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. Returns an id
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- path – tree for which to save the rollback configuration
def roll_config_result(sock, id) ‑> int
-
We use this function to assert that we received the entire rollback configuration over a stream socket.
Keyword arguments:
- sock – a python socket instance
- id – the id returned from roll_config()
def save_config(sock, thandle, flags, path) ‑> int
-
Save the config, returns an id. The flags parameter controls the saving as follows. The value is a bitmask.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- flags – as above
- path – save only configuration below path
def save_config_result(sock, id)
-
Verify that we received the entire configuration over the stream socket.
Keyword arguments:
- sock – a python socket instance
- id – the id returned from save_config
def set_attr(sock, thandle, attr, v, keypath)
-
Set attributes for a node.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- attr – attributes to set
- v – value to set the attribute to
- keypath – path to choice
def set_comment(sock, thandle, comment)
-
Set the Comment that is stored in the rollback file when a transaction towards running is committed.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- comment – the Comment
def set_delayed_when(sock, thandle, on)
-
This function enables (on non-zero) or disables (on == 0) the 'delayed when' mode of a transaction.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- on – disables when on=0, enables for all other n
def set_elem(sock, thandle, v, path)
-
Set element to confdValue.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- v – confdValue
- path – position of elem
def set_elem2(sock, thandle, strval, path)
-
Set element to string.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- strval – confdValue
- path – position of elem
def set_flags(sock, thandle, flags)
-
Modify read/write session aspect. See MAAPI_FLAG_xyz.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- flags – flags to set
def set_label(sock, thandle, label)
-
Set the Label that is stored in the rollback file when a transaction towards running is committed.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- label – the Label
def set_namespace(sock, thandle, hashed_ns)
-
Indicate which namespace to use in case of ambiguities.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- hashed_ns – the namespace to use
def set_next_user_session_id(sock, usessid)
-
Set the user session id that will be assigned to the next user session started. The given value is silently forced to be in the range 100 .. 2^31-1. This function can be used to ensure that session ids for user sessions started by northbound agents or via MAAPI are unique across a restart.
Keyword arguments:
- sock – a python socket instance
- usessid – user session id
def set_object(sock, thandle, values, keypath)
-
Set leafs at path to object.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- values – list of values
- keypath – path to set
def set_readonly_mode(sock, flag)
-
Control if northbound agents should be able to write or not.
Keyword arguments:
- sock – a python socket instance
- flag – non-zero means read-only mode
def set_running_db_status(sock, status)
-
Sets the notion of consistent state of the running db.
Keyword arguments:
- sock – a python socket instance
- status – integer status to set
def set_user_session(sock, usessid)
-
Associate a socket with an already existing user session.
Keyword arguments:
- sock – a python socket instance
- usessid – user session id
def set_values(sock, thandle, values, keypath)
-
Set leafs at path to values.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- values – list of tagValues
- keypath – path to set
-
FASTMAP version of ncs_apply_template.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- template – template name
- variables – None or a list of variables in the form of tuples
- flags – Must be set as 0
- rootpath – in what context to apply the template
-
FASTMAP version of copy_tree.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- flags – Must be set as 0
- frompath – the path to copy the tree from
- topath – the path to copy the tree to
-
FASTMAP version of create.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- flags – Must be set as 0
-
FASTMAP version of insert.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- flags – Must be set as 0
- path – the path to the list to insert a new entry into
-
FASTMAP version of set_elem.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- v – the value to set
- flags – should be 0
- path – the path to the element to set
-
FASTMAP version of set_elem2.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- strval – the value to se
- flags – should be 0
- path – the path to the element to set
-
FASTMAP version of set_values.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- values – list of tagValues
- flags – should be 0
- keypath – path to set
def snmpa_reload(sock, synchronous)
-
Start a reload of SNMP Agent config from external data provider.
Used by external data provider to notify that there is a change to the SNMP Agent config data. Calling the function with the argument 'synchronous' set to 1 or True means that the call will block until the loading is completed.
Keyword arguments:
- sock – a python socket instance
- synchronous – if 1, will wait for the loading complete and return when the loading is complete; if 0, will only initiate the loading and return immediately
def start_phase(sock, phase, synchronous)
-
When the system has been started in phase0, this function tells the system to proceed to start phase 1 or 2.
Keyword arguments:
- sock – a python socket instance
- phase – phase to start, 1 or 2
- synchronous – if 1, will wait for the loading complete and return when the loading is complete; if 0, will only initiate the loading of AAA data and return immediately
def start_progress_span(sock, msg, verbosity, attrs, links, path) ‑> dict
-
Starts a progress span. Progress spans are trace messages written to the progress trace and the developer log. A progress span consists of a start and a stop event which can be used to calculate the duration between the two. Those events can be identified with unique span-ids. Inside the span it is possible to start new spans, which will then become child spans, the parent-span-id is set to the previous spans' span-id. A child span can be used to calculate the duration of a sub task, and is started from consecutive maapi_start_progress_span() calls, and is ended with maapi_end_progress_span().
The concepts of traces, trace-id and spans are highly influenced by https://opentelemetry.io/docs/concepts/signals/traces/#spans
Keyword arguments:
- sock – a python socket instance
- msg – message to report
- verbosity – VERBOSITY_*, default: VERBOSITY_NORMAL (optional)
- attrs – user defined attributes (dict)
- links – to existing traces or spans [{'trace_id':'…', 'span_id':'…'}]
- path – keypath to an action/leaf/service
def start_progress_span_th(sock, thandle, msg, verbosity, attrs, links, path) ‑> dict
-
Starts a progress span. Progress spans are trace messages written to the progress trace and the developer log. A progress span consists of a start and a stop event which can be used to calculate the duration between the two. Those events can be identified with unique span-ids. Inside the span it is possible to start new spans, which will then become child spans, the parent-span-id is set to the previous spans' span-id. A child span can be used to calculate the duration of a sub task, and is started from consecutive maapi_start_progress_span() calls, and is ended with maapi_end_progress_span().
The concepts of traces, trace-id and spans are highly influenced by https://opentelemetry.io/docs/concepts/signals/traces/#spans
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- msg – message to report
- verbosity – VERBOSITY_*, default: VERBOSITY_NORMAL (optional)
- attrs – user defined attributes (dict)
- links – to existing traces or spans [{'trace_id':'…', 'span_id':'…'}]
- path – keypath to an action/leaf/service
def start_trans(sock, name, readwrite) ‑> int
-
Creates a new transaction towards the data store specified by name, which can be one of CONFD_CANDIDATE, CONFD_RUNNING, or CONFD_STARTUP (however updating the startup data store is better done via maapi_copy_running_to_startup()). The readwrite parameter can be either CONFD_READ, to start a readonly transaction, or CONFD_READ_WRITE, to start a read-write transaction. The function returns the transaction id.
Keyword arguments:
- sock – a python socket instance
- name – name of the database
- readwrite – CONFD_READ or CONFD_WRITE
def start_trans2(sock, name, readwrite, usid) ‑> int
-
Start a transaction within an existing user session, returns the transaction id.
Keyword arguments:
- sock – a python socket instance
- name – name of the database
- readwrite – CONFD_READ or CONFD_WRITE
- usid – user session id
def start_trans_flags(sock, name, readwrite, usid) ‑> int
-
The same as start_trans2, but can also set the same flags that 'set_flags' can set.
Keyword arguments:
- sock – a python socket instance
- name – name of the database
- readwrite – CONFD_READ or CONFD_WRITE
- usid – user session id
- flags – same as for 'set_flags'
def start_trans_flags2(sock, name, readwrite, usid, vendor, product, version, client_id) ‑> int
-
This function does the same as start_trans_flags() but allows for additional information to be passed to ConfD/NCS.
Keyword arguments:
- sock – a python socket instance
- name – name of the database
- readwrite – CONFD_READ or CONFD_WRITE
- usid – user session id
- flags – same as for 'set_flags'
- vendor – vendor string (may be None)
- product – product string (may be None)
- version – version string (may be None)
- client_id – client identification string (may be None)
def start_trans_in_trans(sock, readwrite, usid, thandle) ‑> int
-
Start a transaction within an existing transaction, using the started transaction as backend instead of an actual data store. Returns the transaction id as an integer.
Keyword arguments:
- sock – a python socket instance
- readwrite – CONFD_READ or CONFD_WRITE
- usid – user session id
- thandle – identifies the backend transaction to use
def start_user_session(sock, username, context, groups, src_addr, prot)
-
Establish a user session on the socket.
Keyword arguments:
- sock – a python socket instance
- username – the user for the session
- context – context for the session
- groups – groups
- src-addr – src address of e.g. the client connecting
- prot – the protocol used by the client for connecting
def start_user_session2(sock, username, context, groups, src_addr, src_port, prot)
-
Establish a user session on the socket.
Keyword arguments:
- sock – a python socket instance
- username – the user for the session
- context – context for the session
- groups – groups
- src-addr – src address of e.g. the client connecting
- src-port – src port of e.g. the client connecting
- prot – the protocol used by the client for connecting
def start_user_session3(sock, username, context, groups, src_addr, src_port, prot, vendor, product, version, client_id)
-
Establish a user session on the socket.
This function does the same as start_user_session2() but allows for additional information to be passed to ConfD/NCS.
Keyword arguments:
- sock – a python socket instance
- username – the user for the session
- context – context for the session
- groups – groups
- src-addr – src address of e.g. the client connecting
- src-port – src port of e.g. the client connecting
- prot – the protocol used by the client for connecting
- vendor – vendor string (may be None)
- product – product string (may be None)
- version – version string (may be None)
- client_id – client identification string (may be None)
def start_user_session_gen(sock, username, context, groups, vendor, product, version, client_id)
-
Establish a user session on the socket.
This function does the same as start_user_session3() but it takes the source address of the supplied socket from the OS.
Keyword arguments:
- sock – a python socket instance
- username – the user for the session
- context – context for the session
- groups – groups
- vendor – vendor string (may be None)
- product – product string (may be None)
- version – version string (may be None)
- client_id – client identification string (may be None)
def stop(sock)
-
Request that the system stops.
Keyword arguments:
- sock – a python socket instance
def sys_message(sock, to, message)
-
Send a message to a specific user, a specific session or all user depending on the 'to' parameter. 'all',
or can be used. Keyword arguments:
- sock – a python socket instance
- to – user to send message to or 'all' to send to all users
- message – the message
def unhide_group(sock, thandle, group_name)
-
Unhide all nodes belonging to a hide group in a transaction that started with flag FLAG_HIDE_ALL_HIDEGROUPS.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- group_name – the group name
def unlock(sock, name)
-
Unlock database with name.
Keyword arguments:
- sock – a python socket instance
- name – name of the database to unlock
def unlock_partial(sock, lockid)
-
Unlock a subset of a database which is locked by lockid.
Keyword arguments:
- sock – a python socket instance
- lockid – id of the lock
def user_message(sock, to, message, sender)
-
Send a message to a specific user.
Keyword arguments:
- sock – a python socket instance
- to – user to send message to or 'all' to send to all users
- message – the message
- sender – send as
def validate_trans(sock, thandle, unlock, forcevalidation)
-
Validates all data written in a transaction.
If unlock is 1 (or True), the transaction is open for further editing even if validation succeeds. If unlock is 0 (or False) and the function returns CONFD_OK, the next function to be called MUST be maapi_prepare_trans() or maapi_finish_trans().
unlock = 1 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 == 1, the lock is released on success. The lock is always released on failure.
The forcevalidation argument should normally be 0 (or 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 forcevalidation is non-zero.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- unlock – int or bool
- forcevalidation – int or bool
def wait_start(sock, phase)
-
Wait for the system to reach a certain start phase (0,1 or 2).
Keyword arguments:
- sock – a python socket instance
- phase – phase to wait for, 0, 1 or 2
def write_service_log_entry(sock, path, msg, type, level)
-
Write service log entries.
This function makes it possible to write service log entries from FASTMAP code.
Keyword arguments:
- sock – a python socket instance
- path – service instance path
- msg – message to log
- type – log entry type
- level – log entry level
def xpath2kpath(sock, xpath) ‑> HKeypathRef
-
Convert an xpath to a hashed keypath.
Keyword arguments:
- sock – a python socket instance
- xpath – to convert
def xpath2kpath_th(sock, thandle, xpath) ‑> HKeypathRef
-
Convert an xpath to a hashed keypath.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- xpath – to convert
def xpath_eval(sock, thandle, expr, result, trace, path)
-
Evaluate the xpath expression in 'expr'. For each node in the resulting node the function 'result' is called with the keypath to the resulting node as the first argument and, if the node is a leaf and has a value. the value of that node as the second argument. For each invocation of 'result' the function should return ITER_CONTINUE to tell the XPath evaluator to continue or ITER_STOP to stop the evaluation. A trace function, 'pytrace', could be supplied and will be called with a single string as an argument. 'None' can be used if no trace is needed. Unless a 'path' is given the root node will be used as a context for the evaluations.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- expr – the XPath Path expression to evaluate
- result – the result function
- trace – a trace function that takes a string as a parameter
- path – the context node
def xpath_eval_expr(sock, thandle, expr, trace, path) ‑> str
-
Like xpath_eval but returns a string.
Keyword arguments:
- sock – a python socket instance
- thandle – transaction handle
- expr – the XPath Path expression to evaluate
- trace – a trace function that takes a string as a parameter
- path – the context node
Classes
class Cursor (...)
-
struct maapi_cursor object
class MaapiRollback (...)
-
This type represents the c-type struct maapi_rollback.
MaapRollback cannot be directly instantiated from Python.
Instance variables
var comment
-
the comment (string)
var creator
-
the creator (string)
var datestr
-
the date (string)
var fixed_nr
-
the fixed_nr (int)
var label
-
the label (string)
var nr
-
the nr attribute (int)
var via
-
the via (string)