After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 698076 - cli; 'connection add' and 'connection modify' have substantially different syntax
cli; 'connection add' and 'connection modify' have substantially different sy...
Status: RESOLVED FIXED
Product: NetworkManager
Classification: Platform
Component: nmcli
unspecified
Other Linux
: Normal normal
: ---
Assigned To: NetworkManager maintainer(s)
NetworkManager maintainer(s)
: 743436 (view as bug list)
Depends on: 750590
Blocks: tracker-nmcli
 
 
Reported: 2013-04-15 18:38 UTC by Pavel Simerda
Modified: 2015-09-03 04:33 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Pavel Simerda 2013-04-15 18:38:21 UTC
I want to bring this to discussion. When adding a connection using nmcli, you specify shorthand names for attributes, while the 'modify' action requires full option name including section. Example:

nmcli connection add name Slave type ethernet mac 00:aa:bb:cc:dd:ee

nmcli connection modify Slave ethernet.mac-address 00:11:22:33:44:55
Comment 1 Jiri Klimes 2013-04-22 17:15:48 UTC
Because in 'nmcli connection add' the argument keywords are not the exact property names (they are long and ugly sometimes). They are some selected most often used parameters (somebody should maybe review them whether we should and/remove some).

'nmcli connection modify' is a general command that allows modification of arbitrary property.

'nmcli connection modify' can be used as a complementary command to 'add' when some special change is required.

'modify' accepts shortcuts both for setting and property names (man nm-settings)
You can e.g. do:
$ nmcli -p con add type ethernet con-name drat
$ nmcli con modify drat eth.mtu 1400
Comment 2 Pavel Simerda 2013-04-23 14:43:34 UTC
I actually think that both 'add' and 'modify' should accept exact long names (e.g. ethernet.mac-address) and shortcuts (e.g. mac).
Comment 3 Pavel Simerda 2013-04-25 17:20:19 UTC
Upon request for more information on IRC:

Currently there are two ways to express connection properties with nmcli.

1) Advanced. Full property name and value as per the library/dbus API

Example: ethernet.mac-address 00:11:22:33:44:55

This way is universal and allows you to specify *any* property, provided that nmcli knows how to parse it and send it to NetworkManager. Therefore it exposes the whole connection setup via 'nmcli'.

2) Simple. Keywords for selected property names

Example: mac 00:11:22:33:44:55

This way is more user friendly and less verbose. It allows you to specify most common settings in a sensible manner.

****

Currently, #1 is used for 'nmcli connection modify' and #2 is used for 'nmcli connection add', which is cool. The basic idea is that when creating a connection, one usually doesn't need the full power of #2 and that one could still use modify to amend the configuration.

So, what is my proposal? My proposal is to keep the above possibilities and still allow #1 for 'modify' and #2 for 'add' but *also* allow #1 for 'add' and '#2' for modify for those who would like to use it.

Therefore I'm *not* inventing an new syntax and I'm *not* asking to remove any of the current possibilities, just merging the power of 'add' and 'modify'. I believe that in the long term this will make our lives (and the administrator lives) much easier.

Example:

The following two commands would be equivalent (provided that we use short 'name', not 'con-name'):

nmcli connection add \
    type ethernet \
    name Ethernet \
    mac 00:11:22:33:44:55 \
    mtu 1492

nmcli connection add \
    connection.type ethernet \
    connection.name Ethernet \
    ethernet.mac-address 00:11:22:33:44:55 \
    ethernet.mtu 1492

I further propose that the documentation and examples always prefer the short syntax for friendly user experience and note that the full syntax is supported.

I just stumbled upon one issue and that is that 'nmcli modify' only supports a single property to be modified at a time and that it works for resetting when value is not provided. I believe this should be solved, too.

Known foreign syntax: Mikrotik RouterOS is praised for its great command-line capabilities. It uses 'set option1=value1 option2=value2' and 'unset option1 option2 ...'.

It could be 'modify/reset', 'set/reset', 'set/unset' or whatever else. The only drawback is that you still can't perform modifying one option and resetting another in a single command. We could either live with it, or find a better solution.

Would for example an empty string work instead of a missing value? Is that a good idea at all? I personally could live with resetting as a separate operation or maybe even without it (explicit value setting being the alternative).

My goal in this RFE was to give nmcli connection add/modify the full power of library/dbus connection adding/modification interface while keeping the simplicity that jklimes put into the 'nmcli connection add' interface.
Comment 4 Dan Williams 2013-04-30 21:01:26 UTC
I think it's probably a good idea to unify the add/modify commands like you describe, would be neat to have both support the short + full syntax.  It should probably be a goal though, rather than some kind of short-term blocker.
Comment 5 Dan Winship 2013-05-02 15:59:41 UTC
NM bugzilla reorganization... sorry for the bug spam.
Comment 6 Thomas Haller 2015-01-25 12:03:36 UTC
Possible duplicate: bug 740749
Comment 7 Thomas Haller 2015-01-25 12:05:33 UTC
*** Bug 743436 has been marked as a duplicate of this bug. ***
Comment 8 Thomas Haller 2015-06-11 11:56:37 UTC
will be implemented by bug 750590
Comment 9 Lubomir Rintel 2015-07-02 07:38:38 UTC
This problem has been fixed in the unstable development version. The fix will be available in the next major software release. You may need to upgrade your Linux distribution to obtain that newer version.

In master you can now "nmcli c add ... -- <property> <value> ..."
Comment 10 dE 2015-09-03 04:33:41 UTC
Thank you!