blob: a65b342254a1ef44fad3e949904c730e03ef942b [file] [log] [blame]
Andy Bavierfacd0be2018-05-24 15:56:31 -07001#!/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
17set -xe
18
Andy Bavier49ec1a02018-06-18 14:03:29 -070019# This script assumes the following repos exist and will create them if not
Andy Bavierfacd0be2018-05-24 15:56:31 -070020# ~/cord/automation-tools
Andy Bavier49ec1a02018-06-18 14:03:29 -070021# ~/cord/helm-charts
22
23# Sanity tests
24if [[ $UID == 0 ]]; then
25 echo "Please run this script as non-root user"
26 exit 1
27fi
28
29if ! sudo -n true; then
30 echo "Please configure passwordless sudo on this account"
31 exit 1
32fi
33
34
Andy Bavierfacd0be2018-05-24 15:56:31 -070035
36# Location of 'cord' directory for checkouts on the local system
37CORDDIR="${CORDDIR:-${HOME}/cord}"
Andy Baviercedcb5b2018-08-15 14:37:20 -070038XOSDBDIR="/var/local/vol1"
Andy Bavierfacd0be2018-05-24 15:56:31 -070039
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 Bavierfacd0be2018-05-24 15:56:31 -070049# Add keys for VTN
50[ ! -e ~/.ssh/id_rsa ] && ssh-keygen -f ~/.ssh/id_rsa -t rsa -N ""
51cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
52cp ~/.ssh/id_rsa "$CORDDIR"/helm-charts/xos-profiles/base-openstack/files/node_key
53
54# Add dummy fabric interface
Andy Bavier99588852018-06-05 12:59:51 -070055if ! ifconfig fabric &>> /dev/null
56then
57 sudo modprobe dummy
58 sudo ip link set name fabric dev dummy0
59 sudo ifconfig fabric up
60fi
Andy Bavierfacd0be2018-05-24 15:56:31 -070061
62# Install charts for M-CORD
63cd "$CORDDIR"/helm-charts
Andy Baviercedcb5b2018-08-15 14:37:20 -070064
65cat <<EOF > /tmp/xos-values.yaml
66---
67xos-db:
68 needDBPersistence: true
69 storageClassName: local-directory
70
71xos-gui:
72 xos_projectName: "M-CORD"
73
74volumes:
75 - name: "db-pv"
76 size: "2Gi"
77 host: "$( hostname -f )"
78 directory: "${XOSDBDIR}"
79
80computeNodes:
81 master:
82 name: "$( hostname )"
83
84vtn-service:
85 sshUser: "$( whoami )"
86
87global:
88 proxySshUser: "$( whoami )"
89EOF
90sudo mkdir -p "${XOSDBDIR}"
91helm upgrade --install local-directory ./storage/local-directory \
92 -f /tmp/xos-values.yaml
Andy Bavier306279b2018-06-26 10:09:31 -070093
Andy Bavierfacd0be2018-05-24 15:56:31 -070094helm dep update ./xos-core
Andy Bavier49ec1a02018-06-18 14:03:29 -070095helm upgrade --install xos-core ./xos-core \
Andy Baviercedcb5b2018-08-15 14:37:20 -070096 -f /tmp/xos-values.yaml
Andy Bavierfacd0be2018-05-24 15:56:31 -070097~/openstack-helm/tools/deployment/common/wait-for-pods.sh default
98
99helm dep update ./xos-profiles/base-openstack
100helm upgrade --install base-openstack ./xos-profiles/base-openstack \
Andy Baviercedcb5b2018-08-15 14:37:20 -0700101 -f /tmp/xos-values.yaml
Andy Bavierfacd0be2018-05-24 15:56:31 -0700102~/openstack-helm/tools/deployment/common/wait-for-pods.sh default
103
104helm upgrade --install onos-cord ./onos
105~/openstack-helm/tools/deployment/common/wait-for-pods.sh default
106
107helm dep update ./xos-profiles/mcord
108helm upgrade --install mcord ./xos-profiles/mcord \
Andy Baviercedcb5b2018-08-15 14:37:20 -0700109 -f /tmp/xos-values.yaml
Andy Bavierfacd0be2018-05-24 15:56:31 -0700110~/openstack-helm/tools/deployment/common/wait-for-pods.sh default
111
112
Andy Bavier99588852018-06-05 12:59:51 -0700113# Firewall VNC ports for security (CloudLab)
114if [ -d /mnt/extra ]
115then
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
121fi
Andy Bavierfacd0be2018-05-24 15:56:31 -0700122
123echo "M-CORD has been successfully installed"