Skip to content

Commit 6f6d757

Browse files
pavel-shirshovlguohan
authored andcommitted
Testbed v2 (#104)
* Testbed v2 * Restore docker registry * Fix testbed.csv * Remove *.pyc file * Varius fixes * Sync with master * Make testbed-cli executable * Get vm tap interface id dynamically
1 parent a2ab261 commit 6f6d757

204 files changed

Lines changed: 5210 additions & 17390 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ansible/ansible.cfg

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid}
102102
# by default (as of 1.4), Ansible may display deprecation warnings for language
103103
# features that should no longer be used and will be removed in future versions.
104104
# to disable these warnings, set the following value to False:
105-
#deprecation_warnings = True
105+
deprecation_warnings = False
106106

107107
# (as of 1.8), Ansible can optionally warn when usage of the shell and
108108
# command module appear to be simplified by using a default Ansible module
@@ -119,7 +119,7 @@ action_plugins = plugins/action
119119
connection_plugins = plugins/connection
120120
# lookup_plugins = /usr/share/ansible_plugins/lookup_plugins
121121
# vars_plugins = /usr/share/ansible_plugins/vars_plugins
122-
# filter_plugins = /usr/share/ansible_plugins/filter_plugins
122+
filter_plugins = plugins/filter
123123
callback_whitelist = profile_tasks
124124

125125
# by default callbacks are not loaded for /bin/ansible, enable this if you
@@ -232,3 +232,4 @@ accelerate_daemon_timeout = 30
232232
# the default behaviour that copies the existing context or uses the user default
233233
# needs to be changed to use the file system dependant context.
234234
#special_context_filesystems=nfs,vboxsf,fuse
235+

ansible/fanout.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#Example:
2+
# ansible-playbook fanout.yml -i str --limit str-7260-01 -b --vault-password-file ~/password.txt
3+
- hosts: [fanout]
4+
gather_facts: no
5+
roles:
6+
- fanout
7+
8+
9+

ansible/fanout_connect.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#Example:
2+
# ansible-playbook fanout_connect.yml -i str --limit str-7260-01 -b --vault-password-file password.txt -e "server=str-acs-serv-02 server_port=p6p2"
3+
- hosts: all
4+
gather_facts: no
5+
tasks:
6+
- fail: msg="Please provide VM server name and server port name, see comment line in playbook"
7+
when:
8+
- server is not defined
9+
- server_port is not defined
10+
11+
- name: get the username running the deploy
12+
command: whoami
13+
connection: local
14+
become: no
15+
register: calling_username
16+
17+
- set_fact: userid={{ calling_username.stdout }}
18+
19+
- include: roles/fanout/tasks/rootfanout_connect.yml
20+
21+

ansible/files/creategraph.py

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#!/usr/bin/env python
2+
import csv, sys, os
3+
from lxml import etree
4+
5+
DEVICECSV = 'sonic_str_devices.csv'
6+
LINKCSV = 'sonic_str_links.csv'
7+
STARLAB_CONNECTION_GRAPH_ROOT_NAME = 'StarlabConnectionGraph'
8+
STARLAB_CONNECTION_GRAPH_DPGL2_NAME = 'DevicesL2Info'
9+
10+
class LabGraph(object):
11+
12+
"""
13+
This is used to create "graph" file of starlab for all connections and vlan info from csv file
14+
We(both engineer and lab technician) maintian and modify the csv file to keep track of the lab
15+
infrastucture for Sonic development and testing environment.
16+
"""
17+
18+
def __init__(self, dev_csvfile='', link_csvfile=''):
19+
#TODO:make generated xml file name as parameters in the future to make it more flexible
20+
self.devices = []
21+
self.links = []
22+
self.devcsv = dev_csvfile
23+
self.linkcsv = link_csvfile
24+
self.png_xmlfile = 'str_sonic_png.xml'
25+
self.dpg_xmlfile = 'str_sonic_dpg.xml'
26+
self.one_xmlfile = 'starlab_connection_graph.xml'
27+
self.pngroot = etree.Element('PhysicalNetworkGraphDeclaration')
28+
self.dpgroot = etree.Element('DataPlaneGraph')
29+
30+
31+
def read_devices(self):
32+
csv_dev = open(self.devcsv)
33+
csv_devices = csv.DictReader(csv_dev)
34+
devices_root = etree.SubElement(self.pngroot, 'Devices')
35+
for row in csv_devices:
36+
attrs = {}
37+
self.devices.append(row)
38+
for key in row:
39+
if key.lower() != 'managementip':
40+
attrs[key]=row[key].decode('utf-8')
41+
prod = etree.SubElement(devices_root, 'Device', attrs)
42+
csv_dev.close()
43+
44+
def read_links(self):
45+
csv_file = open(self.linkcsv)
46+
csv_links = csv.DictReader(csv_file)
47+
links_root = etree.SubElement(self.pngroot, 'DeviceInterfaceLinks')
48+
for link in csv_links:
49+
attrs = {}
50+
for key in link:
51+
if key.lower() != 'vlanid' and key.lower() != 'vlanmode':
52+
attrs[key]=link[key].decode('utf-8')
53+
prod = etree.SubElement(links_root, 'DeviceInterfaceLink', attrs)
54+
self.links.append(link)
55+
csv_file.close()
56+
57+
def generate_dpg(self):
58+
for dev in self.devices:
59+
hostname = dev.get('Hostname', '')
60+
managementip = dev.get('ManagementIp', '')
61+
if hostname and 'fanout' in dev['Type'].lower():
62+
###### Build Management interface IP here, if we create each device indivial minigraph file, we may comment this out
63+
l3inforoot = etree.SubElement(self.dpgroot, 'DevicesL3Info', {'Hostname': hostname})
64+
etree.SubElement(l3inforoot, 'ManagementIPInterface', {'Name': 'ManagementIp', 'Prefix': managementip})
65+
####### Build L2 information Here
66+
l2inforoot = etree.SubElement(self.dpgroot, STARLAB_CONNECTION_GRAPH_DPGL2_NAME, {'Hostname': hostname})
67+
vlanattr = {}
68+
for link in self.links:
69+
if link['StartDevice'] == hostname:
70+
vlanattr['portname'] = link['StartPort']
71+
if link['EndDevice'] == hostname:
72+
vlanattr['portname'] = link['EndPort']
73+
if link['StartDevice'] == hostname or link['EndDevice'] == hostname:
74+
vlanattr['vlanids'] = link['VlanID']
75+
vlanattr['mode'] = link['VlanMode']
76+
etree.SubElement(l2inforoot, 'InterfaceVlan', vlanattr)
77+
78+
def create_xml(self):
79+
'''
80+
81+
if two seperate file of png and dpg needed, uncomment these part
82+
83+
pngxml = open(self.png_xmlfile, 'w')
84+
png = etree.tostring(self.pngroot, pretty_print=True)
85+
pngxml.write(png)
86+
87+
pngxml = open(self.dpg_xmlfile, 'w')
88+
dpg = etree.tostring(self.dpgroot, pretty_print=True)
89+
pngxml.write(dpg)
90+
'''
91+
92+
onexml = open(self.one_xmlfile, 'w')
93+
root=etree.Element(STARLAB_CONNECTION_GRAPH_ROOT_NAME)
94+
root.append(self.pngroot)
95+
root.append(self.dpgroot)
96+
result = etree.tostring(root, pretty_print=True)
97+
onexml.write(result)
98+
99+
def main():
100+
101+
mygraph = LabGraph(DEVICECSV, LINKCSV)
102+
103+
mygraph.read_devices()
104+
mygraph.read_links()
105+
mygraph.generate_dpg()
106+
mygraph.create_xml()
107+
108+
109+
if __name__ == '__main__':
110+
main()
111+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
str-acs-serv-01:
2+
str-msn2700-01: ptf1-m
3+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Hostname,ManagementIp,HwSku,Type
2+
str-msn2700-01,10.251.0.188/23,Mellanox-2700,DevSonic
3+
str-7260-10,10.251.0.13/23,Arista-7260QX-64,FanoutLeaf
4+
str-7260-11,10.251.0.234/23,Arista-7260QX-64,FanoutRoot
5+
str-acs-serv-01,10.251.0.245/23,TestServ,Server

ansible/files/sonic_str_links.csv

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
StartDevice,StartPort,EndDevice,EndPort,BandWidth,VlanID,VlanMode
2+
str-msn2700-01,Ethernet0,str-7260-10,Ethernet1,40000,1681,Access
3+
str-msn2700-01,Ethernet4,str-7260-10,Ethernet2,40000,1682,Access
4+
str-msn2700-01,Ethernet8,str-7260-10,Ethernet3,40000,1683,Access
5+
str-msn2700-01,Ethernet12,str-7260-10,Ethernet4,40000,1684,Access
6+
str-msn2700-01,Ethernet16,str-7260-10,Ethernet5,40000,1685,Access
7+
str-msn2700-01,Ethernet20,str-7260-10,Ethernet6,40000,1686,Access
8+
str-msn2700-01,Ethernet24,str-7260-10,Ethernet7,40000,1687,Access
9+
str-msn2700-01,Ethernet28,str-7260-10,Ethernet8,40000,1688,Access
10+
str-msn2700-01,Ethernet32,str-7260-10,Ethernet9,40000,1689,Access
11+
str-msn2700-01,Ethernet36,str-7260-10,Ethernet10,40000,1690,Access
12+
str-msn2700-01,Ethernet40,str-7260-10,Ethernet11,40000,1691,Access
13+
str-msn2700-01,Ethernet44,str-7260-10,Ethernet12,40000,1692,Access
14+
str-msn2700-01,Ethernet48,str-7260-10,Ethernet13,40000,1693,Access
15+
str-msn2700-01,Ethernet52,str-7260-10,Ethernet14,40000,1694,Access
16+
str-msn2700-01,Ethernet56,str-7260-10,Ethernet15,40000,1695,Access
17+
str-msn2700-01,Ethernet60,str-7260-10,Ethernet16,40000,1696,Access
18+
str-msn2700-01,Ethernet64,str-7260-10,Ethernet17,40000,1697,Access
19+
str-msn2700-01,Ethernet68,str-7260-10,Ethernet18,40000,1698,Access
20+
str-msn2700-01,Ethernet72,str-7260-10,Ethernet19,40000,1699,Access
21+
str-msn2700-01,Ethernet76,str-7260-10,Ethernet20,40000,1700,Access
22+
str-msn2700-01,Ethernet80,str-7260-10,Ethernet21,40000,1701,Access
23+
str-msn2700-01,Ethernet84,str-7260-10,Ethernet22,40000,1702,Access
24+
str-msn2700-01,Ethernet88,str-7260-10,Ethernet23,40000,1703,Access
25+
str-msn2700-01,Ethernet92,str-7260-10,Ethernet24,40000,1704,Access
26+
str-msn2700-01,Ethernet96,str-7260-10,Ethernet25,40000,1705,Access
27+
str-msn2700-01,Ethernet100,str-7260-10,Ethernet26,40000,1706,Access
28+
str-msn2700-01,Ethernet104,str-7260-10,Ethernet27,40000,1707,Access
29+
str-msn2700-01,Ethernet108,str-7260-10,Ethernet28,40000,1708,Access
30+
str-msn2700-01,Ethernet112,str-7260-10,Ethernet29,40000,1709,Access
31+
str-msn2700-01,Ethernet116,str-7260-10,Ethernet30,40000,1710,Access
32+
str-msn2700-01,Ethernet120,str-7260-10,Ethernet31,40000,1711,Access
33+
str-msn2700-01,Ethernet124,str-7260-10,Ethernet32,40000,1712,Access
34+
str-7260-11,Ethernet19,str-acs-serv-01,p4p1,40000,,Trunk
35+
str-7260-11,Ethernet30,str-7260-10,Ethernet64,40000,1681-1712,Trunk
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<StarlabConnectionGraph>
2+
<PhysicalNetworkGraphDeclaration>
3+
<Devices>
4+
<Device Hostname="str-msn2700-01" HwSku="Mellanox-2700" Type="DevSonic"/>
5+
<Device Hostname="str-7260-10" HwSku="Arista-7260QX-64" Type="FanoutLeaf"/>
6+
<Device Hostname="str-7260-11" HwSku="Arista-7260QX-64" Type="FanoutRoot"/>
7+
<Device Hostname="str-acs-serv-01" HwSku="TestServ" Type="Server"/>
8+
</Devices>
9+
<DeviceInterfaceLinks>
10+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet1" StartDevice="str-msn2700-01" StartPort="Ethernet0"/>
11+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet2" StartDevice="str-msn2700-01" StartPort="Ethernet4"/>
12+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet3" StartDevice="str-msn2700-01" StartPort="Ethernet8"/>
13+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet4" StartDevice="str-msn2700-01" StartPort="Ethernet12"/>
14+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet5" StartDevice="str-msn2700-01" StartPort="Ethernet16"/>
15+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet6" StartDevice="str-msn2700-01" StartPort="Ethernet20"/>
16+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet7" StartDevice="str-msn2700-01" StartPort="Ethernet24"/>
17+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet8" StartDevice="str-msn2700-01" StartPort="Ethernet28"/>
18+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet9" StartDevice="str-msn2700-01" StartPort="Ethernet32"/>
19+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet10" StartDevice="str-msn2700-01" StartPort="Ethernet36"/>
20+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet11" StartDevice="str-msn2700-01" StartPort="Ethernet40"/>
21+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet12" StartDevice="str-msn2700-01" StartPort="Ethernet44"/>
22+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet13" StartDevice="str-msn2700-01" StartPort="Ethernet48"/>
23+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet14" StartDevice="str-msn2700-01" StartPort="Ethernet52"/>
24+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet15" StartDevice="str-msn2700-01" StartPort="Ethernet56"/>
25+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet16" StartDevice="str-msn2700-01" StartPort="Ethernet60"/>
26+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet17" StartDevice="str-msn2700-01" StartPort="Ethernet64"/>
27+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet18" StartDevice="str-msn2700-01" StartPort="Ethernet68"/>
28+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet19" StartDevice="str-msn2700-01" StartPort="Ethernet72"/>
29+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet20" StartDevice="str-msn2700-01" StartPort="Ethernet76"/>
30+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet21" StartDevice="str-msn2700-01" StartPort="Ethernet80"/>
31+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet22" StartDevice="str-msn2700-01" StartPort="Ethernet84"/>
32+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet23" StartDevice="str-msn2700-01" StartPort="Ethernet88"/>
33+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet24" StartDevice="str-msn2700-01" StartPort="Ethernet92"/>
34+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet25" StartDevice="str-msn2700-01" StartPort="Ethernet96"/>
35+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet26" StartDevice="str-msn2700-01" StartPort="Ethernet100"/>
36+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet27" StartDevice="str-msn2700-01" StartPort="Ethernet104"/>
37+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet28" StartDevice="str-msn2700-01" StartPort="Ethernet108"/>
38+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet29" StartDevice="str-msn2700-01" StartPort="Ethernet112"/>
39+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet30" StartDevice="str-msn2700-01" StartPort="Ethernet116"/>
40+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet31" StartDevice="str-msn2700-01" StartPort="Ethernet120"/>
41+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet32" StartDevice="str-msn2700-01" StartPort="Ethernet124"/>
42+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-acs-serv-01" EndPort="p4p1" StartDevice="str-7260-11" StartPort="Ethernet19"/>
43+
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet64" StartDevice="str-7260-11" StartPort="Ethernet30"/>
44+
</DeviceInterfaceLinks>
45+
</PhysicalNetworkGraphDeclaration>
46+
<DataPlaneGraph>
47+
<DevicesL3Info Hostname="str-7260-10">
48+
<ManagementIPInterface Name="ManagementIp" Prefix="10.251.0.13/23"/>
49+
</DevicesL3Info>
50+
<DevicesL2Info Hostname="str-7260-10">
51+
<InterfaceVlan mode="Access" portname="Ethernet1" vlanids="1681"/>
52+
<InterfaceVlan mode="Access" portname="Ethernet2" vlanids="1682"/>
53+
<InterfaceVlan mode="Access" portname="Ethernet3" vlanids="1683"/>
54+
<InterfaceVlan mode="Access" portname="Ethernet4" vlanids="1684"/>
55+
<InterfaceVlan mode="Access" portname="Ethernet5" vlanids="1685"/>
56+
<InterfaceVlan mode="Access" portname="Ethernet6" vlanids="1686"/>
57+
<InterfaceVlan mode="Access" portname="Ethernet7" vlanids="1687"/>
58+
<InterfaceVlan mode="Access" portname="Ethernet8" vlanids="1688"/>
59+
<InterfaceVlan mode="Access" portname="Ethernet9" vlanids="1689"/>
60+
<InterfaceVlan mode="Access" portname="Ethernet10" vlanids="1690"/>
61+
<InterfaceVlan mode="Access" portname="Ethernet11" vlanids="1691"/>
62+
<InterfaceVlan mode="Access" portname="Ethernet12" vlanids="1692"/>
63+
<InterfaceVlan mode="Access" portname="Ethernet13" vlanids="1693"/>
64+
<InterfaceVlan mode="Access" portname="Ethernet14" vlanids="1694"/>
65+
<InterfaceVlan mode="Access" portname="Ethernet15" vlanids="1695"/>
66+
<InterfaceVlan mode="Access" portname="Ethernet16" vlanids="1696"/>
67+
<InterfaceVlan mode="Access" portname="Ethernet17" vlanids="1697"/>
68+
<InterfaceVlan mode="Access" portname="Ethernet18" vlanids="1698"/>
69+
<InterfaceVlan mode="Access" portname="Ethernet19" vlanids="1699"/>
70+
<InterfaceVlan mode="Access" portname="Ethernet20" vlanids="1700"/>
71+
<InterfaceVlan mode="Access" portname="Ethernet21" vlanids="1701"/>
72+
<InterfaceVlan mode="Access" portname="Ethernet22" vlanids="1702"/>
73+
<InterfaceVlan mode="Access" portname="Ethernet23" vlanids="1703"/>
74+
<InterfaceVlan mode="Access" portname="Ethernet24" vlanids="1704"/>
75+
<InterfaceVlan mode="Access" portname="Ethernet25" vlanids="1705"/>
76+
<InterfaceVlan mode="Access" portname="Ethernet26" vlanids="1706"/>
77+
<InterfaceVlan mode="Access" portname="Ethernet27" vlanids="1707"/>
78+
<InterfaceVlan mode="Access" portname="Ethernet28" vlanids="1708"/>
79+
<InterfaceVlan mode="Access" portname="Ethernet29" vlanids="1709"/>
80+
<InterfaceVlan mode="Access" portname="Ethernet30" vlanids="1710"/>
81+
<InterfaceVlan mode="Access" portname="Ethernet31" vlanids="1711"/>
82+
<InterfaceVlan mode="Access" portname="Ethernet32" vlanids="1712"/>
83+
<InterfaceVlan mode="Trunk" portname="Ethernet64" vlanids="1681-1712"/>
84+
</DevicesL2Info>
85+
<DevicesL3Info Hostname="str-7260-11">
86+
<ManagementIPInterface Name="ManagementIp" Prefix="10.251.0.234/23"/>
87+
</DevicesL3Info>
88+
<DevicesL2Info Hostname="str-7260-11">
89+
<InterfaceVlan mode="Trunk" portname="Ethernet19" vlanids=""/>
90+
<InterfaceVlan mode="Trunk" portname="Ethernet30" vlanids="1681-1712"/>
91+
</DevicesL2Info>
92+
</DataPlaneGraph>
93+
</StarlabConnectionGraph>

ansible/group_vars/eos/eos.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# snmp variables
2-
snmp_rocommunity: public
2+
snmp_rocommunity: strcommunity
3+
snmp_location: str
34

ansible/group_vars/leaf_topo_1/topo.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)