mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 10:40:58 +01:00
nmcli: extend nmcli device set command to accept explicit ifname specifier
Without it, you cannot set the properties of a device named "help". Now you can with: $ nmcli device set ifname help autoconnect no
This commit is contained in:
parent
4dffbf8f6a
commit
7405d5c7b7
3 changed files with 14 additions and 5 deletions
|
|
@ -259,7 +259,7 @@ usage (void)
|
|||
"COMMAND := { status | show | connect | disconnect | delete | wifi }\n\n"
|
||||
" status\n\n"
|
||||
" show [<ifname>]\n\n"
|
||||
" set <ifname> [autoconnect yes|no] [managed yes|no]\n\n"
|
||||
" set [ifname] <ifname> [autoconnect yes|no] [managed yes|no]\n\n"
|
||||
" connect <ifname>\n\n"
|
||||
" disconnect <ifname> ...\n\n"
|
||||
" delete <ifname> ...\n\n"
|
||||
|
|
@ -338,7 +338,8 @@ usage_device_set (void)
|
|||
{
|
||||
g_printerr (_("Usage: nmcli device set { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := <ifname> { PROPERTY [ PROPERTY ... ] }\n"
|
||||
"ARGUMENTS := DEVICE { PROPERTY [ PROPERTY ... ] }\n"
|
||||
"DEVICE := [ifname] <ifname> \n"
|
||||
"PROPERTY := { autoconnect { yes | no } |\n"
|
||||
" { managed { yes | no }\n"
|
||||
"\n"
|
||||
|
|
@ -1925,6 +1926,11 @@ do_device_set (NmCli *nmc, int argc, char **argv)
|
|||
[DEV_SET_MANAGED] = { -1 },
|
||||
};
|
||||
|
||||
if (argc >= 1 && g_strcmp0 (*argv, "ifname") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
if (argc == 0) {
|
||||
g_string_printf (nmc->return_text, _("Error: No interface specified."));
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
|
|
|
|||
|
|
@ -596,6 +596,7 @@ _nmcli_compl_ARGS()
|
|||
|
||||
# some commands expect a connection as parameter. This connection can either be given
|
||||
# as id|uuid|path|apath. Parse that connection parameter.
|
||||
# Actually, it can also ask for a device name, like `nmcli device set [ifname] <ifname>`
|
||||
_nmcli_compl_ARGS_CONNECTION()
|
||||
{
|
||||
if ! _nmcli_array_has_value OPTIONS "${words[0]}"; then
|
||||
|
|
@ -1274,9 +1275,11 @@ _nmcli()
|
|||
;;
|
||||
se|set)
|
||||
if [[ ${#words[@]} -eq 3 ]]; then
|
||||
_nmcli_compl_COMMAND_nl "${words[2]}" "$(_nmcli_dev_status DEVICE)"
|
||||
_nmcli_compl_COMMAND_nl "${words[2]}" "$(printf "ifname\n%s" "$(_nmcli_con_show NAME)")"
|
||||
else
|
||||
_nmcli_array_delete_at words 0 2
|
||||
_nmcli_array_delete_at words 0 1
|
||||
OPTIONS=(ifname)
|
||||
_nmcli_compl_ARGS_CONNECTION && return 0
|
||||
OPTIONS=(autoconnect managed)
|
||||
_nmcli_compl_ARGS
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -774,7 +774,7 @@ examined. To get information for a specific device, the interface name has
|
|||
to be provided.
|
||||
.TP
|
||||
.TP
|
||||
.B set <ifname> [autoconnect yes|no] [managed yes|no]
|
||||
.B set [ifname] <ifname> [autoconnect yes|no] [managed yes|no]
|
||||
.br
|
||||
Set device properties.
|
||||
.TP
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue