summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-05-04 22:51:36 +0200
committerChristian Breunig <christian@breunig.cc>2023-05-04 22:51:36 +0200
commit2589efdda542c0dea963a12516e25df449e4662e (patch)
tree781925e025a07fbc764c30de4475ac86b6c6f908
parentf2ecc9710d49d320409700bc72f42632f72b369d (diff)
downloadvyos-1x-2589efdda542c0dea963a12516e25df449e4662e.tar.gz
vyos-1x-2589efdda542c0dea963a12516e25df449e4662e.zip
wwan: op-mode: T5196: inform user about unconfigured interface
-rw-r--r--op-mode-definitions/show-interfaces-wwan.xml.in2
-rwxr-xr-xsrc/op_mode/show_wwan.py8
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}'