diff options
| -rw-r--r-- | op-mode-definitions/reset-connection.xml.in | 2 | ||||
| -rwxr-xr-x | src/op_mode/connect_disconnect.py | 24 |
2 files changed, 15 insertions, 11 deletions
diff --git a/op-mode-definitions/reset-connection.xml.in b/op-mode-definitions/reset-connection.xml.in index e41d8ed20..a3c45d421 100644 --- a/op-mode-definitions/reset-connection.xml.in +++ b/op-mode-definitions/reset-connection.xml.in @@ -11,7 +11,7 @@ <path>interfaces wwan</path> </completionHelp> </properties> - <command>${vyos_op_scripts_dir}/connect_disconnect.py --connect --disconnect --interface "$3"</command> + <command>${vyos_op_scripts_dir}/connect_disconnect.py --reconnect --interface "$3"</command> </tagNode> </children> </node> diff --git a/src/op_mode/connect_disconnect.py b/src/op_mode/connect_disconnect.py index 117e65713..d5db85d25 100755 --- a/src/op_mode/connect_disconnect.py +++ b/src/op_mode/connect_disconnect.py @@ -98,19 +98,23 @@ def main(): group = parser.add_mutually_exclusive_group() group.add_argument("--connect", help="Bring up a connection-oriented network interface", action="store_true") group.add_argument("--disconnect", help="Take down connection-oriented network interface", action="store_true") + group.add_argument("--reconnect", help="Reconnect connection-oriented network interface", action="store_true") parser.add_argument("--interface", help="Interface name", action="store", required=True) args = parser.parse_args() - if args.connect or args.disconnect: - if args.disconnect: - disconnect(args.interface) - - if args.connect: - if commit_in_progress(): - print('Cannot connect while a commit is in progress') - exit(1) - connect(args.interface) - + # Disallow connecting interfaces while their configuration might be changing + if args.connect or args.reconnect: + if commit_in_progress(): + print('Cannot connect while a commit is in progress') + exit(1) + + if args.connect: + connect(args.interface) + elif args.disconnect: + disconnect(args.interface) + elif args.reconnect: + disconnect(args.interface) + connect(args.interface) else: parser.print_help() |
