move to types config
This commit is contained in:
21
config.yaml
21
config.yaml
@ -10,25 +10,10 @@ types:
|
|||||||
devices:
|
devices:
|
||||||
asw100:
|
asw100:
|
||||||
user: pim
|
user: pim
|
||||||
commands:
|
type: srlinux
|
||||||
- show version
|
|
||||||
- show platform fan-tray
|
|
||||||
- show platform linecard
|
|
||||||
- show platform power-supply
|
|
||||||
- info flat from running
|
|
||||||
asw120:
|
asw120:
|
||||||
user: pim
|
user: pim
|
||||||
commands:
|
type: srlinux
|
||||||
- show version
|
|
||||||
- show platform fan-tray
|
|
||||||
- show platform linecard
|
|
||||||
- show platform power-supply
|
|
||||||
- info flat from running
|
|
||||||
asw121:
|
asw121:
|
||||||
user: pim
|
user: pim
|
||||||
commands:
|
type: srlinux
|
||||||
- show version
|
|
||||||
- show platform fan-tray
|
|
||||||
- show platform linecard
|
|
||||||
- show platform power-supply
|
|
||||||
- info flat from running
|
|
||||||
|
@ -183,6 +183,8 @@ def main():
|
|||||||
print("No devices found in config file")
|
print("No devices found in config file")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
types = config.get('types', {})
|
||||||
|
|
||||||
success_count = 0
|
success_count = 0
|
||||||
total_count = len(devices)
|
total_count = len(devices)
|
||||||
|
|
||||||
@ -191,6 +193,11 @@ def main():
|
|||||||
|
|
||||||
user = device_config.get('user')
|
user = device_config.get('user')
|
||||||
commands = device_config.get('commands', [])
|
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:
|
if not user:
|
||||||
print(f"No user specified for {hostname}, skipping")
|
print(f"No user specified for {hostname}, skipping")
|
||||||
|
Reference in New Issue
Block a user