Skip to content

Commit

Permalink
Testbed v2 (#104)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
pavel-shirshov authored and lguohan committed Feb 6, 2017
1 parent a2ab261 commit 6f6d757
Show file tree
Hide file tree
Showing 204 changed files with 5,210 additions and 17,390 deletions.
5 changes: 3 additions & 2 deletions ansible/ansible.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid}
# by default (as of 1.4), Ansible may display deprecation warnings for language
# features that should no longer be used and will be removed in future versions.
# to disable these warnings, set the following value to False:
#deprecation_warnings = True
deprecation_warnings = False

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

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

9 changes: 9 additions & 0 deletions ansible/fanout.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#Example:
# ansible-playbook fanout.yml -i str --limit str-7260-01 -b --vault-password-file ~/password.txt
- hosts: [fanout]
gather_facts: no
roles:
- fanout



21 changes: 21 additions & 0 deletions ansible/fanout_connect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#Example:
# 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"
- hosts: all
gather_facts: no
tasks:
- fail: msg="Please provide VM server name and server port name, see comment line in playbook"
when:
- server is not defined
- server_port is not defined

- name: get the username running the deploy
command: whoami
connection: local
become: no
register: calling_username

- set_fact: userid={{ calling_username.stdout }}

- include: roles/fanout/tasks/rootfanout_connect.yml


111 changes: 111 additions & 0 deletions ansible/files/creategraph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/usr/bin/env python
import csv, sys, os
from lxml import etree

DEVICECSV = 'sonic_str_devices.csv'
LINKCSV = 'sonic_str_links.csv'
STARLAB_CONNECTION_GRAPH_ROOT_NAME = 'StarlabConnectionGraph'
STARLAB_CONNECTION_GRAPH_DPGL2_NAME = 'DevicesL2Info'

class LabGraph(object):

"""
This is used to create "graph" file of starlab for all connections and vlan info from csv file
We(both engineer and lab technician) maintian and modify the csv file to keep track of the lab
infrastucture for Sonic development and testing environment.
"""

def __init__(self, dev_csvfile='', link_csvfile=''):
#TODO:make generated xml file name as parameters in the future to make it more flexible
self.devices = []
self.links = []
self.devcsv = dev_csvfile
self.linkcsv = link_csvfile
self.png_xmlfile = 'str_sonic_png.xml'
self.dpg_xmlfile = 'str_sonic_dpg.xml'
self.one_xmlfile = 'starlab_connection_graph.xml'
self.pngroot = etree.Element('PhysicalNetworkGraphDeclaration')
self.dpgroot = etree.Element('DataPlaneGraph')


def read_devices(self):
csv_dev = open(self.devcsv)
csv_devices = csv.DictReader(csv_dev)
devices_root = etree.SubElement(self.pngroot, 'Devices')
for row in csv_devices:
attrs = {}
self.devices.append(row)
for key in row:
if key.lower() != 'managementip':
attrs[key]=row[key].decode('utf-8')
prod = etree.SubElement(devices_root, 'Device', attrs)
csv_dev.close()

def read_links(self):
csv_file = open(self.linkcsv)
csv_links = csv.DictReader(csv_file)
links_root = etree.SubElement(self.pngroot, 'DeviceInterfaceLinks')
for link in csv_links:
attrs = {}
for key in link:
if key.lower() != 'vlanid' and key.lower() != 'vlanmode':
attrs[key]=link[key].decode('utf-8')
prod = etree.SubElement(links_root, 'DeviceInterfaceLink', attrs)
self.links.append(link)
csv_file.close()

def generate_dpg(self):
for dev in self.devices:
hostname = dev.get('Hostname', '')
managementip = dev.get('ManagementIp', '')
if hostname and 'fanout' in dev['Type'].lower():
###### Build Management interface IP here, if we create each device indivial minigraph file, we may comment this out
l3inforoot = etree.SubElement(self.dpgroot, 'DevicesL3Info', {'Hostname': hostname})
etree.SubElement(l3inforoot, 'ManagementIPInterface', {'Name': 'ManagementIp', 'Prefix': managementip})
####### Build L2 information Here
l2inforoot = etree.SubElement(self.dpgroot, STARLAB_CONNECTION_GRAPH_DPGL2_NAME, {'Hostname': hostname})
vlanattr = {}
for link in self.links:
if link['StartDevice'] == hostname:
vlanattr['portname'] = link['StartPort']
if link['EndDevice'] == hostname:
vlanattr['portname'] = link['EndPort']
if link['StartDevice'] == hostname or link['EndDevice'] == hostname:
vlanattr['vlanids'] = link['VlanID']
vlanattr['mode'] = link['VlanMode']
etree.SubElement(l2inforoot, 'InterfaceVlan', vlanattr)

def create_xml(self):
'''
if two seperate file of png and dpg needed, uncomment these part
pngxml = open(self.png_xmlfile, 'w')
png = etree.tostring(self.pngroot, pretty_print=True)
pngxml.write(png)
pngxml = open(self.dpg_xmlfile, 'w')
dpg = etree.tostring(self.dpgroot, pretty_print=True)
pngxml.write(dpg)
'''

onexml = open(self.one_xmlfile, 'w')
root=etree.Element(STARLAB_CONNECTION_GRAPH_ROOT_NAME)
root.append(self.pngroot)
root.append(self.dpgroot)
result = etree.tostring(root, pretty_print=True)
onexml.write(result)

def main():

mygraph = LabGraph(DEVICECSV, LINKCSV)

mygraph.read_devices()
mygraph.read_links()
mygraph.generate_dpg()
mygraph.create_xml()


if __name__ == '__main__':
main()

3 changes: 3 additions & 0 deletions ansible/files/sonic_server_links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
str-acs-serv-01:
str-msn2700-01: ptf1-m

5 changes: 5 additions & 0 deletions ansible/files/sonic_str_devices.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Hostname,ManagementIp,HwSku,Type
str-msn2700-01,10.251.0.188/23,Mellanox-2700,DevSonic
str-7260-10,10.251.0.13/23,Arista-7260QX-64,FanoutLeaf
str-7260-11,10.251.0.234/23,Arista-7260QX-64,FanoutRoot
str-acs-serv-01,10.251.0.245/23,TestServ,Server
35 changes: 35 additions & 0 deletions ansible/files/sonic_str_links.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
StartDevice,StartPort,EndDevice,EndPort,BandWidth,VlanID,VlanMode
str-msn2700-01,Ethernet0,str-7260-10,Ethernet1,40000,1681,Access
str-msn2700-01,Ethernet4,str-7260-10,Ethernet2,40000,1682,Access
str-msn2700-01,Ethernet8,str-7260-10,Ethernet3,40000,1683,Access
str-msn2700-01,Ethernet12,str-7260-10,Ethernet4,40000,1684,Access
str-msn2700-01,Ethernet16,str-7260-10,Ethernet5,40000,1685,Access
str-msn2700-01,Ethernet20,str-7260-10,Ethernet6,40000,1686,Access
str-msn2700-01,Ethernet24,str-7260-10,Ethernet7,40000,1687,Access
str-msn2700-01,Ethernet28,str-7260-10,Ethernet8,40000,1688,Access
str-msn2700-01,Ethernet32,str-7260-10,Ethernet9,40000,1689,Access
str-msn2700-01,Ethernet36,str-7260-10,Ethernet10,40000,1690,Access
str-msn2700-01,Ethernet40,str-7260-10,Ethernet11,40000,1691,Access
str-msn2700-01,Ethernet44,str-7260-10,Ethernet12,40000,1692,Access
str-msn2700-01,Ethernet48,str-7260-10,Ethernet13,40000,1693,Access
str-msn2700-01,Ethernet52,str-7260-10,Ethernet14,40000,1694,Access
str-msn2700-01,Ethernet56,str-7260-10,Ethernet15,40000,1695,Access
str-msn2700-01,Ethernet60,str-7260-10,Ethernet16,40000,1696,Access
str-msn2700-01,Ethernet64,str-7260-10,Ethernet17,40000,1697,Access
str-msn2700-01,Ethernet68,str-7260-10,Ethernet18,40000,1698,Access
str-msn2700-01,Ethernet72,str-7260-10,Ethernet19,40000,1699,Access
str-msn2700-01,Ethernet76,str-7260-10,Ethernet20,40000,1700,Access
str-msn2700-01,Ethernet80,str-7260-10,Ethernet21,40000,1701,Access
str-msn2700-01,Ethernet84,str-7260-10,Ethernet22,40000,1702,Access
str-msn2700-01,Ethernet88,str-7260-10,Ethernet23,40000,1703,Access
str-msn2700-01,Ethernet92,str-7260-10,Ethernet24,40000,1704,Access
str-msn2700-01,Ethernet96,str-7260-10,Ethernet25,40000,1705,Access
str-msn2700-01,Ethernet100,str-7260-10,Ethernet26,40000,1706,Access
str-msn2700-01,Ethernet104,str-7260-10,Ethernet27,40000,1707,Access
str-msn2700-01,Ethernet108,str-7260-10,Ethernet28,40000,1708,Access
str-msn2700-01,Ethernet112,str-7260-10,Ethernet29,40000,1709,Access
str-msn2700-01,Ethernet116,str-7260-10,Ethernet30,40000,1710,Access
str-msn2700-01,Ethernet120,str-7260-10,Ethernet31,40000,1711,Access
str-msn2700-01,Ethernet124,str-7260-10,Ethernet32,40000,1712,Access
str-7260-11,Ethernet19,str-acs-serv-01,p4p1,40000,,Trunk
str-7260-11,Ethernet30,str-7260-10,Ethernet64,40000,1681-1712,Trunk
93 changes: 93 additions & 0 deletions ansible/files/starlab_connection_graph.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<StarlabConnectionGraph>
<PhysicalNetworkGraphDeclaration>
<Devices>
<Device Hostname="str-msn2700-01" HwSku="Mellanox-2700" Type="DevSonic"/>
<Device Hostname="str-7260-10" HwSku="Arista-7260QX-64" Type="FanoutLeaf"/>
<Device Hostname="str-7260-11" HwSku="Arista-7260QX-64" Type="FanoutRoot"/>
<Device Hostname="str-acs-serv-01" HwSku="TestServ" Type="Server"/>
</Devices>
<DeviceInterfaceLinks>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet1" StartDevice="str-msn2700-01" StartPort="Ethernet0"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet2" StartDevice="str-msn2700-01" StartPort="Ethernet4"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet3" StartDevice="str-msn2700-01" StartPort="Ethernet8"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet4" StartDevice="str-msn2700-01" StartPort="Ethernet12"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet5" StartDevice="str-msn2700-01" StartPort="Ethernet16"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet6" StartDevice="str-msn2700-01" StartPort="Ethernet20"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet7" StartDevice="str-msn2700-01" StartPort="Ethernet24"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet8" StartDevice="str-msn2700-01" StartPort="Ethernet28"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet9" StartDevice="str-msn2700-01" StartPort="Ethernet32"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet10" StartDevice="str-msn2700-01" StartPort="Ethernet36"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet11" StartDevice="str-msn2700-01" StartPort="Ethernet40"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet12" StartDevice="str-msn2700-01" StartPort="Ethernet44"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet13" StartDevice="str-msn2700-01" StartPort="Ethernet48"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet14" StartDevice="str-msn2700-01" StartPort="Ethernet52"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet15" StartDevice="str-msn2700-01" StartPort="Ethernet56"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet16" StartDevice="str-msn2700-01" StartPort="Ethernet60"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet17" StartDevice="str-msn2700-01" StartPort="Ethernet64"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet18" StartDevice="str-msn2700-01" StartPort="Ethernet68"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet19" StartDevice="str-msn2700-01" StartPort="Ethernet72"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet20" StartDevice="str-msn2700-01" StartPort="Ethernet76"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet21" StartDevice="str-msn2700-01" StartPort="Ethernet80"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet22" StartDevice="str-msn2700-01" StartPort="Ethernet84"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet23" StartDevice="str-msn2700-01" StartPort="Ethernet88"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet24" StartDevice="str-msn2700-01" StartPort="Ethernet92"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet25" StartDevice="str-msn2700-01" StartPort="Ethernet96"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet26" StartDevice="str-msn2700-01" StartPort="Ethernet100"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet27" StartDevice="str-msn2700-01" StartPort="Ethernet104"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet28" StartDevice="str-msn2700-01" StartPort="Ethernet108"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet29" StartDevice="str-msn2700-01" StartPort="Ethernet112"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet30" StartDevice="str-msn2700-01" StartPort="Ethernet116"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet31" StartDevice="str-msn2700-01" StartPort="Ethernet120"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet32" StartDevice="str-msn2700-01" StartPort="Ethernet124"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-acs-serv-01" EndPort="p4p1" StartDevice="str-7260-11" StartPort="Ethernet19"/>
<DeviceInterfaceLink BandWidth="40000" EndDevice="str-7260-10" EndPort="Ethernet64" StartDevice="str-7260-11" StartPort="Ethernet30"/>
</DeviceInterfaceLinks>
</PhysicalNetworkGraphDeclaration>
<DataPlaneGraph>
<DevicesL3Info Hostname="str-7260-10">
<ManagementIPInterface Name="ManagementIp" Prefix="10.251.0.13/23"/>
</DevicesL3Info>
<DevicesL2Info Hostname="str-7260-10">
<InterfaceVlan mode="Access" portname="Ethernet1" vlanids="1681"/>
<InterfaceVlan mode="Access" portname="Ethernet2" vlanids="1682"/>
<InterfaceVlan mode="Access" portname="Ethernet3" vlanids="1683"/>
<InterfaceVlan mode="Access" portname="Ethernet4" vlanids="1684"/>
<InterfaceVlan mode="Access" portname="Ethernet5" vlanids="1685"/>
<InterfaceVlan mode="Access" portname="Ethernet6" vlanids="1686"/>
<InterfaceVlan mode="Access" portname="Ethernet7" vlanids="1687"/>
<InterfaceVlan mode="Access" portname="Ethernet8" vlanids="1688"/>
<InterfaceVlan mode="Access" portname="Ethernet9" vlanids="1689"/>
<InterfaceVlan mode="Access" portname="Ethernet10" vlanids="1690"/>
<InterfaceVlan mode="Access" portname="Ethernet11" vlanids="1691"/>
<InterfaceVlan mode="Access" portname="Ethernet12" vlanids="1692"/>
<InterfaceVlan mode="Access" portname="Ethernet13" vlanids="1693"/>
<InterfaceVlan mode="Access" portname="Ethernet14" vlanids="1694"/>
<InterfaceVlan mode="Access" portname="Ethernet15" vlanids="1695"/>
<InterfaceVlan mode="Access" portname="Ethernet16" vlanids="1696"/>
<InterfaceVlan mode="Access" portname="Ethernet17" vlanids="1697"/>
<InterfaceVlan mode="Access" portname="Ethernet18" vlanids="1698"/>
<InterfaceVlan mode="Access" portname="Ethernet19" vlanids="1699"/>
<InterfaceVlan mode="Access" portname="Ethernet20" vlanids="1700"/>
<InterfaceVlan mode="Access" portname="Ethernet21" vlanids="1701"/>
<InterfaceVlan mode="Access" portname="Ethernet22" vlanids="1702"/>
<InterfaceVlan mode="Access" portname="Ethernet23" vlanids="1703"/>
<InterfaceVlan mode="Access" portname="Ethernet24" vlanids="1704"/>
<InterfaceVlan mode="Access" portname="Ethernet25" vlanids="1705"/>
<InterfaceVlan mode="Access" portname="Ethernet26" vlanids="1706"/>
<InterfaceVlan mode="Access" portname="Ethernet27" vlanids="1707"/>
<InterfaceVlan mode="Access" portname="Ethernet28" vlanids="1708"/>
<InterfaceVlan mode="Access" portname="Ethernet29" vlanids="1709"/>
<InterfaceVlan mode="Access" portname="Ethernet30" vlanids="1710"/>
<InterfaceVlan mode="Access" portname="Ethernet31" vlanids="1711"/>
<InterfaceVlan mode="Access" portname="Ethernet32" vlanids="1712"/>
<InterfaceVlan mode="Trunk" portname="Ethernet64" vlanids="1681-1712"/>
</DevicesL2Info>
<DevicesL3Info Hostname="str-7260-11">
<ManagementIPInterface Name="ManagementIp" Prefix="10.251.0.234/23"/>
</DevicesL3Info>
<DevicesL2Info Hostname="str-7260-11">
<InterfaceVlan mode="Trunk" portname="Ethernet19" vlanids=""/>
<InterfaceVlan mode="Trunk" portname="Ethernet30" vlanids="1681-1712"/>
</DevicesL2Info>
</DataPlaneGraph>
</StarlabConnectionGraph>
3 changes: 2 additions & 1 deletion ansible/group_vars/eos/eos.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# snmp variables
snmp_rocommunity: public
snmp_rocommunity: strcommunity
snmp_location: str

7 changes: 0 additions & 7 deletions ansible/group_vars/leaf_topo_1/topo.yml

This file was deleted.

27 changes: 27 additions & 0 deletions ansible/group_vars/str/strinfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"hwsku_map": {
"Arista-7050-Q4S48": "Arista",
"Arista-7508-Q288": "Arista",
"Arista-7260QX-64": "Arista",
"Nexus-3064-NX": "Nexus",
"Force10-S6100": "Force10",
"Force10-S6000": "Force10"
},
"switch_login": {
"Nexus": {
"user": "admin",
"passwd": ["password"],
"enable": null
},
"Arista": {
"user": "admin",
"passwd": ["password", "123456"],
"enable": null
},
"Force10": {
"user": "admin",
"passwd": ["password"],
"enable": ["password"]
}
}
}
8 changes: 6 additions & 2 deletions ansible/group_vars/vm_host/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
root_path: /home/azure/veos-vm
vm_images_url: https://acsbe.blob.core.windows.net/vmimages
cd_image_filename: Aboot-veos-serial-2.1.0.iso
hdd_image_filename: vEOS-lab-4.15.2.1F.vmdk
cd_image_filename: Aboot-veos-serial-8.0.0.iso
hdd_image_filename: vEOS-lab-4.15.9M.vmdk
skip_image_downloading: false

vm_console_base: 7000
memory: 2097152

# proxy
proxy_env:
Expand Down
Loading

0 comments on commit 6f6d757

Please sign in to comment.