Thomas Vachuska | a8e7477 | 2018-02-26 11:33:35 -0800 | [diff] [blame] | 1 | #!/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 | |
| 14 | function 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 | |
| 26 | spines=2 |
| 27 | spineLinks=2 |
| 28 | serviceLeafGroups="A B" |
| 29 | serviceHosts=10 |
| 30 | accessLeaves=8 |
| 31 | accessHosts=100 |
| 32 | |
| 33 | # Scan arguments for user/password or other options... |
| 34 | while 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 |
| 43 | done |
| 44 | |
| 45 | spinePorts=48 |
| 46 | let leafPorts=serviceHosts+8 # derive service ports from service hosts |
| 47 | let accessPorts=accessHosts+8 # derive access ports from access hosts |
| 48 | |
| 49 | let OPC=$OPTIND-1 |
| 50 | shift $OPC |
| 51 | |
| 52 | # config |
| 53 | node=${1:-$OCI} |
| 54 | |
| 55 | |
| 56 | # Create the script of ONOS commands first and then execute it all at once. |
| 57 | export CMDS="/tmp/fab-onos.cmds" |
| 58 | rm $CMDS |
| 59 | |
| 60 | function sim { |
| 61 | echo "$@" >> $CMDS |
| 62 | } |
| 63 | |
Thomas Vachuska | c67a991 | 2018-03-06 14:37:45 -0800 | [diff] [blame] | 64 | function y { |
Thomas Vachuska | fa61549 | 2018-03-19 09:11:51 -0700 | [diff] [blame] | 65 | let p="${3:-400} * ($1 - 1) - (${3:-400} * ($2 - 1)) / 2 + ${4:-0}" |
Thomas Vachuska | c67a991 | 2018-03-06 14:37:45 -0800 | [diff] [blame] | 66 | echo $p |
| 67 | } |
| 68 | |
Thomas Vachuska | a8e7477 | 2018-02-26 11:33:35 -0800 | [diff] [blame] | 69 | # Create spines |
| 70 | for spine in $(seq 1 $spines); do |
Thomas Vachuska | c67a991 | 2018-03-06 14:37:45 -0800 | [diff] [blame] | 71 | sim "null-create-device switch Spine-${spine} ${spinePorts} 0 $(y $spine $spines) grid" |
Thomas Vachuska | a8e7477 | 2018-02-26 11:33:35 -0800 | [diff] [blame] | 72 | done |
| 73 | |
| 74 | # Create 2 leaf pairs with dual links to the spines and a link between the pair |
| 75 | for pair in $serviceLeafGroups; do |
Thomas Vachuska | c67a991 | 2018-03-06 14:37:45 -0800 | [diff] [blame] | 76 | [ $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 Vachuska | a8e7477 | 2018-02-26 11:33:35 -0800 | [diff] [blame] | 80 | 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 |
Thomas Vachuska | fa61549 | 2018-03-19 09:11:51 -0700 | [diff] [blame] | 91 | [ $pair = A ] && offset=-400 || offset=400 |
Thomas Vachuska | a8e7477 | 2018-02-26 11:33:35 -0800 | [diff] [blame] | 92 | for host in $(seq 1 $serviceHosts); do |
Thomas Vachuska | fa61549 | 2018-03-19 09:11:51 -0700 | [diff] [blame] | 93 | sim "null-create-host Leaf-${pair}1,Leaf-${pair}2 10.${pn}.1.${host} -400 $(y $host $serviceHosts 60 $offset) grid" |
Thomas Vachuska | a8e7477 | 2018-02-26 11:33:35 -0800 | [diff] [blame] | 94 | done |
| 95 | done |
| 96 | |
| 97 | # Create single access leafs with dual links to the spines |
| 98 | for access in $(seq $accessLeaves); do |
Thomas Vachuska | c67a991 | 2018-03-06 14:37:45 -0800 | [diff] [blame] | 99 | sim "null-create-device switch Access-${access} ${accessPorts} 200 $(y $access $accessLeaves) grid" |
Thomas Vachuska | a8e7477 | 2018-02-26 11:33:35 -0800 | [diff] [blame] | 100 | |
| 101 | for spine in $(seq 1 $spines); do |
| 102 | for link in $(seq 1 $spineLinks); do |
| 103 | sim "null-create-link direct Spine-${spine} Access-${access}" |
| 104 | done |
| 105 | done |
| 106 | |
| 107 | # Create hosts for each access single leaf |
Thomas Vachuska | fa61549 | 2018-03-19 09:11:51 -0700 | [diff] [blame] | 108 | sim "null-create-hosts Access-${access} 10.1${access}.1.*" $accessHosts 500 $(y $access $accessLeaves) 6 |
Thomas Vachuska | a8e7477 | 2018-02-26 11:33:35 -0800 | [diff] [blame] | 109 | # sim "null-create-hosts Access-${access} 10.1${access}.2.*" $accessHosts |
| 110 | done |
| 111 | |
| 112 | |
| 113 | # make sure null providers are activated and any running simulation is stopped |
| 114 | onos ${node} app activate org.onosproject.null |
| 115 | sleep 2 |
| 116 | onos ${node} null-simulation stop |
| 117 | |
| 118 | # wait until the masterships clear-out across the cluster |
| 119 | while onos ${node} masters | grep -qv " 0 devices"; do sleep 1; done |
| 120 | |
| 121 | # clean-up |
| 122 | onos ${node} wipe-out please |
| 123 | sleep 1 |
| 124 | |
| 125 | # start custom simulation.. |
| 126 | onos ${node} null-simulation start custom |
| 127 | sleep 2 |
| 128 | |
| 129 | # Add devices, links, and hosts |
| 130 | cat $CMDS | onos ${node} |
| 131 | |