Page MenuHomeVyOS Platform

Converting simple op-mode commands from vyatta-op to new syntax
Closed, ResolvedPublic

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

Version
-

Related Objects

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
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.

Added few more rewrites:

  • clear console and reset terminal (PR1, PR2)
  • force arp (PR1, PR2)
syncer edited projects, added VyOS 1.2 Crux; removed VyOS 1.2 Crux (VyOS 1.2.0-rc4).
syncer moved this task from Need Triage to Finished on the VyOS 1.2 Crux board.