Git Product home page Git Product logo

sysrepo's Introduction

Sysrepo

BSD license Website Build Docs Coverity Codecov

Sysrepo is a YANG-based configuration and operational state data store for Unix/Linux applications.

Applications can use sysrepo to store their configuration modeled by provided YANG model instead of using e.g. flat configuration files. Sysrepo will ensure data consistency of the data stored in the datastore and enforce data constraints defined by YANG model. Applications can currently use C language API of sysrepo Client Library to access the configuration in the datastore, but the support for other programming languages is planed for later, too.

Sysrepo can be easily integrated with management agents such as NETCONF or RESTCONF servers, using the same client library API that applications use to access their configuration. As of now, sysrepo is integrated with the Netopeer 2 NETCONF server. This means that applications that use sysrepo to store their configuration can automatically benefit from the ability to being controlled via NETCONF.

Branches

The project uses 2 main branches master and devel. Other branches should not be cloned. In master there are files of the last official release. Any latest improvements and changes, which were tested at least briefly are found in devel. On every new release, devel is merged into master.

This means that when only stable official releases are to be used, either master can be used or specific releases downloaded. If all the latest bugfixes should be applied, devel branch is the one to be used. Note that whenever a new issue is created and it occurs on the master branch, the first response will likely be to use devel before any further provided support.

Compatibility Between Versions

When upgrading Sysrepo to a newer major SO version, look into the compatibility directory for a summary of changes. Each directory describes the changes between the specific SO versions. Be aware that they do not match project versions.

Provided Features

  • Ability to store / retrieve YANG-modeled data elements adressed by XPath
  • Startup, running, candidate, and operational datastore support
  • Data consistency and constraints enforcement according to YANG models
  • No single point of failure design (is just a library)
  • Full transaction and concurrency support
  • Notifications of subscribed applications about the changes made in the datastore
  • Commit verifiers (change verification by subscribed applications)
  • Operational data support (publishing of application's state/configuration data to sysrepo)
  • YANG 1.1 support
  • Custom RPC, Event Notifications, YANG 1.1 Actions support
  • Notification store & notification replay
  • Factory Default Datastore support (RFC 8808)

Packages

Binary RPM or DEB packages of the latest release can be built locally using apkg, look into README in the distro directory.

Security Notes

Sysrepo does not have any master process that could enforce complex access control. So instead, it relies on and utilizes standard file system permissions but there are some things to bear in mind.

To prevent any sensitive data from being accessible by unauthorized processes, it is imperative to always set correct permissions and owner for all YANG modules being installed. The utility sysrepoctl can help with both displaying all the permissions (--list) and modifying them (--change <module>) in addition to this functionality being available in the API.

Having made certain of this, the default configuration should be suitable for a reasonably secure machine that has no malicious running processes. Specifically, it is trivial for such a process to completely break sysrepo by writing into shared files that must be accessible for all the processes linked with sysrepo. Also, with some reverse engineering, it may even be possible to access data by an unathorized process when they are being communicated in these shared files.

In order to avoid all such security issues, there are 2 cmake variables SYSREPO_UMASK and SYSREPO_GROUP that should be adjusted. Generally, a new system group should be created and set for SYSREPO_GROUP and then all outside access frobidden by setting SYSREPO_UMASK to 00007. If then all the users executing sysrepo processes belong to this group, none of sysrepo files and no sensitive information should be accessible to other users.

Requirements

Build Requirements

  • C compiler (gcc >= 4.8.4, clang >= 3.0, ...)
  • cmake >= 2.8.12
  • libyang
  • tar(1)

Optional

  • pkg-config & libsystemd (to support sysrepo-plugind systemd service)
  • doxygen (for generating documentation)
  • cmocka >= 1.0.1 (for tests only, see Tests)
  • valgrind (for enhanced testing)
  • gcov (for code coverage)
  • lcov (for code coverage)
  • genhtml (for code coverage)

Building

$ mkdir build; cd build
$ cmake ..
$ make
# make install

Plugin development documentation

Another markdown document aimed at plugin developers is available in plugin_dev_doc.md. The goal of the document is to provide a single place where a complete overview of information required to start developing plugins is available. The document describes the basics of Sysrepo plugin development and the technologies required to work with Sysrepo like YANG, XPath, NETCONF and others.

Useful CMake sysrepo Options

Set custom repository path:

-DREPO_PATH=/opt/sysrepo/my_repository

Set custom sysrepo DS and NTF plugins path:

-DSR_PLUGINS_PATH=/opt/sysrepo/plugins

Set custom sysrepo-plugind plugins path:

-DSRPD_PLUGINS_PATH=/opt/sysrepo-plugind/plugins

Set global umask for all sysrepo file and directory creation:

-DSYSREPO_UMASK=00007

Set system group to own all sysrepo-related files:

-DSYSREPO_GROUP=sysrepo

Set systemd system service unit path:

-DSYSTEMD_UNIT_DIR=/usr/lib/systemd/system

Set NACM recovery username with unrestricted access:

-DNACM_RECOVERY_USER=root

Set NACM configuration data and 'sysrepo-monitoring' default permissions:

-DNACM_SRMON_DATA_PERM=000

Set startup and factory-default datastore data for internal modules (such as ietf-netconf-acm):

-DINTERNAL_MODULE_DATA_PATH=/etc/config/factory_default_config.xml

Useful CMake Build Options

Changing Compiler

Set CC variable:

$ CC=/usr/bin/clang cmake ..

Changing Install Path

To change the prefix where the library, headers and any other files are installed, set CMAKE_INSTALL_PREFIX variable:

$ cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr ..

Default prefix is /usr/local.

Build Modes

There are two build modes:

  • Release. This generates library for the production use without any debug information.
  • Debug. This generates library with the debug information and disables optimization of the code.

The Debug mode is currently used as the default one. to switch to the Release mode, enter at the command line:

$ cmake -D CMAKE_BUILD_TYPE:String="Release" ..

Code Coverage

Based on the tests run, it is possible to generate code coverage report. But it must be enabled and these commands are needed to generate the report:

$ cmake -DENABLE_COVERAGE=ON ..
$ make
$ make coverage

Usage

All basic Sysrepo functions are available via the main header:

#include <sysrepo.h>

To compile your program with libsysrepo, it is necessary to link it using the following linker parameters:

-lsysrepo

Note, that it may be necessary to call ldconfig(8) after library installation and if the library was installed into a non-standard path, the path to it must be specified to the linker. To help with setting all the compiler's options, there is sysrepo.pc file for pkg-config(1) available in the source tree. The file is installed with the library.

Utils

There are additional utility functions available as part of Sysrepo but their headers need to be included manually. They are:

#include <sysrepo/error_format.h>

Implements basic creation and retrieval of well-known Sysrepo errors generated by callbacks. Currently, the only supported error format is NETCONF.

#include <sysrepo/netconf_acm.h>

NETCONF Access Control Module with configuration data in ietf-netconf-acm YANG module is implemented as part of sysrepo. By default, no users other than the recovery user (default root) will be allowed to write any data but should be granted read and execute permissions unless the access was modified by a NACM extension.

#include <sysrepo/subscribed_notifications.h>

This header provides additional functionality to simplify implementing ietf-subscribed-notifications and ietf-yang-push YANG modules. But these modules need to be installed manually and can be found with all their imports in modules/subscribed_notifications.

#include <sysrepo/values.h>

Utility header for working with sr_val_t Sysrepo value structures. Note that these are generally considered deprecated and libyang struct lyd_node should be used instead.

#include <sysrepo/xpath.h>

More complex handling of XPath expressions that has lots of features at the cost of efficiency.

Used run-time enviromental variables

It is possible to change the repository path by setting SYSREPO_REPOSITORY_PATH variable. Also, if SYSREPO_SHM_PREFIX is defined, it is used for all SHM files created. This way everal sysrepo instances can effectively be run simultanously on one machine.

CLI

There are 2 simple binaries sysrepoctl(1) and sysrepocfg(1) included that can execute commands related to managed YANG modules and stored YANG data, respectively. Full CLI is available only as separate projects such as:

Factory Default

The factory-default datastore contents of a module are automatically populated by the initial data used when installing the specific module and cannot be changed (unless the module is reinstalled). There is an internal subscription to the /ietf-factory-default:factory-reset RPC which performs the copying of factory-default data into all the other datastores. This RPC has a priority 10 so applications are able to subscribe to it with higher or lower priority and perform any other tasks required for a device to be rest to its factory settings.

Examples

See examples directory, which contains an example for basic API functions.

Bindings

There are no bindings for other languages directly in this project but they are available separately.

Tests

There are several tests included and built with cmocka. The tests can be found in tests subdirectory and they are designed for checking library functionality after code changes.

The tests are by default built in the Debug build mode by running

$ make

In case of the Release mode, the tests are not built by default (it requires additional dependency), but they can be enabled via cmake option:

$ cmake -DENABLE_TESTS=ON ..

Note that if the necessary cmocka headers are not present in the system include paths, tests are not available despite the build mode or cmake's options.

Tests can be run by the make's test target:

$ make test

Perf

There is a performance measurement tool included that prints information about the time required to execute common use-cases of working with large YANG instance data.

To enable this test, use an option and to get representative results, enable Release build type:

$ cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_PERF_TESTS=ON ..

and to run the test with seeing its output run:

$ make
$ ctest -V -R sr_perf

sysrepo's People

Contributors

apropp-molex avatar borna-blazevic avatar calvinjolinux avatar ctadmor-new avatar fredgan avatar gotthardp avatar hthiery avatar humblesaw avatar imiller0 avatar irfanhaslanded avatar jeremie6wind avatar jktjkt avatar johnbeckettn2e avatar jruzicka-nic avatar jsmolic avatar jvijtiuk avatar lepici avatar lpaulic avatar lsang6wind avatar michalvasko avatar mzagozen avatar peckato1 avatar pfeige avatar pieterlexis avatar rcmcdonald91 avatar rjarry avatar rkrejci avatar rshearman avatar snar avatar syyyr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sysrepo's Issues

sysrepoctl --repair feature

sysrepoctl should support --repair feature that would rebuild module dependency metadata from scratch in case that it was broken for some reason.

Return proper error when sysrepo deamon has been stopped / restarted

The Client Library should return a proper error by each API call when Sysrepo Daemon has been stopped / restarted (SR_ERR_DISCONNECT). The application is supposed to close the connection causing the error and start a new connection - which must always succeed, in case that the daemon is not running a local Sysrepo Engine should be started.

This behavior should be also specified in the public API documentation.

Release build type

Hi,
currently sysrepo build fails if configured with cmake parameter -DCMAKE_BUILD_TYPE=Release on my machine and also in our travis build, so I think you introduced it in the latest release. Can you please look at it?

Regards,
Michal

Implement blocking connect in the Connection Manager

If connect() to the socket cannot be completed immediately without blocking, Sysrepo returns error. This code path is not yet implemented. Note that it should not be needed for unix-domain sockets on Linux, but we should have it implemented just in case.

Marked with following TODO in connection_manager.c:

// TODO: monitor socket for writing and send message later

sysrepocfg shell should support subscriptions

sudo sysrepocfg --import=./test.xml --format=xml --datastore=running test
Cannot operate on the running datastore as there are no active subscriptions.
Cancelling the operation.

--sub Like this srcfg_test_subscribe("test").
sudo sysrepocfg --sub --import=./test.xml --format=xml --datastore=running test
The new configuration was successfully applied.

sudo sysrepocfg --sub --import=./test.xml --format=xml --datastore=running -p test
The new configuration was successfully applied.

Getting error on make

My gcc version
gcc (GCC) 4.4.4 20100630 (Red Hat 4.4.4-10)

& g++ version is
g++ (GCC) 4.4.4 20100630 (Red Hat 4.4.4-10)

I ma getting error on make as below:-
cc1: error: unrecognized command line option "-Wpedantic"
cc1: error: unrecognized command line option "-std=gnu11"

Any response is greatly appreciated

Sysrepo plugin daemon should not rely on the plugin extension *.so

When sysrepo plugin daemon loads plugins, it scans for *.so files in the plugin directory. On some platforms (e.g. Mac OS X), shared libraries can also have different extensions. Instead, sysrepo daemon should load all binary files in the plugins directory that implement the function sr_plugin_init_cb.

Inconsistent parsing of non-option arguments.

sysrepocfg requires the module name to be the last argument - it can't be in any other position.

  • sysrepocfg ietf-interfaces -x produces "sysrepocfg: Module name is not specified."
  • sysrepocfg -x blah blah blah ietf-interfaces is treated the same as sysrepocfg -x ietf-interfaces

Most Linux tools allow non-option arguments to be specified in any position.

sysrepoctl and sysrepocfg causing error message

Latest master:
Sysrepod is runing and use sysrepoctl to install a yang model, or sysrepocfg to import a start up file, some times I see the following messages from sysrepod:

WRN There are some (1) unprocessed messages for the session id=1462340675 when session stop has been requested, this can lead to unspecified behavior - check RP caller code!!!

Import start up error messages

devl branch: commit ffd70d6
Yang model and start up file:
https://github.com/oplinkoms/yang-model/tree/master/oplink/Of-Config

  1. start sysrepod

  2. install yang mode and import start up file:
    jimmy@sdn-VirtualBox:/workspace/yang-model/oplink/Of-Config$ sysrepoctl --install --yang=of-config.yang
    Installing a new module from file 'of-config.yang' ...
    Installing the YANG file to '/home/jimmy/datastore/sysrepo/build/repository/yang/[email protected]' ...
    Installing data files for module of-config...
    Installing data file '/home/jimmy/datastore/sysrepo/build/repository/data/of-config.startup' ...
    Installing data file '/home/jimmy/datastore/sysrepo/build/repository/data/of-config.running' ...
    Installing data file '/home/jimmy/datastore/sysrepo/build/repository/data/of-config.startup.lock' ...
    Installing data file '/home/jimmy/datastore/sysrepo/build/repository/data/of-config.running.lock' ...
    Installing data file '/home/jimmy/datastore/sysrepo/build/repository/data/of-config.persist' ...
    Installing data file '/home/jimmy/datastore/sysrepo/build/repository/data/of-config.candidate.lock' ...
    Notifying sysrepo about the change ...
    Install operation completed successfully.
    jimmy@sdn-VirtualBox:
    /workspace/yang-model/oplink/Of-Config$ vi install.sh jimmy@sdn-VirtualBox:~/workspace/yang-model/oplink/Of-Config$ sysrepocfg --import=of-config-startup.xml --datastore=startup of-config
    The new configuration was successfully applied.

I checked sysrepo/build/repository and the start up file was imported correctly.
However, sysrepod report error:
WRN Validation of xpath /of-config:*//. was not successful.

libsysrepo unlock crash

Hi,
I encountered a crash with this backtrace:

#0  0x00007ffff7bd03d8 in __lll_unlock_elision () from /lib64/libpthread.so.0
#1  0x00007ffff74953a7 in sr_get_last_errors (session=0x6b1ab0, error_info=0x7ffff3d7f840, error_cnt=0x7ffff3d7f838)
    at /home/vasko/Documents/sysrepo/src/client_library.c:1350
#2  0x000000000040cc95 in op_editconfig (rpc=0x7fffec0018e0, ncs=0x6aaba0) at op_editconfig.c:534
#3  0x00007ffff76e8e39 in nc_send_reply (session=0x6aaba0, rpc=0x7fffec001da0) at /home/vasko/Documents/libnetconf2/src/session_server.c:913
#4  0x00007ffff76e960e in nc_ps_poll (ps=0x6a7360, timeout=500, session=0x7ffff3d7fdf8) at /home/vasko/Documents/libnetconf2/src/session_server.c:1112
#5  0x0000000000404ebb in process_loop (arg=0x0) at main.c:423
#6  0x00007ffff7bc70db in start_thread () from /lib64/libpthread.so.0
#7  0x00007ffff718790d in clone () from /lib64/libc.so.6

It probably always happens when an edit-config is applied by netopeer2-server and the validation fails.

Regards,
Michal

dm_commit_notify may cause memory access error when the model include leaf-list node

Repetition of steps๏ผš

  1. define a yang model(module.yang) with a leaflist and some other nodes.
    2.use copy-config to initialize data using right.xml file is successful.
    3.use edit-config to set data using modify.xml file result in memory access error.

Error happen position:
edit-config invoke dm_commit_notify, then invoke lyd_diff in line 2511 araise error because of first and second lyd_node include a leaflist node which have an invalid child node.
why leaflist node have an invalid child node?
when using dm_load_data_tree to load a lyd tree, invoke dm_load_data_tree_file-->lyd_parse_fd(data_manager.c 489)-->lyd_parse_(tree_data.c 160)-->lyd_parse_xml(tree_data.c 123)-->xml_parse_data(parser_xml.c 555)

when parse leaflist node, invoke xml_parse_data(in line 443), then invoke xml_get_value(parser_xml.c 340)
in function xml_get_value line 85,when we modify leaf->value_str, we modify the lyd_node *node's child member,because struct lyd_node_leaf_list's value_str member is the same as struct lyd_node's child member in the memory.
the follow struct explain the detail.

module.yang

module CopyConfigTest{
    namespace "urn:ietf:params:xml:ns:yang:zte:copyconfig";
    prefix CopyConfigTest;

    container Mo{
        leaf f1{
            type int8;
        }

            leaf-list f3{
                type string;
                max-elements 3;
            }

            list ListMo{
                key "name";
                leaf name{
                    type string;
                }

                leaf value{
                    type int8;
                }
            }
    }

}

right.xml

<Mo xmlns="urn:ietf:params:xml:ns:yang:zte:copyconfig" xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0" xc:operation="create">
    <f1>1</f1>

        <f3>111</f3>

        <ListMo>
            <name>list1</name>
        </ListMo>
        <ListMo>
            <name>list2</name>
            <value>88</value>
        </ListMo>
</Mo>

modify.xml

<Mo xmlns="urn:ietf:params:xml:ns:yang:zte:copyconfig" xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0" xc:operation="merge">
    <f1>127</f1>
</Mo>

sysrepocfg fails when operational state exists

root@t460s:~/ietf962/sysrepo-plugin-system# sysrepocfg ietf-system
[ERR] (srcfg_ly_log_cb:87) libyang: Unknown element "system-state".
[ERR] (srcfg_get_module_data:331) Received data tree from sysrepo is not valid: Unknown element "system-state".
Errors were encountered during editing. Cancelling the operation.

stale subscription sockets

Sometimes, not always, if sysrepod is restarted, the following error message shows:

ERR Unable to connect to subscriber socket=/tmp/sysrepo-subscriptions/com-att-device/25210.Qckquw.sock: Connection refused

The only way to recover is to remove /tmp/sysrepo-subscriptions manually and restart sysrepod.

YANG model update/upgrade procedure

Implement the YANG model update/upgrade procedure: When there is a new version of a YANG model (with the same revision date or with a newer revision date), the datastore should allow to switch to the new model while preserving existing startup (or even running?) datastore data - if possible. If it is not possible, the incompatible data leaves should be either removed, or whole operation should be skipped.

For this we should implement a new operation of sysrepoctl, e.g. sysrepoctl --upgrade.

In the simplest case, it should do the equivalent of:

sysrepocfg --export
sysrepoctl --uninstall
sysrepoctl --install
sysrepocfg --import

rpc request failure when include list node

error occur in function dm_validate_rpc
arg_cnt_p is 4,
rpc_xpath as follows:

/rpcTest:setcondata/aa
/rpcTest:setcondata/aa/bb[name='abc']
/rpcTest:setcondata/aa/bb[name='abc']/name
/rpcTest:setcondata/aa/bb[name='abc']/value

after deal xpath as /rpcTest:setcondata/aa/bb[name='abc'], deal xpath as /rpcTest:setcondata/aa/bb[name='abc']/name report error, by code:
SR_LOG_ERR("RPC argument xpath validation failed('%s'): %s", args[i].xpath, ly_errmsg());

int
dm_validate_rpc(dm_ctx_t *dm_ctx, dm_session_t *session, const char *rpc_xpath, sr_val_t **args_p, size_t *arg_cnt_p, bool input)
{
    sr_val_t *args = NULL;
    size_t arg_cnt = 0;
    const struct lys_node *sch_node = NULL;
    struct lyd_node *data_tree = NULL, *new_node = NULL;
    char *string_value = NULL, *tmp_xpath = NULL;
    struct ly_set *ly_nodes = NULL;
    int ret = 0, rc = SR_ERR_OK;

    args = *args_p;
    arg_cnt = *arg_cnt_p;

    pthread_rwlock_rdlock(&dm_ctx->lyctx_lock);

    data_tree = lyd_new_path(NULL, dm_ctx->ly_ctx, rpc_xpath, NULL, 0);
    if (NULL == data_tree) {
        SR_LOG_ERR("RPC xpath validation failed ('%s'): %s", rpc_xpath, ly_errmsg());
        pthread_rwlock_unlock(&dm_ctx->lyctx_lock);
        return dm_report_error(session, ly_errmsg(), rpc_xpath, SR_ERR_BAD_ELEMENT);
    }

    for (size_t i = 0; i < arg_cnt; i++) {
        /* get schema node */
        sch_node = ly_ctx_get_node2(dm_ctx->ly_ctx, NULL, args[i].xpath, (input ? 0 : 1));
        if (NULL == sch_node) {
            SR_LOG_ERR("RPC argument xpath validation failed('%s'): %s", args[i].xpath, ly_errmsg());
            rc = dm_report_error(session, ly_errmsg(), args[i].xpath, SR_ERR_BAD_ELEMENT);
            break;
        }

cli-display:

user-rpc --content /root/z-conf/z3/data.xml
ERROR
type: application
tag: operation-failed
severity: error
message: Sending an RPC (setcondata) to sysrepo failed (Validation of the changes failed).

data:

<setcondata xmlns="urn:ietf:params:xml:ns:yang:zte.rpc">
    <aa>
        <bb>
            <name>abc</name>
            <value>5</value>
        </bb>
    </aa>
</setcondata>

module:

module rpcTest {
    namespace "urn:ietf:params:xml:ns:yang:zte.rpc";
    prefix rpcTest;

  rpc setcondata{
        input{
            container aa{
            list bb{
                key "name";
                leaf name{
                    type string;
                }
                leaf value{
                    type int8;
                }
            }
        }
      }
      output{
            container aa{
            list bb{
                key "name";
                leaf name{
                    type string;
                }
                leaf value{
                    type int8;
                }
            }
          }
      }
    }
}

in my test i only found he first time model change notify MSG on the sr client log, and the follow-up notify MSG seems can not receive,is any one can do me a favor,thanks a lot.

in my test i only found he first time model change notify MSG on the sr client log, and the follow-up notify MSG seems can not receive,is any one can do me a favor,thanks a lot.

===first time model change log ===

netopeer2-server[14610]: (rp_dt_commit:697) Commit (3/7): all modified models loaded successfully
netopeer2-server[14610]: (rp_dt_commit:706) Commit (4/7): replay of operation succeeded
netopeer2-server[14610]: (rp_dt_commit:715) Commit (5/7): merged models validation succeeded
netopeer2-server[14610]: (rp_dt_commit:720) Commit (6/7): data write succeeded
netopeer2-server[14610]: (dm_commit_notify:2488) Sending notifications about the changes made in running datastore...
netopeer2-server[14610]: (np_subscription_notify:751) Sending module-change notification to '/tmp/sysrepo-subscriptions/ManagedElement/14610.x02Lih.sock' @ 1843744969.
netopeer2-server[14610]: (cl_sm_notif_process:556) Received a notification for subscription id=1843744969 (source address='/tmp/sysrepo-local-14610.sock').

netopeer2-server[14610]: (sm_session_create:467) New session created successfully, real user=root, effective user=(null), session id=665374554.
netopeer2-server[14610]: (cl_sm_notif_process:609) Calling module-change callback for subscription id=1843744969.
netopeer2-server[14610]: *** Handle change of module ManagedElement ... ***
netopeer2-server[14610]: (dm_unlock_datastore:786) Unlock datastore request
netopeer2-server[14610]: (rp_dt_commit:741) Commit (7/7): finished successfully
netopeer2-server[14610]: EDIT-CONFIG: done.

===second time model change log === --can not see the _cl_sm_notif_process receive msg

netopeer2-server[14610]: (rp_dt_commit:697) Commit (3/7): all modified models loaded successfully
netopeer2-server[14610]: (rp_dt_commit:706) Commit (4/7): replay of operation succeeded
netopeer2-server[14610]: (rp_dt_commit:715) Commit (5/7): merged models validation succeeded
netopeer2-server[14610]: (rp_dt_commit:720) Commit (6/7): data write succeeded
netopeer2-server[14610]: (dm_commit_notify:2488) Sending notifications about the changes made in running datastore...
netopeer2-server[14610]: (np_subscription_notify:751) Sending module-change notification to '/tmp/sysrepo-subscriptions/ManagedElement/14610.x02Lih.sock' @ 1843744969.
netopeer2-server[14610]: (dm_unlock_datastore:786) Unlock datastore request
netopeer2-server[14610]: (rp_dt_commit:741) Commit (7/7): finished successfully
netopeer2-server[14610]: EDIT-CONFIG: done.

create presence empty container failure when the container has a leaf with default value

create presence empty container failure(cli result is OK,but .running file is empty) when the container has a leaf with default value. if any leaf of the presence node has no default value, edit-config is successful.

edit-config file is:

<Mo xmlns="urn:ietf:params:xml:ns:yang:zte:subpubcreatetest" xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">
    <A3 xc:operation="create">
    </A3>
</Mo>

model file is:

module SubPubCreateTest{
    namespace "urn:ietf:params:xml:ns:yang:zte:subpubcreatetest";
    prefix SubPubCreateTest;

    revision 2016-05-10;

    container Mo{
        leaf ff{
            type int8;
            default 4;
        }

        container A3{
            presence "A3";
            leaf A3_a1{
                type int8;
                default 3;
            }

            leaf A3_a2{
                type int8;
            }
        }
    }
}

Segmentation fault on sr_rpc_subscribe()

Hi,
recent changes cause this example application to crash.

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <string.h>

#include <sysrepo.h>

int
rpc_clb(const char *xpath, const sr_val_t *input, const size_t input_cnt, sr_val_t **output, size_t *output_cnt, void *private_ctx)
{
    return SR_ERR_OK;
}

int
main()
{
    int rc;
    sr_subscription_ctx_t *sr_subs;
    sr_conn_ctx_t *sr_ctx;
    sr_session_ctx_t *sr_sess;

    rc = sr_connect("test-app", SR_CONN_DAEMON_REQUIRED, &sr_ctx);
    if (rc != SR_ERR_OK) {
        printf("sr_connect fail (%s).\n", sr_strerror(rc));
        return 1;
    }

    rc = sr_session_start(sr_ctx, SR_DS_RUNNING, 0, &sr_sess);
    if (rc != SR_ERR_OK) {
        printf("sr_session_start fail (%s).\n", sr_strerror(rc));
        return 1;
    }

    rc = sr_rpc_subscribe(sr_sess, "/test-module:activate-software-image", rpc_clb, NULL, &sr_subs);
    if (rc != SR_ERR_OK) {
        printf("sr_rpc_subscribe fail (%s).\n", sr_strerror(rc));
        return 1;
    }

    sr_unsubscribe(sr_sess, sr_subs);
    sr_session_stop(sr_sess);
    sr_disconnect(sr_ctx);
    return 0;
}

Regards,
Michal

XPath addressing

Hi,
I am referring to this document. In it you have defined what I would think is a subset of XPath, which was simplified for your needs. However, the XPath expression to get all top-level nodes from a model (/model:) is actually not a valid XPath. Valid XPath with exactly the same meaning would be /model:*. My question is, was this deviation from XPath intentional and if so, what was the reason for it?

Regards,
Michal

when i delete a leaf-list element with special value, the whole leaf list elements was deleted

when i delete a leaf-list element with special value, the whole leaf list elements was deleted, is this a bug?

as an example ,when i use edit-config xml to delete "EFGH" element ,the "ABCD" also be deleted.

data like follow:
<ManagedElement xmlns="urn:fox:params:xml:ns:yang:ran:ManagedElement" xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0" > <RUNRADIOMODE xc:operation="create">ABCD</RUNRADIOMODE> <RUNRADIOMODE xc:operation="create">EFGH</RUNRADIOMODE> </ManagedElement>

edit-config xml like the follow:

<ManagedElement xmlns="urn:fox:params:xml:ns:yang:ran:ManagedElement" xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"> <RUNRADIOMODE xc:operation="delete">EFGH</RUNRADIOMODE> </ManagedElement>

ietf-system fails to parse in netopeer2

After installing the ietf-system module, it is not visible in netopeer2.

This is printed when starting netopeer2-server with -d -v3:

{code}
netopeer2-server[9843]: (cl_request_process:401) Sending get-schema request.
netopeer2-server[9843]: (cl_request_process:423) get-schema request sent, waiting for response.
netopeer2-server[9843]: (cl_request_process:445) get-schema response received, processing.
netopeer2-server[9843]: Invalid attribute definition, "=" expected.
netopeer2-server[9843]: Module parsing failed.
netopeer2-server[9843]: Getting ietf-system (2014-08-06) schema from sysrepo failed, data from this module won't be available.
{code}

Segfault on startup

mp@t460s:~/ietf962/sysrepo-plugin-system$ sudo gdb --args sysrepod -dl4
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
.
Find the GDB manual and other documentation resources online at:
.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from sysrepod...done.
(gdb) run
Starting program: /usr/bin/sysrepod -dl4
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[DBG] (sr_log_stderr:146) Setting log level for stderr logs to 4.
[DBG] (main:117) Sysrepo daemon initialization started.
[DBG] (cm_init:1668) Connection Manager init started.
[DBG] (sr_cbuff_init:402) Initiating circular buffer for 10 elements.
[DBG] (sm_init:287) Session Manager initialized successfully, ctx=0x604230.
[DBG] (cm_server_init:154) Initializing sysrepo server at socket=/var/run/sysrepod.sock
[DBG] (rp_init:1906) Request Processor init started.
[DBG] (sr_cbuff_init:402) Initiating circular buffer for 10 elements.
[DBG] (np_init:338) Notification Processor initialized successfully.
[INF] (dm_init:1067) Initializing Data Manager, schema_search_dir=/etc/sysrepo/yang/, data_search_dir=/etc/sysrepo/data/
[DBG] (sr_locking_set_lock_fd:734) File /etc/sysrepo/data/turing-machine.persist has been locked
[DBG] (pm_load_data_tree:173) Persist data successfully loaded from file '/etc/sysrepo/data/turing-machine.persist'.
[DBG] (sr_locking_set_unlock_close_fd:803) File /etc/sysrepo/data/turing-machine.persist (fd = 6) has been unlocked
[DBG] (pm_get_module_info:579) Returning info from 'turing-machine' persist file: module disabled, 0 subtrees enabled in running, 0 features enabled.
[INF] (dm_load_all_schemas:449) Schema file for module 'turing-machine@2013-12-27' loaded successfully
[DBG] (pm_load_data_tree:138) Persist data file '/etc/sysrepo/data/iana-if-type.persist' does not exist.
[WRN] (pm_load_data_tree:159) Persist data tree load for 'iana-if-type' has failed.
[INF] (dm_load_all_schemas:449) Schema file for module 'iana-if-type@2014-05-08' loaded successfully
[DBG] (sr_locking_set_lock_fd:734) File /etc/sysrepo/data/ietf-interfaces.persist has been locked
[DBG] (pm_load_data_tree:173) Persist data successfully loaded from file '/etc/sysrepo/data/ietf-interfaces.persist'.
[DBG] (sr_locking_set_unlock_close_fd:803) File /etc/sysrepo/data/ietf-interfaces.persist (fd = 6) has been unlocked
[INF] (dm_load_all_schemas:449) Schema file for module 'ietf-interfaces@2014-05-08' loaded successfully
[DBG] (pm_load_data_tree:138) Persist data file '/etc/sysrepo/data/ietf-ip.persist' does not exist.
[WRN] (pm_load_data_tree:159) Persist data tree load for 'ietf-ip' has failed.
[INF] (dm_load_all_schemas:449) Schema file for module 'ietf-ip@2014-06-16' loaded successfully
[DBG] (sr_locking_set_lock_fd:734) File /etc/sysrepo/data/sysrepo-raspberry-demo.persist has been locked
[DBG] (pm_load_data_tree:173) Persist data successfully loaded from file '/etc/sysrepo/data/sysrepo-raspberry-demo.persist'.
[DBG] (sr_locking_set_unlock_close_fd:803) File /etc/sysrepo/data/sysrepo-raspberry-demo.persist (fd = 6) has been unlocked
[INF] (dm_load_all_schemas:449) Schema file for module 'sysrepo-raspberry-demo@2016-07-12' loaded successfully
[DBG] (sr_locking_set_lock_fd:734) File /etc/sysrepo/data/ietf-netconf-acm.persist has been locked
[DBG] (pm_load_data_tree:173) Persist data successfully loaded from file '/etc/sysrepo/data/ietf-netconf-acm.persist'.
[DBG] (sr_locking_set_unlock_close_fd:803) File /etc/sysrepo/data/ietf-netconf-acm.persist (fd = 6) has been unlocked
[INF] (dm_load_all_schemas:449) Schema file for module 'ietf-netconf-acm@2012-02-22' loaded successfully
[DBG] (pm_load_data_tree:138) Persist data file '/etc/sysrepo/data/iana-crypt-hash.persist' does not exist.
[WRN] (pm_load_data_tree:159) Persist data tree load for 'iana-crypt-hash' has failed.
[INF] (dm_load_all_schemas:449) Schema file for module 'iana-crypt-hash@2014-04-04' loaded successfully
[DBG] (dm_ly_log_cb:689) libyang error: Opening file "/etc/sysrepo/yang/[email protected]" failed (No such file or directory).
[WRN] (dm_load_schema_file:312) Unable to parse a schema file: /etc/sysrepo/yang/[email protected]
[ERR] (dm_load_all_schemas:445) Loading schema file for module 'ietf-system@2014-08-06' failed.
[ERR] (rp_init:1957) Data Manager initialization failed.

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff72f59f0 in rb_openlist () from /usr/local/lib/libredblack.so.0
(gdb) bt
#0  0x00007ffff72f59f0 in rb_openlist () from /usr/local/lib/libredblack.so.0
#1  0x00007ffff72f4b77 in rbopenlist () from /usr/local/lib/libredblack.so.0
#2  0x00007ffff7b06cb7 in sr_btree_cleanup (tree=0x623d90) at /home/mp/ietf962/sysrepo/src/common/sr_data_structs.c:271
#3  0x00007ffff7b67f91 in dm_cleanup (dm_ctx=0x61b250) at /home/mp/ietf962/sysrepo/src/data_manager.c:1147
#4  0x00007ffff7b44c11 in rp_init (cm_ctx=0x604030, rp_ctx_p=0x604040) at /home/mp/ietf962/sysrepo/src/request_processor.c:1981
#5  0x00007ffff7b2c630 in cm_init (mode=CM_MODE_DAEMON, socket_path=0x401ae1 "/var/run/sysrepod.sock", cm_ctx_p=0x7fffffffe9f8) at /home/mp/ietf962/sysrepo/src/connection_manager.c:1721
#6  0x0000000000401251 in main (argc=2, argv=0x7fffffffeae8) at /home/mp/ietf962/sysrepo/src/executables/sysrepod.c:120
(gdb) frame 4
#4  0x00007ffff7b44c11 in rp_init (cm_ctx=0x604030, rp_ctx_p=0x604040) at /home/mp/ietf962/sysrepo/src/request_processor.c:1981
1981        dm_cleanup(ctx->dm_ctx);
(gdb) list
1976    
1977        *rp_ctx_p = ctx;
1978        return SR_ERR_OK;
1979    
1980    cleanup:
1981        dm_cleanup(ctx->dm_ctx);
1982        np_cleanup(ctx->np_ctx);
1983        pm_cleanup(ctx->pm_ctx);
1984        ac_cleanup(ctx->ac_ctx);
1985        sr_cbuff_cleanup(ctx->request_queue);

Installed modules are:

  • iana-crypt-hash
  • ietf-interfaces
  • ietf-netconf-acm
  • sysrepo-raspberry-demo
  • iana-if-type
  • ietf-ip
  • turing-machine

Also, ietf-system was installed, then uninstalled, then I tried to install it again (which gave me an "internal error" message) then I restarted sysrepod and got this crash.

core.zip

sr_set_item_example report error

I tried latest devl branch. (commit ffd70d6)

  1. start sysrepod
    jimmy@sdn-VirtualBox:~$ sysrepod -d
    WRN Persist data tree load for 'info-module' has failed.
    WRN Persist data tree load for 'iana-if-type' has failed.
    WRN Persist data tree load for 'ietf-ip' has failed.

  2. run example:
    jimmy@sdn-VirtualBox:~/datastore/sysrepo/build/examples$ ./sr_set_item_example
    DBG Setting log level for stderr logs to 4.
    DBG Connecting to Sysrepo Engine.
    DBG Connecting to socket=/tmp/sysrepod.sock
    INF Connected to daemon Sysrepo Engine at socket=/tmp/sysrepod.sock
    DBG Sending session-start request.
    DBG session-start request sent, waiting for response.
    DBG session-start response received, processing.
    DBG Sending set-item request.
    DBG set-item request sent, waiting for response.
    DBG set-item response received, processing.
    DBG Sending commit request.
    DBG commit request sent, waiting for response.
    DBG commit response received, processing.
    ERR Error by processing of commit request.
    Error by sr_commit: Validation of the changes failed
    DBG Sending session-stop request.
    DBG session-stop request sent, waiting for response.
    DBG session-stop response received, processing.

from sysrepod, we can see the error as well:

ERR Data validation failed

the position of new_value and old_value in function "sr_get_change_next" are differ in declaration and defination

the position of new_value and old_value in function "sr_get_change_next" are differ in declaration and defination

declaration in "sysrepo.h"
int sr_get_change_next(sr_session_ctx_t _session, sr_change_iter_t *iter, sr_change_oper_t *operation,
sr_val_t *_new_value, sr_val_t **old_value);

defination in client_library.c
int
sr_get_change_next(sr_session_ctx_t _session, sr_change_iter_t *iter, sr_change_oper_t *operation,
sr_val_t *_old_value, sr_val_t **new_value)

sysrepod -d does not work

Hi,
when starting freshly installed sysrepod to run on foreground (-d) it tries to parse some submodules, which is not possible, but without -d it starts fine. The full output:

libyang[0]: Parser fails around the line 2.
libyang[0]: Invalid keyword "submodule".
libyang[0]: Module parsing failed.
[WRN] (dm_load_schema_file:138) Unable to parse a schema file: [email protected]
[WRN] (dm_load_schemas:163) Loading schema file: [email protected] failed.
libyang[0]: Parser fails around the line 2.
libyang[0]: Invalid keyword "submodule".
libyang[0]: Module parsing failed.
[WRN] (dm_load_schema_file:138) Unable to parse a schema file: [email protected]
[WRN] (dm_load_schemas:163) Loading schema file: [email protected] failed.
libyang[0]: Parser fails around the line 2.
libyang[0]: Invalid keyword "submodule".
libyang[0]: Module parsing failed.
[WRN] (dm_load_schema_file:138) Unable to parse a schema file: [email protected]
[WRN] (dm_load_schemas:163) Loading schema file: [email protected] failed.
User defined signal 1

Regards,
Michal

oper data and counter get request callback

My understanding is that Netopeer2 will use sysrepo for both config data and pm/oper/counter data retrieval for a Netconf get request.

I have only seen the ability to register for a call back for config data changes. Is there a way to get a callback for a NETCONF get request on pm/oper / counter data using libnetconf2/netopeer2/sysrepo so that the device can fill in the data for these requests from the HW? This type of data is not config data, it is real time oper data and as such would not reside in the sysrepo data store as it is located in the device.

Also the plugin sample code appears to also be config data only as well.
Any info you can provide on how to do this would be very much appreciated.
thanks

Why can't if-feature be used?

//module file test.yang
module test {
  namespace "urn:ietf:params:xml:ns:yang:test";
  prefix ts;

  organization "organization";
  description
    "example yang module";

  feature pre-prov {
      description
        "This feature test";
  }

  container item{
    leaf name {
      type string;
    }
    leaf prov {
      if-feature pre-prov;
      type string;
    }
  }
}

//data  file test.xml

<item xmlns="urn:ietf:params:xml:ns:yang:test">
  <name>good</name>
  <prov>tt</prov>
</item>

root@trusty:~/work/sysrepo-master/build$ sysrepoctl --install --yang=test.yang --owner=root:root --permissions=644
Installing a new module from file 'test.yang' ...
Installing the YANG file to '/home/root/work/sysrepo-master/build/repository/yang/test.yang' ...
Installing data files for module test...
Installing data file '/home/root/work/sysrepo-master/build/repository/data/test.startup' ...
Installing data file '/home/root/work/sysrepo-master/build/repository/data/test.running' ...
Installing data file '/home/root/work/sysrepo-master/build/repository/data/test.startup.lock' ...
Installing data file '/home/root/work/sysrepo-master/build/repository/data/test.running.lock' ...
Installing data file '/home/root/work/sysrepo-master/build/repository/data/test.persist' ...
Installing data file '/home/root/work/sysrepo-master/build/repository/data/test.candidate.lock' ...
Notifying sysrepo about the change ...
Install operation completed successfully.

root@trusty:~/work/sysrepo-master/build$ sysrepoctl --feature-enable=pre-prov --module=test
Enabling feature 'pre-prov' in the module 'test'.
Operation completed successfully.

root@trusty:~/work/sysrepo-master/build$ sysrepoctl -l
Module Name                   | Revision   | Data Owner          | Permissions | Submodules                    | Enabled Features
---------------------------------------------------------------------------------------------------------------------------------
test                          |            | root:root             | 644         |                               | pre-prov


root@trusty:~/work/sysrepo-master/build$ sysrepoctl --import=xml --module=test < test.xml
Error: Unable to parse the data: Unknown element "prov"..
root@trusty:~/work/sysrepo-master/build$ 

Empty startup not copied to running

If the startup configuration for a module is empty, then when the plugin loads it doesn't seem to get copied to running.

  1. Load a plugin
  2. Set running configuration to something
  3. Set the startup configuration to a blank file
  4. Stop and start the plugin
  5. Observe the running configuration still contains its previous contents - it should be blank but it is not.

why "node is not enabled in running datastore" occured when I try to call "sr_set_item" in running datastore? And how can I enable it?

log:
netopeer2-server[17710]: EDIT_CONFIG: leaf /mytest:b/x, operation 1
netopeer2-server[17710]: EDIT_CONFIG: type string (10), value x1
netopeer2-server[17710]: (cl_request_process:401) Sending set-item request.
netopeer2-server[17710]: (cl_request_process:423) set-item request sent, waiting for response.
netopeer2-server[17710]: (cm_conn_read_cb:877) fd 8 readable
netopeer2-server[17710]: (cm_conn_read_cb:890) 47 bytes of data received on fd 8
netopeer2-server[17710]: (cm_conn_read_cb:900) fd 8 would block
netopeer2-server[17710]: (cm_conn_in_buff_process:829) New message of size 43 bytes received.
netopeer2-server[17710]: (sr_cbuff_enqueue:291) Circular buffer enqueue to position=2, current count=1.
netopeer2-server[17710]: (rp_worker_thread_execute:1367) Thread id=140321709696768 signaled.
netopeer2-server[17710]: (sr_cbuff_dequeue:307) Circular buffer dequeue, new buffer head=3, count=0.
netopeer2-server[17710]: (rp_set_item_req_process:381) Processing set_item request.
netopeer2-server[17710]: (dm_load_data_tree_file:407) Loaded module mytest: mtime sec=1464933133 nsec=334644600
netopeer2-server[17710]: (dm_load_data_tree_file:441) Data file /root/swapkvm/fch/z-conf/sysrepo/build/repository/data/mytest.running loaded successfully
netopeer2-server[17710]: (dm_get_data_info:1357) Module mytest has been loaded
netopeer2-server[17710]: (rp_dt_set_item:313) The node is not enabled in running datastore /mytest:b/x
netopeer2-server[17710]: (rp_dt_set_item_wrapper:543) Set item failed
netopeer2-server[17710]: (rp_set_item_req_process:413) Set item failed for '/mytest:b/x', session id=1138069209.

my yang model:
module mytest{
namespace "http://www.mytest.com/";
prefix "mytest";

container b{
leaf x{
type string;
}
leaf y{
type string;
}
leaf z{
type string;
}
}
}

Bootstrap configuration generator

sysrepocfg could allow to generate some meaningless bootstrap configuration for the specified YANG model, so that the user who is adding some new configuration into an empty datastore does not need to write so much of XML/JSON on their own. The generated configuration could be placed inside of a comment in the editor opened by sysrepocfg. Generated leaves can contain random or zeroed values, but the values should be still valid according to the YANG model.

the data stored in .running file is wrong when use user define value to create a leaf which has default value in an exist presence container

the data stored in .running file is wrong when use user define value to create a leaf which has default value in an exist presence container,the stored value is default value not user defined

recurrence steps
1.create presence container with leafs
2.use user define value to create a leaf which has default value

the bug appear when we use create operation which defined in "urn:ietf:params:xml:ns:netconf:base:1.0" to create leaf in an exist container,rpc xml like the follow:
<ManagedElement xmlns="urn:xxx:params:xml:ns:yang:ran:ManagedElement" xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0" > <userLabel xc:operation="create">SDRMAO--A</userLabel> </ManagedElement>

the bug does not occur when we use merge operation which defined in "urn:ietf:params:xml:ns:netconf:base:1.0" to create leaf in an exist container,rpc xml like the follow:

<ManagedElement xmlns="urn:xxx:params:xml:ns:yang:ran:ManagedElement" xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0" >
  <userLabel xc:operation="merge">SDRMAO--A</userLabel> 
</ManagedElement>

Sysrepo Engine should not allow to be stopped while there is an ongoing commit

Sysrepo Engine should not allow to be stopped while there is an ongoing commit (there is a not released commit context in DM). Instead, if stop was requested, it should be just marked for stopping while the commit is still in progress, and automatically stopped just after the commit has finished.

Steps to reproduce: Do not start sysrepo daemon. Run examples/application_example. Try to make some changes in running datastore using sysrepocfg. After few attempts (8th worked form me), you'll get an error:

========== CONFIG HAS CHANGED, CURRENT RUNNING CONFIG: ==========

Error by sr_get_items: The peer disconnected

The issue affects users only if the Sysrepo Engine is running in library mode, therefore tracking this as an enhancement.

When application sub a module only with argument parameters ,it failed at first time of the application start up ,when the application start again it success.

When application sub a module only with argument parameters ,it failed at first time of the application start up ,when the application start again it success.

the reason of this issue may be:
when we use sysrepoctl to install a module only with argument parameters, it does not generate ".startup" file. And when application sub this module, we will create the module socket ,before we create it we will check if the module's subscriptions socket dir can be access( subscriptions dir path like: "/tmp/sysrepo-subscriptions/ModuleManagedElement/"). if it can't, we will make the dir and set the dir permission by module's data ".startup" file permission, as the "startup" file does not exist, we failed to get the data file permission, so we create the module socket failed, and the sub failed.

some questions

  1. the data ".startup" file of the module only with argument parameters should be create when install?
  2. as the application does not know the reason of the module can not be sub is cause by argument or other problem, so if we should offer a way for app to judge?
  3. i think if we use "sr_set_socket_dir_permissions" failed , we should remove the dir.in the function "cl_sm_get_server_socket_filename"
    if (-1 == access(path, F_OK)) { old_umask = umask(0); ret = mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO); umask(old_umask); CHECK_ZERO_LOG_RETURN(ret, SR_ERR_INTERNAL, "Unable to create the directory '%s': %s", path, sr_strerror_safe(errno)); rc = sr_set_socket_dir_permissions(path, module_name, false); CHECK_RC_LOG_RETURN(rc, "Unable to set socket directory permissions for '%s'.", path); }

example module of this issue

module Root {
  namespace "urn:ietf:params:xml:ns:yang:zte:Root";
  prefix Root;

  container Root {
    presence "real Me";
    leaf RootId {
      type int32;
    }
  }
}
module ArgumentModule {
  namespace "urn:ietf:params:xml:ns:yang:fox:ArgumentModule";
  prefix ArgumentModule;
  import Root{
    prefix Root;
  }

  augment "/Root:Root"{
    container ArgumentModule {
      presence "ArgumentModule";
      leaf Id {
        type int32;
      }
    }
  } 
}

sysrepocfg reload all the modules when import a startup file

When importing startup config, I saw the following:

sysrepocfg --import=com-att-device-internal-startup.xml --datastore=startup com-att-device-internal
ERR libyang: Module "module-a" in another revision already implemented.
ERR libyang: Module "module-a" parsing failed.
ERR libyang: Invalid keyword "submodule".
ERR libyang: Module parsing failed.
ERR libyang: Invalid keyword "submodule".
ERR libyang: Module parsing failed.
ERR libyang: Invalid keyword "submodule".
ERR libyang: Module parsing failed.
ERR Error by processing of commit request.
ERR Error returned from sr_commit: Validation of the changes failed.
Errors were encountered during importing. Cancelling the operation.

The first 8 errors are unrelated to the actual issue behind the failed import. At the moment, sysrepocfg loads all yang files in the repository, including submodules, which is not correct (and also not optimal) and libyang reports this in multiple errors.

Local Sysrepo Engine should not be tied to the first connection

When sysrepod is not running, Client Library spawns its own Sysrepo Engine (SE) within the process that is using it. This SE is tied to the first connection (first sr_connect), and released once this connection is disconnected. When there are multiple connections, it should not be released with the first connection, but when the last connection is disconnected.

Example:

sr_connect(conn1);      <-- SE is started
sr_connect(conn2);      <-- uses existing SE

sr_disconnect(conn1);   <-- SE is stopped
sr_get_item(conn2);     <-- ERROR
sr_disconnect(conn2);   <-- SE should be released now

Implement public sr_val_t <-> string conversion API

Many applications / plugins use strings to represent configuration internally. Because of this, they need to implement their own sr_val_t <-> string conversion functions. Sysrepo should provide this helper API for their convenience.

sysrepocfg version 0.3.0 import error messages

When importing startup config, I saw the following:

sysrepocfg --import=com-att-device-internal-startup.xml --datastore=startup com-att-device-internal
ERR libyang: Module "module-a" in another revision already implemented.
ERR libyang: Module "module-a" parsing failed.
ERR libyang: Invalid keyword "submodule".
ERR libyang: Module parsing failed.
ERR libyang: Invalid keyword "submodule".
ERR libyang: Module parsing failed.
ERR libyang: Invalid keyword "submodule".
ERR libyang: Module parsing failed.
ERR Error by processing of commit request.
ERR Error returned from sr_commit: Validation of the changes failed.
Errors were encountered during importing. Cancelling the operation.

It seems that the validation of the input data has failed. It also turns out that after the recent changes made in sysrepocfg the actual validation problems are not printed out, so this error log is not really helpful in narrowing down the exact places in the input data where the conformance with the schema is broken.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.