Thomas Vachuska | 722224e | 2018-03-26 10:56:18 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
Thomas Vachuska | 0d93386 | 2018-04-06 00:29:30 -0700 | [diff] [blame] | 3 | # Creates a hierarchical access spine-leaf fabric with large number of hosts |
| 4 | # using null providers. |
Thomas Vachuska | 722224e | 2018-03-26 10:56:18 -0700 | [diff] [blame] | 5 | # |
| 6 | # Default setup as follows: |
Thomas Vachuska | 0d93386 | 2018-04-06 00:29:30 -0700 | [diff] [blame] | 7 | # 2 primary spines (or more if needed, but this is typically not the case) |
| 8 | # 2 aggregating spines per access headend |
| 9 | # ~3 access leaves per headend |
| 10 | # 2 leaf pairs for connecting gateways and compute (services/caching/etc.) |
Thomas Vachuska | 722224e | 2018-03-26 10:56:18 -0700 | [diff] [blame] | 11 | # ----------------------------------------------------------------------------- |
| 12 | |
| 13 | function usage { |
| 14 | echo "usage: $(basename $0) [options] [onos-ip]" |
| 15 | echo "" |
| 16 | echo "Options:" |
| 17 | echo " -s spines" |
| 18 | echo " -l spineLinks" |
| 19 | echo " -S serviceHosts" |
Thomas Vachuska | 0d93386 | 2018-04-06 00:29:30 -0700 | [diff] [blame] | 20 | echo " -G gateways" |
Thomas Vachuska | 722224e | 2018-03-26 10:56:18 -0700 | [diff] [blame] | 21 | echo " -f fieldOffices" |
| 22 | echo " -a accessLeaves" |
| 23 | echo " -A accessHosts" |
| 24 | exit 1 |
| 25 | } |
| 26 | |
| 27 | spines=2 |
| 28 | spineLinks=2 |
| 29 | serviceLeafGroups="A B" |
| 30 | serviceHosts=10 |
| 31 | fieldOffices=3 |
| 32 | accessLeaves=3 |
| 33 | accessHosts=60 |
Thomas Vachuska | 0d93386 | 2018-04-06 00:29:30 -0700 | [diff] [blame] | 34 | gateways=2 |
Thomas Vachuska | 722224e | 2018-03-26 10:56:18 -0700 | [diff] [blame] | 35 | |
| 36 | # Scan arguments for user/password or other options... |
Thomas Vachuska | 0d93386 | 2018-04-06 00:29:30 -0700 | [diff] [blame] | 37 | while getopts s:l:a:f:A:S:G:?h o; do |
Thomas Vachuska | 722224e | 2018-03-26 10:56:18 -0700 | [diff] [blame] | 38 | case "$o" in |
| 39 | s) spines=$OPTARG;; |
| 40 | l) spineLinks=$OPTARG;; |
| 41 | a) accessLeaves=$OPTARG;; |
| 42 | f) fieldOffices=$OPTARG;; |
| 43 | A) accessHosts=$OPTARG;; |
| 44 | S) serviceHosts=$OPTARG;; |
Thomas Vachuska | 0d93386 | 2018-04-06 00:29:30 -0700 | [diff] [blame] | 45 | G) gateways=$OPTARG;; |
Thomas Vachuska | 722224e | 2018-03-26 10:56:18 -0700 | [diff] [blame] | 46 | *) usage $0;; |
| 47 | esac |
| 48 | done |
| 49 | |
| 50 | spinePorts=48 |
| 51 | let leafPorts=serviceHosts+8 # derive service ports from service hosts |
| 52 | let accessPorts=accessHosts+8 # derive access ports from access hosts |
| 53 | let hagPorts=accessLeaves+8 # derive hag ports from access leaves |
| 54 | |
| 55 | let totalHags=fieldOffices*spines |
| 56 | let totalAccess=fieldOffices*accessLeaves |
| 57 | |
| 58 | let OPC=$OPTIND-1 |
| 59 | shift $OPC |
| 60 | |
| 61 | # Optional ONOS node IP |
| 62 | node=${1:-$OCI} |
| 63 | |
| 64 | # Create the script of ONOS commands first and then execute it all at once. |
Thomas Vachuska | 0d93386 | 2018-04-06 00:29:30 -0700 | [diff] [blame] | 65 | export CMDS="/tmp/access-onos.cmds" |
| 66 | rm -f $CMDS 2>/dev/null |
Thomas Vachuska | 722224e | 2018-03-26 10:56:18 -0700 | [diff] [blame] | 67 | |
| 68 | function sim { |
| 69 | echo "$@" >> $CMDS |
| 70 | } |
| 71 | |
Thomas Vachuska | 722224e | 2018-03-26 10:56:18 -0700 | [diff] [blame] | 72 | # Create central office spines |
| 73 | for spine in $(seq 1 $spines); do |
Thomas Vachuska | 1351e7e | 2018-04-19 16:24:22 -0700 | [diff] [blame] | 74 | sim "null-create-device switch Spine-${spine} ${spinePorts}" |
Thomas Vachuska | 722224e | 2018-03-26 10:56:18 -0700 | [diff] [blame] | 75 | done |
| 76 | |
| 77 | # Create 2 leaf pairs with dual links to the spines and a link between the pair |
| 78 | for pair in $serviceLeafGroups; do |
| 79 | [ $pair = A ] && l1=1 || l1=3 |
| 80 | [ $pair = A ] && l2=2 || l2=4 |
Thomas Vachuska | 1351e7e | 2018-04-19 16:24:22 -0700 | [diff] [blame] | 81 | sim "null-create-device switch Leaf-${pair}1 ${leafPorts}" |
| 82 | sim "null-create-device switch Leaf-${pair}2 ${leafPorts}" |
Thomas Vachuska | 722224e | 2018-03-26 10:56:18 -0700 | [diff] [blame] | 83 | sim "null-create-link direct Leaf-${pair}1 Leaf-${pair}2" |
| 84 | |
| 85 | for spine in $(seq 1 $spines); do |
| 86 | for link in $(seq 1 $spineLinks); do |
| 87 | sim "null-create-link direct Spine-${spine} Leaf-${pair}1" |
| 88 | sim "null-create-link direct Spine-${spine} Leaf-${pair}2" |
| 89 | done |
| 90 | done |
| 91 | |
Thomas Vachuska | 0d93386 | 2018-04-06 00:29:30 -0700 | [diff] [blame] | 92 | # Create gateways attached to each leaf group; multi-homed to each leaf in the pair |
Thomas Vachuska | 722224e | 2018-03-26 10:56:18 -0700 | [diff] [blame] | 93 | [ $pair = A ] && pn=1 || pn=2 |
Thomas Vachuska | 0d93386 | 2018-04-06 00:29:30 -0700 | [diff] [blame] | 94 | for gw in $(seq 1 $gateways); do |
Thomas Vachuska | 1351e7e | 2018-04-19 16:24:22 -0700 | [diff] [blame] | 95 | sim "null-create-host Leaf-${pair}1,Leaf-${pair}2 10.${pn}.0.${gw}" |
Thomas Vachuska | 0d93386 | 2018-04-06 00:29:30 -0700 | [diff] [blame] | 96 | done |
| 97 | |
| 98 | # Create hosts for each leaf group; multi-homed to each leaf in the pair |
Thomas Vachuska | 722224e | 2018-03-26 10:56:18 -0700 | [diff] [blame] | 99 | for host in $(seq 1 $serviceHosts); do |
Thomas Vachuska | 1351e7e | 2018-04-19 16:24:22 -0700 | [diff] [blame] | 100 | sim "null-create-host Leaf-${pair}1,Leaf-${pair}2 10.${pn}.1.${host}" |
Thomas Vachuska | 722224e | 2018-03-26 10:56:18 -0700 | [diff] [blame] | 101 | done |
| 102 | done |
| 103 | |
Thomas Vachuska | 722224e | 2018-03-26 10:56:18 -0700 | [diff] [blame] | 104 | # Create field offices |
| 105 | for field in $(seq $fieldOffices); do |
| 106 | # Create HAG spines for each office and connect it to central office spines |
| 107 | for spine in $(seq $spines); do |
Thomas Vachuska | 1351e7e | 2018-04-19 16:24:22 -0700 | [diff] [blame] | 108 | sim "null-create-device switch Spine-${field}-${spine} ${hagPorts}" |
Thomas Vachuska | 722224e | 2018-03-26 10:56:18 -0700 | [diff] [blame] | 109 | sim "null-create-link direct Spine-${spine} Spine-${field}-${spine}" |
Thomas Vachuska | 722224e | 2018-03-26 10:56:18 -0700 | [diff] [blame] | 110 | done |
| 111 | |
| 112 | # Create single access leafs with links to the spines |
| 113 | for access in $(seq $accessLeaves); do |
Thomas Vachuska | 1351e7e | 2018-04-19 16:24:22 -0700 | [diff] [blame] | 114 | sim "null-create-device switch Access-${field}-${access} ${accessPorts}" |
Thomas Vachuska | 722224e | 2018-03-26 10:56:18 -0700 | [diff] [blame] | 115 | for spine in $(seq 1 $spines); do |
| 116 | sim "null-create-link direct Spine-${field}-${spine} Access-${field}-${access}" |
| 117 | done |
| 118 | |
| 119 | # Create hosts for each access single leaf |
Thomas Vachuska | 1351e7e | 2018-04-19 16:24:22 -0700 | [diff] [blame] | 120 | sim "null-create-hosts Access-${field}-${access} 10.${field}${access}.1.* $accessHosts" |
Thomas Vachuska | 722224e | 2018-03-26 10:56:18 -0700 | [diff] [blame] | 121 | done |
| 122 | done |
| 123 | |
| 124 | # make sure null providers are activated and any running simulation is stopped |
| 125 | onos ${node} app activate org.onosproject.null |
| 126 | sleep 2 |
| 127 | onos ${node} null-simulation stop |
| 128 | |
| 129 | # wait until the masterships clear-out across the cluster |
| 130 | while onos ${node} masters | grep -qv " 0 devices"; do sleep 1; done |
| 131 | |
| 132 | # clean-up |
| 133 | onos ${node} wipe-out please |
| 134 | sleep 1 |
| 135 | |
| 136 | # start custom simulation.. |
| 137 | onos ${node} null-simulation start custom |
| 138 | sleep 2 |
| 139 | |
| 140 | # Add devices, links, and hosts |
| 141 | cat $CMDS | onos ${node} |
| 142 | |