Commit Graph
81 Commits
Author SHA1 Message Date
Joachim WibergandTobias Waldekranz 41b17fc64d package/mech: drop, unused after migration to sysrepo
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-13 12:22:29 +02:00
Tobias Waldekranz e9c4bafb4c confd: Treat all build warnings as errors
We exclude unused parameters, since many callbacks have parameters
that we're not interested in.
2023-04-13 09:30:43 +02:00
Tobias Waldekranz f5259b32d8 confd: Kill all -Wall -Wextra warnings 2023-04-13 09:30:43 +02:00
Tobias Waldekranz 3320175abd confd: Fix symbol redefinition error 2023-04-13 09:27:36 +02:00
Richard AlpeandJoachim Wiberg 02ac6a7ea7 src/confd: add the ability to change MotD in cli
Add the ability to set and delete system MotD (Message Of The Day)
using the cli.

This patch augments the standard ietf-system yang schema with
a new infix-system schema which contains a new motd leaf.

The default value is hard coded in two places, confd and the rootfs
file /etc/motd. The intention is to fix this in upcoming patches.

Introduces:
exec> configure> set system motd STRING
exec> configure> delete system motd
2023-04-12 16:51:08 +02:00
Joachim Wiberg 22a18f3e61 src/confd: skeleton for ietf-interfaces
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-12 09:22:50 +02:00
Joachim Wiberg 82c8423cea src/net: fixes after spec. audit by wkz
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-08 10:53:44 +02:00
Joachim Wiberg 8f1f74263d src/net: first prototype
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-05 16:08:07 +02:00
Joachim Wiberg 2ba8612f7f src/confd: add commit_done_hook() to call initctl reload
This is needed to confirm the new system configuration generation and
reload all affected services.  E.g., when configuring an NTP server
and committing the candidate to running, the ietf-system plugin has
only enabled the service, as a last step we need to tell Finit to
actually start it.

This hook needs to run last since the enabled service(s) may depend on
other service(s), or networking, to be enabled in the proper order.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-03 20:35:55 +02:00
Joachim Wiberg 59d5340eae src/confd: mark missing yang support with XXX
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-03 19:33:37 +02:00
Joachim Wiberg 69920cb230 src/confd: add support for /ietf-system:system/dns-resolver
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-03 19:31:34 +02:00
Joachim Wiberg 42281378f8 src/confd: new function, sr_get_int()
Really ugly handling here, needs to be reworked into sr_uint8() etc.,
adding as-is for big upcoming demo.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-03 19:29:55 +02:00
Joachim Wiberg 443cb2ddf1 src/confd: add support for /ietf-system:system/clock, with deviation
Declare deviation for /ietf-system:system/clock/timezone-utc-offset,
which we currently do not support.

Please note, when setting out to add support for timezone-utc-offset,
you need to ensure the user does not input both, that should be a
validation error.  It's an either-or thing.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-03 18:17:59 +02:00
Joachim Wiberg 68a5a50040 src/confd: add timezone support to set-current-datetime rpc
How to verify, use the following command and paste the XML below:

    $ sysrepocfg -R
    <sys:set-current-datetime xmlns:sys="urn:ietf:params:xml:ns:yang:ietf-system">
        <sys:current-datetime>2022-01-12T14:29:00-02:00</sys:current-datetime>
    </sys:set-current-datetime>

Reuse code from mech, verified and working.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-03 16:37:23 +02:00
Joachim Wiberg 4e0d7ad494 src/confd: use /etc/os-release for platform operational data
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-03 14:14:05 +02:00
Joachim Wiberg a2d2d0948f src/confd: minor refactor
Reuse code from mech, verified and working.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-03 14:08:30 +02:00
Joachim Wiberg 79eb5fd5f4 confd: startup-config hook with support for merging in at bootstrap
This change adds a hook to the startup datastore, we use the ietf-system
module because the module argument is mandatory.  The hook runs when all
changes have been saved to the internal store.  Since sysrepo has many
startup files in /etc/sysrepo, we saving a JSON copy of all these files
in /cfg/startup-config.cfg, which is persistent.  On system bootstrap
this file is merged into the (empty) running datastore, which is what
the sysrepo maintainers recommend to be independent of any yang model
updates that might occur on image upgrades.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-02 16:24:08 +02:00
Joachim Wiberg d8eb88e6da src/confd: improve error handling in ietf-system
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-02 16:24:08 +02:00
Joachim Wiberg af5c5bc3d2 src/confd: refactor, expose flags arg to change subscrie
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-02 16:24:08 +02:00
Joachim Wiberg 405e1f1b70 src/confd: minor refactor, split in multiple files
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-02 16:24:08 +02:00
Joachim Wiberg b3b25ed4d6 src/confd: improved coverage of ietf-system
- Call external programs safely with run()
 - Use augeas to update /etc/hostname and /etc/hosts
 - Add support for generating /etc/chrony.conf
 - Update license copyright due to significant contrib.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-02 16:24:08 +02:00
Tobias Waldekranz e729c82c32 klinfix: Initial add
Infix integration of klish and klish-plugin-sysrepo.

Initially we add:

More flexible management of running vs. startup: Instead of always
committing changes both to running and startup, commit only modifies
running. To persist changes to startup, the copy command is
introduced. This lets the user copy from factory/startup/running to
startup/running at any time.

Well-known verbs like abort, leave, end, etc.
2023-03-31 17:31:34 +02:00
Joachim Wiberg 3cce1e6427 src/confd: drop shortname yang module aliases and load with version
Drop the shortname yang aliases, installed they become copies of
their versioned counterpart, which is not the intention, but also,
no other yang consumer does this.

We'd like to use ly_ctx_load_module() directly, or a slim sysrepo
wrapper of the same, but no such API (load by yang module *name*
with optional revision) exists currently.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-29 13:00:10 +02:00
Joachim Wiberg 24a1eb542d src/confd: add support for enabling yang features
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-29 08:03:37 +02:00
Joachim Wiberg 708b756eba src/confd: minor, coding style
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-29 07:43:48 +02:00
Joachim Wiberg 3bbc5c49cd src/confd: derive YANG module search path from configure
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-29 07:12:13 +02:00
Joachim Wiberg 41db19ffaa src/confd: import updated yang models from mech
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-29 06:22:27 +02:00
Joachim Wiberg 1907bd6a75 src/confd: adjust Denis' copyright year, last changed 2020
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-29 06:22:27 +02:00
Joachim Wiberg 767296e830 src/confd: port to sysrepo 2.x
Changes compared to original project:

 - installs into the sysrepo-plugind plugin directory, so no need
   for calling sysrepoctl to load the plugin
 - the plugin loads its yang module, so no need for calling sysrepoctl
   to load the module before starting sysrepo-plugind
 - bug fix ERROR() macro

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-28 20:27:18 +02:00
Joachim Wiberg 91d67e6b00 src/confd: import sysrepo ietf-system plugin by Denis Kalashnikov
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-28 20:27:18 +02:00
Joachim Wiberg fe20f4a470 mech: new autocli commands, cut-and-paste from various examples
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-27 14:10:26 +02:00
Joachim Wiberg ac7b9073a5 mech: disable debug dumps of transactions by default
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-27 14:08:27 +02:00
Joachim Wiberg aec2514eae mech: add support for ietf-syste:system/dns-resolver
This commit adds multi-nameserver support using openresolv (resolvconf)
and dnsmasq.  This means that a DHCP client (dhcpcd) or VPN client can
be providers of nameservers to the system.  Dnsmasq takes over as the
system resolver, except when the user has set up static configuration.

Static nameserver(s), as well as search and options, are always added
first by openresolv to /etc/resolv.conf.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-27 14:05:03 +02:00
Joachim Wiberg a5258d7102 mech: wrap system() as run(), returning WEXITSTATUS() or -1 on error
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-27 14:03:03 +02:00
Joachim Wiberg 4acaa170e4 mech: add support for ietf-system:set-current-datetime rpc
Also adds:
 - namespace validation
 - proper rpc operation lookup

Fixes:
 - ietf-system:system-shutdown (broken due do invalid op)

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-24 01:50:36 +01:00
Joachim Wiberg 688c0ce2f7 mech: add support for ietf-system state data
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-24 01:50:36 +01:00
Joachim Wiberg b25a374409 mech: drop unused code
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-23 18:40:18 +01:00
Joachim Wiberg 89d08338ce mech: initial support for ietf-interfaces state data
First example of how to implement supoort for ro/state-data.
Only oper-status and phys-address per interface currently.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-23 13:25:23 +01:00
Joachim Wiberg 2abb0a5eb9 mech: add support for setting interface description as ifalias
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-23 13:24:26 +01:00
Joachim Wiberg 4730f3fe09 mech: clean up developer logs in ietf-interfaces
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-23 13:23:54 +01:00
Joachim Wiberg cbc0374251 mech: add support for ietf-system:system-restart and system-shutdown
Shutdown depends on how the kernel is configured, on most embedded
systems this just means reboot.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-16 19:32:24 +01:00
Joachim Wiberg 2124f27d2c mech: initial support for ietf-interfaces and ietf-ip
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-16 17:40:39 +01:00
Tobias Waldekranz c74203720a mech: Compress empty yang containers in CLI
E.g. instead of: `set interfaces interface eth0`

We can now say: `set interface eth0`
2023-03-16 16:13:09 +01:00
Joachim Wiberg 74cf105512 mech: fix disabling chronyd when system ntp client is disabled
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-16 15:55:13 +01:00
Joachim Wiberg 0da4578362 board/common: allow lldpd to run by default in NETCONF mode
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-16 15:55:13 +01:00
Tobias Waldekranz 3c6c2ec66d mech: Import ietf-{interface,ip} models 2023-03-16 15:48:38 +01:00
Joachim Wiberg 4e46b60b6f mech: deviation /sys:system/clock/timezone-utc-offset not-supported
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-16 08:26:21 +01:00
Joachim Wiberg 0185efeb3f mech: add support for setting timezone, e.g. Europe/Stockholm
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-16 08:00:40 +01:00
Joachim Wiberg 4ca2e2d8c4 mech: initial support for ietf-system ntp using chrony
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-16 07:26:40 +01:00
Joachim Wiberg fa45015140 mech: debug transactions
For observability. All transactions that reach ietf-system are logged
with LOG_DEBUG log level.  See /var/log/debug for details.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-16 06:37:56 +01:00