summaryrefslogtreecommitdiff
path: root/src/conf_mode/service_console-server.py
diff options
context:
space:
mode:
authorWilliam Hughes <will@willhughes.name>2022-09-26 16:07:55 +1300
committerWilliam Hughes <will@willhughes.name>2022-09-28 17:33:07 +1300
commit3930be3b878643034fcfa99d9f428a0d38daec35 (patch)
treeebd1d94d11ce94cf7bd76eab5539db04dc96c136 /src/conf_mode/service_console-server.py
parent53bd9fe11e449c66656fef9cb72084d5d0800a75 (diff)
downloadvyos-1x-3930be3b878643034fcfa99d9f428a0d38daec35.tar.gz
vyos-1x-3930be3b878643034fcfa99d9f428a0d38daec35.zip
conserver: T4717: Support for setting a name for console-server devices
This adds a new 'alias' property to the console-server device definition to allow users to connect to a console using a human-readable name rather than just the device name. For a configuration like: service { console-server { device ttyUSB0 { speed 115200 alias my-server } } } Users can connect either by doing `connect console ttyUSB0`, or `connect console my-server`. Names: * Must be unique * Are limited to 128 characters * Are optional - if not specified, only the `connect console ttyX` form can be used
Diffstat (limited to 'src/conf_mode/service_console-server.py')
-rwxr-xr-xsrc/conf_mode/service_console-server.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/conf_mode/service_console-server.py b/src/conf_mode/service_console-server.py
index a2e411e49..ee4fe42ab 100755
--- a/src/conf_mode/service_console-server.py
+++ b/src/conf_mode/service_console-server.py
@@ -61,6 +61,7 @@ def verify(proxy):
if not proxy:
return None
+ aliases = []
processes = process_iter(['name', 'cmdline'])
if 'device' in proxy:
for device, device_config in proxy['device'].items():
@@ -75,6 +76,12 @@ def verify(proxy):
if 'ssh' in device_config and 'port' not in device_config['ssh']:
raise ConfigError(f'Port "{device}" requires SSH port to be set!')
+ if 'alias' in device_config:
+ if device_config['alias'] in aliases:
+ raise ConfigError("Console aliases must be unique")
+ else:
+ aliases.append(device_config['alias'])
+
return None
def generate(proxy):