Skip to content

src/confd: add the ability to change MotD in cli#7

Merged
troglobit merged 1 commit intokernelkit:sysrepofrom
rical:sysrepo
Apr 12, 2023
Merged

src/confd: add the ability to change MotD in cli#7
troglobit merged 1 commit intokernelkit:sysrepofrom
rical:sysrepo

Conversation

@rical
Copy link
Copy Markdown
Contributor

@rical rical commented Apr 11, 2023

Pull Request

Not sure if this is even something we want? I did it mainly to learn and to test the work flow.
If this is indeed something we want then I intent to fix the duplication of the default value (in skel /etc/motd and in the confd C code).
I might also hook it into the aug framework, even tho it should never fail (TM) and "abort" seems to work as intended?

Commit message

Add the ability to set and delete system MotD (Message Of The Day) using the cli.

So there's no staging concept (aug), if user issues "leave" the change takes immediate effect.

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

@troglobit
Copy link
Copy Markdown
Contributor

First of all, Yes, this is something we want, and it's a great example to start with I think!

Now, there are a few things that I believe need to be fixed:

  1. The standard models must be kept as-is, extensions should be in separate yang file(s) that we load in (in this case) ietf-system.c and use the augment syntax. See ietf-ip.yang for an example. Also, even though we've decided to go with IETF, there's another world of YANG models there that might serve as inspiration https://github.com/openconfig/public/blob/master/release/models/system/openconfig-system.yang (syntax, description, and types used for validation come to mind.)
  2. You should add switch (event) in your callback so you don't regenerate the file multiple times (you'll get at least two events per change), this will also allow you to handle abort without too much effort, or like I did with change_hostname(), just ignore all events except DONE (last event) and just trust that recreating the file(s) work and validation is done by libyang.

Oh, and you don't need to remove the duplicate /etc/motd file. Infix has three operating modes (selectable with the setup tool) and one is the native mode in which users edit /etc manually. These modes share the same rootfs. Your default MOTD can be something like "To enter the CLI, type 'cli' at the shell prompt." or "Remember to change your default password at first login.", something more geared towards NETCONF (operating mode) users.

Last, Augeas is a really cool project and for anything more complex it's super useful. However, it's perfectly OK to render all simple files manually like you've done (and I did with chrony.conf). After all, we've got a lot of models to implement ... ;-)

@troglobit troglobit requested a review from wkz April 11, 2023 17:34
Copy link
Copy Markdown
Contributor

@troglobit troglobit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, we just need to rebase+squash at merge. Handing over to @wkz for final review.

@troglobit troglobit marked this pull request as ready for review April 12, 2023 14:15
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
@troglobit troglobit merged commit 02ac6a7 into kernelkit:sysrepo Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants