Fix minor issue with permissions in Charmed Installer
[osm/devops.git] / installers / charmed_install.sh
index 7f05e04..3e7800e 100755 (executable)
@@ -19,6 +19,7 @@ JUJU_AGENT_VERSION=2.8.6
 K8S_CLOUD_NAME="k8s-cloud"
 KUBECTL="microk8s.kubectl"
 MICROK8S_VERSION=1.19
+OSMCLIENT_VERSION=9.0
 IMAGES_OVERLAY_FILE=~/.osm/images-overlay.yaml
 PATH=/snap/bin:${PATH}
 
@@ -26,6 +27,7 @@ MODEL_NAME=osm
 
 OSM_BUNDLE=cs:osm-54
 OSM_HA_BUNDLE=cs:osm-ha-40
+TAG=9
 
 function check_arguments(){
     while [ $# -gt 0 ] ; do
@@ -49,13 +51,18 @@ function check_arguments(){
 function install_snaps(){
     if [ ! -v KUBECFG ]; then
         sudo snap install microk8s --classic --channel=${MICROK8S_VERSION}/stable
+        sudo cat /var/snap/microk8s/current/args/kube-apiserver | grep advertise-address || (
+                echo "--advertise-address $DEFAULT_IP" | sudo tee -a /var/snap/microk8s/current/args/kube-apiserver
+                microk8s.stop
+                microk8s.start
+            )
         sudo usermod -a -G microk8s `whoami`
         mkdir -p ~/.kube
         sudo chown -f -R `whoami` ~/.kube
         KUBEGRP="microk8s"
         sg ${KUBEGRP} -c "microk8s status --wait-ready"
         KUBECONFIG=~/.osm/microk8s-config.yaml
-        sg ${KUBEGRP} -c "microk8s config" > ${KUBECONFIG}
+        sg ${KUBEGRP} -c "microk8s config" | tee ${KUBECONFIG}
     else
         KUBECTL="kubectl"
         sudo snap install kubectl --classic
@@ -385,7 +392,7 @@ applications:
       image: ${REGISTRY_URL}opensourcemano/pol:$TAG ${REGISTRY_CREDENTIALS}
   pla:
     options:
-      image: ${REGISTRY_URL}opensourcemano/pla:$TAG ${REGISTRY_CREDENTIALS}
+      image: ${REGISTRY_URL}opensourcemano/pla:8 ${REGISTRY_CREDENTIALS}
   ng-ui:
     resources:
       image: /tmp/ng_ui_registry.yaml
@@ -396,9 +403,23 @@ EOF
     mv /tmp/images-overlay.yaml $IMAGES_OVERLAY_FILE
 }
 
+function refresh_osmclient_snap() {
+    osmclient_snap_install_refresh refresh
+}
+
+function install_osm_client_snap() {
+    osmclient_snap_install_refresh install
+}
+
+function osmclient_snap_install_refresh() {
+    channel_preference="stable candidate beta edge"
+    for channel in $channel_preference; do
+        echo "Trying to install osmclient from channel $OSMCLIENT_VERSION/$channel"
+        sudo snap $1 osmclient --channel $OSMCLIENT_VERSION/$channel 2> /dev/null && echo osmclient snap installed && break
+    done
+}
 function install_osmclient() {
-    sudo snap install osmclient
-    sudo snap alias osmclient.osm osm
+    snap info osmclient | grep -E ^installed: && refresh_osmclient_snap || install_osm_client_snap
 }
 
 function add_local_k8scluster() {