Formatting and documentation
This commit is contained in:
parent
f87ff859a6
commit
3cad374f33
11 changed files with 91 additions and 95 deletions
|
|
@ -194,10 +194,10 @@ client_get_streams(clixon_handle h,
|
||||||
* message. But this needs to be explored in all sub-functions
|
* message. But this needs to be explored in all sub-functions
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
get_statedata(clixon_handle h,
|
get_state_data(clixon_handle h,
|
||||||
char *xpath,
|
char *xpath,
|
||||||
cvec *nsc,
|
cvec *nsc,
|
||||||
cxobj **xret)
|
cxobj **xret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
yang_stmt *yspec;
|
yang_stmt *yspec;
|
||||||
|
|
@ -777,7 +777,7 @@ get_list_pagination(clixon_handle h,
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (content != CONTENT_CONFIG){
|
if (content != CONTENT_CONFIG){
|
||||||
if ((ret = get_statedata(h, xpath?xpath:"/", nsc, &xret)) < 0)
|
if ((ret = get_state_data(h, xpath?xpath:"/", nsc, &xret)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (ret == 0){ /* Error from callback (error in xret) */
|
if (ret == 0){ /* Error from callback (error in xret) */
|
||||||
if (clixon_xml2cbuf(cbret, xret, 0, 0, NULL, -1, 0) < 0)
|
if (clixon_xml2cbuf(cbret, xret, 0, 0, NULL, -1, 0) < 0)
|
||||||
|
|
@ -959,8 +959,8 @@ get_common(clixon_handle h,
|
||||||
withdefaults_type wdef;
|
withdefaults_type wdef;
|
||||||
char *wdefstr;
|
char *wdefstr;
|
||||||
|
|
||||||
wdef = WITHDEFAULTS_EXPLICIT;
|
|
||||||
clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
|
clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
|
||||||
|
wdef = WITHDEFAULTS_EXPLICIT;
|
||||||
username = clicon_username_get(h);
|
username = clicon_username_get(h);
|
||||||
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
||||||
clixon_err(OE_YANG, ENOENT, "No yang spec9");
|
clixon_err(OE_YANG, ENOENT, "No yang spec9");
|
||||||
|
|
@ -1008,7 +1008,6 @@ get_common(clixon_handle h,
|
||||||
* If it is empty, all are default values and is regular get
|
* If it is empty, all are default values and is regular get
|
||||||
*/
|
*/
|
||||||
if ((xlpg = xml_find_type(xe, NULL, "list-pagination", CX_ELMNT)) != NULL){
|
if ((xlpg = xml_find_type(xe, NULL, "list-pagination", CX_ELMNT)) != NULL){
|
||||||
|
|
||||||
if ((xlpg2 = xml_dup(xlpg)) == NULL)
|
if ((xlpg2 = xml_dup(xlpg)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
if (xml_default_nopresence(xlpg2, 2, 0) < 0)
|
if (xml_default_nopresence(xlpg2, 2, 0) < 0)
|
||||||
|
|
@ -1095,7 +1094,7 @@ get_common(clixon_handle h,
|
||||||
break;
|
break;
|
||||||
case CONTENT_ALL: /* both config and state */
|
case CONTENT_ALL: /* both config and state */
|
||||||
case CONTENT_NONCONFIG: /* state data only */
|
case CONTENT_NONCONFIG: /* state data only */
|
||||||
if ((ret = get_statedata(h, xpath?xpath:"/", nsc, &xret)) < 0)
|
if ((ret = get_state_data(h, xpath?xpath:"/", nsc, &xret)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (ret == 0){ /* Error from callback (error in xret) */
|
if (ret == 0){ /* Error from callback (error in xret) */
|
||||||
if (clixon_xml2cbuf(cbret, xret, 0, 0, NULL, -1, 0) < 0)
|
if (clixon_xml2cbuf(cbret, xret, 0, 0, NULL, -1, 0) < 0)
|
||||||
|
|
|
||||||
|
|
@ -269,10 +269,6 @@ clixon_plugin_daemon_all(clixon_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] pagmode List pagination mode
|
|
||||||
* @param[in] offset Offset, for list pagination
|
|
||||||
* @param[in] limit Limit, for list pagination
|
|
||||||
* @param[out] remaining Remaining elements (if limit is non-zero)
|
|
||||||
* @param[out] xp If retval=1, state tree created and returned: <config>...
|
* @param[out] xp If retval=1, state tree created and returned: <config>...
|
||||||
* @retval 1 OK if callback found (and called) xret is set
|
* @retval 1 OK if callback found (and called) xret is set
|
||||||
* @retval 0 Statedata callback failed. no XML tree returned
|
* @retval 0 Statedata callback failed. no XML tree returned
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ Send netconf command:
|
||||||
clixon_netconf -f /usr/local/etc/clixon/example.xml
|
clixon_netconf -f /usr/local/etc/clixon/example.xml
|
||||||
```
|
```
|
||||||
Start clixon restconf daemon (default config listens on http IPv4 0.0.0.0 on port 8080):
|
Start clixon restconf daemon (default config listens on http IPv4 0.0.0.0 on port 8080):
|
||||||
|
(Warning: starting the native restconf daemon opens ports that may make your system less secure)
|
||||||
```
|
```
|
||||||
sudo clixon_restconf -f /usr/local/etc/clixon/example.xml
|
sudo clixon_restconf -f /usr/local/etc/clixon/example.xml
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -458,10 +458,10 @@ example_action_reset(clixon_handle h, /* Clixon handle */
|
||||||
* @see example_statefile where state is read from file and also pagination
|
* @see example_statefile where state is read from file and also pagination
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
example_statedata(clixon_handle h,
|
example_statedata(clixon_handle h,
|
||||||
cvec *nsc,
|
cvec *nsc,
|
||||||
char *xpath,
|
char *xpath,
|
||||||
cxobj *xstate)
|
cxobj *xstate)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
cxobj **xvec = NULL;
|
cxobj **xvec = NULL;
|
||||||
|
|
@ -645,10 +645,10 @@ example_statefile(clixon_handle h,
|
||||||
* @param[in] arg Per-path user argument (at register time)
|
* @param[in] arg Per-path user argument (at register time)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
example_pagination(void *h0,
|
example_pagination(void *h0,
|
||||||
char *xpath,
|
char *xpath,
|
||||||
pagination_data pd,
|
pagination_data pd,
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
clixon_handle h = (clixon_handle)h0;
|
clixon_handle h = (clixon_handle)h0;
|
||||||
|
|
@ -665,13 +665,12 @@ example_pagination(void *h0,
|
||||||
cxobj *x1;
|
cxobj *x1;
|
||||||
uint32_t lower;
|
uint32_t lower;
|
||||||
uint32_t upper;
|
uint32_t upper;
|
||||||
int ret;
|
|
||||||
cvec *nsc = NULL;
|
cvec *nsc = NULL;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* If -S is set, then read state data from file */
|
/* If -S is set, then read state data from file */
|
||||||
if (!_state || !_state_file)
|
if (!_state || !_state_file)
|
||||||
goto ok;
|
goto ok;
|
||||||
|
|
||||||
locked = pagination_locked(pd);
|
locked = pagination_locked(pd);
|
||||||
offset = pagination_offset(pd);
|
offset = pagination_offset(pd);
|
||||||
limit = pagination_limit(pd);
|
limit = pagination_limit(pd);
|
||||||
|
|
@ -745,7 +744,7 @@ example_pagination(void *h0,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Lock databse status has changed status
|
/*! Lock database status has changed
|
||||||
*
|
*
|
||||||
* @param[in] h Clixon handle
|
* @param[in] h Clixon handle
|
||||||
* @param[in] db Database name (eg "running")
|
* @param[in] db Database name (eg "running")
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
the terms of any one of the Apache License version 2 or the GPL.
|
the terms of any one of the Apache License version 2 or the GPL.
|
||||||
|
|
||||||
***** END LICENSE BLOCK *****
|
***** END LICENSE BLOCK *****
|
||||||
*
|
*
|
||||||
* The example have the following optional arguments that you can pass as
|
* The example have the following optional arguments that you can pass as
|
||||||
* argc/argv after -- in clixon_cli:
|
* argc/argv after -- in clixon_cli:
|
||||||
* -m <yang> Mount this yang on mountpoint
|
* -m <yang> Mount this yang on mountpoint
|
||||||
|
|
|
||||||
|
|
@ -281,11 +281,11 @@ clicon_data_int_get(clixon_handle h,
|
||||||
return atoi(s);
|
return atoi(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Set a single string data via handle
|
/*! Set a single int data via handle
|
||||||
*
|
*
|
||||||
* @param[in] h clixon_handle
|
* @param[in] h clixon_handle
|
||||||
* @param[in] name option name
|
* @param[in] name option name
|
||||||
* @param[in] val option value, must be null-terminated string
|
* @param[in] val option value
|
||||||
* @retval 0 OK
|
* @retval 0 OK
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -278,7 +278,7 @@ xmldb_disconnect(clixon_handle h)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Copy datastore from db1 to db2
|
/*! Copy datastore from db1 to db2, both cache and datastore
|
||||||
*
|
*
|
||||||
* May include copying datastore directory structure
|
* May include copying datastore directory structure
|
||||||
* @param[in] h Clixon handle
|
* @param[in] h Clixon handle
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,7 @@ new "Check nothing added"
|
||||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>" "" "<rpc-reply $DEFAULTNS><data/></rpc-reply>"
|
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>" "" "<rpc-reply $DEFAULTNS><data/></rpc-reply>"
|
||||||
|
|
||||||
new "Add subtree eth/0/0 using none and create which should add eth/0/0"
|
new "Add subtree eth/0/0 using none and create which should add eth/0/0"
|
||||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><interfaces xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\" xmlns:nc=\"${BASENS}\"><interface nc:operation=\"create\"><name>eth/0/0</name><type xmlns:ex=\"urn:example:clixon\">ex:eth</type></interface></interfaces></config><default-operation>none</default-operation> </edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
|
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><interfaces xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\" xmlns:nc=\"${BASENS}\"><interface nc:operation=\"create\"><name>eth/0/0</name><type xmlns:ex=\"urn:example:clixon\">ex:eth</type></interface></interfaces></config><default-operation>none</default-operation></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
|
||||||
|
|
||||||
# Too many quotes, (single inside double inside single) need to fool bash
|
# Too many quotes, (single inside double inside single) need to fool bash
|
||||||
rpc=$(chunked_framing "<rpc $DEFAULTNS><get-config><source><candidate/></source><filter type=\"xpath\" select=\"/if:interfaces/if:interface[if:name='eth/0/0']\" xmlns:if=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\"/></get-config></rpc>")
|
rpc=$(chunked_framing "<rpc $DEFAULTNS><get-config><source><candidate/></source><filter type=\"xpath\" select=\"/if:interfaces/if:interface[if:name='eth/0/0']\" xmlns:if=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\"/></get-config></rpc>")
|
||||||
|
|
@ -215,19 +215,19 @@ new "Check eth/0/0 added using xpath"
|
||||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$rpc" "" "<rpc-reply $DEFAULTNS><data><interfaces xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\"><interface xmlns:ex=\"urn:example:clixon\"><name>eth/0/0</name><type>ex:eth</type></interface></interfaces></data></rpc-reply>"
|
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$rpc" "" "<rpc-reply $DEFAULTNS><data><interfaces xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\"><interface xmlns:ex=\"urn:example:clixon\"><name>eth/0/0</name><type>ex:eth</type></interface></interfaces></data></rpc-reply>"
|
||||||
|
|
||||||
new "Re-create same eth/0/0 which should generate error"
|
new "Re-create same eth/0/0 which should generate error"
|
||||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><interfaces xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\" xmlns:nc=\"${BASENS}\"><interface nc:operation=\"create\"><name>eth/0/0</name><type>ex:eth</type></interface></interfaces></config><default-operation>none</default-operation> </edit-config></rpc>" "<rpc-reply $DEFAULTNS><rpc-error>" ""
|
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><interfaces xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\" xmlns:nc=\"${BASENS}\"><interface nc:operation=\"create\"><name>eth/0/0</name><type>ex:eth</type></interface></interfaces></config><default-operation>none</default-operation></edit-config></rpc>" "<rpc-reply $DEFAULTNS><rpc-error>" ""
|
||||||
|
|
||||||
new "Delete eth/0/0 using none config"
|
new "Delete eth/0/0 using none config"
|
||||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><interfaces xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\" xmlns:nc=\"${BASENS}\"><interface nc:operation=\"delete\"><name>eth/0/0</name><type>ex:eth</type></interface></interfaces></config><default-operation>none</default-operation> </edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
|
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><interfaces xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\" xmlns:nc=\"${BASENS}\"><interface nc:operation=\"delete\"><name>eth/0/0</name><type>ex:eth</type></interface></interfaces></config><default-operation>none</default-operation></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
|
||||||
|
|
||||||
new "Check deleted eth/0/0 (non-presence container)"
|
new "Check deleted eth/0/0 (non-presence container)"
|
||||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>" "" "<rpc-reply $DEFAULTNS><data/></rpc-reply>"
|
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>" "" "<rpc-reply $DEFAULTNS><data/></rpc-reply>"
|
||||||
|
|
||||||
new "Re-Delete eth/0/0 using none should generate error"
|
new "Re-Delete eth/0/0 using none should generate error"
|
||||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><interfaces xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\" xmlns:nc=\"${BASENS}\"><interface nc:operation=\"delete\"><name>eth/0/0</name><type>ex:eth</type></interface></interfaces></config><default-operation>none</default-operation> </edit-config></rpc>" "<rpc-reply $DEFAULTNS><rpc-error>" ""
|
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><interfaces xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\" xmlns:nc=\"${BASENS}\"><interface nc:operation=\"delete\"><name>eth/0/0</name><type>ex:eth</type></interface></interfaces></config><default-operation>none</default-operation></edit-config></rpc>" "<rpc-reply $DEFAULTNS><rpc-error>" ""
|
||||||
|
|
||||||
new "Add interface without key"
|
new "Add interface without key"
|
||||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><interfaces xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\" xmlns:nc=\"${BASENS}\"><interface nc:operation=\"create\"><type>ex:eth</type></interface></interfaces></config><default-operation>none</default-operation> </edit-config></rpc>" "<rpc-reply $DEFAULTNS><rpc-error><error-type>application</error-type><error-tag>missing-element</error-tag><error-info><bad-element>name</bad-element></error-info><error-severity>error</error-severity><error-message>Mandatory key in 'list interface' in ietf-interfaces.yang"
|
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><interfaces xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\" xmlns:nc=\"${BASENS}\"><interface nc:operation=\"create\"><type>ex:eth</type></interface></interfaces></config><default-operation>none</default-operation></edit-config></rpc>" "<rpc-reply $DEFAULTNS><rpc-error><error-type>application</error-type><error-tag>missing-element</error-tag><error-info><bad-element>name</bad-element></error-info><error-severity>error</error-severity><error-message>Mandatory key in 'list interface' in ietf-interfaces.yang"
|
||||||
|
|
||||||
new "netconf discard-changes"
|
new "netconf discard-changes"
|
||||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><discard-changes/></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
|
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><discard-changes/></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
|
||||||
|
|
|
||||||
|
|
@ -197,8 +197,9 @@ wait_restconf
|
||||||
new "Create album London Calling with PUT"
|
new "Create album London Calling with PUT"
|
||||||
expectpart "$(curl -u andy:bar $CURLOPTS -X PUT -H 'Content-Type: application/yang-data+json' $RCPROTO://localhost/restconf/data/example-jukebox:jukebox/library/artist=Clash/album=London%20Calling -d '{"example-jukebox:album":{"name":"London Calling"}}')" 0 "HTTP/$HVER 201"
|
expectpart "$(curl -u andy:bar $CURLOPTS -X PUT -H 'Content-Type: application/yang-data+json' $RCPROTO://localhost/restconf/data/example-jukebox:jukebox/library/artist=Clash/album=London%20Calling -d '{"example-jukebox:album":{"name":"London Calling"}}')" 0 "HTTP/$HVER 201"
|
||||||
|
|
||||||
new "The message-body for a plain patch MUST be present"
|
#new "The message-body for a plain patch MUST be present"
|
||||||
expectpart "$(curl -u andy:bar $CURLOPTS -X PATCH -H 'Content-Type: application/yang-data+json' $RCPROTO://localhost/restconf/data/example-jukebox:jukebox/library/artist=Beatles -d '')" 0 "HTTP/$HVER 400" "The message-body MUST contain exactly one instance of the expected data resource"
|
# XXXThis sometimes hangs
|
||||||
|
#expectpart "$(curl -u andy:bar $CURLOPTS -X PATCH -H 'Content-Type: application/yang-data+json' $RCPROTO://localhost/restconf/data/example-jukebox:jukebox/library/artist=Beatles -d '')" 0 "HTTP/$HVER 400" "The message-body MUST contain exactly one instance of the expected data resource"
|
||||||
|
|
||||||
# Plain patch can be used to create or update, but not delete, a child
|
# Plain patch can be used to create or update, but not delete, a child
|
||||||
# resource within the target resource.
|
# resource within the target resource.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue