diff options
| -rw-r--r-- | op-mode-definitions/show-interfaces-wwan.xml.in | 2 | ||||
| -rwxr-xr-x | src/op_mode/show_wwan.py | 8 | 
2 files changed, 8 insertions, 2 deletions
diff --git a/op-mode-definitions/show-interfaces-wwan.xml.in b/op-mode-definitions/show-interfaces-wwan.xml.in index 2707c0d8e..45558115b 100644 --- a/op-mode-definitions/show-interfaces-wwan.xml.in +++ b/op-mode-definitions/show-interfaces-wwan.xml.in @@ -72,7 +72,7 @@                  <properties>                    <help>Show WWAN module detailed information summary</help>                  </properties> -                <command>mmcli --modem ${4#wwan}</command> +                <command>if cli-shell-api existsActive interfaces wwan $4; then mmcli --modem ${4#wwan}; else echo "Interface \"$4\" unconfigured!"; fi</command>                </leafNode>                <leafNode name="log">                  <properties> diff --git a/src/op_mode/show_wwan.py b/src/op_mode/show_wwan.py index 529b5bd0f..eb601a456 100755 --- a/src/op_mode/show_wwan.py +++ b/src/op_mode/show_wwan.py @@ -1,6 +1,6 @@  #!/usr/bin/env python3  # -# Copyright (C) 2021 VyOS maintainers and contributors +# Copyright (C) 2021-2023 VyOS maintainers and contributors  #  # This program is free software; you can redistribute it and/or modify  # it under the terms of the GNU General Public License version 2 or later as @@ -17,6 +17,7 @@  import argparse  from sys import exit +from vyos.configquery import ConfigTreeQuery  from vyos.util import cmd  parser = argparse.ArgumentParser() @@ -49,6 +50,11 @@ def qmi_cmd(device, command, silent=False):  if __name__ == '__main__':      args = parser.parse_args() +    tmp = ConfigTreeQuery() +    if not tmp.exists(['interfaces', 'wwan', args.interface]): +        print(f'Interface "{args.interface}" unconfigured!') +        exit(1) +      # remove the WWAN prefix from the interface, required for the CDC interface      if_num = args.interface.replace('wwan','')      cdc = f'/dev/cdc-wdm{if_num}'  | 
