ubuntu20 as base image for OSM installation
[osm/devops.git] / installers / full_install_osm.sh
index 03be9a6..7413bd6 100755 (executable)
@@ -36,7 +36,8 @@ function usage(){
     echo -e "     -P <VCA pubkey> use VCA/juju public key file"
     echo -e "     -A <VCA apiproxy> use VCA/juju API proxy"
     echo -e "     --pla:          install the PLA module for placement support"
-    echo -e "     --ng-sa:        install Airflow and Pushgateway to get VNF and NS status (experimental)"
+    echo -e "     --old-sa:       install old Service Assurance framework (MON, POL); do not install Airflow and Pushgateway"
+    echo -e "     --ng-sa:        install new Service Assurance framework (Airflow, AlertManager and Pushgateway)  (enabled by default)"
     echo -e "     -m <MODULE>:    install OSM but only rebuild or pull the specified docker images (NG-UI, NBI, LCM, RO, MON, POL, PLA, KAFKA, MONGO, PROMETHEUS, PROMETHEUS-CADVISOR, KEYSTONE-DB, NONE)"
     echo -e "     -o <ADDON>:     ONLY (un)installs one of the addons (k8s_monitor, ng-sa)"
     echo -e "     -O <openrc file path/cloud name>: Install OSM to an OpenStack infrastructure. <openrc file/cloud name> is required. If a <cloud name> is used, the clouds.yaml file should be under ~/.config/openstack/ or /etc/openstack/"
@@ -215,13 +216,12 @@ function docker_login() {
     [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
 }
 
-function generate_docker_images() {
+function pull_docker_images() {
     [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
-    echo "Pulling and generating docker images"
-    [ -n "${DOCKER_REGISTRY_URL}" ] && docker_login
-
     echo "Pulling docker images"
+    [ -n "${DOCKER_REGISTRY_URL}" ] && docker_login
 
+    echo "Pulling non-OSM docker images"
     if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q KAFKA ; then
         sg docker -c "docker pull wurstmeister/zookeeper" || FATAL "cannot get zookeeper docker image"
         sg docker -c "docker pull wurstmeister/kafka:${KAFKA_TAG}" || FATAL "cannot get kafka docker image"
@@ -248,48 +248,51 @@ function generate_docker_images() {
         sg docker -c "docker pull mysql:5" || FATAL "cannot get mysql docker image"
     fi
 
-    if [ -n "$PULL_IMAGES" ]; then
-        echo "Pulling OSM docker images"
-        for module in MON POL NBI KEYSTONE RO LCM NG-UI PLA osmclient; do
+    echo "Pulling OSM docker images"
+    for module in MON POL NBI KEYSTONE RO LCM NG-UI PLA osmclient Airflow; do
+        module_lower=${module,,}
+        if [ $module == "PLA" -a ! -n "$INSTALL_PLA" ]; then
+            continue
+        fi
+        module_tag="${OSM_DOCKER_TAG}"
+        if [ -n "${MODULE_DOCKER_TAG}" ] && echo $TO_REBUILD | grep -q $module ; then
+            module_tag="${MODULE_DOCKER_TAG}"
+        fi
+        echo "Pulling ${DOCKER_REGISTRY_URL}${DOCKER_USER}/${module_lower}:${module_tag} docker image"
+        sg docker -c "docker pull ${DOCKER_REGISTRY_URL}${DOCKER_USER}/${module_lower}:${module_tag}" || FATAL "cannot pull $module docker image"
+    done
+
+    echo "Finished pulling docker images"
+    [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
+}
+
+function generate_docker_images() {
+    [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
+    echo "Generating docker images"
+    _build_from=$COMMIT_ID
+    [ -z "$_build_from" ] && _build_from="latest"
+    echo "OSM Docker images generated from $_build_from"
+    LWTEMPDIR="$(mktemp -d -q --tmpdir "installosmlight.XXXXXX")"
+    trap 'rm -rf "${LWTEMPDIR}"' EXIT
+    for module in MON POL NBI KEYSTONE RO LCM NG-UI PLA; do
+        if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q ${module} ; then
             module_lower=${module,,}
             if [ $module == "PLA" -a ! -n "$INSTALL_PLA" ]; then
                 continue
             fi
-            module_tag="${OSM_DOCKER_TAG}"
-            if [ -n "${MODULE_DOCKER_TAG}" ] && echo $TO_REBUILD | grep -q $module ; then
-                module_tag="${MODULE_DOCKER_TAG}"
-            fi
-            echo "Pulling ${DOCKER_REGISTRY_URL}${DOCKER_USER}/${module_lower}:${module_tag} docker image"
-            sg docker -c "docker pull ${DOCKER_REGISTRY_URL}${DOCKER_USER}/${module_lower}:${module_tag}" || FATAL "cannot pull $module docker image"
-        done
-    else
-        _build_from=$COMMIT_ID
-        [ -z "$_build_from" ] && _build_from="latest"
-        echo "OSM Docker images generated from $_build_from"
-        LWTEMPDIR="$(mktemp -d -q --tmpdir "installosmlight.XXXXXX")"
-        trap 'rm -rf "${LWTEMPDIR}"' EXIT
-        for module in MON POL NBI KEYSTONE RO LCM NG-UI PLA; do
-            if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q ${module} ; then
-                module_lower=${module,,}
-                if [ $module == "PLA" -a ! -n "$INSTALL_PLA" ]; then
-                    continue
-                fi
-                git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/$module
-                git -C ${LWTEMPDIR}/${module} checkout ${COMMIT_ID}
-                sg docker -c "docker build ${LWTEMPDIR}/${module} -f ${LWTEMPDIR}/${module}/docker/Dockerfile -t ${DOCKER_USER}/${module_lower} --no-cache" || FATAL "cannot build ${module} docker image"
-            fi
-        done
-        if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q osmclient; then
-            BUILD_ARGS+=(--build-arg REPOSITORY="$REPOSITORY")
-            BUILD_ARGS+=(--build-arg RELEASE="$RELEASE")
-            BUILD_ARGS+=(--build-arg REPOSITORY_KEY="$REPOSITORY_KEY")
-            BUILD_ARGS+=(--build-arg REPOSITORY_BASE="$REPOSITORY_BASE")
-            sg docker -c "docker build -t ${DOCKER_USER}/osmclient ${BUILD_ARGS[@]} -f $OSM_DEVOPS/docker/osmclient ."
+            git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/$module
+            git -C ${LWTEMPDIR}/${module} checkout ${COMMIT_ID}
+            sg docker -c "docker build ${LWTEMPDIR}/${module} -f ${LWTEMPDIR}/${module}/docker/Dockerfile -t ${DOCKER_USER}/${module_lower} --no-cache" || FATAL "cannot build ${module} docker image"
         fi
-        echo "Finished generation of docker images"
+    done
+    if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q osmclient; then
+        BUILD_ARGS+=(--build-arg REPOSITORY="$REPOSITORY")
+        BUILD_ARGS+=(--build-arg RELEASE="$RELEASE")
+        BUILD_ARGS+=(--build-arg REPOSITORY_KEY="$REPOSITORY_KEY")
+        BUILD_ARGS+=(--build-arg REPOSITORY_BASE="$REPOSITORY_BASE")
+        sg docker -c "docker build -t ${DOCKER_USER}/osmclient ${BUILD_ARGS[@]} -f $OSM_DEVOPS/docker/osmclient ."
     fi
-
-    echo "Finished pulling and generating docker images"
+    echo "Finished generation of docker images"
     [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
 }
 
@@ -530,7 +533,9 @@ function deploy_osm_pla_service() {
 
 function install_osm_ngsa_service() {
     [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
-    $OSM_DEVOPS/installers/install_ngsa.sh -d ${OSM_HELM_WORK_DIR} -D ${OSM_DEVOPS} -t ${OSM_DOCKER_TAG} ${DEBUG_INSTALL} || \
+    NGSA_OPTS="-d ${OSM_HELM_WORK_DIR} -D ${OSM_DEVOPS} -t ${OSM_DOCKER_TAG} -U ${DOCKER_USER} ${DEBUG_INSTALL}"
+    [ -n "${DOCKER_REGISTRY_URL}" ] && NGSA_OPTS="${NGSA_OPTS} -r ${DOCKER_REGISTRY_URL}"
+    $OSM_DEVOPS/installers/install_ngsa.sh ${NGSA_OPTS} || \
     FATAL_TRACK install_osm_ngsa_service "install_ngsa.sh failed"
     [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
 }
@@ -790,7 +795,8 @@ function install_osm() {
     fi
 
     # Deploy OSM services
-    [ -z "$DOCKER_NOBUILD" ] && generate_docker_images
+    [ -z "$DOCKER_NOBUILD" ] && pull_docker_images
+    [ -z "$DOCKER_NOBUILD" ] && [ -z "$PULL_IMAGES" ] && generate_docker_images
     track docker_images docker_images_ok
 
     generate_k8s_manifest_files
@@ -999,7 +1005,7 @@ DEBUG_INSTALL=""
 RELEASE="ReleaseTEN"
 REPOSITORY="stable"
 INSTALL_K8S_MONITOR=""
-INSTALL_NGSA=""
+INSTALL_NGSA="y"
 INSTALL_PLA=""
 INSTALL_VIMEMU=""
 LXD_REPOSITORY_BASE="https://osm-download.etsi.org/repository/osm/lxd"
@@ -1199,6 +1205,7 @@ while getopts ":a:b:r:n:k:u:R:D:o:O:m:N:H:S:s:t:U:P:A:l:L:K:d:p:T:f:F:-: hy" o;
             [ "${OPTARG}" == "tag" ] && continue
             [ "${OPTARG}" == "registry" ] && continue
             [ "${OPTARG}" == "pla" ] && INSTALL_PLA="y" && continue
+            [ "${OPTARG}" == "old-sa" ] && INSTALL_NGSA="" && continue
             [ "${OPTARG}" == "ng-sa" ] && INSTALL_NGSA="y" && continue
             [ "${OPTARG}" == "volume" ] && OPENSTACK_ATTACH_VOLUME="true" && continue
             [ "${OPTARG}" == "nocachelxdimages" ] && continue