blob: 86ac0c29be1d1e12c0d89ed4cd21a61ee38c06de [file] [log] [blame]
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +01001#! /bin/bash
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
David Garcia42375212020-04-27 19:07:49 +020015
16# set -eux
17
18K8S_CLOUD_NAME="k8s-cloud"
beierlmdfd42882020-07-02 14:21:09 -040019KUBECTL="microk8s.kubectl"
David Garcia69388c22020-05-07 12:14:19 +020020IMAGES_OVERLAY_FILE=~/.osm/images-overlay.yaml
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +010021function check_arguments(){
22 while [ $# -gt 0 ] ; do
David Garcia42375212020-04-27 19:07:49 +020023 case $1 in
24 --bundle) BUNDLE="$2" ;;
Dominik Fleischmann7a97a4c2020-06-04 10:52:05 +020025 --k8s) KUBECFG="$2" ;;
26 --vca) CONTROLLER="$2" ;;
27 --lxd) LXD_CLOUD="$2" ;;
28 --lxd-cred) LXD_CREDENTIALS="$2" ;;
David Garcia69388c22020-05-07 12:14:19 +020029 --microstack) MICROSTACK=y ;;
beierlm7e54dfc2020-09-24 15:27:53 -040030 --ha) BUNDLE="cs:osm-ha-39" ;;
David Garcia69388c22020-05-07 12:14:19 +020031 --tag) TAG="$2" ;;
David Garcia42375212020-04-27 19:07:49 +020032 esac
33 shift
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +010034 done
35
David Garcia42375212020-04-27 19:07:49 +020036 # echo $BUNDLE $KUBECONFIG $LXDENDPOINT
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +010037}
beierlm838e3fd2020-07-28 09:21:07 -040038
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +010039function install_snaps(){
beierlm838e3fd2020-07-28 09:21:07 -040040 if [ ! -v KUBECFG ]; then
41 sudo snap install microk8s --classic
42 sudo usermod -a -G microk8s `whoami`
43 mkdir -p ~/.kube
44 sudo chown -f -R `whoami` ~/.kube
45 KUBEGRP="microk8s"
46 else
47 KUBECTL="kubectl"
48 sudo snap install kubectl --classic
49 export KUBECONFIG=${KUBECFG}
50 KUBEGRP=$(id -g -n)
51 fi
beierlm7e54dfc2020-09-24 15:27:53 -040052 sleep 10
Dominik Fleischmann71997c12020-06-30 14:25:19 +020053 sudo snap install juju --classic --channel=2.8/stable
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +010054}
55
56function bootstrap_k8s_lxd(){
David Garcia42375212020-04-27 19:07:49 +020057 [ -v CONTROLLER ] && ADD_K8S_OPTS="--controller ${CONTROLLER}" && CONTROLLER_NAME=$CONTROLLER
beierlm9425dd22020-07-16 16:57:09 -040058 [ ! -v CONTROLLER ] && ADD_K8S_OPTS="--client" && BOOTSTRAP_NEEDED="yes" && CONTROLLER_NAME="osm-vca"
59
60 if [ -v BOOTSTRAP_NEEDED ]; then
61 CONTROLLER_PRESENT=$(juju controllers 2>/dev/null| grep ${CONTROLLER_NAME} | wc -l)
62 if [ $CONTROLLER_PRESENT -ge 1 ]; then
63 cat << EOF
64Threre is already a VCA present with the installer reserved name of "${CONTROLLER_NAME}".
65You may either explicitly use this VCA with the "--vca ${CONTROLLER_NAME}" option, or remove it
66using this command:
67
68 juju destroy-controller --release-storage --destroy-all-models -y ${CONTROLLER_NAME}
69
70Please retry the installation once this conflict has been resolved.
71EOF
72 exit 1
73 fi
74 fi
David Garcia42375212020-04-27 19:07:49 +020075
76 if [ -v KUBECFG ]; then
77 cat $KUBECFG | juju add-k8s $K8S_CLOUD_NAME $ADD_K8S_OPTS
beierlm62e60442020-09-15 16:00:34 -040078 [ -v BOOTSTRAP_NEEDED ] && juju bootstrap $K8S_CLOUD_NAME $CONTROLLER_NAME \
79 --config controller-service-type=loadbalancer \
beierlmc784e7c2020-09-30 06:03:45 -040080 --agent-version=2.8.1
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +010081 else
beierlm838e3fd2020-07-28 09:21:07 -040082 sg ${KUBEGRP} -c "echo ${DEFAULT_IP}-${DEFAULT_IP} | microk8s.enable metallb"
83 sg ${KUBEGRP} -c "microk8s.enable storage dns"
beierlm9425dd22020-07-16 16:57:09 -040084 TIME_TO_WAIT=30
85 start_time="$(date -u +%s)"
Dominik Fleischmannc57296f2020-06-09 11:45:08 +020086 while true
87 do
beierlm9425dd22020-07-16 16:57:09 -040088 now="$(date -u +%s)"
89 if [[ $(( now - start_time )) -gt $TIME_TO_WAIT ]];then
90 echo "Microk8s storage failed to enable"
beierlm838e3fd2020-07-28 09:21:07 -040091 sg ${KUBEGRP} -c "microk8s.status"
beierlm9425dd22020-07-16 16:57:09 -040092 exit 1
93 fi
calvinosanc1698b5b32020-08-21 12:12:52 +020094 storage_status=`sg ${KUBEGRP} -c "microk8s.status -a storage"`
95 if [[ $storage_status == "enabled" ]]; then
Dominik Fleischmannc57296f2020-06-09 11:45:08 +020096 break
97 fi
98 sleep 1
99 done
David Garcia42375212020-04-27 19:07:49 +0200100
beierlm838e3fd2020-07-28 09:21:07 -0400101 [ ! -v BOOTSTRAP_NEEDED ] && sg ${KUBEGRP} -c "microk8s.config" | juju add-k8s $K8S_CLOUD_NAME $ADD_K8S_OPTS
beierlm62e60442020-09-15 16:00:34 -0400102 [ -v BOOTSTRAP_NEEDED ] && sg ${KUBEGRP} -c \
103 "juju bootstrap microk8s $CONTROLLER_NAME --config controller-service-type=loadbalancer --agent-version=2.8.1" \
104 && K8S_CLOUD_NAME=microk8s
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100105 fi
106
David Garcia42375212020-04-27 19:07:49 +0200107 if [ -v LXD_CLOUD ]; then
108 if [ ! -v LXD_CREDENTIALS ]; then
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100109 echo "The installer needs the LXD server certificate if the LXD is external"
110 exit 1
111 fi
112 else
113 LXDENDPOINT=$DEFAULT_IP
David Garcia42375212020-04-27 19:07:49 +0200114 LXD_CLOUD=~/.osm/lxd-cloud.yaml
115 LXD_CREDENTIALS=~/.osm/lxd-credentials.yaml
116 # Apply sysctl production values for optimal performance
117 sudo cp /usr/share/osm-devops/installers/60-lxd-production.conf /etc/sysctl.d/60-lxd-production.conf
118 sudo sysctl --system
119 # Install LXD snap
120 sudo apt-get remove --purge -y liblxc1 lxc-common lxcfs lxd lxd-client
121 sudo snap install lxd
122 sudo apt-get install zfsutils-linux -y
123 # Configure LXD
124 sudo usermod -a -G lxd `whoami`
125 cat /usr/share/osm-devops/installers/lxd-preseed.conf | sed 's/^config: {}/config:\n core.https_address: '$LXDENDPOINT':8443/' | sg lxd -c "lxd init --preseed"
126 sg lxd -c "lxd waitready"
127 DEFAULT_MTU=$(ip addr show $DEFAULT_IF | perl -ne 'if (/mtu\s(\d+)/) {print $1;}')
128 sg lxd -c "lxc profile device set default eth0 mtu $DEFAULT_MTU"
David Garciad00e49c2020-06-19 10:33:37 +0200129 sg lxd -c "lxc network set lxdbr0 bridge.mtu $DEFAULT_MTU"
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100130
David Garcia42375212020-04-27 19:07:49 +0200131 cat << EOF > $LXD_CLOUD
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100132clouds:
133 lxd-cloud:
134 type: lxd
135 auth-types: [certificate]
136 endpoint: "https://$LXDENDPOINT:8443"
137 config:
138 ssl-hostname-verification: false
139EOF
David Garcia42375212020-04-27 19:07:49 +0200140 openssl req -nodes -new -x509 -keyout ~/.osm/client.key -out ~/.osm/client.crt -days 365 -subj "/C=FR/ST=Nice/L=Nice/O=ETSI/OU=OSM/CN=osm.etsi.org"
141 local server_cert=`cat /var/snap/lxd/common/lxd/server.crt | sed 's/^/ /'`
142 local client_cert=`cat ~/.osm/client.crt | sed 's/^/ /'`
143 local client_key=`cat ~/.osm/client.key | sed 's/^/ /'`
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100144
David Garcia42375212020-04-27 19:07:49 +0200145 cat << EOF > $LXD_CREDENTIALS
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100146credentials:
147 lxd-cloud:
David Garcia42375212020-04-27 19:07:49 +0200148 lxd-cloud:
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100149 auth-type: certificate
150 server-cert: |
151$server_cert
152 client-cert: |
153$client_cert
154 client-key: |
155$client_key
156EOF
David Garcia42375212020-04-27 19:07:49 +0200157 lxc config trust add local: ~/.osm/client.crt
158 fi
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100159
David Garcia42375212020-04-27 19:07:49 +0200160 juju add-cloud -c $CONTROLLER_NAME lxd-cloud $LXD_CLOUD --force
161 juju add-credential -c $CONTROLLER_NAME lxd-cloud -f $LXD_CREDENTIALS
162 sg lxd -c "lxd waitready"
beierlm9425dd22020-07-16 16:57:09 -0400163 #juju add-model test lxd-cloud || true
Dominik Fleischmann71997c12020-06-30 14:25:19 +0200164 juju controller-config features=[k8s-operators]
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100165}
166
beierlm838e3fd2020-07-28 09:21:07 -0400167function wait_for_port(){
168 SERVICE=$1
169 INDEX=$2
170 TIME_TO_WAIT=30
171 start_time="$(date -u +%s)"
172 while true
173 do
174 now="$(date -u +%s)"
175 if [[ $(( now - start_time )) -gt $TIME_TO_WAIT ]];then
176 echo "Failed to expose external ${SERVICE} interface port"
177 exit 1
178 fi
179
180 if [ $(sg ${KUBEGRP} -c "${KUBECTL} get ingress -n osm -o json | jq -r '.items[$INDEX].metadata.name'") == ${SERVICE} ] ; then
181 break
182 fi
183 sleep 1
184 done
185}
186
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100187function deploy_charmed_osm(){
188 create_overlay
189 echo "Creating OSM model"
David Garcia42375212020-04-27 19:07:49 +0200190 if [ -v KUBECFG ]; then
191 juju add-model osm $K8S_CLOUD_NAME
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100192 else
beierlm838e3fd2020-07-28 09:21:07 -0400193 sg ${KUBEGRP} -c "juju add-model osm $K8S_CLOUD_NAME"
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100194 fi
195 echo "Deploying OSM with charms"
beierlmb5332cf2020-07-08 11:43:59 -0400196 images_overlay=""
197 [ -v TAG ] && generate_images_overlay && images_overlay="--overlay $IMAGES_OVERLAY_FILE"
David Garcia42375212020-04-27 19:07:49 +0200198 if [ -v BUNDLE ]; then
beierlmb5332cf2020-07-08 11:43:59 -0400199 juju deploy $BUNDLE --overlay ~/.osm/vca-overlay.yaml $images_overlay
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100200 else
beierlm7e54dfc2020-09-24 15:27:53 -0400201 juju deploy cs:osm-49 --overlay ~/.osm/vca-overlay.yaml $images_overlay
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100202 fi
beierlm51b71282020-08-14 09:26:27 -0400203
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100204 echo "Waiting for deployment to finish..."
beierlm51b71282020-08-14 09:26:27 -0400205 check_osm_deployed
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100206 echo "OSM with charms deployed"
beierlm838e3fd2020-07-28 09:21:07 -0400207 if [ ! -v KUBECFG ]; then
208 sg ${KUBEGRP} -c "microk8s.enable ingress"
209 API_SERVER=${DEFAULT_IP}
210 else
211 API_SERVER=$(kubectl config view --minify | grep server | cut -f 2- -d ":" | tr -d " ")
212 proto="$(echo $API_SERVER | grep :// | sed -e's,^\(.*://\).*,\1,g')"
213 url="$(echo ${API_SERVER/$proto/})"
214 user="$(echo $url | grep @ | cut -d@ -f1)"
215 hostport="$(echo ${url/$user@/} | cut -d/ -f1)"
216 API_SERVER="$(echo $hostport | sed -e 's,:.*,,g')"
217 fi
218
219 juju config nbi-k8s juju-external-hostname=nbi.${API_SERVER}.xip.io
220 juju expose nbi-k8s
221
222 wait_for_port nbi-k8s 0
223 sg ${KUBEGRP} -c "${KUBECTL} get ingress -n osm -o json | jq '.items[0].metadata.annotations += {\"nginx.ingress.kubernetes.io/backend-protocol\": \"HTTPS\"}' | ${KUBECTL} --validate=false replace -f -"
224 sg ${KUBEGRP} -c "${KUBECTL} get ingress -n osm -o json | jq '.items[0].metadata.annotations += {\"nginx.ingress.kubernetes.io/proxy-body-size\": \"0\"}' | ${KUBECTL} replace -f -"
225
beierlm51b71282020-08-14 09:26:27 -0400226 juju config ng-ui juju-external-hostname=ui.${API_SERVER}.xip.io
beierlm838e3fd2020-07-28 09:21:07 -0400227 juju expose ng-ui
228
229 wait_for_port ng-ui 1
beierlm51b71282020-08-14 09:26:27 -0400230 sg ${KUBEGRP} -c "${KUBECTL} get ingress -n osm -o json | jq '.items[2].metadata.annotations += {\"nginx.ingress.kubernetes.io/proxy-body-size\": \"0\"}' | ${KUBECTL} --validate=false replace -f -"
beierlm838e3fd2020-07-28 09:21:07 -0400231
232 juju config ui-k8s juju-external-hostname=osm.${API_SERVER}.xip.io
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100233 juju expose ui-k8s
beierlm838e3fd2020-07-28 09:21:07 -0400234
235 wait_for_port ui-k8s 2
beierlm51b71282020-08-14 09:26:27 -0400236 sg ${KUBEGRP} -c "${KUBECTL} get ingress -n osm -o json | jq '.items[1].metadata.annotations += {\"nginx.ingress.kubernetes.io/proxy-body-size\": \"0\"}' | ${KUBECTL} --validate=false replace -f -"
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100237}
238
239function check_osm_deployed() {
beierlm51b71282020-08-14 09:26:27 -0400240 TIME_TO_WAIT=600
beierlm838e3fd2020-07-28 09:21:07 -0400241 start_time="$(date -u +%s)"
beierlm7e54dfc2020-09-24 15:27:53 -0400242 total_service_count=15
243 previous_count=0
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100244 while true
245 do
beierlm51b71282020-08-14 09:26:27 -0400246 service_count=$(juju status | grep kubernetes | grep active | wc -l)
247 echo "$service_count / $total_service_count services active"
248 if [ $service_count -eq $total_service_count ]; then
249 break
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100250 fi
beierlm7e54dfc2020-09-24 15:27:53 -0400251 if [ $service_count -ne $previous_count ]; then
252 previous_count=$service_count
253 start_time="$(date -u +%s)"
254 fi
beierlm838e3fd2020-07-28 09:21:07 -0400255 now="$(date -u +%s)"
256 if [[ $(( now - start_time )) -gt $TIME_TO_WAIT ]];then
beierlm51b71282020-08-14 09:26:27 -0400257 echo "Timed out waiting for OSM services to become ready"
beierlm838e3fd2020-07-28 09:21:07 -0400258 exit 1
259 fi
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100260 sleep 10
261 done
262}
263
264function create_overlay() {
David Garcia42375212020-04-27 19:07:49 +0200265 sudo snap install jq
266 sudo apt install python3-pip -y
267 python3 -m pip install yq
268 PATH=$PATH:$HOME/.local/bin # make yq command available
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100269 local HOME=/home/$USER
David Garcia42375212020-04-27 19:07:49 +0200270 local vca_user=$(cat $HOME/.local/share/juju/accounts.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME].user')
271 local vca_password=$(cat $HOME/.local/share/juju/accounts.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME].password')
beierlmdfd42882020-07-02 14:21:09 -0400272 local vca_host=$(cat $HOME/.local/share/juju/controllers.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME]["api-endpoints"][0]' --raw-output | cut -d ":" -f 1)
273 local vca_port=$(cat $HOME/.local/share/juju/controllers.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME]["api-endpoints"][0]' --raw-output | cut -d ":" -f 2)
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100274 local vca_pubkey=\"$(cat $HOME/.local/share/juju/ssh/juju_id_rsa.pub)\"
275 local vca_cloud="lxd-cloud"
276 # Get the VCA Certificate
beierlmdfd42882020-07-02 14:21:09 -0400277 local vca_cacert=$(cat $HOME/.local/share/juju/controllers.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME]["ca-cert"]' --raw-output | base64 | tr -d \\n)
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100278
279 # Calculate the default route of this machine
Dominik Fleischmannc57296f2020-06-09 11:45:08 +0200280 local DEFAULT_IF=`ip route list match 0.0.0.0 | awk '{print $5}'`
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100281
282 # Generate a new overlay.yaml, overriding any existing one
David Garcia42375212020-04-27 19:07:49 +0200283 cat << EOF > /tmp/vca-overlay.yaml
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100284applications:
285 lcm-k8s:
286 options:
287 vca_user: $vca_user
288 vca_password: $vca_password
289 vca_host: $vca_host
290 vca_port: $vca_port
291 vca_pubkey: $vca_pubkey
292 vca_cacert: $vca_cacert
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100293 vca_cloud: $vca_cloud
Dominik Fleischmann71997c12020-06-30 14:25:19 +0200294 vca_k8s_cloud: $K8S_CLOUD_NAME
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100295 mon-k8s:
296 options:
297 vca_user: $vca_user
298 vca_password: $vca_password
299 vca_host: $vca_host
300 vca_cacert: $vca_cacert
301EOF
David Garcia42375212020-04-27 19:07:49 +0200302 mv /tmp/vca-overlay.yaml ~/.osm/
303 OSM_VCA_HOST=$vca_host
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100304}
305
David Garcia69388c22020-05-07 12:14:19 +0200306function generate_images_overlay(){
307 cat << EOF > /tmp/images-overlay.yaml
308applications:
309 lcm-k8s:
310 options:
311 image: opensourcemano/lcm:$TAG
312 mon-k8s:
313 options:
314 image: opensourcemano/mon:$TAG
315 ro-k8s:
316 options:
317 image: opensourcemano/ro:$TAG
318 nbi-k8s:
319 options:
320 image: opensourcemano/nbi:$TAG
321 pol-k8s:
322 options:
323 image: opensourcemano/pol:$TAG
324 ui-k8s:
325 options:
326 image: opensourcemano/light-ui:$TAG
David Garcia5863d3e2020-07-09 13:14:13 +0200327 pla:
328 options:
329 image: opensourcemano/pla:$TAG
David Garciafa55bd72020-07-07 11:14:19 +0200330 ng-ui:
331 options:
332 image: opensourcemano/ng-ui:$TAG
David Garcia69388c22020-05-07 12:14:19 +0200333
334EOF
335 mv /tmp/images-overlay.yaml $IMAGES_OVERLAY_FILE
336}
337
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100338function install_osmclient() {
339 sudo snap install osmclient
340 sudo snap alias osmclient.osm osm
341}
342
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100343
344function install_microstack() {
345 sudo snap install microstack --classic --beta
346 sudo microstack.init --auto
347 wget https://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img -P ~/.osm/
348 microstack.openstack image create \
David Garcia42375212020-04-27 19:07:49 +0200349 --public \
350 --disk-format qcow2 \
351 --container-format bare \
352 --file ~/.osm/ubuntu-16.04-server-cloudimg-amd64-disk1.img \
353 ubuntu1604
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100354 ssh-keygen -t rsa -N "" -f ~/.ssh/microstack
355 microstack.openstack keypair create --public-key ~/.ssh/microstack.pub microstack
Dominik Fleischmannc57296f2020-06-09 11:45:08 +0200356 export OSM_HOSTNAME=`juju status --format json | jq -rc '.applications."nbi-k8s".address'`
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100357 osm vim-create --name microstack-site \
David Garcia42375212020-04-27 19:07:49 +0200358 --user admin \
359 --password keystone \
360 --auth_url http://10.20.20.1:5000/v3 \
361 --tenant admin \
362 --account_type openstack \
363 --config='{security_groups: default,
364 keypair: microstack,
365 project_name: admin,
366 user_domain_name: default,
367 region_name: microstack,
368 insecure: True,
369 availability_zone: nova,
370 version: 3}'
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100371}
372
Dominik Fleischmannc57296f2020-06-09 11:45:08 +0200373DEFAULT_IF=`ip route list match 0.0.0.0 | awk '{print $5}'`
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100374DEFAULT_IP=`ip -o -4 a |grep ${DEFAULT_IF}|awk '{split($4,a,"/"); print a[1]}'`
375
376check_arguments $@
David Garcia42375212020-04-27 19:07:49 +0200377mkdir -p ~/.osm
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100378install_snaps
379bootstrap_k8s_lxd
380deploy_charmed_osm
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100381install_osmclient
David Garcia42375212020-04-27 19:07:49 +0200382if [ -v MICROSTACK ]; then
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100383 install_microstack
384fi
beierlm9425dd22020-07-16 16:57:09 -0400385
beierlm7e54dfc2020-09-24 15:27:53 -0400386OSM_HOSTNAME=$(juju config nbi-k8s juju-external-hostname):443
387
beierlm9425dd22020-07-16 16:57:09 -0400388echo "Your installation is now complete, follow these steps for configuring the osmclient:"
389echo
beierlm838e3fd2020-07-28 09:21:07 -0400390echo "1. Create the OSM_HOSTNAME environment variable with the NBI IP"
beierlm9425dd22020-07-16 16:57:09 -0400391echo
beierlm7e54dfc2020-09-24 15:27:53 -0400392echo "export OSM_HOSTNAME=$OSM_HOSTNAME"
beierlm9425dd22020-07-16 16:57:09 -0400393echo
beierlm838e3fd2020-07-28 09:21:07 -0400394echo "2. Add the previous command to your .bashrc for other Shell sessions"
beierlm9425dd22020-07-16 16:57:09 -0400395echo
beierlm7e54dfc2020-09-24 15:27:53 -0400396echo "echo \"export OSM_HOSTNAME=$OSM_HOSTNAME\" >> ~/.bashrc"
beierlm9425dd22020-07-16 16:57:09 -0400397echo
398echo "DONE"