Renamed paging to pagination

This commit is contained in:
Olof hagsand 2021-09-08 11:50:07 +02:00
parent 60193cca0d
commit ff3f600920
11 changed files with 50 additions and 51 deletions

View file

@ -35,7 +35,7 @@ Expected: September, 2021
### New features ### New features
* List paging for Netconf and Restconf * List pagination for Netconf and Restconf
* Experimental, work-in-progress * Experimental, work-in-progress
* Enable with LIST_PAGINATION compile-time option * Enable with LIST_PAGINATION compile-time option
* According to: * According to:
@ -48,7 +48,7 @@ Expected: September, 2021
* ietf-yang-metadata@2016-08-05.yang * ietf-yang-metadata@2016-08-05.yang
* ietf-netconf-with-defaults@2011-06-01.yang * ietf-netconf-with-defaults@2011-06-01.yang
* New state callback signature (ca_statedata2) * New state callback signature (ca_statedata2)
* The new callback contains parameters for paging * The new callback contains parameters for pagination
* Goal is to replace ca_statedata callback * Goal is to replace ca_statedata callback
* YANG Leafref feature update * YANG Leafref feature update
@ -71,7 +71,7 @@ Expected: September, 2021
* New http media: application/yang-collection+xml/json * New http media: application/yang-collection+xml/json
* New state callback signature (ca_statedata2) * New state callback signature (ca_statedata2)
* The new callback contains parameters for paging * The new callback contains parameters for pagination
* Goal is to replace ca_statedata callback * Goal is to replace ca_statedata callback
@ -120,7 +120,7 @@ Developers may need to change their code
* In this case, eg "uses", single quotes can now be used, but not `qstring + qstring` in this case * In this case, eg "uses", single quotes can now be used, but not `qstring + qstring` in this case
* Fixed: [Performance issue when parsing large JSON param](https://github.com/clicon/clixon/issues/266) * Fixed: [Performance issue when parsing large JSON param](https://github.com/clicon/clixon/issues/266)
* Fixed: [Duplicate lines emitted by cli_show_config (cli output style) when yang list element has composite key](https://github.com/clicon/clixon/issues/258) * Fixed: [Duplicate lines emitted by cli_show_config (cli output style) when yang list element has composite key](https://github.com/clicon/clixon/issues/258)
* Fixed: Typing 'q' in CLI more paging did not properly quit output * Fixed: Typing 'q' in CLI more scrolling did not properly quit output
* Output continued but was not shown, for a very large file this could cause considerable delay * Output continued but was not shown, for a very large file this could cause considerable delay
* Fixed: Lock was broken in first get get access * Fixed: Lock was broken in first get get access
* if the first netconf operation to a backend was lock;get;unlock, the lock was broken in the first get access. * if the first netconf operation to a backend was lock;get;unlock, the lock was broken in the first get access.
@ -773,7 +773,7 @@ Developers may need to change their code
* The register function has removed `from` and `rev` parameters: `upgrade_callback_register(h, cb, namespace, arg)` * The register function has removed `from` and `rev` parameters: `upgrade_callback_register(h, cb, namespace, arg)`
* The callback function has a new `op` parameter with possible values: `XML_FLAG_ADD`, `XML_FLAG_CHANGE` or `XML_FLAG_CHANGE`: `clicon_upgrade_cb(h, xn, ns, op, from, to, arg, cbret)` * The callback function has a new `op` parameter with possible values: `XML_FLAG_ADD`, `XML_FLAG_CHANGE` or `XML_FLAG_CHANGE`: `clicon_upgrade_cb(h, xn, ns, op, from, to, arg, cbret)`
* Added new cli show functions to work with cligen_output for cligen paging to work. To achieve this, replace function calls as follows: * Added new cli show functions to work with cligen_output for cligen scrolling to work. To achieve this, replace function calls as follows:
* `xml2txt(...)` --> `xml2txt_cb(..., cligen_output)` * `xml2txt(...)` --> `xml2txt_cb(..., cligen_output)`
* `xml2cli(...)` --> `xml2cli_cb(..., cligen_output)` * `xml2cli(...)` --> `xml2cli_cb(..., cligen_output)`
* `clicon_xml2file(...)` --> `clicon_xml2file_cb(..., cligen_output)` * `clicon_xml2file(...)` --> `clicon_xml2file_cb(..., cligen_output)`

View file

@ -258,7 +258,7 @@ get_client_statedata(clicon_handle h,
goto fail; goto fail;
} }
/* Use plugin state callbacks */ /* Use plugin state callbacks */
if ((ret = clixon_plugin_statedata_all(h, yspec, nsc, xpath, PAGING_NONE, 0, 0, NULL, xret)) < 0) if ((ret = clixon_plugin_statedata_all(h, yspec, nsc, xpath, PAGINATION_NONE, 0, 0, NULL, xret)) < 0)
goto done; goto done;
if (ret == 0) if (ret == 0)
goto fail; goto fail;
@ -467,10 +467,10 @@ get_list_pagination(clicon_handle h,
cxobj *xerr = NULL; cxobj *xerr = NULL;
cbuf *cbmsg = NULL; /* For error msg */ cbuf *cbmsg = NULL; /* For error msg */
cxobj *xret = NULL; cxobj *xret = NULL;
char *xpath2; /* With optional paging predicate */ char *xpath2; /* With optional pagination predicate */
int ret; int ret;
uint32_t iddb; /* DBs lock, if any */ uint32_t iddb; /* DBs lock, if any */
paging_status_t pagingstatus; pagination_mode_t pagmode;
cxobj *x1 = NULL; cxobj *x1 = NULL;
cxobj *xcache = NULL; cxobj *xcache = NULL;
uint32_t total = 0; uint32_t total = 0;
@ -600,12 +600,12 @@ get_list_pagination(clicon_handle h,
else {/* Check if running locked (by this session) */ else {/* Check if running locked (by this session) */
if ((iddb = xmldb_islocked(h, "running")) != 0 && if ((iddb = xmldb_islocked(h, "running")) != 0 &&
iddb == ce->ce_id) iddb == ce->ce_id)
pagingstatus = PAGING_LOCK; pagmode = PAGINATION_LOCK;
else else
pagingstatus = PAGING_STATELESS; pagmode = PAGINATION_STATELESS;
/* Use plugin state callbacks */ /* Use plugin state callbacks */
if ((ret = clixon_plugin_statedata_all(h, yspec, nsc, xpath, if ((ret = clixon_plugin_statedata_all(h, yspec, nsc, xpath,
pagingstatus, pagmode,
offset, limit, &remaining, &xret)) < 0) offset, limit, &remaining, &xret)) < 0)
goto done; goto done;
} }

View file

@ -239,7 +239,7 @@ clixon_plugin_daemon_all(clicon_handle h)
* @param[in] h clicon handle * @param[in] h clicon handle
* @param[in] nsc namespace context for xpath * @param[in] nsc namespace context for xpath
* @param[in] xpath String with XPATH syntax. or NULL for all * @param[in] xpath String with XPATH syntax. or NULL for all
* @param[in] pagingstatus List pagination status * @param[in] pagmode List pagination mode
* @param[in] offset Offset, for list pagination * @param[in] offset Offset, for list pagination
* @param[in] limit Limit, for list pagination * @param[in] limit Limit, for list pagination
* @param[out] remaining Remaining elements (if limit is non-zero) * @param[out] remaining Remaining elements (if limit is non-zero)
@ -253,7 +253,7 @@ clixon_plugin_statedata_one(clixon_plugin_t *cp,
clicon_handle h, clicon_handle h,
cvec *nsc, cvec *nsc,
char *xpath, char *xpath,
paging_status_t pagingstatus, pagination_mode_t pagmode,
uint32_t offset, uint32_t offset,
uint32_t limit, uint32_t limit,
uint32_t *remaining, uint32_t *remaining,
@ -268,7 +268,7 @@ clixon_plugin_statedata_one(clixon_plugin_t *cp,
if ((fn2 = clixon_plugin_api_get(cp)->ca_statedata2) != NULL){ if ((fn2 = clixon_plugin_api_get(cp)->ca_statedata2) != NULL){
if ((x = xml_new(DATASTORE_TOP_SYMBOL, NULL, CX_ELMNT)) == NULL) if ((x = xml_new(DATASTORE_TOP_SYMBOL, NULL, CX_ELMNT)) == NULL)
goto done; goto done;
if (fn2(h, nsc, xpath, pagingstatus, offset, limit, remaining, x) < 0){ if (fn2(h, nsc, xpath, pagmode, offset, limit, remaining, x) < 0){
if (clicon_errno < 0) if (clicon_errno < 0)
clicon_log(LOG_WARNING, "%s: Internal error: State callback in plugin: %s returned -1 but did not make a clicon_err call", clicon_log(LOG_WARNING, "%s: Internal error: State callback in plugin: %s returned -1 but did not make a clicon_err call",
__FUNCTION__, clixon_plugin_name_get(cp)); __FUNCTION__, clixon_plugin_name_get(cp));
@ -302,7 +302,7 @@ clixon_plugin_statedata_one(clixon_plugin_t *cp,
* @param[in] yspec Yang spec * @param[in] yspec Yang spec
* @param[in] nsc Namespace context * @param[in] nsc Namespace context
* @param[in] xpath String with XPATH syntax. or NULL for all * @param[in] xpath String with XPATH syntax. or NULL for all
* @param[in] pagination List pagination * @param[in] pagmode List pagination mode
* @param[in] offset Offset, for list pagination * @param[in] offset Offset, for list pagination
* @param[in] limit Limit, for list pagination * @param[in] limit Limit, for list pagination
* @param[out] remaining Remaining elements (if limit is non-zero) * @param[out] remaining Remaining elements (if limit is non-zero)
@ -317,7 +317,7 @@ clixon_plugin_statedata_all(clicon_handle h,
yang_stmt *yspec, yang_stmt *yspec,
cvec *nsc, cvec *nsc,
char *xpath, char *xpath,
paging_status_t pagingstatus, pagination_mode_t pagmode,
uint32_t offset, uint32_t offset,
uint32_t limit, uint32_t limit,
uint32_t *remaining, uint32_t *remaining,
@ -332,7 +332,7 @@ clixon_plugin_statedata_all(clicon_handle h,
clicon_debug(1, "%s", __FUNCTION__); clicon_debug(1, "%s", __FUNCTION__);
while ((cp = clixon_plugin_each(h, cp)) != NULL) { while ((cp = clixon_plugin_each(h, cp)) != NULL) {
if ((ret = clixon_plugin_statedata_one(cp, h, nsc, xpath, pagingstatus, if ((ret = clixon_plugin_statedata_one(cp, h, nsc, xpath, pagmode,
offset, limit, remaining, &x)) < 0) offset, limit, remaining, &x)) < 0)
goto done; goto done;
if (ret == 0){ if (ret == 0){

View file

@ -76,7 +76,7 @@ int clixon_plugin_pre_daemon_all(clicon_handle h);
int clixon_plugin_daemon_all(clicon_handle h); int clixon_plugin_daemon_all(clicon_handle h);
int clixon_plugin_statedata_all(clicon_handle h, yang_stmt *yspec, cvec *nsc, char *xpath, int clixon_plugin_statedata_all(clicon_handle h, yang_stmt *yspec, cvec *nsc, char *xpath,
paging_status_t pagingstatus, pagination_mode_t pagmode,
uint32_t offset, uint32_t limit, uint32_t *remaining, uint32_t offset, uint32_t limit, uint32_t *remaining,
cxobj **xtop); cxobj **xtop);
int clixon_plugin_lockdb_all(clicon_handle h, char *db, int lock, int id); int clixon_plugin_lockdb_all(clicon_handle h, char *db, int lock, int id);

View file

@ -93,7 +93,7 @@ static char *_state_file = NULL;
*/ */
static int _state_file_cached = 0; static int _state_file_cached = 0;
/*! Cache control of read state file paging example, /*! Cache control of read state file pagination example,
* keep xml tree cache as long as db is locked * keep xml tree cache as long as db is locked
*/ */
static cxobj *_state_xml_cache = NULL; /* XML cache */ static cxobj *_state_xml_cache = NULL; /* XML cache */
@ -353,7 +353,7 @@ example_copy_extra(clicon_handle h, /* Clicon handle */
* @param[in] h Clicon handle * @param[in] h Clicon handle
* @param[in] nsc External XML namespace context, or NULL * @param[in] nsc External XML namespace context, or NULL
* @param[in] xpath String with XPATH syntax. or NULL for all * @param[in] xpath String with XPATH syntax. or NULL for all
* @param[in] paging List pagination (not uses here) * @param[in] pagmode List pagination (not used here)
* @param[in] offset Offset, for list pagination * @param[in] offset Offset, for list pagination
* @param[in] limit Limit, for list pagination * @param[in] limit Limit, for list pagination
* @param[out] remaining Remaining elements (if limit is non-zero) * @param[out] remaining Remaining elements (if limit is non-zero)
@ -370,14 +370,13 @@ example_copy_extra(clicon_handle h, /* Clicon handle */
} }
} }
* This yang snippet is present in clixon-example.yang for example. * This yang snippet is present in clixon-example.yang for example.
* XXX paging for lock * @see example_statefile where state is read from file and also pagination
* @see example_statefile where state is read from file and also paging
*/ */
int int
example_statedata(clicon_handle h, example_statedata(clicon_handle h,
cvec *nsc, cvec *nsc,
char *xpath, char *xpath,
paging_status_t paging, pagination_mode_t pagmode,
uint32_t offset, uint32_t offset,
uint32_t limit, uint32_t limit,
uint32_t *remaining, uint32_t *remaining,
@ -456,14 +455,14 @@ example_statedata(clicon_handle h,
return retval; return retval;
} }
/*! Called to get state data from plugin by reading a file, also paging /*! Called to get state data from plugin by reading a file, also pagination
* *
* The example shows how to read and parse a state XML file, (which is cached in the -i case). * The example shows how to read and parse a state XML file, (which is cached in the -i case).
* Return the requested xpath / paging xstate by copying from the parsed state XML file * Return the requested xpath / pagination xstate by copying from the parsed state XML file
* @param[in] h Clicon handle * @param[in] h Clicon handle
* @param[in] nsc External XML namespace context, or NULL * @param[in] nsc External XML namespace context, or NULL
* @param[in] xpath String with XPATH syntax. or NULL for all * @param[in] xpath String with XPATH syntax. or NULL for all
* @param[in] paging List pagination * @param[in] pagmode List pagination mode
* @param[in] offset Offset, for list pagination * @param[in] offset Offset, for list pagination
* @param[in] limit Limit, for list pagination * @param[in] limit Limit, for list pagination
* @param[out] xstate XML tree, <config/> on entry. Copy to this * @param[out] xstate XML tree, <config/> on entry. Copy to this
@ -476,7 +475,7 @@ int
example_statefile(clicon_handle h, example_statefile(clicon_handle h,
cvec *nsc, cvec *nsc,
char *xpath, char *xpath,
paging_status_t paging, pagination_mode_t pagmode,
uint32_t offset, uint32_t offset,
uint32_t limit, uint32_t limit,
uint32_t *remaining, uint32_t *remaining,
@ -516,13 +515,13 @@ example_statefile(clicon_handle h,
xt = _state_xml_cache; xt = _state_xml_cache;
if (xpath_vec(xt, nsc, "%s", &xvec, &xlen, xpath) < 0) if (xpath_vec(xt, nsc, "%s", &xvec, &xlen, xpath) < 0)
goto done; goto done;
switch (paging){ switch (pagmode){
case PAGING_NONE: case PAGINATION_NONE:
lower = 0; lower = 0;
upper = xlen; upper = xlen;
break; break;
case PAGING_STATELESS: case PAGINATION_STATELESS:
case PAGING_LOCK: case PAGINATION_LOCK:
lower = offset; lower = offset;
if (limit == 0) if (limit == 0)
upper = xlen; upper = xlen;
@ -552,7 +551,7 @@ example_statefile(clicon_handle h,
goto done; goto done;
if (_state_file_cached) if (_state_file_cached)
xt = NULL; /* ensure cache is not cleared */ xt = NULL; /* ensure cache is not cleared */
if (paging == PAGING_LOCK) if (pagmode == PAGINATION_LOCK)
_state_file_transaction++; _state_file_transaction++;
ok: ok:
retval = 0; retval = 0;
@ -584,7 +583,7 @@ example_lockdb(clicon_handle h,
clicon_debug(1, "%s Lock callback: db%s: locked:%d", __FUNCTION__, db, lock); clicon_debug(1, "%s Lock callback: db%s: locked:%d", __FUNCTION__, db, lock);
/* Part of cached paging example /* Part of cached pagination example
*/ */
if (strcmp(db, "running") == 0 && lock == 0 && if (strcmp(db, "running") == 0 && lock == 0 &&
_state && _state_file && _state_file_cached && _state_file_transaction){ _state && _state_file && _state_file_cached && _state_file_transaction){

View file

@ -206,31 +206,31 @@ typedef int (plgreset_t)(clicon_handle h, const char *db);
*/ */
typedef int (plgstatedata_t)(clicon_handle h, cvec *nsc, char *xpath, cxobj *xtop); typedef int (plgstatedata_t)(clicon_handle h, cvec *nsc, char *xpath, cxobj *xtop);
/*! List paging status in the plugin state data callback /*! List pagination status in the plugin state data callback
* *
* List paging is either enabled or not. * List pagination is either enabled or not.
* If paging is enabled, the xpath addresses a list/ leaf-list and the plugin should return * If pagination is enabled, the xpath addresses a list/ leaf-list and the plugin should return
* entries according to the values of offset and limit. * entries according to the values of offset and limit.
* Paging can use a lock/transaction mechanism * Pagination can use a lock/transaction mechanism
* If locking is not used, the plugin cannot expect more paging calls, and no state or caching * If locking is not used, the plugin cannot expect more pagination calls, and no state or caching
* should be used * should be used
* If locking is used, the paging is part of a session transaction and the plugin may cache * If locking is used, the pagination is part of a session transaction and the plugin may cache
* state (such as a cache) and can expect more paging calls until the running db-lock is released, * state (such as a cache) and can expect more pagination calls until the running db-lock is released,
* (see ca_lockdb) * (see ca_lockdb)
* The transaction is the regular lock/unlock db of running-db of a specific session. * The transaction is the regular lock/unlock db of running-db of a specific session.
*/ */
enum paging_status{ enum pagination_mode{
PAGING_NONE, /* No list paging: limit/offset are no-ops */ PAGINATION_NONE, /* No list pagination: limit/offset are no-ops */
PAGING_STATELESS, /* Stateless list paging, dont expect more paging calls */ PAGINATION_STATELESS, /* Stateless list pagination, dont expect more pagination calls */
PAGING_LOCK /* Transactional list paging, can expect more paging until lock release */ PAGINATION_LOCK /* Transactional list pagination, can expect more pagination until lock release */
}; };
typedef enum paging_status paging_status_t; typedef enum pagination_mode pagination_mode_t;
/* Plugin statedata /* Plugin statedata
* @param[in] Clicon handle * @param[in] Clicon handle
* @param[in] xpath Part of state requested * @param[in] xpath Part of state requested
* @param[in] nsc XPATH namespace context. * @param[in] nsc XPATH namespace context.
* @param[in] paging List pagination mode * @param[in] pagmode List pagination mode
* @param[in] offset Offset, for list pagination * @param[in] offset Offset, for list pagination
* @param[in] limit Limit, for list pagination * @param[in] limit Limit, for list pagination
* @param[out] remaining Remaining elements (if limit is non-zero) * @param[out] remaining Remaining elements (if limit is non-zero)
@ -239,7 +239,7 @@ typedef enum paging_status paging_status_t;
* @retval 0 OK * @retval 0 OK
*/ */
typedef int (plgstatedata2_t)(clicon_handle h, cvec *nsc, char *xpath, typedef int (plgstatedata2_t)(clicon_handle h, cvec *nsc, char *xpath,
paging_status_t paging, pagination_mode_t pagmode,
uint32_t offset, uint32_t limit, uint32_t offset, uint32_t limit,
uint32_t *remaining, uint32_t *remaining,
cxobj *xtop); cxobj *xtop);

View file

@ -692,7 +692,7 @@ module clixon-config {
type int32; type int32;
default 24; default 24;
description description
"Set to number of CLI terminal rows for paging/scrolling. 0 means unlimited. "Set to number of CLI terminal rows for scrolling. 0 means unlimited.
The number is set statically UNLESS: The number is set statically UNLESS:
- there is no terminal, such as file input, in which case nr lines is 0 - there is no terminal, such as file input, in which case nr lines is 0
- there is a terminal sufficiently powerful to read the number of lines from - there is a terminal sufficiently powerful to read the number of lines from

View file

@ -80,7 +80,7 @@ module clixon-netconf-list-pagination {
represent any value greater than or equal to 2^32-1 represent any value greater than or equal to 2^32-1
elements."; elements.";
} }
grouping paging-parameters { grouping pagination-parameters {
leaf list-pagination { leaf list-pagination {
type boolean; type boolean;
default false; default false;
@ -173,10 +173,10 @@ module clixon-netconf-list-pagination {
} }
} }
augment /nc:get-config/nc:input { augment /nc:get-config/nc:input {
uses paging-parameters; uses pagination-parameters;
} }
// extending the get operation // extending the get operation
augment /nc:get/nc:input { augment /nc:get/nc:input {
uses paging-parameters; uses pagination-parameters;
} }
} }