Revert "Feature 11071: Modular OSM installation. Remove charms, juju and lxd"

This reverts commit a0f0d8ef4f2aa0dd227ecb651002490b66498bab.

Change-Id: I92394e4074dad4e457c107c58e4ebc17d507f8b2
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
diff --git a/installers/full_install_osm.sh b/installers/full_install_osm.sh
index 522d228..f0723ea 100755
--- a/installers/full_install_osm.sh
+++ b/installers/full_install_osm.sh
@@ -21,7 +21,7 @@
     echo -e "     -h / --help:    print this help"
     echo -e "     -y:             do not prompt for confirmation, assumes yes"
     echo -e "     -r <repo>:      use specified repository name for osm packages"
-    echo -e "     -R <release>:   use specified release for osm binaries (deb packages, ...)"
+    echo -e "     -R <release>:   use specified release for osm binaries (deb packages, lxd images, ...)"
     echo -e "     -u <repo base>: use specified repository url for osm packages"
     echo -e "     -k <repo key>:  use specified repository public key url"
     echo -e "     -a <apt proxy url>: use this apt proxy url when downloading apt packages (air-gapped installation)"
@@ -33,20 +33,92 @@
     echo -e "     --no-aux-cluster: Do not provision an auxiliary cluster for cloud-native gitops operations in OSM (NEW in Release SIXTEEN) (by default, it is installed)"
     echo -e "     -D <devops path>:   use local devops installation path"
     echo -e "     -s <namespace>  namespace when installed using k8s, default is osm"
+    echo -e "     -H <VCA host>   use specific juju host controller IP"
+    echo -e "     -S <VCA secret> use VCA/juju secret key"
+    echo -e "     -P <VCA pubkey> use VCA/juju public key file"
+    echo -e "     -A <VCA apiproxy> use VCA/juju API proxy"
     echo -e "     -w <work dir>:   Location to store runtime installation"
+    echo -e "     -l:             LXD cloud yaml file"
+    echo -e "     -L:             LXD credentials yaml file"
     echo -e "     -K:             Specifies the name of the controller to use - The controller must be already bootstrapped"
     echo -e "     -d <docker registry URL> use docker registry URL instead of dockerhub"
     echo -e "     -p <docker proxy URL> set docker proxy URL as part of docker CE configuration"
     echo -e "     -T <docker tag> specify docker tag for the modules specified with option -m"
     echo -e "     --debug:        debug mode"
+    echo -e "     --nocachelxdimages:  do not cache local lxd images, do not create cronjob for that cache (will save installation time, might affect instantiation time)"
+    echo -e "     --cachelxdimages:  cache local lxd images, create cronjob for that cache (will make installation longer)"
+    echo -e "     --nolxd:        do not install and configure LXD, allowing unattended installations (assumes LXD is already installed and confifured)"
     echo -e "     --nodocker:     do not install docker, do not initialize a swarm (assumes docker is already installed and a swarm has been initialized)"
+    echo -e "     --nojuju:       do not juju, assumes already installed"
+    echo -e "     --nohostports:  do not expose docker ports to host (useful for creating multiple instances of osm on the same host)"
     echo -e "     --nohostclient: do not install the osmclient"
     echo -e "     --uninstall:    uninstall OSM: remove the containers and delete NAT rules"
     echo -e "     --k8s_monitor:  install the OSM kubernetes monitoring with prometheus and grafana"
     echo -e "     --showopts:     print chosen options and exit (only for debugging)"
+    echo -e "     --charmed:                   Deploy and operate OSM with Charms on k8s"
+    echo -e "     [--bundle <bundle path>]:    Specify with which bundle to deploy OSM with charms (--charmed option)"
+    echo -e "     [--k8s <kubeconfig path>]:   Specify with which kubernetes to deploy OSM with charms (--charmed option)"
+    echo -e "     [--vca <name>]:              Specifies the name of the controller to use - The controller must be already bootstrapped (--charmed option)"
+    echo -e "     [--small-profile]:           Do not install and configure LXD which aims to use only K8s Clouds (--charmed option)"
+    echo -e "     [--lxd <yaml path>]:         Takes a YAML file as a parameter with the LXD Cloud information (--charmed option)"
+    echo -e "     [--lxd-cred <yaml path>]:    Takes a YAML file as a parameter with the LXD Credentials information (--charmed option)"
+    echo -e "     [--microstack]:              Installs microstack as a vim. (--charmed option)"
+    echo -e "     [--overlay]:                 Add an overlay to override some defaults of the default bundle (--charmed option)"
+    echo -e "     [--ha]:                      Installs High Availability bundle. (--charmed option)"
+    echo -e "     [--tag]:                     Docker image tag. (--charmed option)"
+    echo -e "     [--registry]:                Docker registry with optional credentials as user:pass@hostname:port (--charmed option)"
     [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
 }
 
+# takes a juju/accounts.yaml file and returns the password specific
+# for a controller. I wrote this using only bash tools to minimize
+# additions of other packages
+function parse_juju_password {
+    [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
+    password_file="${HOME}/.local/share/juju/accounts.yaml"
+    local controller_name=$1
+    local s='[[:space:]]*' w='[a-zA-Z0-9_-]*' fs=$(echo @|tr @ '\034')
+    sed -ne "s|^\($s\):|\1|" \
+         -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
+         -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $password_file |
+    awk -F$fs -v controller=$controller_name '{
+        indent = length($1)/2;
+        vname[indent] = $2;
+        for (i in vname) {if (i > indent) {delete vname[i]}}
+        if (length($3) > 0) {
+            vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
+            if (match(vn,controller) && match($2,"password")) {
+                printf("%s",$3);
+            }
+        }
+    }'
+    [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
+}
+
+function set_vca_variables() {
+    OSM_VCA_CLOUDNAME="lxd-cloud"
+    [ -n "$OSM_VCA_HOST" ] && OSM_VCA_CLOUDNAME="localhost"
+    if [ -z "$OSM_VCA_HOST" ]; then
+        [ -z "$CONTROLLER_NAME" ] && OSM_VCA_HOST=`sg lxd -c "juju show-controller $OSM_NAMESPACE"|grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'`
+        [ -n "$CONTROLLER_NAME" ] && OSM_VCA_HOST=`juju show-controller $CONTROLLER_NAME |grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'`
+        [ -z "$OSM_VCA_HOST" ] && FATAL "Cannot obtain juju controller IP address"
+    fi
+    if [ -z "$OSM_VCA_SECRET" ]; then
+        [ -z "$CONTROLLER_NAME" ] && OSM_VCA_SECRET=$(parse_juju_password $OSM_NAMESPACE)
+        [ -n "$CONTROLLER_NAME" ] && OSM_VCA_SECRET=$(parse_juju_password $CONTROLLER_NAME)
+        [ -z "$OSM_VCA_SECRET" ] && FATAL "Cannot obtain juju secret"
+    fi
+    if [ -z "$OSM_VCA_PUBKEY" ]; then
+        OSM_VCA_PUBKEY=$(cat $HOME/.local/share/juju/ssh/juju_id_rsa.pub)
+        [ -z "$OSM_VCA_PUBKEY" ] && FATAL "Cannot obtain juju public key"
+    fi
+    if [ -z "$OSM_VCA_CACERT" ]; then
+        [ -z "$CONTROLLER_NAME" ] && OSM_VCA_CACERT=$(juju controllers --format json | jq -r --arg controller $OSM_NAMESPACE '.controllers[$controller]["ca-cert"]' | base64 | tr -d \\n)
+        [ -n "$CONTROLLER_NAME" ] && OSM_VCA_CACERT=$(juju controllers --format json | jq -r --arg controller $CONTROLLER_NAME '.controllers[$controller]["ca-cert"]' | base64 | tr -d \\n)
+        [ -z "$OSM_VCA_CACERT" ] && FATAL "Cannot obtain juju CA certificate"
+    fi
+}
+
 function generate_secret() {
     [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
     head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32
@@ -127,6 +199,12 @@
     [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
     # Generate helm values to be passed with -f osm-values.yaml
     sudo mkdir -p ${OSM_HELM_WORK_DIR}
+    if [ -n "${INSTALL_JUJU}" ]; then
+        sudo bash -c "cat << EOF > ${OSM_HELM_WORK_DIR}/osm-values.yaml
+vca:
+  pubkey: \"${OSM_VCA_PUBKEY}\"
+EOF"
+    fi
 
     # Generate helm values to be passed with --set
     OSM_HELM_OPTS=""
@@ -150,6 +228,18 @@
         OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.gitops.pubkey=${AGE_MGMT_PUBKEY}"
     fi
 
+    if [ -n "${INSTALL_JUJU}" ]; then
+        OSM_HELM_OPTS="${OSM_HELM_OPTS} --set vca.enabled=true"
+        OSM_HELM_OPTS="${OSM_HELM_OPTS} --set vca.host=${OSM_VCA_HOST}"
+        OSM_HELM_OPTS="${OSM_HELM_OPTS} --set vca.secret=${OSM_VCA_SECRET}"
+        OSM_HELM_OPTS="${OSM_HELM_OPTS} --set vca.cacert=${OSM_VCA_CACERT}"
+    fi
+    [ -n "$OSM_VCA_APIPROXY" ] && OSM_HELM_OPTS="${OSM_HELM_OPTS} --set lcm.config.OSMLCM_VCA_APIPROXY=${OSM_VCA_APIPROXY}"
+
+    OSM_HELM_OPTS="${OSM_HELM_OPTS} --set airflow.defaultAirflowRepository=${DOCKER_REGISTRY_URL}${DOCKER_USER}/airflow"
+    [ ! "$OSM_DOCKER_TAG" == "testing-daily" ] && OSM_HELM_OPTS="${OSM_HELM_OPTS} --set-string airflow.defaultAirflowTag=${OSM_DOCKER_TAG}"
+    OSM_HELM_OPTS="${OSM_HELM_OPTS} --set airflow.ingress.web.hosts[0].name=airflow.${OSM_K8S_EXTERNAL_IP}.nip.io"
+
     if [ -n "${OSM_BEHIND_PROXY}" ]; then
         OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.behindHttpProxy=true"
         [ -n "${HTTP_PROXY}" ] && OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.httpProxy.HTTP_PROXY=\"${HTTP_PROXY}\""
@@ -165,6 +255,9 @@
         fi
     fi
 
+    if [ -n "${INSTALL_JUJU}" ]; then
+        OSM_HELM_OPTS="-f ${OSM_HELM_WORK_DIR}/osm-values.yaml ${OSM_HELM_OPTS}"
+    fi
     echo "helm upgrade --install -n $OSM_NAMESPACE --create-namespace $OSM_NAMESPACE $OSM_DEVOPS/installers/helm/osm ${OSM_HELM_OPTS}"
     helm upgrade --install -n $OSM_NAMESPACE --create-namespace $OSM_NAMESPACE $OSM_DEVOPS/installers/helm/osm ${OSM_HELM_OPTS}
     # Override existing values.yaml with the final values.yaml used to install OSM
@@ -214,10 +307,11 @@
     [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
 
     [ -z "$ASSUME_YES" ] && ! ask_user "The installation will do the following
-    1. Install required packages
-    2. Install docker CE
-    3. Disable swap space
-    4. Install and initialize Kubernetes
+    1. Install and configure LXD
+    2. Install juju
+    3. Install docker CE
+    4. Disable swap space
+    5. Install and initialize Kubernetes
     as pre-requirements.
     Do you want to proceed (Y/n)? " y && echo "Cancelled!" && exit 1
 
@@ -245,19 +339,19 @@
 ${OSM_PROXY_ENV_VARIABLES}.
 
 This suggests that this machine is behind a proxy and a special configuration is required.
-The installer will install Docker CE and a Kubernetes to work behind a proxy using those
+The installer will install Docker CE, LXD and Juju to work behind a proxy using those
 env variables.
 
-Take into account that the installer uses apt, curl, wget and docker.
+Take into account that the installer uses apt, curl, wget, docker, lxd, juju and snap.
 Depending on the program, the env variables to work behind a proxy might be different
 (e.g. http_proxy vs HTTP_PROXY).
 
 For that reason, it is strongly recommended that at least http_proxy, https_proxy, HTTP_PROXY
 and HTTPS_PROXY are defined.
 
-Finally, some of the programs (apt) are run as sudoer, requiring that those env variables
-are also set for root user. If you are not sure whether those variables are configured for
-the root user, you can stop the installation now.
+Finally, some of the programs (apt, snap) those programs are run as sudoer, requiring that
+those env variables are also set for root user. If you are not sure whether those variables
+are configured for the root user, you can stop the installation now.
 
 Do you want to proceed with the installation (Y/n)? " y && echo "Cancelled!" && exit 1
     else
@@ -270,14 +364,27 @@
 function find_devops_folder() {
     [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
     if [ -z "$OSM_DEVOPS" ]; then
-        echo -e "\nCreating temporary dir for OSM installation"
-        OSM_DEVOPS="$(mktemp -d -q --tmpdir "installosm.XXXXXX")"
-        trap 'rm -rf "$OSM_DEVOPS"' EXIT
-        git clone https://osm.etsi.org/gerrit/osm/devops.git $OSM_DEVOPS
+        if [ -n "$TEST_INSTALLER" ]; then
+            echo -e "\nUsing local devops repo for OSM installation"
+            OSM_DEVOPS="$(dirname $(realpath $(dirname $0)))"
+        else
+            echo -e "\nCreating temporary dir for OSM installation"
+            OSM_DEVOPS="$(mktemp -d -q --tmpdir "installosm.XXXXXX")"
+            trap 'rm -rf "$OSM_DEVOPS"' EXIT
+            git clone https://osm.etsi.org/gerrit/osm/devops.git $OSM_DEVOPS
+        fi
     fi
     [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
 }
 
+function install_lxd() {
+    [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
+    LXD_INSTALL_OPTS="-D ${OSM_DEVOPS} -i ${OSM_DEFAULT_IF} ${DEBUG_INSTALL}"
+    [ -n "${OSM_BEHIND_PROXY}" ] && LXD_INSTALL_OPTS="${LXD_INSTALL_OPTS} -P"
+    $OSM_DEVOPS/installers/install_lxd.sh ${LXD_INSTALL_OPTS} || FATAL_TRACK lxd "install_lxd.sh failed"
+    [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
+}
+
 function install_docker_ce() {
     [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
     DOCKER_CE_OPTS="-D ${OSM_DEVOPS} ${DEBUG_INSTALL}"
@@ -344,7 +451,10 @@
     trap ctrl_c INT
 
     check_osm_behind_proxy
-    check_packages "git wget curl tar"
+    check_packages "git wget curl tar snapd"
+    if [ -n "${INSTALL_JUJU}" ]; then
+        sudo snap install jq || FATAL "Could not install jq (snap package). Make sure that snap works"
+    fi
     find_devops_folder
 
     track start release $RELEASE none none docker_tag $OSM_DOCKER_TAG none none installation_type $OSM_INSTALLATION_TYPE none none os_info $os_info none none
@@ -365,6 +475,9 @@
     # configure apt proxy
     [ -n "$APT_PROXY_URL" ] && configure_apt_proxy $APT_PROXY_URL
 
+    # if lxd is requested, we will install it
+    [ -n "$INSTALL_LXD" ] && install_lxd
+
     track prereq prereqok_ok
 
     if [ -n "$INSTALL_DOCKER" ] || [ "${K8S_CLUSTER_ENGINE}" == "kubeadm" ]; then
@@ -386,6 +499,22 @@
     kubectl create namespace ${OSM_NAMESPACE}
     track k8scluster k8scluster_ok
 
+    if [ -n "${INSTALL_JUJU}" ]; then
+        echo "Installing Juju ..."
+        JUJU_OPTS="-D ${OSM_DEVOPS} -s ${OSM_NAMESPACE} -i ${OSM_DEFAULT_IP} ${DEBUG_INSTALL} ${INSTALL_CACHELXDIMAGES}"
+        [ -n "${OSM_VCA_HOST}" ] && JUJU_OPTS="$JUJU_OPTS -H ${OSM_VCA_HOST}"
+        [ -n "${LXD_CLOUD_FILE}" ] && JUJU_OPTS="$JUJU_OPTS -l ${LXD_CLOUD_FILE}"
+        [ -n "${LXD_CRED_FILE}" ] && JUJU_OPTS="$JUJU_OPTS -L ${LXD_CRED_FILE}"
+        [ -n "${CONTROLLER_NAME}" ] && JUJU_OPTS="$JUJU_OPTS -K ${CONTROLLER_NAME}"
+        [ -n "${OSM_BEHIND_PROXY}" ] && JUJU_OPTS="${JUJU_OPTS} -P"
+        $OSM_DEVOPS/installers/install_juju.sh ${JUJU_OPTS} || FATAL_TRACK juju "install_juju.sh failed"
+        set_vca_variables
+    fi
+    track juju juju_ok
+
+    # This track is maintained for backwards compatibility
+    track docker_images docker_images_ok
+
     # Install mgmt cluster
     echo "Installing mgmt cluster ..."
     MGMTCLUSTER_INSTALL_OPTS="-D ${OSM_DEVOPS} ${DEBUG_INSTALL}"
@@ -428,6 +557,11 @@
     add_local_k8scluster
     track final_ops add_local_k8scluster_ok
 
+    # if lxd is requested, iptables firewall is updated to work with both docker and LXD
+    if [ -n "$INSTALL_LXD" ]; then
+        arrange_docker_default_network_policy
+    fi
+
     wget -q -O- https://osm-download.etsi.org/ftp/osm-16.0-sixteen/README2.txt &> /dev/null
     track end
     sudo find /etc/osm
@@ -435,6 +569,13 @@
     return 0
 }
 
+function arrange_docker_default_network_policy() {
+    echo -e "Fixing firewall so docker and LXD can share the same host without affecting each other."
+    sudo iptables -I DOCKER-USER -j ACCEPT
+    sudo iptables-save | sudo tee /etc/iptables/rules.v4
+    sudo ip6tables-save | sudo tee /etc/iptables/rules.v6
+}
+
 function install_k8s_monitoring() {
     [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
     # install OSM monitoring
@@ -450,21 +591,30 @@
     echo "DOCKER_PROXY_URL=$DOCKER_PROXY_URL"
     echo "DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL"
     echo "DOCKER_USER=$DOCKER_USER"
+    echo "INSTALL_CACHELXDIMAGES=$INSTALL_CACHELXDIMAGES"
+    echo "INSTALL_JUJU=$INSTALL_JUJU"
     echo "INSTALL_K8S_MONITOR=$INSTALL_K8S_MONITOR"
+    echo "INSTALL_LXD=$INSTALL_LXD"
     echo "INSTALL_DOCKER=$INSTALL_DOCKER"
     echo "OSM_DEVOPS=$OSM_DEVOPS"
     echo "OSM_DOCKER_TAG=$OSM_DOCKER_TAG"
     echo "OSM_K8S_EXTERNAL_IP=$OSM_K8S_EXTERNAL_IP"
     echo "OSM_HELM_WORK_DIR=$OSM_HELM_WORK_DIR"
     echo "OSM_NAMESPACE=$OSM_NAMESPACE"
+    echo "OSM_VCA_HOST=$OSM_VCA_HOST"
+    echo "OSM_VCA_PUBKEY=$OSM_VCA_PUBKEY"
+    echo "OSM_VCA_SECRET=$OSM_VCA_SECRET"
     echo "OSM_WORK_DIR=$OSM_WORK_DIR"
     echo "PULL_IMAGES=$PULL_IMAGES"
+    echo "RECONFIGURE=$RECONFIGURE"
     echo "RELEASE=$RELEASE"
     echo "REPOSITORY=$REPOSITORY"
     echo "REPOSITORY_BASE=$REPOSITORY_BASE"
     echo "REPOSITORY_KEY=$REPOSITORY_KEY"
     echo "SHOWOPTS=$SHOWOPTS"
+    echo "TEST_INSTALLER=$TEST_INSTALLER"
     echo "UNINSTALL=$UNINSTALL"
+    echo "UPDATE=$UPDATE"
     [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
 }
 
@@ -484,6 +634,10 @@
 }
 
 UNINSTALL=""
+UPDATE=""
+RECONFIGURE=""
+TEST_INSTALLER=""
+INSTALL_LXD=""
 SHOWOPTS=""
 ASSUME_YES=""
 APT_PROXY_URL=""
@@ -492,11 +646,20 @@
 RELEASE="testing-daily"
 REPOSITORY="testing"
 INSTALL_K8S_MONITOR=""
+LXD_REPOSITORY_BASE="https://osm-download.etsi.org/repository/osm/lxd"
+LXD_REPOSITORY_PATH=""
 INSTALL_DOCKER=""
+INSTALL_JUJU=""
 INSTALL_NOHOSTCLIENT=""
+INSTALL_CACHELXDIMAGES=""
 INSTALL_AUX_CLUSTER="y"
 INSTALL_MGMT_CLUSTER="y"
 OSM_DEVOPS=
+OSM_VCA_HOST=
+OSM_VCA_SECRET=
+OSM_VCA_PUBKEY=
+OSM_VCA_CLOUDNAME="localhost"
+OSM_VCA_K8S_CLOUDNAME="k8scloud"
 OSM_NAMESPACE=osm
 REPOSITORY_KEY="OSM%20ETSI%20Release%20Key.gpg"
 REPOSITORY_BASE="https://osm-download.etsi.org/repository/osm/debian"
@@ -525,7 +688,7 @@
 MODULE_DOCKER_TAG=
 OSM_INSTALLATION_TYPE="Default"
 
-while getopts ":a:c:e:r:n:k:u:R:D:o:O:N:s:t:U:l:L:K:d:p:T:f:F:G:M:-: hy" o; do
+while getopts ":a:c:e:r:n:k:u:R:D:o:O:N:H:S:s:t:U:P:A:l:L:K:d:p:T:f:F:G:M:-: hy" o; do
     case "${o}" in
         a)
             APT_PROXY_URL=${OPTARG}
@@ -559,6 +722,12 @@
         D)
             OSM_DEVOPS="${OPTARG}"
             ;;
+        H)
+            OSM_VCA_HOST="${OPTARG}"
+            ;;
+        S)
+            OSM_VCA_SECRET="${OPTARG}"
+            ;;
         s)
             OSM_NAMESPACE="${OPTARG}" && [[ ! "${OPTARG}" =~ $RE_CHECK ]] && echo "Namespace $OPTARG is invalid. Regex used for validation is $RE_CHECK" && exit 0
             ;;
@@ -569,6 +738,18 @@
         U)
             DOCKER_USER="${OPTARG}"
             ;;
+        P)
+            OSM_VCA_PUBKEY=$(cat ${OPTARG})
+            ;;
+        A)
+            OSM_VCA_APIPROXY="${OPTARG}"
+            ;;
+        l)
+            LXD_CLOUD_FILE="${OPTARG}"
+            ;;
+        L)
+            LXD_CRED_FILE="${OPTARG}"
+            ;;
         K)
             CONTROLLER_NAME="${OPTARG}"
             ;;
@@ -593,11 +774,33 @@
             [ "${OPTARG}" == "uninstall" ] && UNINSTALL="y" && continue
             [ "${OPTARG}" == "no-mgmt-cluster" ] && INSTALL_MGMT_CLUSTER="" && continue
             [ "${OPTARG}" == "no-aux-cluster" ] && INSTALL_AUX_CLUSTER="" && continue
+            [ "${OPTARG}" == "update" ] && UPDATE="y" && continue
+            [ "${OPTARG}" == "reconfigure" ] && RECONFIGURE="y" && continue
+            [ "${OPTARG}" == "test" ] && TEST_INSTALLER="y" && continue
+            [ "${OPTARG}" == "lxdinstall" ] && INSTALL_LXD="y" && continue
+            [ "${OPTARG}" == "lxd" ] && INSTALL_LXD="y" && continue
+            [ "${OPTARG}" == "nolxd" ] && INSTALL_LXD="" && continue
             [ "${OPTARG}" == "docker" ] && INSTALL_DOCKER="y" && continue
             [ "${OPTARG}" == "nodocker" ] && INSTALL_DOCKER="" && continue
             [ "${OPTARG}" == "showopts" ] && SHOWOPTS="y" && continue
+            [ "${OPTARG}" == "juju" ] && INSTALL_JUJU="y" && continue
+            [ "${OPTARG}" == "nojuju" ] && INSTALL_JUJU="" && continue
             [ "${OPTARG}" == "nohostclient" ] && INSTALL_NOHOSTCLIENT="y" && continue
             [ "${OPTARG}" == "k8s_monitor" ] && INSTALL_K8S_MONITOR="y" && continue
+            [ "${OPTARG}" == "charmed" ] && CHARMED="y" && OSM_INSTALLATION_TYPE="Charmed" && continue
+            [ "${OPTARG}" == "bundle" ] && continue
+            [ "${OPTARG}" == "k8s" ] && continue
+            [ "${OPTARG}" == "lxd-cred" ] && continue
+            [ "${OPTARG}" == "microstack" ] && continue
+            [ "${OPTARG}" == "overlay" ] && continue
+            [ "${OPTARG}" == "only-vca" ] && continue
+            [ "${OPTARG}" == "small-profile" ] && continue
+            [ "${OPTARG}" == "vca" ] && continue
+            [ "${OPTARG}" == "ha" ] && continue
+            [ "${OPTARG}" == "tag" ] && continue
+            [ "${OPTARG}" == "registry" ] && continue
+            [ "${OPTARG}" == "nocachelxdimages" ] && continue
+            [ "${OPTARG}" == "cachelxdimages" ] && INSTALL_CACHELXDIMAGES="--cachelxdimages" && continue
             echo -e "Invalid option: '--$OPTARG'\n" >&2
             usage && exit 1
             ;;
@@ -628,8 +831,13 @@
 
 # Uninstall if "--uninstall"
 if [ -n "$UNINSTALL" ]; then
-    ${OSM_DEVOPS}/installers/uninstall_osm.sh "$@" || \
-    FATAL_TRACK community_uninstall "uninstall_osm.sh failed"
+    if [ -n "$CHARMED" ]; then
+        ${OSM_DEVOPS}/installers/charmed_uninstall.sh -R $RELEASE -r $REPOSITORY -u $REPOSITORY_BASE -D $OSM_DEVOPS -t $DOCKER_TAG "$@" || \
+        FATAL_TRACK charmed_uninstall "charmed_uninstall.sh failed"
+    else
+        ${OSM_DEVOPS}/installers/uninstall_osm.sh "$@" || \
+        FATAL_TRACK community_uninstall "uninstall_osm.sh failed"
+    fi
     echo -e "\nDONE"
     exit 0
 fi