blob: 3ecefc3a737beb50d181b127c170fb21833b042a [file] [log] [blame]
Thomas Vachuskaa8e74772018-02-26 11:33:35 -08001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Creates a spine-leaf fabric with large number of hosts using null providers
4#
5# Default setup as follows:
6# 2 spines, can potentially be few more
7# 12 leaves in total
8#     2 leaf pair
9#     8 non-paired
10# Host per leaf up to 1K
11#
12# -----------------------------------------------------------------------------
13
14function usage {
15 echo "usage: $(basename $0) [options] [onos-ip]"
16 echo ""
17 echo "Options:"
18 echo " -s spines"
19 echo " -l spineLinks"
20 echo " -S serviceHosts"
21 echo " -a accessLeaves"
22 echo " -A accessHosts"
23 exit 1
24}
25
26spines=2
27spineLinks=2
28serviceLeafGroups="A B"
29serviceHosts=10
30accessLeaves=8
31accessHosts=100
32
33# Scan arguments for user/password or other options...
34while getopts s:l:a:A:S:?h o; do
35 case "$o" in
36 s) spines=$OPTARG;;
37 l) spineLinks=$OPTARG;;
38 a) accessLeaves=$OPTARG;;
39 A) accessHosts=$OPTARG;;
40 S) serviceHosts=$OPTARG;;
41 *) usage $0;;
42 esac
43done
44
45spinePorts=48
46let leafPorts=serviceHosts+8 # derive service ports from service hosts
47let accessPorts=accessHosts+8 # derive access ports from access hosts
48
49let OPC=$OPTIND-1
50shift $OPC
51
52# config
53node=${1:-$OCI}
54
55
56# Create the script of ONOS commands first and then execute it all at once.
57export CMDS="/tmp/fab-onos.cmds"
58rm $CMDS
59
60function sim {
61 echo "$@" >> $CMDS
62}
63
Thomas Vachuskac67a9912018-03-06 14:37:45 -080064function y {
65 let p="${3:-300} * ($1 - 1) - (${3:-300} * ($2 - 1)) / 2"
66 echo $p
67}
68
Thomas Vachuskaa8e74772018-02-26 11:33:35 -080069# Create spines
70for spine in $(seq 1 $spines); do
Thomas Vachuskac67a9912018-03-06 14:37:45 -080071 sim "null-create-device switch Spine-${spine} ${spinePorts} 0 $(y $spine $spines) grid"
Thomas Vachuskaa8e74772018-02-26 11:33:35 -080072done
73
74# Create 2 leaf pairs with dual links to the spines and a link between the pair
75for pair in $serviceLeafGroups; do
Thomas Vachuskac67a9912018-03-06 14:37:45 -080076 [ $pair = A ] && l1=1 || l1=3
77 [ $pair = A ] && l2=2 || l2=4
78 sim "null-create-device switch Leaf-${pair}1 ${leafPorts} -200 $(y $l1 4) grid"
79 sim "null-create-device switch Leaf-${pair}2 ${leafPorts} -200 $(y $l2 4) grid"
Thomas Vachuskaa8e74772018-02-26 11:33:35 -080080 sim "null-create-link direct Leaf-${pair}1 Leaf-${pair}2"
81
82 for spine in $(seq 1 $spines); do
83 for link in $(seq 1 $spineLinks); do
84 sim "null-create-link direct Spine-${spine} Leaf-${pair}1"
85 sim "null-create-link direct Spine-${spine} Leaf-${pair}2"
86 done
87 done
88
89 # Create hosts for each leaf group; multi-homed to each leaf in the pair
90 [ $pair = A ] && pn=1 || pn=2
91 for host in $(seq 1 $serviceHosts); do
92 sim "null-create-host Leaf-${pair}1,Leaf-${pair}2 10.${pn}.1.${host}"
93 done
94done
95
96# Create single access leafs with dual links to the spines
97for access in $(seq $accessLeaves); do
Thomas Vachuskac67a9912018-03-06 14:37:45 -080098 sim "null-create-device switch Access-${access} ${accessPorts} 200 $(y $access $accessLeaves) grid"
Thomas Vachuskaa8e74772018-02-26 11:33:35 -080099
100 for spine in $(seq 1 $spines); do
101 for link in $(seq 1 $spineLinks); do
102 sim "null-create-link direct Spine-${spine} Access-${access}"
103 done
104 done
105
106 # Create hosts for each access single leaf
107 sim "null-create-hosts Access-${access} 10.1${access}.1.*" $accessHosts
108 # sim "null-create-hosts Access-${access} 10.1${access}.2.*" $accessHosts
109done
110
111
112# make sure null providers are activated and any running simulation is stopped
113onos ${node} app activate org.onosproject.null
114sleep 2
115onos ${node} null-simulation stop
116
117# wait until the masterships clear-out across the cluster
118while onos ${node} masters | grep -qv " 0 devices"; do sleep 1; done
119
120# clean-up
121onos ${node} wipe-out please
122sleep 1
123
124# start custom simulation..
125onos ${node} null-simulation start custom
126sleep 2
127
128# Add devices, links, and hosts
129cat $CMDS | onos ${node}
130