Converting simple op-mode commands from vyatta-op to new syntax
Open, NormalPublic

Description

After reading the blog post about new op-mode definitions i've taken upon the task to convert some simple commands to new syntax.
I've started with some simple commands in "vyatta-op". progress can be followed in https://github.com/runborg/vyos-1x . and i will make a PR soon.

Edit by @dmbaturin
This is the blog post in question: http://blog.vyos.net/new-style-operational-mode-command-definitions-are-here
Everyone is invited to join the effort!

Details

Difficulty level
Unknown (require assessment)
Version
-
Why the issue appeared?
Will be filled on close
This request is:
Service Request
runar created this task.Jun 7 2018, 9:31 PM
runar created this object in space S1 VyOS Public.
runar added a subscriber: VyOS 1.2.x.
runar added a comment.EditedJun 7 2018, 10:30 PM

Finished so far:

  • reboot
  • poweroff
  • show arp
  • show bridge
  • show date
  • show disk
  • show configuration
  • show hardware
  • show raid
  • show users

You may stop and want @c-po and/or @dmbaturin review it
so you not end up with lot of things to redo

runar added a comment.Jun 7 2018, 10:39 PM

Sure @syncer!

i've added all files i have finished now.
i also have nearly completed files for show system and show log, but they need some tweeking and completion/op_mode scripts to be finished.

Will wait for a review from @c-po and/or @dmbaturin before i continue converting syntaxes

Do PR please !
And thanks for participation :)

syncer assigned this task to runar.Jun 7 2018, 11:05 PM
syncer triaged this task as Normal priority.
syncer changed the visibility from "Subscribers" to "Public (No Login Required)".

When trying to migrate " show login " and "show history" the new syntax scripts fails to retrieve information from the current user.
The reason is that everything that is executed by the new syntax scripts are wrapped inside sudo.
(from build-command-op-templates line 140: node_def += "run: sudo sh -c \"{0}\"\n".format(command.text) . )

This makes running commands as the current user impossible to do.
I haven't looked into more commands that needs to be executed as current user but i think a lot of the commands that for now is running inside sudo actually don't need to do that.

Could the command field inside new syntax scripts be added an option to run as current user? or possible creating a <user_command> option?
Just throwing up some options here :)

@runar The sudo wrapper is mostly due to the fact that the op mode convertor is largely a clone of the conf mode convertor. This also interfers with operator level users' ability to run anything at all, so this is a good point.
We likely need to switch to adding sudo where needed instead, but we need to test which commands break from it when run by non-admin users.

@runar Found an issue: show-raid.xml refers to ${vyos_op_scripts_dir}/show_raid.sh file, but that file does not exist.

@dmbaturin ahh, my fault.

The script is actually named "show-raid.sh" with a dash instead of underscore...
and while on to it i see all xml files are named with dash'es but all the op_mode scripts are named with underscore... if we want to follow the same name convention, iv'e also done the same fault on "show-configuration-files.sh" and "show-disk-format.sh" .

iv'e updated filenames in my newest PR: https://github.com/vyos/vyos-1x/pull/17

in my latest PR i've also added a rewrite of "show host *" in show-host.xml. this rewrite does not need any wrapper scripts.

dmbaturin updated the task description. (Show Details)Sat, Jul 28, 6:57 PM