Changes in clixon-config.yang:

* Removed obsolete options:
    * `CLICON_YANG_LIST_CHECK`
    * `CLICON_RESTCONF_PATH` (moved to restconf/fcgi-path)
  * Fixed: Configure option `CLICON_RESTCONF_PRETTY` was marked as obsolete but was still used.
    * `CLICON_RESTCONF_PRETTY` is now obsolete for sure
    * Instead restconf/pretty is used with API function restconf_pretty_get()
This commit is contained in:
Olof hagsand 2021-12-28 11:44:19 +01:00
parent 32930f4f6b
commit 3117332ddd
16 changed files with 81 additions and 66 deletions

View file

@ -59,6 +59,12 @@ Users may have to change how they access the system
* New `clixon-config@2021-12-05.yang` revision
* Imported (as a sub-spec): clixon-clispec.yang
* Removed obsolete options:
* `CLICON_YANG_LIST_CHECK`
* `CLICON_RESTCONF_PATH` (moved to restconf/fcgi-path)
* Fixed: Configure option `CLICON_RESTCONF_PRETTY` was marked as obsolete but was still used.
* `CLICON_RESTCONF_PRETTY` is now obsolete for sure
* Instead restconf/pretty is used with API function restconf_pretty_get()
### Minor features

View file

@ -255,7 +255,7 @@ convert_evhtp_params2clixon(clicon_handle h,
if (restconf_param_set(h, "REQUEST_URI", path->full) < 0)
goto done;
clicon_debug(1, "%s proto:%d", __FUNCTION__, req->proto);
pretty = clicon_option_bool(h, "CLICON_RESTCONF_PRETTY");
pretty = restconf_pretty_get(h);
/* XXX: Any two http numbers seem accepted by evhtp, like 1.99, 99.3 as http/1.1*/
if (req->proto != EVHTP_PROTO_10 &&
req->proto != EVHTP_PROTO_11){

View file

@ -93,6 +93,7 @@ struct restconf_handle {
/* ------ end of common handle ------ */
clicon_hash_t *rh_params; /* restconf parameters, including http headers */
clixon_auth_type_t rh_auth_type; /* authentication type */
int rh_pretty; /* pretty-print for http replies */
};
/*! Creates and returns a clicon config handle for other CLICON API calls
@ -100,7 +101,11 @@ struct restconf_handle {
clicon_handle
restconf_handle_init(void)
{
return clicon_handle_init0(sizeof(struct restconf_handle));
struct restconf_handle *rh;
rh = clicon_handle_init0(sizeof(struct restconf_handle));
rh->rh_pretty = 1; /* clixon-restconf.yang : pretty is default true*/
return rh;
}
/*! Deallocates a backend handle, including all client structs
@ -205,3 +210,33 @@ restconf_auth_type_set(clicon_handle h,
rh->rh_auth_type = type;
return 0;
}
/*! Get restconf pretty-print (for replies)
* @param[in] h Clicon handle
* @retval pretty
*/
int
restconf_pretty_get(clicon_handle h)
{
struct restconf_handle *rh = handle(h);
return rh->rh_pretty;
}
/*! Set restconf pretty-print
* @param[in] h Clicon handle
* @param[in] name Data name
* @param[in] val Data value as null-terminated string
* @retval 0 OK
* @retval -1 Error
* Currently using clixon runtime data but there is risk for colliding names
*/
int
restconf_pretty_set(clicon_handle h,
int pretty)
{
struct restconf_handle *rh = handle(h);
rh->rh_pretty = pretty;
return 0;
}

View file

@ -49,5 +49,7 @@ int restconf_param_set(clicon_handle h, const char *param, char *val);
int restconf_param_del_all(clicon_handle h);
clixon_auth_type_t restconf_auth_type_get(clicon_handle h);
int restconf_auth_type_set(clicon_handle h, clixon_auth_type_t type);
int restconf_pretty_get(clicon_handle h);
int restconf_pretty_set(clicon_handle h, int pretty);
#endif /* _RESTCONF_HANDLE_H_ */

View file

@ -773,13 +773,10 @@ restconf_config_init(clicon_handle h,
}
if ((x = xpath_first(xrestconf, nsc, "pretty")) != NULL &&
(bstr = xml_body(x)) != NULL){
/* XXX redirection to (obsolete) option, fix by replacing its accesses */
clicon_option_str_set(h, "CLICON_RESTCONF_PRETTY", bstr);
}
if ((x = xpath_first(xrestconf, nsc, "fcgi-socket")) != NULL &&
(bstr = xml_body(x)) != NULL){
/* XXX redirection to (obsolete) option, fix by replacing its accesses */
clicon_option_str_set(h, "CLICON_RESTCONF_PATH", bstr);
if (strcmp(bstr, "true") == 0)
restconf_pretty_set(h, 1);
else if (strcmp(bstr, "false") == 0)
restconf_pretty_set(h, 0);
}
retval = 1;
done:

View file

@ -523,11 +523,6 @@ main(int argc,
clicon_err(OE_DAEMON, EFAULT, "Restconf daemon config not found or disabled");
goto done;
}
/* XXX see restconf_config_init access directly */
if ((sockpath = clicon_option_str(h, "CLICON_RESTCONF_PATH")) == NULL){
clicon_err(OE_CFG, errno, "No CLICON_RESTCONF_PATH in clixon configure file");
goto done;
}
if (FCGX_Init() != 0){ /* How to cleanup memory after this? */
clicon_err(OE_CFG, errno, "FCGX_Init");
goto done;

View file

@ -384,7 +384,7 @@ restconf_sd_read(nghttp2_session *session,
#endif
assert(cbuf_len(cb) > sd->sd_body_offset);
remain = cbuf_len(cb) - sd->sd_body_offset;
clicon_debug(1, "%s length:%zu totlen:%d, offset:%zu remain:%zu",
clicon_debug(1, "%s length:%zu totlen:%zu, offset:%zu remain:%zu",
__FUNCTION__,
length,
cbuf_len(cb),

View file

@ -84,7 +84,6 @@ api_well_known(clicon_handle h,
int retval = -1;
char *request_method;
cbuf *cb = NULL;
int pretty;
int head;
clicon_debug(1, "%s", __FUNCTION__);
@ -95,8 +94,7 @@ api_well_known(clicon_handle h,
request_method = restconf_param_get(h, "REQUEST_METHOD");
head = strcmp(request_method, "HEAD") == 0;
if (!head && strcmp(request_method, "GET") != 0){
pretty = clicon_option_bool(h, "CLICON_RESTCONF_PRETTY");
if (restconf_method_notallowed(h, req, "GET,HEAD", pretty, YANG_DATA_JSON) < 0)
if (restconf_method_notallowed(h, req, "GET,HEAD", restconf_pretty_get(h), YANG_DATA_JSON) < 0)
goto done;
goto ok;
}
@ -445,8 +443,7 @@ api_root_restconf(clicon_handle h,
request_method = restconf_param_get(h, "REQUEST_METHOD");
if ((path = restconf_uripath(h)) == NULL)
goto done;
/* XXX see restconf_config_init access directly */
pretty = clicon_option_bool(h, "CLICON_RESTCONF_PRETTY");
pretty = restconf_pretty_get(h);
/* Get media for output (proactive negotiation) RFC7231 by using
* Accept:. This is for methods that have output, such as GET,
* operation POST, etc

View file

@ -399,8 +399,7 @@ api_stream(clicon_handle h,
clicon_debug(1, "%s", __FUNCTION__);
if ((path = restconf_uripath(h)) == NULL)
goto done;
/* XXX see restconf_config_init access directly */
pretty = clicon_option_bool(h, "CLICON_RESTCONF_PRETTY");
pretty = restconf_pretty_get(h);
if ((pvec = clicon_strsep(path, "/", &pn)) == NULL)
goto done;
/* Sanity check of path. Should be /stream/<name> */

4
configure vendored
View file

@ -5666,8 +5666,8 @@ else
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Standard YANG files should be in ${YANG_STANDARD_DIR}" >&5
$as_echo "Standard YANG files should be in ${YANG_STANDARD_DIR}" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Standard YANG files expected to be in ${YANG_STANDARD_DIR}" >&5
$as_echo "Standard YANG files expected to be in ${YANG_STANDARD_DIR}" >&6; }
# Default location for config file

View file

@ -344,7 +344,7 @@ AC_ARG_WITH(yang-standard-dir,
[YANG_STANDARD_DIR="$withval"],
[YANG_STANDARD_DIR="${prefix}/share/yang/standard"]
)
AC_MSG_RESULT(Standard YANG files should be in ${YANG_STANDARD_DIR})
AC_MSG_RESULT(Standard YANG files expected to be in ${YANG_STANDARD_DIR})
# Default location for config file
AC_DEFINE_UNQUOTED(CLIXON_DEFAULT_CONFIG,"${CLIXON_DEFAULT_CONFIG}",[Location for apps to find default config file])

View file

@ -428,6 +428,13 @@ clicon_nacm_cache_set(clicon_handle h,
/*! Get YANG specification for Clixon system options and features
* Must use hash functions directly since they are not strings.
* Example: features are typically accessed directly in the config tree.
* @code
* cxobj *x = NULL;
* while ((x = xml_child_each(clicon_conf_xml(h), x, CX_ELMNT)) != NULL) {
* if (strcmp(xml_name(x), "CLICON_YANG_DIR") != 0)
* break;
* }
* @endcode
*/
cxobj *
clicon_conf_xml(clicon_handle h)
@ -454,6 +461,9 @@ clicon_conf_xml_set(clicon_handle h,
* That is, get the XML of clixon-config/restconf container of clixon-config.yang
* @param[in] h Clicon handle
* @retval x XML tree containing restconf xml node from clixon-restconf.yang
* @code
* cxobj *xrestconf = clicon_conf_restconf(h);
* @endcode
* @note The clixon-restconf.yang instance can also be a part of the running datastore if
* CLICON_BACKEND_RESTCONF_PROCESS is true
*/
@ -472,6 +482,9 @@ clicon_conf_restconf(clicon_handle h)
* That is, get the XML of clixon-config/clispec container of clixon-config.yang
* @param[in] h Clicon handle
* @retval x XML tree containing clispec xml node from clixon-clispec.yang
* @code
* cxobj *xclispec = clicon_conf_clispec(h);
* @endcode
*/
cxobj *
clicon_conf_clispec(clicon_handle h)

View file

@ -1201,7 +1201,7 @@ yang_find_schemanode(yang_stmt *yn,
return ysmatch;
}
/*! Given a yang statement, find the prefix associated to this module
/*! Given a yang statement, or module itself, find the prefix associated to this module
*
* @param[in] ys Yang statement in module tree (or module itself)
* @retval NULL No prefix found. This is an error

View file

@ -1260,8 +1260,7 @@ ys_schemanode_check(yang_stmt *ys,
* Verify the following rule:
* RFC 7950 7.8.2: The "key" statement, which MUST be present if the list represents
* configuration and MAY be present otherwise
* Unless CLICON_YANG_LIST_CHECK is false (obsolete)
* OR it is the "errors" rule of the ietf-restconf spec which seems to be a special case.
* Unless it is the "errors" rule of the ietf-restconf spec which seems to be a special case.
*/
static int
ys_list_check(clicon_handle h,
@ -1289,18 +1288,11 @@ ys_list_check(clicon_handle h,
/* Except nokey exceptions such as rrc 8040 yang-data */
if (!yang_flag_get(yroot, YANG_FLAG_NOKEY)){
/* Note obsolete */
if (clicon_option_bool(h, "CLICON_YANG_LIST_CHECK")){
clicon_log(LOG_ERR, "Error: LIST \"%s\" in module \"%s\" lacks key statement which MUST be present (See RFC 7950 Sec 7.8.2)",
yang_argument_get(ys),
yang_argument_get(ymod)
);
goto done;
}
else
clicon_log(LOG_WARNING, "Warning: LIST \"%s\" in module \"%s\" lacks key statement which MUST be present (See RFC 7950 Sec 7.8.2)",
yang_argument_get(ys),
yang_argument_get(ymod)
);
clicon_log(LOG_ERR, "Error: LIST \"%s\" in module \"%s\" lacks key statement which MUST be present (See RFC 7950 Sec 7.8.2)",
yang_argument_get(ys),
yang_argument_get(ymod)
);
goto done;
}
}
/* Traverse subs */

View file

@ -29,7 +29,6 @@ cat <<EOF > $cfg
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$IETFRFC</CLICON_YANG_DIR>
<CLICON_YANG_MAIN_DIR>$dir</CLICON_YANG_MAIN_DIR>
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_BACKEND_PIDFILE>$dir/restconf.pidfile</CLICON_BACKEND_PIDFILE>

View file

@ -49,8 +49,11 @@ module clixon-config {
revision 2021-12-05 {
description
"Added option:
Imported
Imported sub-spec:
clixon-clispec.yang
Removed obsolete options:
CLICON_YANG_LIST_CHECK
CLICON_RESTCONF_PATH
Released in Clixon 5.5";
}
revision 2021-11-11 {
@ -456,19 +459,6 @@ module clixon-config {
There is a 'good-enough' posix translation mode and a complete
libxml2 mode";
}
leaf CLICON_YANG_LIST_CHECK {
type boolean;
default true;
description
"If false, skip Yang list check sanity checks from RFC 7950, Sec 7.8.2:
The 'key' statement, which MUST be present if the list represents configuration.
Some yang specs seem not to fulfil this. However, if you reset this, there may
be follow-up errors due to code that assumes a configuration list has keys
Marked as obsolete since the observation above seemed to be related to the
yang-data extension in RFC8040 allows non-key lists. This has been implemented
by a YANG_FLAG_NOKEY yang flag mechanism";
status obsolete;
}
leaf CLICON_YANG_UNKNOWN_ANYDATA{
type boolean;
default false;
@ -531,16 +521,6 @@ module clixon-config {
early in the bootstrapping phase, before clixon-restconf.yang config may
be loaded.";
}
leaf CLICON_RESTCONF_PATH {
type string;
default "/www-data/fastcgi_restconf.sock";
description
"FastCGI unix socket. Should be specified in webserver
Eg in nginx: fastcgi_pass unix:/www-data/clicon_restconf.sock
Only if with-restconf=fcgi, NOT native
Note: Obsolete, use fcgi-socket in clixon-restconf.yang instead";
status obsolete;
}
leaf CLICON_RESTCONF_INSTALLDIR {
type string;
description