infix icon indicating copy to clipboard operation
infix copied to clipboard

UNIX `copy` command to load/save/check .cfg files

Open troglobit opened this issue 1 year ago • 4 comments

Suggestion to add a command line tool, similar to sysrepocfg, but one that knows more about Infix.

  • Prefers /cfg for storing files
  • Supports validation of .cfg files, when importing old backups
  • Provides a stable API for external users

troglobit avatar Apr 01 '24 23:04 troglobit

@wkz + @mattiaswal RFC on an idea I that's been floating around for a while. The most important feature in my mind right now is the validation, so that users can verify the new configuration would actually work.

troglobit avatar Apr 01 '24 23:04 troglobit

I like it!

Some initial thoughts:

  • Since we might want a configure program in the future (retiring cli and letting bash assume the role of admin-exec), I think we should choose a name that is a bit more distinct in order to avoid future confusion. Maybe cfgcp for "configuration copy"
  • Validation could probably make use of yanglint's -Y option.
  • cfgcp could have a -n/--dry-run option that only runs validation

wkz avatar Apr 02 '24 08:04 wkz

Interesting, maybe as a general rule of thumb, use the same names as we use today in the CLI admin-exec context, in this case copy? Would mean less retraining of personnel and possibly less support issues.

For the validation, my idea was to connect to sysrepo, import the file to candidate, and run the validation/check we do today from the CLI. That way we don't need to first extract all modules and enabled features using sysrepoctl to feed into yanglint.

A validation could then look like:

admin@example:~$ copy --dry-run some-file.cfg running-config
Incompatible source (some-file.cfg) with system YANG models:
<detailed error from libyang via sysrepo>

troglobit avatar Apr 02 '24 10:04 troglobit

Yes, that is way better than my suggestion! :+1:

wkz avatar Apr 02 '24 20:04 wkz

Make sure to clean up any relative-path checks as well, see https://github.com/kernelkit/infix/pull/717#discussion_r1806026263

troglobit avatar Oct 18 '24 07:10 troglobit