move to types config
This commit is contained in:
21
config.yaml
21
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
|
||||
|
@ -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")
|
||||
|
Reference in New Issue
Block a user