clicon / clixon

YANG-based toolchain including NETCONF and RESTCONF interfaces and an interactive CLI
http://www.clicon.org/
Other
206 stars 69 forks source link

commit goes 2 times #488

Closed khromenokroman closed 5 months ago

khromenokroman commented 5 months ago

my plug

clixon_plugin_api *clixon_plugin_init(clicon_handle h) {
    clixon_log(h, LOG_NOTICE, "[%s]: Created ver: %s", NAME, APP_EXT_VERSION);
    strcpy(api.ca_name, NAME);
    api.ca_start = plugin_start;
    api.ca_exit = plugin_exit;
    api.u.cau_backend.cb_trans_validate = commit_validate;
    api.u.cau_backend.cb_trans_commit = commit_commit;
    api.u.cau_backend.cb_trans_commit_done = commit_done;
    return &api;
}

static int commit_validate(clicon_handle h, transaction_data td) {
    (void) h;
    (void) td;
    clicon_log(LOG_INFO, "[%s]: commit validate", NAME);
    return 0;

}

static int commit_commit(clicon_handle h, transaction_data td) {
    (void) h;
    (void) td;
    clicon_log(LOG_INFO, "[%s]: commit commit", NAME);
    return 0;

}

static int commit_done(clicon_handle h, transaction_data td) {
    (void) h;
    (void) td;
    clicon_log(LOG_INFO, "[%s]: commit done", NAME);
    return 0;

}

static int plugin_start(clixon_handle h) {
    (void) h;
    clicon_log(LOG_INFO, "[%s]: START", NAME);
    return 0;
}

static int plugin_exit(clixon_handle h) {
    (void) h;
    clicon_log(LOG_NOTICE, "[%s]: EXIT", NAME);
    return 0;
}

put the directory

root@user:/home/user# ls -l /usr/lib/test/clixon/plugins/backend/
total 464
-rwxr-xr-x 1 root root 474128 янв 31 10:10 libclixon-plug-converter.so

systemctl restart clixon-backend I log into the cli and make a commit

jan 31 10:11:58 user systemd[1]: Stopped Clixon backend API service.
jan 31 10:11:58 user systemd[1]: Starting Clixon backend API service...
jan 31 10:11:58 user clixon_backend[33331]: [clixon-plugin-converter]: Created ver: 1.0.25@322
jan 31 10:11:58 user clixon_backend[33331]: Jan 31 10:11:58: [clixon-plugin-converter]: Created ver: 1.0.25@322
jan 31 10:11:58 user clixon_backend[33331]: [clixon-plugin-converter]: START
jan 31 10:11:58 user clixon_backend[33331]: Jan 31 10:11:58: [clixon-plugin-converter]: START
jan 31 10:11:58 user clixon_backend[33332]: clixon_backend: 33332 Started
jan 31 10:11:58 user systemd[1]: Started Clixon backend API service.
jan 31 10:12:02 user clixon_backend[33332]: [clixon-plugin-converter]: commit validate
jan 31 10:12:02 user clixon_backend[33332]: [clixon-plugin-converter]: commit commit
jan 31 10:12:02 user clixon_backend[33332]: [clixon-plugin-converter]: commit done
jan 31 10:12:02 user clixon_backend[33332]: [clixon-plugin-converter]: commit validate
jan 31 10:12:02 user clixon_backend[33332]: [clixon-plugin-converter]: commit commit
jan 31 10:12:02 user clixon_backend[33332]: [clixon-plugin-converter]: commit done

commit stages are executed 2 times, is this how it should be? or did I do something wrong?? Need help, thanks

olofhagsand commented 5 months ago

No, there should not be two commit callbacks: one per plugin. As described here: https://clixon-docs.readthedocs.io/en/latest/backend.html#transactions

olofhagsand commented 5 months ago

My (unfounded) suspicion is that the plugin is registered twice? Sometimes extra .so plugins could be lying around in the plugin dir. This would be seen in an initial debug log with flag -D default (-D 1) For example:

> clixon_backend -F -s init -f /usr/local/etc/clixon/example.xml
Feb  5 19:43:23: clixon_plugins_load:432: Loading plugin '/usr/local/lib/example/backend/example_backend_nacm.so'
Feb  5 19:43:23: plugin_load_one:331: file:/usr/local/lib/example/backend/example_backend_nacm.so function:clixon_plugin_init
Feb  5 19:43:23: clixon_plugin_init:244: backend nacm
Feb  5 19:43:23: clixon_plugin_init CLICON_NACM_MODE not enabled: example nacm module disabled

Would it be possible to run a gdb session of clixon_backend, break in the two occurrences of eg. commit_commit and see what the back-trace is in the two different calls. What differs?

khromenokroman commented 5 months ago

I'am not understand

[Unit]
Description=Clixon backend API service
After=local-fs.target network.target
PartOf=fw-clixon.target fw.target

[Service]
Type=forking
User=mng
RestartSec=60
Restart=on-failure
ExecStart=clixon_backend -F -D 5 -f /usr/share/fw/clixon/clixon-fw.xml -s init

[Install]
WantedBy=multi-user.target

systemctl restart clixon-backend

feb 06 19:31:46 user systemd[1]: Stopped Clixon backend API service.
feb 06 19:31:46 user systemd[1]: Starting Clixon backend API service...
feb 06 19:31:46 user clixon_backend[92626]: CLICON_CONFIGFILE=/usr/share/fw/clixon/clixon.xml
feb 06 19:31:46 user clixon_backend[92626]: Feb  6 19:31:46: CLICON_CONFIGFILE=/usr/share/fw/clixon/clixon.xml
feb 06 19:31:46 user clixon_backend[92626]: pseudo yang metadata
feb 06 19:31:46 user clixon_backend[92626]: Feb  6 19:31:46: pseudo yang metadata
feb 06 19:31:46 user clixon_backend[92626]: Feb  6 19:31:46: Loading plugin '/usr/lib/fw/clixon/plugins/backend/libclixon-plug-system.so'
feb 06 19:31:46 user clixon_backend[92626]: Feb  6 19:31:46: file:/usr/lib/fw/clixon/plugins/backend/libclixon-plug-system.so function:clixon_plugin_init
feb 06 19:31:46 user clixon_backend[92626]: Loading plugin '/usr/lib/fw/clixon/plugins/backend/libclixon-plug-system.so'
feb 06 19:31:46 user clixon_backend[92626]: file:/usr/lib/fw/clixon/plugins/backend/libclixon-plug-system.so function:clixon_plugin_init
feb 06 19:31:46 user clixon_backend[92626]: [clixon-plug-system]: Created ver: 0.0.3@32
feb 06 19:31:46 user clixon_backend[92626]: Feb  6 19:31:46: [clixon-plug-system]: Created ver: 0.0.3@32
feb 06 19:31:46 user clixon_backend[92626]: Feb  6 19:31:46: retval:1

does he download the same plugin 2 times?

khromenokroman commented 5 months ago

interesting clixon_backend -F -D 5 -f /usr/share/fw/clixon/clixon.xml

Feb  6 19:50:28: CLICON_CONFIGFILE=/usr/share/fw/clixon/clixon.xml
Feb  6 19:50:28: pseudo yang metadata
Feb  6 19:50:28: Loading plugin '/usr/lib/fw/clixon/plugins/backend/libclixon-plug-system.so'
Feb  6 19:50:28: file:/usr/lib/fw/clixon/plugins/backend/libclixon-plug-system.so function:clixon_plugin_init
Feb  6 19:50:28: [clixon-plug-system]: Created ver: 0.0.3@32
Feb  6 19:50:28: retval:1
Feb  6 19:50:29: get-config
Feb  6 19:50:29: edit-config

if I run it like this, it loads 1 time, I don't understand what the problem is? but when commits like this are also duplicated

olofhagsand commented 5 months ago

The syslog looks strange.

feb 06 19:31:46 user clixon_backend[92626]: Feb  6 19:31:46: Loading plugin '/usr/lib/fw/clixon/plugins/backend/libclixon-plug-system.so'
feb 06 19:31:46 user clixon_backend[92626]: Loading plugin '/usr/lib/fw/clixon/plugins/backend/libclixon-plug-system.so'
f

The second log entry does not have a syslog header. Maybe one is stderr, and the other syslog? maybe this is duplicated log-entries, not duplicated plugin load How did you start the backend?

khromenokroman commented 5 months ago

The syslog looks strange.

feb 06 19:31:46 user clixon_backend[92626]: Feb  6 19:31:46: Loading plugin '/usr/lib/fw/clixon/plugins/backend/libclixon-plug-system.so'
feb 06 19:31:46 user clixon_backend[92626]: Loading plugin '/usr/lib/fw/clixon/plugins/backend/libclixon-plug-system.so'
f

The second log entry does not have a syslog header. Maybe one is stderr, and the other syslog? maybe this is duplicated log-entries, not duplicated plugin load How did you start the backend?

ExecStart=clixon_backend -F -D 5 -f /usr/share/fw/clixon/clixon-fw.xml -s init

khromenokroman commented 5 months ago

The syslog looks strange.

feb 06 19:31:46 user clixon_backend[92626]: Feb  6 19:31:46: Loading plugin '/usr/lib/fw/clixon/plugins/backend/libclixon-plug-system.so'
feb 06 19:31:46 user clixon_backend[92626]: Loading plugin '/usr/lib/fw/clixon/plugins/backend/libclixon-plug-system.so'
f

The second log entry does not have a syslog header. Maybe one is stderr, and the other syslog? maybe this is duplicated log-entries, not duplicated plugin load How did you start the backend?

maybe you were right, but then I don't understand anything, then the plugin loads 1 time, how does it turn out that the plugin loads 2 times? very interesting

khromenokroman commented 5 months ago

The syslog looks strange.

feb 06 19:31:46 user clixon_backend[92626]: Feb  6 19:31:46: Loading plugin '/usr/lib/fw/clixon/plugins/backend/libclixon-plug-system.so'
feb 06 19:31:46 user clixon_backend[92626]: Loading plugin '/usr/lib/fw/clixon/plugins/backend/libclixon-plug-system.so'
f

The second log entry does not have a syslog header. Maybe one is stderr, and the other syslog? maybe this is duplicated log-entries, not duplicated plugin load How did you start the backend?

yes, you were right, I experimented with this configuration, the output to the log is not duplicated

[Unit]
Description=Clixon backend API service
After=local-fs.target network.target
PartOf=fw-clixon.target fw.target

[Service]
Type=forking
User=mng
RestartSec=60
Restart=on-failure
ExecStart=clixon_backend -D 5 -f /usr/share/fw/clixon/clixon.xml
StandardOutput=null
StandardError=null

[Install]
WantedBy=multi-user.target

add

StandardOutput=null
StandardError=null

log:

feb 06 22:06:22 user systemd[1]: Stopped Clixon backend API service.
feb 06 22:06:22 user systemd[1]: Starting Clixon backend API service...
feb 06 22:06:22 user clixon_backend[95930]: CLICON_CONFIGFILE=/usr/share/fw/clixon/clixon.xml
feb 06 22:06:22 user clixon_backend[95930]: pseudo yang metadata
feb 06 22:06:22 user clixon_backend[95930]: Loading plugin '/usr/lib/fw/clixon/plugins/backend/libclixon-plug-system.so'
feb 06 22:06:22 user clixon_backend[95930]: file:/usr/lib/fw/clixon/plugins/backend/libclixon-plug-system.so function:clixon_plugin_init
feb 06 22:06:22 user clixon_backend[95930]: [clixon-plug-system]: Created ver: 0.0.5
feb 06 22:06:22 user clixon_backend[95930]: retval:1
feb 06 22:06:22 user clixon_backend[95930]: get-config
feb 06 22:06:22 user clixon_backend[95930]: edit-config

but this does not solve the problem in duplicate commit :(((

khromenokroman commented 5 months ago

plugin

#include "version.h"
#include <cligen/cligen.h>
#include <clixon/clixon.h>
#include <clixon/clixon_backend.h>
#include <unistd.h>
#include <syslog.h>

#define API_VERSION 0

#define NAME "clixon-plug-useradm"

static clixon_plugin_api api;
static int plugin_start(clixon_handle h);
static int plugin_exit(clixon_handle h);
static int commit_validate(clicon_handle h, transaction_data td);

static int plugin_start(clixon_handle h) {
    (void) h;
    clixon_log(h,LOG_INFO, "[%s]: START", NAME);
    return 0;
}

static int plugin_exit(clixon_handle h) {
    (void) h;
    clixon_log(h,LOG_NOTICE, "[%s]: EXIT", NAME);
    return 0;
}

static int commit_validate(clicon_handle h, transaction_data td) {
    (void) h;
    (void) td;

    clicon_log(LOG_INFO, "[%s]: commit_validate", NAME);
    return 0;
}

clixon_plugin_api *clixon_plugin_init(clicon_handle h) {
    (void) h;
    clicon_log(LOG_NOTICE,  "[%s]: Created ver: %s", NAME, APP_EXT_VERSION);
    strcpy(api.ca_name, NAME);
    api.ca_start = plugin_start;
    api.ca_exit = plugin_exit;
    api.u.cau_backend.cb_trans_validate = commit_validate;
    return &api;
}

unit

[Unit]
Description=Clixon backend API service
After=local-fs.target network.target
PartOf=fw-clixon.target fw.target

[Service]
Type=forking
User=mng
RestartSec=60
Restart=on-failure
ExecStart=clixon_backend -D 5 -f /usr/share/clixon/clixon.xml
StandardOutput=null
StandardError=null

[Install]
WantedBy=multi-user.target

root@deb11:/home/user# ls -l /usr/lib/clixon/plugins/backend/

total 388
-rwxr-xr-x 1 root root 393568 feb  6 22:24 libclixon-plug-useradm.so

systemctl restart clixon-backend

feb 06 22:26:00 user systemd[1]: clixon-backend.service: Succeeded.
feb 06 22:26:00 user systemd[1]: Stopped Clixon backend API service.
feb 06 22:26:00 user systemd[1]: Starting Clixon backend API service...
feb 06 22:26:00 user clixon_backend[96218]: CLICON_CONFIGFILE=/usr/share//clixon/clixon-.xml
feb 06 22:26:00 user clixon_backend[96218]: pseudo yang metadata
feb 06 22:26:00 user clixon_backend[96218]: Loading plugin '/usr/lib//clixon/plugins/backend/libclixon-plug-useradm.so'
feb 06 22:26:00 user clixon_backend[96218]: file:/usr/lib//clixon/plugins/backend/libclixon-plug-useradm.so function:clixon_plugin_init
feb 06 22:26:00 user clixon_backend[96218]: [clixon-plug-useradm]: Created ver: 0.0.21@174
feb 06 22:26:00 user clixon_backend[96218]: retval:1
feb 06 22:26:00 user clixon_backend[96218]: get-config
feb 06 22:26:00 user clixon_backend[96218]: edit-config
feb 06 22:26:00 user clixon_backend[96218]: copy-config
feb 06 22:26:00 user clixon_backend[96218]: delete-config
feb 06 22:26:00 user clixon_backend[96218]: lock
feb 06 22:26:00 user clixon_backend[96218]: unlock
feb 06 22:26:00 user clixon_backend[96218]: get
feb 06 22:26:00 user clixon_backend[96218]: close-session
feb 06 22:26:00 user clixon_backend[96218]: kill-session
feb 06 22:26:00 user clixon_backend[96218]: action
feb 06 22:26:00 user clixon_backend[96218]: commit
feb 06 22:26:00 user clixon_backend[96218]: discard-changes
feb 06 22:26:00 user clixon_backend[96218]: cancel-commit
feb 06 22:26:00 user clixon_backend[96218]: validate
feb 06 22:26:00 user clixon_backend[96218]: create-subscription
feb 06 22:26:00 user clixon_backend[96218]: get-schema
feb 06 22:26:00 user clixon_backend[96218]: debug
feb 06 22:26:00 user clixon_backend[96218]: ping
feb 06 22:26:00 user clixon_backend[96218]: stats
feb 06 22:26:00 user clixon_backend[96218]: restart-plugin
feb 06 22:26:00 user clixon_backend[96218]: process-control
feb 06 22:26:00 user clixon_backend[96218]: Reading datastore /var/lib//clixon/db//tmp_db using xml
feb 06 22:26:00 user clixon_backend[96218]: Reading datastore /var/lib//clixon/db//tmp_db using xml
feb 06 22:26:00 user clixon_backend[96218]: running candidate
feb 06 22:26:00 user clixon_backend[96218]: [clixon-plug-useradm]: START
feb 06 22:26:00 user clixon_backend[96218]: CLICON_PLUGIN_DLOPEN_GLOBAL =         "false"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_RESTCONF_HTTP2_PLAIN =         "false"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_CLI_HELPSTRING_LINES =         "0"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_PLUGIN_CALLBACK_CHECK =         "0"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_CLI_DIR =         "/usr/lib//clixon/plugins/cli"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_YANG_UNKNOWN_ANYDATA =         "false"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_CLI_MODE =         "administrator"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_CLI_UTF8 =         "0"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_XMLDB_UPGRADE_CHECKOLD =         "true"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_NACM_DISABLED_ON_EMPTY =         "false"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_NETCONF_HELLO_OPTIONAL =         "false"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_NACM_MODE =         "disabled"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_XMLDB_DIR =         "/var/lib//clixon/db/"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_NETCONF_BASE_CAPABILITY =         "1"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_SOCK_PORT =         "4535"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_CONFIGFILE =         "/usr/share//clixon/clixon-.xml"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_STREAM_DISCOVERY_RFC8040 =         "false"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_STREAM_DISCOVERY_RFC5277 =         "true"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_CLI_HELPSTRING_TRUNCATE =         "false"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_AUTOCOMMIT =         "0"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_SOCK_GROUP =         "mng"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_STREAM_URL =         "https://localhost"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_BACKEND_RESTCONF_PROCESS =         "false"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_BACKEND_DIR =         "/usr/lib//clixon/plugins/backend"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_CLISPEC_DIR =         "/usr/share//clixon/cli-spec/"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_NETCONF_DIR =         "/usr/lib/netconf"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_SOCK_FAMILY =         "UNIX"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_NAMESPACE_NETCONF_DEFAULT =         "false"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_STREAM_PATH =         "streams"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_YANG_REGEXP =         "posix"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_CLI_VARONLY =         "1"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_CLI_TAB_MODE =         "0"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_XMLDB_FORMAT =         "xml"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_RESTCONF_DIR =         "/usr/lib/restconf/111"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_YANG_LIBRARY =         "true"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_STARTUP_MODE =         "init"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_XMLDB_PRETTY =         "true"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_YANG_AUGMENT_ACCEPT_BROKEN =         "false"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_XML_CHANGELOG =         "false"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_CLI_HIST_FILE =         "~/.clixon_cli_history"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_MODULE_SET_ID =         "0"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_CLI_BUF_START =         "256"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_RESTCONF_USER =         "mng"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_CLI_HIST_SIZE =         "300"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_BACKEND_REGEXP =         "(.so)$"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_NETCONF_MESSAGE_ID_OPTIONAL =         "false"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_XMLDB_MODSTATE =         "false"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_BACKEND_PIDFILE =         "/var/run/clixon/clixon-.pid"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_HTTP_DATA_PATH =         "/"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_RESTCONF_STARTUP_DONTUPDATE =         "false"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_DATASTORE_CACHE =         "cache"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_HTTP_DATA_ROOT =         "/var/www"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_ANONYMOUS_USER =         "mng"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_SNMP_AGENT_SOCK =         "unix:/var/run/clixon/snmp.sock"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_NACM_CREDENTIALS =         "except"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_YANG_MODULE_MAIN =         "clixon-"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_STREAM_RETENTION =         "3600"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_LOG_STRING_LIMIT =         "0"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_CLI_LINESCROLLING =         "0"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_CLI_LINES_DEFAULT =         "24"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_CLI_BUF_THRESHOLD =         "65536"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_YANG_SCHEMA_MOUNT =         "false"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_SOCK =         "/var/run/clixon/clixon-.sock"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_RESTCONF_API_ROOT =         "/restconf"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_BACKEND_PRIVILEGES =         "none"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_CLI_EXPAND_LEAFREF =         "true"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_NETCONF_MONITORING =         "true"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_VALIDATE_STATE_XML =         "false"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_RESTCONF_PRIVILEGES =         "drop_perm"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_YANG_DIR =         "/usr/share//clixon/yang/"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_FEATURE =         "*:*"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_FEATURE =         "clixon-restconf:allow-auth-none"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_FEATURE =         "clixon-restconf:fcgi"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_FEATURE =         "ietf-netconf:candidate"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_FEATURE =         "ietf-netconf:confirmed-commit"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_FEATURE =         "ietf-netconf:startup"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_FEATURE =         "ietf-netconf:validate"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_FEATURE =         "ietf-netconf:xpath"
feb 06 22:26:00 user clixon_backend[96218]: CLICON_SNMP_MIB =         "SNMP-TARGET-MIB"
feb 06 22:26:00 user systemd[1]: Started Clixon backend API service.
feb 06 22:26:00 user clixon_backend[96219]: Opened pidfile /var/run/clixon/clixon-.pid with pid 96219
feb 06 22:26:00 user clixon_backend[96219]: clixon_backend: 96219 Started
feb 06 22:27:01 user clixon_backend[96219]: Reading datastore /var/lib//clixon/db//candidate_db using xml
feb 06 22:27:05 user clixon_backend[96219]: Reading datastore /var/lib//clixon/db//running_db using xml
feb 06 22:27:06 user clixon_backend[96219]: [clixon-plug-useradm]: commit_validate
feb 06 22:27:06 user clixon_backend[96219]: candidate running
feb 06 22:27:06 user clixon_backend[96219]: [clixon-plug-useradm]: commit_validate
feb 06 22:27:06 user clixon_backend[96219]: candidate running

commit 2 times :(((((

khromenokroman commented 5 months ago

I found this pattern: if I make a commit from the cli, it turns out 2 commits, and if through netconf, then 1 commit netconf

<?xml version="1.0" encoding="UTF-8"?>
<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <capabilities>
    <capability>urn:ietf:params:netconf:base:1.0</capability>
  </capabilities>
</hello>
]]>]]>

<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
  <edit-config>
    <target>
      <candidate/>
    </target>
    <config>
      <system xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm">
        <security-mode>
          <alldeny>enabled</alldeny>
        </security-mode>
      </system>
    </config>
  </edit-config>
</rpc>
]]>]]>

<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="102">
  <commit/>
</rpc>
]]>]]>

send cat request | clixon_netconf -f /usr/share/ngfw/clixon/clixon-ngfw.xml

log cli

feb 06 23:33:35 user clixon_backend[96603]: [clixon-plug-useradm]: commit_validate
feb 06 23:33:35 user clixon_backend[96603]: candidate running
feb 06 23:33:35 user clixon_backend[96603]: [clixon-plug-useradm]: commit_validate
feb 06 23:33:35 user clixon_backend[96603]: candidate running

log netconf

feb 06 23:36:05 user clixon_backend[96603]: [clixon-plug-useradm]: commit_validate
feb 06 23:36:05 user clixon_backend[96603]: candidate running
olofhagsand commented 5 months ago

I can confirm that the commit entry in example/main/example_cli.cliindeed generates two commits. Good catch, thanks! Something wrong, or unexpected behavior, of the clispec file. Workaround: Replace the commit entry with simply:

   commit("Commit the changes"), cli_commit();
olofhagsand commented 5 months ago

Updated example cli code.

khromenokroman commented 5 months ago

I can confirm that the commit entry in example/main/example_cli.cliindeed generates two commits. Good catch, thanks! Something wrong, or unexpected behavior, of the clispec file. Workaround: Replace the commit entry with simply:

   commit("Commit the changes"), cli_commit();

Thanks, I did it. And how was it going to work before, or is it only going to be used this way now?

It was

commit("commit"), cli_commit();
{
  [persist-id("persist-id") <persist-id-val:string show:"string">("")], cli_commit(); {
    <cancel:string keyword:cancel>("cancel"), cli_commit();
    <confirmed:string keyword:confirmed>("commit confirmed") {
       [persist("persist") <persist-val:string show:"string">("number")]
       [<timeout:uint32 range[1:4294967295] show:"1..4294967295">("timeout in seconds")], cli_commit();
    }
  }
}

now

commit("Commit the changes"), cli_commit();

I don't want to say that I use it, but for understanding, is this functionality planned to be supported in the future?

olofhagsand commented 5 months ago

No thats the workaround. the committed fix is:

diff --git a/example/main/example_cli.cli b/example/main/example_cli.cli
index 5981fc18..719d7500 100644
--- a/example/main/example_cli.cli
+++ b/example/main/example_cli.cli
@@ -48,7 +48,7 @@ delete("Delete a configuration item") {
       all("Delete whole candidate configuration"), delete_all("candidate");
 }
 validate("Validate changes"), cli_validate();
-commit("Commit the changes"), cli_commit(); {
+commit("Commit the changes") {
   [persist-id("Specify the 'persist' value of a previous confirmed-commit") <persist-id-val:string show:"string">("The 'persist' value of the persistent confirmed-commit")], cli_commit(); {
     <cancel:string keyword:cancel>("Cancel an ongoing confirmed-commit"), cli_commit();
     <confirmed:string keyword:confirmed>("Require a confirming commit") {

Note that this is just example code.

khromenokroman commented 5 months ago

No thats the workaround. the committed fix is:

diff --git a/example/main/example_cli.cli b/example/main/example_cli.cli
index 5981fc18..719d7500 100644
--- a/example/main/example_cli.cli
+++ b/example/main/example_cli.cli
@@ -48,7 +48,7 @@ delete("Delete a configuration item") {
       all("Delete whole candidate configuration"), delete_all("candidate");
 }
 validate("Validate changes"), cli_validate();
-commit("Commit the changes"), cli_commit(); {
+commit("Commit the changes") {
   [persist-id("Specify the 'persist' value of a previous confirmed-commit") <persist-id-val:string show:"string">("The 'persist' value of the persistent confirmed-commit")], cli_commit(); {
     <cancel:string keyword:cancel>("Cancel an ongoing confirmed-commit"), cli_commit();
     <confirmed:string keyword:confirmed>("Require a confirming commit") {

Note that this is just example code.

Okay, thanks very much