Andy Bavier | facd0be | 2018-05-24 15:56:31 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright 2017-present Open Networking Foundation |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | set -xe |
| 18 | |
Andy Bavier | 49ec1a0 | 2018-06-18 14:03:29 -0700 | [diff] [blame] | 19 | # This script assumes the following repos exist and will create them if not |
Andy Bavier | facd0be | 2018-05-24 15:56:31 -0700 | [diff] [blame] | 20 | # ~/cord/automation-tools |
Andy Bavier | 49ec1a0 | 2018-06-18 14:03:29 -0700 | [diff] [blame] | 21 | # ~/cord/helm-charts |
| 22 | |
| 23 | # Sanity tests |
| 24 | if [[ $UID == 0 ]]; then |
| 25 | echo "Please run this script as non-root user" |
| 26 | exit 1 |
| 27 | fi |
| 28 | |
| 29 | if ! sudo -n true; then |
| 30 | echo "Please configure passwordless sudo on this account" |
| 31 | exit 1 |
| 32 | fi |
| 33 | |
| 34 | |
Andy Bavier | facd0be | 2018-05-24 15:56:31 -0700 | [diff] [blame] | 35 | |
| 36 | # Location of 'cord' directory for checkouts on the local system |
| 37 | CORDDIR="${CORDDIR:-${HOME}/cord}" |
Andy Bavier | cedcb5b | 2018-08-15 14:37:20 -0700 | [diff] [blame] | 38 | XOSDBDIR="/var/local/vol1" |
Andy Bavier | facd0be | 2018-05-24 15:56:31 -0700 | [diff] [blame] | 39 | |
| 40 | [ ! -d "$CORDDIR" ] && mkdir -p "$CORDDIR" |
| 41 | [ ! -d "$CORDDIR"/automation-tools ] && cd "$CORDDIR" && git clone https://gerrit.opencord.org/automation-tools |
| 42 | [ ! -d "$CORDDIR"/helm-charts ] && cd "$CORDDIR" && git clone https://gerrit.opencord.org/helm-charts |
| 43 | |
| 44 | |
| 45 | # Install K8S, Helm, Openstack |
| 46 | "$CORDDIR"/automation-tools/openstack-helm/openstack-helm-dev-setup.sh |
| 47 | |
| 48 | |
Andy Bavier | facd0be | 2018-05-24 15:56:31 -0700 | [diff] [blame] | 49 | # Add keys for VTN |
| 50 | [ ! -e ~/.ssh/id_rsa ] && ssh-keygen -f ~/.ssh/id_rsa -t rsa -N "" |
| 51 | cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys |
| 52 | cp ~/.ssh/id_rsa "$CORDDIR"/helm-charts/xos-profiles/base-openstack/files/node_key |
| 53 | |
| 54 | # Add dummy fabric interface |
Andy Bavier | 9958885 | 2018-06-05 12:59:51 -0700 | [diff] [blame] | 55 | if ! ifconfig fabric &>> /dev/null |
| 56 | then |
| 57 | sudo modprobe dummy |
| 58 | sudo ip link set name fabric dev dummy0 |
| 59 | sudo ifconfig fabric up |
| 60 | fi |
Andy Bavier | facd0be | 2018-05-24 15:56:31 -0700 | [diff] [blame] | 61 | |
| 62 | # Install charts for M-CORD |
| 63 | cd "$CORDDIR"/helm-charts |
Andy Bavier | cedcb5b | 2018-08-15 14:37:20 -0700 | [diff] [blame] | 64 | |
| 65 | cat <<EOF > /tmp/xos-values.yaml |
| 66 | --- |
| 67 | xos-db: |
| 68 | needDBPersistence: true |
| 69 | storageClassName: local-directory |
| 70 | |
| 71 | xos-gui: |
| 72 | xos_projectName: "M-CORD" |
| 73 | |
| 74 | volumes: |
| 75 | - name: "db-pv" |
| 76 | size: "2Gi" |
| 77 | host: "$( hostname -f )" |
| 78 | directory: "${XOSDBDIR}" |
| 79 | |
| 80 | computeNodes: |
| 81 | master: |
| 82 | name: "$( hostname )" |
| 83 | |
| 84 | vtn-service: |
| 85 | sshUser: "$( whoami )" |
| 86 | |
| 87 | global: |
| 88 | proxySshUser: "$( whoami )" |
| 89 | EOF |
| 90 | sudo mkdir -p "${XOSDBDIR}" |
| 91 | helm upgrade --install local-directory ./storage/local-directory \ |
| 92 | -f /tmp/xos-values.yaml |
Andy Bavier | 306279b | 2018-06-26 10:09:31 -0700 | [diff] [blame] | 93 | |
Andy Bavier | facd0be | 2018-05-24 15:56:31 -0700 | [diff] [blame] | 94 | helm dep update ./xos-core |
Andy Bavier | 49ec1a0 | 2018-06-18 14:03:29 -0700 | [diff] [blame] | 95 | helm upgrade --install xos-core ./xos-core \ |
Andy Bavier | cedcb5b | 2018-08-15 14:37:20 -0700 | [diff] [blame] | 96 | -f /tmp/xos-values.yaml |
Andy Bavier | facd0be | 2018-05-24 15:56:31 -0700 | [diff] [blame] | 97 | ~/openstack-helm/tools/deployment/common/wait-for-pods.sh default |
| 98 | |
| 99 | helm dep update ./xos-profiles/base-openstack |
| 100 | helm upgrade --install base-openstack ./xos-profiles/base-openstack \ |
Andy Bavier | cedcb5b | 2018-08-15 14:37:20 -0700 | [diff] [blame] | 101 | -f /tmp/xos-values.yaml |
Andy Bavier | facd0be | 2018-05-24 15:56:31 -0700 | [diff] [blame] | 102 | ~/openstack-helm/tools/deployment/common/wait-for-pods.sh default |
| 103 | |
| 104 | helm upgrade --install onos-cord ./onos |
| 105 | ~/openstack-helm/tools/deployment/common/wait-for-pods.sh default |
| 106 | |
| 107 | helm dep update ./xos-profiles/mcord |
| 108 | helm upgrade --install mcord ./xos-profiles/mcord \ |
Andy Bavier | cedcb5b | 2018-08-15 14:37:20 -0700 | [diff] [blame] | 109 | -f /tmp/xos-values.yaml |
Andy Bavier | facd0be | 2018-05-24 15:56:31 -0700 | [diff] [blame] | 110 | ~/openstack-helm/tools/deployment/common/wait-for-pods.sh default |
| 111 | |
| 112 | |
Andy Bavier | 9958885 | 2018-06-05 12:59:51 -0700 | [diff] [blame] | 113 | # Firewall VNC ports for security (CloudLab) |
| 114 | if [ -d /mnt/extra ] |
| 115 | then |
| 116 | sudo ufw default allow incoming |
| 117 | sudo ufw default allow outgoing |
| 118 | sudo ufw default allow routed |
| 119 | sudo ufw deny proto tcp from any to any port 5900:5950 comment 'vnc' |
| 120 | sudo ufw --force enable |
| 121 | fi |
Andy Bavier | facd0be | 2018-05-24 15:56:31 -0700 | [diff] [blame] | 122 | |
| 123 | echo "M-CORD has been successfully installed" |