59c4397720c66362e2c0079694899668025ecc34
[osm/devops.git] / installers / charmed_install.sh
1 #! /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 #
15
16 # set -eux
17
18 LXD_VERSION=5.0
19 JUJU_VERSION=2.9
20 JUJU_AGENT_VERSION=2.9.34
21 K8S_CLOUD_NAME="k8s-cloud"
22 KUBECTL="microk8s.kubectl"
23 MICROK8S_VERSION=1.23
24 OSMCLIENT_VERSION=latest
25 IMAGES_OVERLAY_FILE=~/.osm/images-overlay.yaml
26 PASSWORD_OVERLAY_FILE=~/.osm/password-overlay.yaml
27 PATH=/snap/bin:${PATH}
28 OSM_DEVOPS="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. &> /dev/null && pwd )"
29 INSTALL_PLA=""
30 PLA_OVERLAY_FILE=~/.osm/pla-overlay.yaml
31
32 if [ -f ${OSM_DEVOPS}/common/all_funcs ] ; then
33 source ${OSM_DEVOPS}/common/all_funcs
34 else
35 function track(){
36 true
37 }
38 function FATAL_TRACK(){
39 exit 1
40 }
41 fi
42
43 MODEL_NAME=osm
44
45 OSM_BUNDLE=ch:osm
46 OSM_HA_BUNDLE=ch:osm-ha
47 CHARMHUB_CHANNEL=latest/beta
48 unset TAG
49
50 function check_arguments(){
51 while [ $# -gt 0 ] ; do
52 case $1 in
53 --bundle) BUNDLE="$2" ;;
54 --overlay) OVERLAY="$2" ;;
55 --k8s) KUBECFG="$2" ;;
56 --vca) CONTROLLER="$2" ;;
57 --small-profile) INSTALL_NOLXD=y;;
58 --lxd) LXD_CLOUD="$2" ;;
59 --lxd-cred) LXD_CREDENTIALS="$2" ;;
60 --microstack) MICROSTACK=y ;;
61 --ha) BUNDLE=$OSM_HA_BUNDLE ;;
62 --tag) TAG="$2" ;;
63 --registry) REGISTRY_INFO="$2" ;;
64 --only-vca) ONLY_VCA=y ;;
65 --pla) INSTALL_PLA=y ;;
66 esac
67 shift
68 done
69
70 # echo $BUNDLE $KUBECONFIG $LXDENDPOINT
71 }
72
73 function install_snaps(){
74 if [ ! -v KUBECFG ]; then
75 KUBEGRP="microk8s"
76 sudo snap install microk8s --classic --channel=${MICROK8S_VERSION}/stable ||
77 FATAL_TRACK k8scluster "snap install microk8s ${MICROK8S_VERSION}/stable failed"
78 sudo usermod -a -G microk8s `whoami`
79 sudo cat /var/snap/microk8s/current/args/kube-apiserver | grep advertise-address || (
80 echo "--advertise-address $DEFAULT_IP" | sudo tee -a /var/snap/microk8s/current/args/kube-apiserver
81 sg ${KUBEGRP} -c microk8s.stop
82 sg ${KUBEGRP} -c microk8s.start
83 )
84 mkdir -p ~/.kube
85 sudo chown -f -R `whoami` ~/.kube
86 sg ${KUBEGRP} -c "microk8s status --wait-ready"
87 KUBECONFIG=~/.osm/microk8s-config.yaml
88 sg ${KUBEGRP} -c "microk8s config" | tee ${KUBECONFIG}
89 track k8scluster k8scluster_ok
90 else
91 KUBECTL="kubectl"
92 sudo snap install kubectl --classic
93 export KUBECONFIG=${KUBECFG}
94 KUBEGRP=$(id -g -n)
95 fi
96 sudo snap install juju --classic --channel=$JUJU_VERSION/stable ||
97 FATAL_TRACK juju "snap install juju ${JUJU_VERSION}/stable failed"
98 track juju juju_ok
99 }
100
101 function bootstrap_k8s_lxd(){
102 [ -v CONTROLLER ] && ADD_K8S_OPTS="--controller ${CONTROLLER}" && CONTROLLER_NAME=$CONTROLLER
103 [ ! -v CONTROLLER ] && ADD_K8S_OPTS="--client" && BOOTSTRAP_NEEDED="yes" && CONTROLLER_NAME="osm-vca"
104
105 if [ -v BOOTSTRAP_NEEDED ]; then
106 CONTROLLER_PRESENT=$(juju controllers 2>/dev/null| grep ${CONTROLLER_NAME} | wc -l)
107 if [ $CONTROLLER_PRESENT -ge 1 ]; then
108 cat << EOF
109 Threre is already a VCA present with the installer reserved name of "${CONTROLLER_NAME}".
110 You may either explicitly use this VCA with the "--vca ${CONTROLLER_NAME}" option, or remove it
111 using this command:
112
113 juju destroy-controller --release-storage --destroy-all-models -y ${CONTROLLER_NAME}
114
115 Please retry the installation once this conflict has been resolved.
116 EOF
117 FATAL_TRACK bootstrap_k8s "VCA already present"
118 fi
119 else
120 CONTROLLER_PRESENT=$(juju controllers 2>/dev/null| grep ${CONTROLLER_NAME} | wc -l)
121 if [ $CONTROLLER_PRESENT -le 0 ]; then
122 cat << EOF
123 Threre is no VCA present with the name "${CONTROLLER_NAME}". Please specify a VCA
124 that exists, or remove the --vca ${CONTROLLER_NAME} option.
125
126 Please retry the installation with one of the solutions applied.
127 EOF
128 FATAL_TRACK bootstrap_k8s "Requested VCA not present"
129 fi
130 fi
131
132 if [ -v KUBECFG ]; then
133 cat $KUBECFG | juju add-k8s $K8S_CLOUD_NAME $ADD_K8S_OPTS
134 [ -v BOOTSTRAP_NEEDED ] && juju bootstrap $K8S_CLOUD_NAME $CONTROLLER_NAME \
135 --config controller-service-type=loadbalancer \
136 --agent-version=$JUJU_AGENT_VERSION
137 else
138 sg ${KUBEGRP} -c "echo ${DEFAULT_IP}-${DEFAULT_IP} | microk8s.enable metallb"
139 sg ${KUBEGRP} -c "microk8s.enable ingress"
140 sg ${KUBEGRP} -c "microk8s.enable storage dns"
141 TIME_TO_WAIT=30
142 start_time="$(date -u +%s)"
143 while true
144 do
145 now="$(date -u +%s)"
146 if [[ $(( now - start_time )) -gt $TIME_TO_WAIT ]];then
147 echo "Microk8s storage failed to enable"
148 sg ${KUBEGRP} -c "microk8s.status"
149 FATAL_TRACK bootstrap_k8s "Microk8s storage failed to enable"
150 fi
151 storage_status=`sg ${KUBEGRP} -c "microk8s.status -a storage"`
152 if [[ $storage_status == "enabled" ]]; then
153 break
154 fi
155 sleep 1
156 done
157
158 [ ! -v BOOTSTRAP_NEEDED ] && sg ${KUBEGRP} -c "microk8s.config" | juju add-k8s $K8S_CLOUD_NAME $ADD_K8S_OPTS
159 [ -v BOOTSTRAP_NEEDED ] && sg ${KUBEGRP} -c \
160 "juju bootstrap microk8s $CONTROLLER_NAME --config controller-service-type=loadbalancer --agent-version=$JUJU_AGENT_VERSION" \
161 && K8S_CLOUD_NAME=microk8s
162 fi
163 track bootstrap_k8s bootstrap_k8s_ok
164
165 if [ ! -v INSTALL_NOLXD ]; then
166 if [ -v LXD_CLOUD ]; then
167 if [ ! -v LXD_CREDENTIALS ]; then
168 echo "The installer needs the LXD server certificate if the LXD is external"
169 FATAL_TRACK bootstrap_lxd "No LXD certificate supplied"
170 fi
171 else
172 LXDENDPOINT=$DEFAULT_IP
173 LXD_CLOUD=~/.osm/lxd-cloud.yaml
174 LXD_CREDENTIALS=~/.osm/lxd-credentials.yaml
175 # Apply sysctl production values for optimal performance
176 sudo cp /usr/share/osm-devops/installers/60-lxd-production.conf /etc/sysctl.d/60-lxd-production.conf
177 sudo sysctl --system
178 # Install LXD snap
179 sudo apt-get remove --purge -y liblxc1 lxc-common lxcfs lxd lxd-client
180 snap info lxd | grep installed > /dev/null
181 if [ $? -eq 0 ]; then
182 sudo snap refresh lxd --channel $LXD_VERSION/stable
183 else
184 sudo snap install lxd --channel $LXD_VERSION/stable
185 fi
186 # Configure LXD
187 sudo usermod -a -G lxd `whoami`
188 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"
189 sg lxd -c "lxd waitready"
190 DEFAULT_MTU=$(ip addr show $DEFAULT_IF | perl -ne 'if (/mtu\s(\d+)/) {print $1;}')
191 sg lxd -c "lxc profile device set default eth0 mtu $DEFAULT_MTU"
192 sg lxd -c "lxc network set lxdbr0 bridge.mtu $DEFAULT_MTU"
193
194 cat << EOF > $LXD_CLOUD
195 clouds:
196 lxd-cloud:
197 type: lxd
198 auth-types: [certificate]
199 endpoint: "https://$LXDENDPOINT:8443"
200 config:
201 ssl-hostname-verification: false
202 EOF
203 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"
204 cat << EOF > $LXD_CREDENTIALS
205 credentials:
206 lxd-cloud:
207 lxd-cloud:
208 auth-type: certificate
209 server-cert: /var/snap/lxd/common/lxd/server.crt
210 client-cert: ~/.osm/client.crt
211 client-key: ~/.osm/client.key
212 EOF
213 lxc config trust add local: ~/.osm/client.crt
214 fi
215
216 juju add-cloud -c $CONTROLLER_NAME lxd-cloud $LXD_CLOUD --force
217 juju add-credential -c $CONTROLLER_NAME lxd-cloud -f $LXD_CREDENTIALS
218 sg lxd -c "lxd waitready"
219 juju controller-config features=[k8s-operators]
220 track bootstrap_lxd bootstrap_lxd_ok
221 fi
222 }
223
224 function deploy_charmed_osm(){
225 if [ -v REGISTRY_INFO ] ; then
226 registry_parts=(${REGISTRY_INFO//@/ })
227 if [ ${#registry_parts[@]} -eq 1 ] ; then
228 # No credentials supplied
229 REGISTRY_USERNAME=""
230 REGISTRY_PASSWORD=""
231 REGISTRY_URL=${registry_parts[0]}
232 else
233 credentials=${registry_parts[0]}
234 credential_parts=(${credentials//:/ })
235 REGISTRY_USERNAME=${credential_parts[0]}
236 REGISTRY_PASSWORD=${credential_parts[1]}
237 REGISTRY_URL=${registry_parts[1]}
238 fi
239 # Ensure the URL ends with a /
240 case $REGISTRY_URL in
241 */) ;;
242 *) REGISTRY_URL=${REGISTRY_URL}/
243 esac
244 fi
245
246 echo "Creating OSM model"
247 if [ -v KUBECFG ]; then
248 juju add-model $MODEL_NAME $K8S_CLOUD_NAME
249 else
250 sg ${KUBEGRP} -c "juju add-model $MODEL_NAME $K8S_CLOUD_NAME"
251 fi
252 echo "Deploying OSM with charms"
253 images_overlay=""
254 if [ -v REGISTRY_URL ]; then
255 [ ! -v TAG ] && TAG='latest'
256 fi
257 [ -v TAG ] && generate_images_overlay && images_overlay="--overlay $IMAGES_OVERLAY_FILE"
258
259 if [ -v OVERLAY ]; then
260 extra_overlay="--overlay $OVERLAY"
261 fi
262 echo "Creating Password Overlay"
263
264 generate_password_overlay && secret_overlay="--overlay $PASSWORD_OVERLAY_FILE"
265
266 [ -n "$INSTALL_PLA" ] && create_pla_overlay && pla_overlay="--overlay $PLA_OVERLAY_FILE"
267
268 if [ -v BUNDLE ]; then
269 juju deploy --trust --channel $CHARMHUB_CHANNEL -m $MODEL_NAME $BUNDLE $images_overlay $extra_overlay $secret_overlay $pla_overlay
270 else
271 juju deploy --trust --channel $CHARMHUB_CHANNEL -m $MODEL_NAME $OSM_BUNDLE $images_overlay $extra_overlay $secret_overlay $pla_overlay
272 fi
273
274 if [ ! -v KUBECFG ]; then
275 API_SERVER=${DEFAULT_IP}
276 else
277 API_SERVER=$(kubectl config view --minify | grep server | cut -f 2- -d ":" | tr -d " ")
278 proto="$(echo $API_SERVER | grep :// | sed -e's,^\(.*://\).*,\1,g')"
279 url="$(echo ${API_SERVER/$proto/})"
280 user="$(echo $url | grep @ | cut -d@ -f1)"
281 hostport="$(echo ${url/$user@/} | cut -d/ -f1)"
282 API_SERVER="$(echo $hostport | sed -e 's,:.*,,g')"
283 fi
284 # Configure VCA Integrator
285 juju config vca \
286 k8s-cloud=microk8s \
287 lxd-cloud=lxd-cloud:lxd-cloud \
288 controllers="`cat ~/.local/share/juju/controllers.yaml`" \
289 accounts="`cat ~/.local/share/juju/accounts.yaml`" \
290 public-key="`cat ~/.local/share/juju/ssh/juju_id_rsa.pub`"
291 # Expose OSM services
292 juju config -m $MODEL_NAME nbi external-hostname=nbi.${API_SERVER}.nip.io
293 juju config -m $MODEL_NAME ng-ui external-hostname=ui.${API_SERVER}.nip.io
294 juju config -m $MODEL_NAME grafana site_url=https://grafana.${API_SERVER}.nip.io
295 juju config -m $MODEL_NAME prometheus site_url=https://prometheus.${API_SERVER}.nip.io
296
297 echo "Waiting for deployment to finish..."
298 check_osm_deployed
299 grafana_leader=`juju status -m $MODEL_NAME grafana | grep "*" | cut -d "*" -f 1`
300 grafana_admin_password=`juju run -m $MODEL_NAME --unit $grafana_leader "echo \\$GF_SECURITY_ADMIN_PASSWORD"`
301 juju config -m $MODEL_NAME mon grafana-password=$grafana_admin_password
302 check_osm_deployed
303 echo "OSM with charms deployed"
304 }
305
306 function check_osm_deployed() {
307 TIME_TO_WAIT=600
308 start_time="$(date -u +%s)"
309 total_service_count=15
310 [ -n "$INSTALL_PLA" ] && total_service_count=$((total_service_count + 1))
311 previous_count=0
312 while true
313 do
314 service_count=$(juju status --format json -m $MODEL_NAME | jq '.applications[]."application-status".current' | grep active | wc -l)
315 echo "$service_count / $total_service_count services active"
316 if [ $service_count -eq $total_service_count ]; then
317 break
318 fi
319 if [ $service_count -ne $previous_count ]; then
320 previous_count=$service_count
321 start_time="$(date -u +%s)"
322 fi
323 now="$(date -u +%s)"
324 if [[ $(( now - start_time )) -gt $TIME_TO_WAIT ]];then
325 echo "Timed out waiting for OSM services to become ready"
326 FATAL_TRACK deploy_osm "Timed out waiting for services to become ready"
327 fi
328 sleep 10
329 done
330 }
331
332 function generate_password_overlay() {
333 # prometheus
334 web_config_password=`openssl rand -hex 16`
335 # keystone
336 keystone_db_password=`openssl rand -hex 16`
337 keystone_admin_password=`openssl rand -hex 16`
338 keystone_service_password=`openssl rand -hex 16`
339 # mariadb
340 mariadb_password=`openssl rand -hex 16`
341 mariadb_root_password=`openssl rand -hex 16`
342 cat << EOF > /tmp/password-overlay.yaml
343 applications:
344 prometheus:
345 options:
346 web_config_password: $web_config_password
347 keystone:
348 options:
349 keystone-db-password: $keystone_db_password
350 admin-password: $keystone_admin_password
351 service-password: $keystone_service_password
352 mariadb:
353 options:
354 password: $mariadb_password
355 root_password: $mariadb_root_password
356 EOF
357 mv /tmp/password-overlay.yaml $PASSWORD_OVERLAY_FILE
358 }
359
360 function create_pla_overlay(){
361 echo "Creating PLA Overlay"
362 [ $BUNDLE == $OSM_HA_BUNDLE ] && scale=3 || scale=1
363 cat << EOF > /tmp/pla-overlay.yaml
364 applications:
365 pla:
366 charm: osm-pla
367 channel: latest/stable
368 scale: $scale
369 series: kubernetes
370 options:
371 log_level: DEBUG
372 resources:
373 image: opensourcemano/pla:testing-daily
374 relations:
375 - - pla:kafka
376 - kafka:kafka
377 - - pla:mongodb
378 - mongodb:database
379 EOF
380 mv /tmp/pla-overlay.yaml $PLA_OVERLAY_FILE
381 }
382
383 function generate_images_overlay(){
384 echo "applications:" > /tmp/images-overlay.yaml
385
386 charms_with_resources="nbi lcm mon pol ng-ui ro"
387 [ -n "$INSTALL_PLA" ] && charms_with_resources+=" pla"
388 for charm in $charms_with_resources; do
389 cat << EOF > /tmp/${charm}_registry.yaml
390 registrypath: ${REGISTRY_URL}opensourcemano/${charm}:$TAG
391 EOF
392 if [ ! -z "$REGISTRY_USERNAME" ] ; then
393 echo username: $REGISTRY_USERNAME >> /tmp/${charm}_registry.yaml
394 echo password: $REGISTRY_PASSWORD >> /tmp/${charm}_registry.yaml
395 fi
396
397 cat << EOF >> /tmp/images-overlay.yaml
398 ${charm}:
399 resources:
400 ${charm}-image: /tmp/${charm}_registry.yaml
401
402 EOF
403 done
404 ch_charms_with_resources="keystone"
405 for charm in $ch_charms_with_resources; do
406 cat << EOF > /tmp/${charm}_registry.yaml
407 registrypath: ${REGISTRY_URL}opensourcemano/${charm}:$TAG
408 EOF
409 if [ ! -z "$REGISTRY_USERNAME" ] ; then
410 echo username: $REGISTRY_USERNAME >> /tmp/${charm}_registry.yaml
411 echo password: $REGISTRY_PASSWORD >> /tmp/${charm}_registry.yaml
412 fi
413
414 cat << EOF >> /tmp/images-overlay.yaml
415 ${charm}:
416 resources:
417 ${charm}-image: /tmp/${charm}_registry.yaml
418
419 EOF
420 done
421
422 mv /tmp/images-overlay.yaml $IMAGES_OVERLAY_FILE
423 }
424
425 function refresh_osmclient_snap() {
426 osmclient_snap_install_refresh refresh
427 }
428
429 function install_osm_client_snap() {
430 osmclient_snap_install_refresh install
431 }
432
433 function osmclient_snap_install_refresh() {
434 channel_preference="stable candidate beta edge"
435 for channel in $channel_preference; do
436 echo "Trying to install osmclient from channel $OSMCLIENT_VERSION/$channel"
437 sudo snap $1 osmclient --channel $OSMCLIENT_VERSION/$channel 2> /dev/null && echo osmclient snap installed && break
438 done
439 }
440 function install_osmclient() {
441 snap info osmclient | grep -E ^installed: && refresh_osmclient_snap || install_osm_client_snap
442 }
443
444 function add_local_k8scluster() {
445 osm --all-projects vim-create \
446 --name _system-osm-vim \
447 --account_type dummy \
448 --auth_url http://dummy \
449 --user osm --password osm --tenant osm \
450 --description "dummy" \
451 --config '{management_network_name: mgmt}'
452 tmpfile=$(mktemp --tmpdir=${HOME})
453 cp ${KUBECONFIG} ${tmpfile}
454 osm --all-projects k8scluster-add \
455 --creds ${tmpfile} \
456 --vim _system-osm-vim \
457 --k8s-nets '{"net1": null}' \
458 --version '1.19' \
459 --description "OSM Internal Cluster" \
460 _system-osm-k8s
461 rm -f ${tmpfile}
462 }
463
464 function install_microstack() {
465 sudo snap install microstack --beta --devmode
466
467 CHECK=$(microstack.openstack server list)
468 if [ $? -ne 0 ] ; then
469 if [[ $CHECK == *"not initialized"* ]]; then
470 echo "Setting MicroStack dashboard to listen to port 8080"
471 sudo snap set microstack config.network.ports.dashboard=8080
472 echo "Initializing MicroStack. This can take several minutes"
473 sudo microstack.init --auto --control
474 fi
475 fi
476
477 sudo snap alias microstack.openstack openstack
478
479 echo "Updating default security group in MicroStack to allow all access"
480
481 for i in $(microstack.openstack security group list | awk '/default/{ print $2 }'); do
482 for PROTO in icmp tcp udp ; do
483 echo " $PROTO ingress"
484 CHECK=$(microstack.openstack security group rule create $i --protocol $PROTO --remote-ip 0.0.0.0/0 2>&1)
485 if [ $? -ne 0 ] ; then
486 if [[ $CHECK != *"409"* ]]; then
487 echo "Error creating ingress rule for $PROTO"
488 echo $CHECK
489 fi
490 fi
491 done
492 done
493
494 microstack.openstack network show osm-ext &>/dev/null
495 if [ $? -ne 0 ]; then
496 echo "Creating osm-ext network with router to bridge to MicroStack external network"
497 microstack.openstack network create --enable --no-share osm-ext
498 microstack.openstack subnet create osm-ext-subnet --network osm-ext --dns-nameserver 8.8.8.8 \
499 --subnet-range 172.30.0.0/24
500 microstack.openstack router create external-router
501 microstack.openstack router add subnet external-router osm-ext-subnet
502 microstack.openstack router set --external-gateway external external-router
503 fi
504
505 microstack.openstack image list | grep ubuntu20.04 &> /dev/null
506 if [ $? -ne 0 ] ; then
507 echo "Fetching Ubuntu 20.04 image and upLoading to MicroStack"
508 wget -q -O- https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img \
509 | microstack.openstack image create --public --container-format=bare \
510 --disk-format=qcow2 ubuntu20.04 | grep status
511 fi
512
513 if [ ! -f ~/.ssh/microstack ]; then
514 ssh-keygen -t rsa -N "" -f ~/.ssh/microstack
515 microstack.openstack keypair create --public-key ~/.ssh/microstack.pub microstack
516 fi
517
518 echo "Creating VIM microstack-site in OSM"
519 . /var/snap/microstack/common/etc/microstack.rc
520
521 osm vim-create \
522 --name microstack-site \
523 --user "$OS_USERNAME" \
524 --password "$OS_PASSWORD" \
525 --auth_url "$OS_AUTH_URL" \
526 --tenant "$OS_USERNAME" \
527 --account_type openstack \
528 --config='{use_floating_ip: True,
529 insecure: True,
530 keypair: microstack,
531 management_network_name: osm-ext}'
532 }
533
534 DEFAULT_IF=`ip route list match 0.0.0.0 | awk '{print $5; exit}'`
535 DEFAULT_IP=`ip -o -4 a |grep ${DEFAULT_IF}|awk '{split($4,a,"/"); print a[1]; exit}'`
536
537 check_arguments $@
538 mkdir -p ~/.osm
539 install_snaps
540 bootstrap_k8s_lxd
541 if [ -v ONLY_VCA ]; then
542 HOME=/home/$USER
543 k8scloud=microk8s
544 lxdcloud=lxd-cloud:lxd-cloud
545 controllers="`cat $HOME/.local/share/juju/controllers.yaml`"
546 accounts="`cat $HOME/.local/share/juju/accounts.yaml`"
547 publickey="`cat $HOME/.local/share/juju/ssh/juju_id_rsa.pub`"
548 echo "Use the following command to register the installed VCA to your OSM VCA integrator charm"
549 echo -e " juju config vca \\\n k8s-cloud=$k8scloud \\\n lxd-cloud=$lxdcloud \\\n controllers=$controllers \\\n accounts=$accounts \\\n public-key=$publickey"
550 track deploy_osm deploy_vca_only_ok
551 else
552 deploy_charmed_osm
553 track deploy_osm deploy_osm_services_k8s_ok
554 install_osmclient
555 track osmclient osmclient_ok
556 export OSM_HOSTNAME=$(juju config -m $MODEL_NAME nbi external-hostname):443
557 export OSM_PASSWORD=$keystone_admin_password
558 sleep 10
559 add_local_k8scluster
560 track final_ops add_local_k8scluster_ok
561 if [ -v MICROSTACK ]; then
562 install_microstack
563 track final_ops install_microstack_ok
564 fi
565
566 echo "Your installation is now complete, follow these steps for configuring the osmclient:"
567 echo
568 echo "1. Create the OSM_HOSTNAME environment variable with the NBI IP"
569 echo
570 echo "export OSM_HOSTNAME=$OSM_HOSTNAME"
571 echo "export OSM_PASSWORD=$OSM_PASSWORD"
572 echo
573 echo "2. Add the previous commands to your .bashrc for other Shell sessions"
574 echo
575 echo "echo \"export OSM_HOSTNAME=$OSM_HOSTNAME\" >> ~/.bashrc"
576 echo "echo \"export OSM_PASSWORD=$OSM_PASSWORD\" >> ~/.bashrc"
577 echo
578 echo "3. Login OSM GUI by using admin password: $OSM_PASSWORD"
579 echo
580 echo "DONE"
581 track end
582 fi
583