Feature 10892/10893/8460: refactor of OSM installer
This change covers:
- Feature 10892. Installation of OSM on top of Ubuntu20.04. Changes
are mostly in full_install_osm.sh and are related to the use of new
versions of kubeadm and docker-ce. In addition, changes in Jenkins
groovy files have been done to indicate the base image to be used,
either 18.04 or 20.04.
- Feature 10893. Better tracking of installation. The code for tracking
in in common/track. There is a function track that it is called in
the different steps of the installation.
- Feature 8460: Cleanup old code in full_install_osm.sh. The script
full_install_osm.sh has been split in different scripts performing
specific tasks, thus simplifying the installer: install_docker_ce.sh,
install_juju.sh and install_kubeadm_cluster.sh.
Change-Id: I1e388ec56285337eaf34f68470aa5a9b23ff45ff
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
diff --git a/common/all_funcs b/common/all_funcs
index d469373..f6c48fa 100644
--- a/common/all_funcs
+++ b/common/all_funcs
@@ -22,7 +22,7 @@
export OSM_DEVOPS=$(realpath ${BASH_SOURCE[0]} )
fi
-for file in logging config container git_functions; do
+for file in logging config container git_functions track; do
. ${OSM_DEVOPS}/common/$file
INFO "$file sourced"
done
diff --git a/common/logging b/common/logging
index a95b563..a48e01d 100644
--- a/common/logging
+++ b/common/logging
@@ -45,11 +45,11 @@
}
INFO() {
- echo "## $(date) ${FUNCNAME[1]}: $*" >&2
+ echo "## $(date) ${FUNCNAME[1]}: INFO: $*" >&2
}
DEBUG() {
- echo "# $(date) ${FUNCNAME[1]}: $*" >&2
+ echo "# $(date) ${FUNCNAME[1]}: DEBUG: $*" >&2
}
CMD() {
diff --git a/common/track b/common/track
new file mode 100644
index 0000000..627c680
--- /dev/null
+++ b/common/track
@@ -0,0 +1,86 @@
+#!/bin/bash
+# This file is meant to be SOURCED
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+function track(){
+# Tracks events by sending HTTP GET requests with query strings to a web server
+# - First argument: event name
+# - Rest of arguments (if they exist): tuples of operation-value-comment-tags
+# - operation: particular operation in an event (if it is not provided, the operation will be named after the event)
+# - value: particular value for an operation
+# - comment
+# - none will be passed when empty
+# - will be parsed to replace spaces by underscores
+# - tags
+# - none will be passed when empty
+# - will be parsed to replace spaces by ~
+
+ if [ $# -lt 1 ]; then
+ echo "Unexpected error in track function. At least 1 arg is expected: event"
+ return 1
+ fi
+
+ osm_track_event_name=$1
+
+ ctime=`date +%s`
+
+ query_string=""
+ query_string="${query_string}&installation_id=${OSM_TRACK_INSTALLATION_ID}"
+ query_string="${query_string}&local_ts=${ctime}"
+ query_string="${query_string}&event=${osm_track_event_name}"
+
+ shift 1
+ if [ $# -eq 0 ]; then
+ operation="${osm_track_event_name}"
+ value=""
+ comment=""
+ tags=""
+ final_query_string="${query_string}"
+ final_query_string="${final_query_string}&operation=${operation}"
+ final_query_string="${final_query_string}&value=${value}"
+ final_query_string="${final_query_string}&comment=${comment}"
+ final_query_string="${final_query_string}&tags=${tags}"
+ url="https://osm.etsi.org/InstallLog.php?${final_query_string}"
+ echo "Track $osm_track_event_name $operation: ${url}"
+ wget -q -O /dev/null $url
+ else
+ while (( "$#" > 0 )); do
+ operation="${1:-${osm_track_event_name}}"
+ shift 1
+ value="${1:-}"
+ shift 1
+ comment="${1:-}"
+ shift 1
+ comment="${comment// /_}"
+ tags="${1:-}"
+ shift 1
+ tags="${tags//,/\~}"
+ [ "$value" == "none" ] && value=""
+ [ "$comment" == "none" ] && comment=""
+ [ "$tags" == "none" ] && tags=""
+ final_query_string="${query_string}"
+ final_query_string="${final_query_string}&operation=${operation}"
+ final_query_string="${final_query_string}&value=${value}"
+ final_query_string="${final_query_string}&comment=${comment}"
+ final_query_string="${final_query_string}&tags=${tags}"
+ url="https://osm.etsi.org/InstallLog.php?${final_query_string}"
+ echo "Track $osm_track_event_name $operation: ${url}"
+ wget -q -O /dev/null $url
+ done
+ fi
+ return 0
+}
+
+