-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
107 lines (87 loc) · 2.76 KB
/
Copy pathconfig.py
File metadata and controls
107 lines (87 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
"""
Configuration module for topology discovery.
This module handles device configuration and settings.
"""
class DeviceConfig:
"""Configuration for a single network device."""
def __init__(self, host="", username=None, password=None, port=22, ssh_config_file=None):
self.host = host
self.username = username
self.password = password
self.port = port
self.ssh_config_file = ssh_config_file
def to_dict(self):
"""Convert to dictionary format for router initialization."""
return {
'host': self.host,
'username': self.username,
'password': self.password,
'port': self.port,
'ssh_config_file': self.ssh_config_file
}
def get_default_devices():
"""
Get default device configuration.
Returns:
List of DeviceConfig objects for default devices.
"""
dev_list = _get_default_devices()
# Check for duplicates based on host
hosts = [device.host for device in dev_list]
duplicates = [host for host in hosts if hosts.count(host) > 1]
if duplicates:
unique_duplicates = list(set(duplicates))
raise ValueError(f"Duplicate device hosts found: {', '.join(unique_duplicates)}")
return dev_list
def _get_default_devices():
# LLDP topology
return [
DeviceConfig(
host='sonic1-lldp',
username='admin',
password='YourPaSsWoRd',
ssh_config_file="/home/maniam/.ssh/config"
),
DeviceConfig(
host='sonic2-lldp',
username='admin',
password='YourPaSsWoRd',
ssh_config_file="/home/maniam/.ssh/config"
),
DeviceConfig(
host='sonic3-lldp',
username='admin',
password='YourPaSsWoRd',
ssh_config_file="/home/maniam/.ssh/config"
),
DeviceConfig(
host='sonic4-lldp',
username='admin',
password='YourPaSsWoRd',
ssh_config_file="/home/maniam/.ssh/config"
)
]
# snake test (single DUT)
# return [
# DeviceConfig(
# host='sonic1-snake',
# username='admin',
# password='YourPaSsWoRd',
# ssh_config_file="/home/maniam/.ssh/config"
# )
# ]
# snake test (dual DUT)
# return [
# DeviceConfig(
# host='sonic1-snake-dual',
# username='admin',
# password='YourPaSsWoRd',
# ssh_config_file="/home/maniam/.ssh/config"
# ),
# DeviceConfig(
# host='sonic2-snake-dual',
# username='admin',
# password='YourPaSsWoRd',
# ssh_config_file="/home/maniam/.ssh/config"
# )
# ]