From 2b438ae17e2cf34d80663b497b36a2320768ae8c Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Sat, 5 Jul 2025 23:27:52 +0000 Subject: [PATCH] move to types config --- config.yaml | 21 +++------------------ router_backup.py | 7 +++++++ 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/config.yaml b/config.yaml index 1f22416..c5fc5d2 100644 --- a/config.yaml +++ b/config.yaml @@ -10,25 +10,10 @@ types: devices: asw100: user: pim - commands: - - show version - - show platform fan-tray - - show platform linecard - - show platform power-supply - - info flat from running + type: srlinux asw120: user: pim - commands: - - show version - - show platform fan-tray - - show platform linecard - - show platform power-supply - - info flat from running + type: srlinux asw121: user: pim - commands: - - show version - - show platform fan-tray - - show platform linecard - - show platform power-supply - - info flat from running + type: srlinux diff --git a/router_backup.py b/router_backup.py index f869924..2677688 100755 --- a/router_backup.py +++ b/router_backup.py @@ -183,6 +183,8 @@ def main(): print("No devices found in config file") sys.exit(1) + types = config.get('types', {}) + success_count = 0 total_count = len(devices) @@ -191,6 +193,11 @@ def main(): user = device_config.get('user') commands = device_config.get('commands', []) + device_type = device_config.get('type') + + # If device has a type, get commands from types section + if device_type and device_type in types: + commands = types[device_type].get('commands', []) if not user: print(f"No user specified for {hostname}, skipping")