Add --only-vca flag to charmed installer 25/10725/1
authorDavid Garcia <david.garcia@canonical.com>
Mon, 3 May 2021 16:27:18 +0000 (18:27 +0200)
committerDavid Garcia <david.garcia@canonical.com>
Mon, 3 May 2021 16:27:18 +0000 (18:27 +0200)
It will help feature 10239, in order to automate the deployment of the
VCA without needing to deploy OSM.

When the option is enabled in the installation, in the end a string will
be printed out with the command to be executed in OSM to register the
installed VCA.

Change-Id: I1b284a5a650b50e89c07a6d08507406823c6cc2d
Signed-off-by: David Garcia <david.garcia@canonical.com>
installers/charmed_install.sh
installers/full_install_osm.sh

index b36d582..107397f 100755 (executable)
@@ -41,6 +41,7 @@ function check_arguments(){
             --ha) BUNDLE=$OSM_HA_BUNDLE ;;
             --tag) TAG="$2" ;;
             --registry) REGISTRY_INFO="$2" ;;
+            --only-vca) ONLY_VCA=y ;;
         esac
         shift
     done
@@ -235,7 +236,6 @@ function deploy_charmed_osm(){
         esac
     fi
 
-    create_overlay
     echo "Creating OSM model"
     if [ -v KUBECFG ]; then
         juju add-model $MODEL_NAME $K8S_CLOUD_NAME
@@ -440,25 +440,40 @@ check_arguments $@
 mkdir -p ~/.osm
 install_snaps
 bootstrap_k8s_lxd
-deploy_charmed_osm
-install_osmclient
-export OSM_HOSTNAME=$(juju config -m $MODEL_NAME nbi site_url | sed "s/http.*\?:\/\///"):443
-sleep 10
-add_local_k8scluster
-
-if [ -v MICROSTACK ]; then
-    install_microstack
-fi
+create_overlay
+if [ -v ONLY_VCA ]; then
+    HOME=/home/$USER
+    vca_user=$(cat $HOME/.local/share/juju/accounts.yaml | yq e .controllers.$CONTROLLER_NAME.user - )
+    vca_secret=$(cat $HOME/.local/share/juju/accounts.yaml | yq e .controllers.$CONTROLLER_NAME.password - )
+    vca_host=$(cat $HOME/.local/share/juju/controllers.yaml | yq e .controllers.$CONTROLLER_NAME.api-endpoints[0] - | cut -d ":" -f 1)
+    vca_port=$(cat $HOME/.local/share/juju/controllers.yaml | yq e .controllers.$CONTROLLER_NAME.api-endpoints[0] - | cut -d ":" -f 2)
+    vca_pubkey=\"$(cat $HOME/.local/share/juju/ssh/juju_id_rsa.pub)\"
+    vca_cloud="lxd-cloud"
+    vca_cacert=$(cat $HOME/.local/share/juju/controllers.yaml | yq e .controllers.$CONTROLLER_NAME.ca-cert - | base64 | tr -d \\n)
+    hostname=`cat /etc/hostname`
+
+    echo "Use the following command to register the installed VCA to your OSM:"
+    echo -e "  osm vca-add --endpoints $vca_host:$vca_port \ \n         --user $vca_user \ \n         --secret $vca_secret \ \n         --cacert $vca_cacert \ \n         --lxd-cloud lxd-cloud \ \n         --lxd-credentials lxd-cloud \ \n         --k8s-cloud microk8s \ \n         --k8s-credentials microk8s\ \n         $hostname-vca"
+else
+    deploy_charmed_osm
+    install_osmclient
+    export OSM_HOSTNAME=$(juju config -m $MODEL_NAME nbi site_url | sed "s/http.*\?:\/\///"):443
+    sleep 10
+    add_local_k8scluster
+    if [ -v MICROSTACK ]; then
+        install_microstack
+    fi
 
+    echo "Your installation is now complete, follow these steps for configuring the osmclient:"
+    echo
+    echo "1. Create the OSM_HOSTNAME environment variable with the NBI IP"
+    echo
+    echo "export OSM_HOSTNAME=$OSM_HOSTNAME"
+    echo
+    echo "2. Add the previous command to your .bashrc for other Shell sessions"
+    echo
+    echo "echo \"export OSM_HOSTNAME=$OSM_HOSTNAME\" >> ~/.bashrc"
+    echo
+    echo "DONE"
+fi
 
-echo "Your installation is now complete, follow these steps for configuring the osmclient:"
-echo
-echo "1. Create the OSM_HOSTNAME environment variable with the NBI IP"
-echo
-echo "export OSM_HOSTNAME=$OSM_HOSTNAME"
-echo
-echo "2. Add the previous command to your .bashrc for other Shell sessions"
-echo
-echo "echo \"export OSM_HOSTNAME=$OSM_HOSTNAME\" >> ~/.bashrc"
-echo
-echo "DONE"
index 11723fe..57cc4fb 100755 (executable)
@@ -1824,6 +1824,7 @@ while getopts ":b:r:c:n:k:u:R:D:o:O:m:N:H:S:s:w:t:U:P:A:l:L:K:d:p:T:f:F:-: hy" o
             [ "${OPTARG}" == "lxd" ] && continue
             [ "${OPTARG}" == "lxd-cred" ] && continue
             [ "${OPTARG}" == "microstack" ] && continue
+            [ "${OPTARG}" == "only-vca" ] && continue
             [ "${OPTARG}" == "vca" ] && continue
             [ "${OPTARG}" == "ha" ] && continue
             [ "${OPTARG}" == "tag" ] && continue