Simon Pasquier | d3a0b91 | 2017-05-02 15:32:20 +0200 | [diff] [blame] | 1 | #!/bin/bash -x |
| 2 | exec > >(tee -i /tmp/"$(basename "$0" .sh)"_"$(date '+%Y-%m-%d_%H-%M-%S')".log) 2>&1 |
| 3 | |
| 4 | CWD="$(dirname "$(readlink -f "$0")")" |
| 5 | |
| 6 | # Import common functions |
| 7 | COMMONS="$CWD"/common_functions.sh |
| 8 | if [ ! -f "$COMMONS" ]; then |
| 9 | echo "File $COMMONS does not exist" |
| 10 | exit 1 |
| 11 | fi |
| 12 | . "$COMMONS" |
| 13 | |
| 14 | # Configure compute nodes |
| 15 | salt "cmp*" state.apply |
| 16 | salt "cmp*" state.apply |
| 17 | |
| 18 | # Provision opencontrail virtual routers |
| 19 | hosts=($(salt-call pillar.get linux:network:host | egrep 'cmp0.*:' | sed -e 's/ *//' -e 's/://')) |
Olivier Bourdon | 53f5891 | 2017-06-20 12:53:34 +0200 | [diff] [blame] | 20 | vip=$(salt-call pillar.get _param:opencontrail_control_address | grep '^ ' | sed -e 's/ *//') |
Simon Pasquier | d3a0b91 | 2017-05-02 15:32:20 +0200 | [diff] [blame] | 21 | nb=$(( ${#hosts[@]} - 1 )) |
| 22 | for i in $(seq 0 $nb); do |
| 23 | h=${hosts[$i]} |
| 24 | ip=$(salt-call pillar.get linux:network:host:"${h}":address | grep '^ ' | sed -e 's/ *//') |
| 25 | salt -C 'I@opencontrail:control:id:1' cmd.run "/usr/share/contrail-utils/provision_vrouter.py --host_name $h --host_ip $ip --api_server_ip $vip --oper add --admin_user admin --admin_password workshop --admin_tenant_name admin" |
| 26 | done |
| 27 | |
| 28 | # Reboot compute nodes |
| 29 | salt "cmp*" system.reboot |
| 30 | |
| 31 | # Wait for all compute nodes in current deployment to be available |
| 32 | wait_for "$(get_nodes_names "cmp[0-9]" | wc -l)" "cmp*" |