3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
17 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of
function
18 echo -e "usage: $0 [OPTIONS]"
19 echo -e "Install OSM from binaries or source code (by default, from binaries)"
21 echo -e " -h / --help: print this help"
22 echo -e " -y: do not prompt for confirmation, assumes yes"
23 echo -e " -r <repo>: use specified repository name for osm packages"
24 echo -e " -R <release>: use specified release for osm binaries (deb packages, lxd images, ...)"
25 echo -e " -u <repo base>: use specified repository url for osm packages"
26 echo -e " -k <repo key>: use specified repository public key url"
27 echo -e " -b <refspec>: install OSM from source code using a specific branch (master, v2.0, ...) or tag"
28 echo -e " -b master (main dev branch)"
29 echo -e " -b v2.0 (v2.0 branch)"
30 echo -e " -b tags/v1.1.0 (a specific tag)"
32 echo -e " -a <apt proxy url>: use this apt proxy url when downloading apt packages (air-gapped installation)"
33 echo -e " -s <namespace> namespace when installed using k8s, default is osm"
34 echo -e " -H <VCA host> use specific juju host controller IP"
35 echo -e " -S <VCA secret> use VCA/juju secret key"
36 echo -e " -P <VCA pubkey> use VCA/juju public key file"
37 echo -e " -A <VCA apiproxy> use VCA/juju API proxy"
38 echo -e " --pla: install the PLA module for placement support"
39 echo -e " --old-sa: install old Service Assurance framework (MON, POL); do not install Airflow and Pushgateway"
40 echo -e " --ng-sa: install new Service Assurance framework (Airflow, AlertManager and Pushgateway) (enabled by default)"
41 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)"
42 echo -e " -o <ADDON>: ONLY (un)installs one of the addons (k8s_monitor, ng-sa)"
43 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/"
44 echo -e " -N <openstack public network name/ID>: Public network name required to setup OSM to OpenStack"
45 echo -e " -f <path to SSH public key>: Public SSH key to use to deploy OSM to OpenStack"
46 echo -e " -F <path to cloud-init file>: Cloud-Init userdata file to deploy OSM to OpenStack"
47 echo -e " -D <devops path> use local devops installation path"
48 echo -e " -w <work dir> Location to store runtime installation"
49 echo -e " -t <docker tag> specify osm docker tag (default is latest)"
50 echo -e " -l: LXD cloud yaml file"
51 echo -e " -L: LXD credentials yaml file"
52 echo -e " -K: Specifies the name of the controller to use - The controller must be already bootstrapped"
53 echo -e " -d <docker registry URL> use docker registry URL instead of dockerhub"
54 echo -e " -p <docker proxy URL> set docker proxy URL as part of docker CE configuration"
55 echo -e " -T <docker tag> specify docker tag for the modules specified with option -m"
56 echo -e " --debug: debug mode"
57 echo -e " --nocachelxdimages: do not cache local lxd images, do not create cronjob for that cache (will save installation time, might affect instantiation time)"
58 echo -e " --cachelxdimages: cache local lxd images, create cronjob for that cache (will make installation longer)"
59 echo -e " --nolxd: do not install and configure LXD, allowing unattended installations (assumes LXD is already installed and confifured)"
60 echo -e " --nodocker: do not install docker, do not initialize a swarm (assumes docker is already installed and a swarm has been initialized)"
61 echo -e " --nojuju: do not juju, assumes already installed"
62 echo -e " --nodockerbuild:do not build docker images (use existing locally cached images)"
63 echo -e " --nohostports: do not expose docker ports to host (useful for creating multiple instances of osm on the same host)"
64 echo -e " --nohostclient: do not install the osmclient"
65 echo -e " --uninstall: uninstall OSM: remove the containers and delete NAT rules"
66 echo -e " --source: install OSM from source code using the latest stable tag"
67 echo -e " --develop: (deprecated, use '-b master') install OSM from source code using the master branch"
68 echo -e " --pullimages: pull/run osm images from docker.io/opensourcemano"
69 echo -e " --k8s_monitor: install the OSM kubernetes monitoring with prometheus and grafana"
70 echo -e " --volume: create a VM volume when installing to OpenStack"
71 echo -e " --showopts: print chosen options and exit (only for debugging)"
72 echo -e " --charmed: Deploy and operate OSM with Charms on k8s"
73 echo -e " [--bundle <bundle path>]: Specify with which bundle to deploy OSM with charms (--charmed option)"
74 echo -e " [--k8s <kubeconfig path>]: Specify with which kubernetes to deploy OSM with charms (--charmed option)"
75 echo -e " [--vca <name>]: Specifies the name of the controller to use - The controller must be already bootstrapped (--charmed option)"
76 echo -e " [--small-profile]: Do not install and configure LXD which aims to use only K8s Clouds (--charmed option)"
77 echo -e " [--lxd <yaml path>]: Takes a YAML file as a parameter with the LXD Cloud information (--charmed option)"
78 echo -e " [--lxd-cred <yaml path>]: Takes a YAML file as a parameter with the LXD Credentials information (--charmed option)"
79 echo -e " [--microstack]: Installs microstack as a vim. (--charmed option)"
80 echo -e " [--overlay]: Add an overlay to override some defaults of the default bundle (--charmed option)"
81 echo -e " [--ha]: Installs High Availability bundle. (--charmed option)"
82 echo -e " [--tag]: Docker image tag. (--charmed option)"
83 echo -e " [--registry]: Docker registry with optional credentials as user:pass@hostname:port (--charmed option)"
84 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of
function
87 # takes a juju/accounts.yaml file and returns the password specific
88 # for a controller. I wrote this using only bash tools to minimize
89 # additions of other packages
90 function parse_juju_password
{
91 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of
function
92 password_file
="${HOME}/.local/share/juju/accounts.yaml"
93 local controller_name
=$1
94 local s
='[[:space:]]*' w
='[a-zA-Z0-9_-]*' fs
=$
(echo @|
tr @
'\034')
95 sed -ne "s|^\($s\):|\1|" \
96 -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
97 -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $password_file |
98 awk -F$fs -v controller
=$controller_name '{
99 indent = length($1)/2;
101 for (i in vname) {if (i > indent) {delete vname[i]}}
102 if (length($3) > 0) {
103 vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
104 if (match(vn,controller) && match($2,"password")) {
109 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of
function
112 function set_vca_variables
() {
113 OSM_VCA_CLOUDNAME
="lxd-cloud"
114 [ -n "$OSM_VCA_HOST" ] && OSM_VCA_CLOUDNAME
="localhost"
115 if [ -z "$OSM_VCA_HOST" ]; then
116 [ -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}'`
117 [ -n "$CONTROLLER_NAME" ] && OSM_VCA_HOST
=`juju show-controller $CONTROLLER_NAME |grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'`
118 [ -z "$OSM_VCA_HOST" ] && FATAL
"Cannot obtain juju controller IP address"
120 if [ -z "$OSM_VCA_SECRET" ]; then
121 [ -z "$CONTROLLER_NAME" ] && OSM_VCA_SECRET
=$
(parse_juju_password
$OSM_NAMESPACE)
122 [ -n "$CONTROLLER_NAME" ] && OSM_VCA_SECRET
=$
(parse_juju_password
$CONTROLLER_NAME)
123 [ -z "$OSM_VCA_SECRET" ] && FATAL
"Cannot obtain juju secret"
125 if [ -z "$OSM_VCA_PUBKEY" ]; then
126 OSM_VCA_PUBKEY
=$
(cat $HOME/.local
/share
/juju
/ssh
/juju_id_rsa.pub
)
127 [ -z "$OSM_VCA_PUBKEY" ] && FATAL
"Cannot obtain juju public key"
129 if [ -z "$OSM_VCA_CACERT" ]; then
130 [ -z "$CONTROLLER_NAME" ] && OSM_VCA_CACERT
=$
(juju controllers
--format json | jq
-r --arg controller
$OSM_NAMESPACE '.controllers[$controller]["ca-cert"]' | base64 |
tr -d \\n
)
131 [ -n "$CONTROLLER_NAME" ] && OSM_VCA_CACERT
=$
(juju controllers
--format json | jq
-r --arg controller
$CONTROLLER_NAME '.controllers[$controller]["ca-cert"]' | base64 |
tr -d \\n
)
132 [ -z "$OSM_VCA_CACERT" ] && FATAL
"Cannot obtain juju CA certificate"
136 function generate_secret
() {
137 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of
function
138 head /dev
/urandom |
tr -dc A-Za-z0-9 |
head -c 32
139 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of
function
142 function check_packages
() {
144 echo -e "Checking required packages: ${NEEDED_PACKAGES}"
145 for PACKAGE
in ${NEEDED_PACKAGES} ; do
147 if [ $?
-ne 0 ]; then
148 echo -e "Package ${PACKAGE} is not installed."
149 echo -e "Updating apt-cache ..."
151 echo -e "Installing ${PACKAGE} ..."
152 sudo apt-get
install -y ${PACKAGE} || FATAL
"failed to install ${PACKAGE}"
155 echo -e "Required packages are present: ${NEEDED_PACKAGES}"
159 # ask to the user and parse a response among 'y', 'yes', 'n' or 'no'. Case insensitive
160 # Params: $1 text to ask; $2 Action by default, can be 'y' for yes, 'n' for no, other or empty for not allowed
161 # Return: true(0) if user type 'yes'; false (1) if user type 'no'
162 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of
function
163 read -e -p "$1" USER_CONFIRMATION
165 [ -z "$USER_CONFIRMATION" ] && [ "$2" == 'y' ] && return 0
166 [ -z "$USER_CONFIRMATION" ] && [ "$2" == 'n' ] && return 1
167 [ "${USER_CONFIRMATION,,}" == "yes" ] ||
[ "${USER_CONFIRMATION,,}" == "y" ] && return 0
168 [ "${USER_CONFIRMATION,,}" == "no" ] ||
[ "${USER_CONFIRMATION,,}" == "n" ] && return 1
169 read -e -p "Please type 'yes' or 'no': " USER_CONFIRMATION
171 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of
function
174 function install_osmclient
(){
175 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of
function
176 CLIENT_RELEASE
=${RELEASE#"-R "}
177 CLIENT_REPOSITORY_KEY
="OSM%20ETSI%20Release%20Key.gpg"
178 CLIENT_REPOSITORY
=${REPOSITORY#"-r "}
179 CLIENT_REPOSITORY_BASE
=${REPOSITORY_BASE#"-u "}
180 key_location
=$CLIENT_REPOSITORY_BASE/$CLIENT_RELEASE/$CLIENT_REPOSITORY_KEY
181 curl
$key_location | sudo APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE
=1 apt-key add
-
182 sudo add-apt-repository
-y "deb [arch=amd64] $CLIENT_REPOSITORY_BASE/$CLIENT_RELEASE $CLIENT_REPOSITORY osmclient IM"
184 sudo apt-get
install -y python3-pip
185 sudo
-H LC_ALL
=C python3
-m pip
install -U pip
186 sudo
-H LC_ALL
=C python3
-m pip
install -U python-magic pyangbind verboselogs
187 sudo apt-get
install -y python3-osm-im python3-osmclient
188 if [ -f /usr
/lib
/python
3/dist-packages
/osm_im
/requirements.txt
]; then
189 python3
-m pip
install -r /usr
/lib
/python
3/dist-packages
/osm_im
/requirements.txt
191 if [ -f /usr
/lib
/python
3/dist-packages
/osmclient
/requirements.txt
]; then
192 sudo apt-get
install -y libcurl4-openssl-dev libssl-dev libmagic1
193 python3
-m pip
install -r /usr
/lib
/python
3/dist-packages
/osmclient
/requirements.txt
195 [ -z "$INSTALL_LIGHTWEIGHT" ] && export OSM_HOSTNAME
=`lxc list | awk '($2=="SO-ub"){print $6}'`
196 [ -z "$INSTALL_LIGHTWEIGHT" ] && export OSM_RO_HOSTNAME
=`lxc list | awk '($2=="RO"){print $6}'`
197 echo -e "\nOSM client installed"
198 if [ -z "$INSTALL_LIGHTWEIGHT" ]; then
199 echo -e "You might be interested in adding the following OSM client env variables to your .bashrc file:"
200 echo " export OSM_HOSTNAME=${OSM_HOSTNAME}"
201 echo " export OSM_RO_HOSTNAME=${OSM_RO_HOSTNAME}"
203 echo -e "OSM client assumes that OSM host is running in localhost (127.0.0.1)."
204 echo -e "In case you want to interact with a different OSM host, you will have to configure this env variable in your .bashrc file:"
205 echo " export OSM_HOSTNAME=<OSM_host>"
207 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of
function
211 function docker_login
() {
212 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of
function
214 [ -z "${DEBUG_INSTALL}" ] || DEBUG
"Docker registry user: ${DOCKER_REGISTRY_USER}"
215 sg docker
-c "docker login -u ${DOCKER_REGISTRY_USER} -p ${DOCKER_REGISTRY_PASSWORD} --password-stdin"
216 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of
function
219 function pull_docker_images
() {
220 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of
function
221 echo "Pulling docker images"
222 [ -n "${DOCKER_REGISTRY_URL}" ] && docker_login
224 echo "Pulling non-OSM docker images"
225 if [ -z "$TO_REBUILD" ] ||
echo $TO_REBUILD |
grep -q KAFKA
; then
226 sg docker
-c "docker pull wurstmeister/zookeeper" || FATAL
"cannot get zookeeper docker image"
227 sg docker
-c "docker pull wurstmeister/kafka:${KAFKA_TAG}" || FATAL
"cannot get kafka docker image"
230 if [ -z "$TO_REBUILD" ] ||
echo $TO_REBUILD |
grep -q PROMETHEUS
; then
231 sg docker
-c "docker pull prom/prometheus:${PROMETHEUS_TAG}" || FATAL
"cannot get prometheus docker image"
234 if [ -z "$TO_REBUILD" ] ||
echo $TO_REBUILD |
grep -q PROMETHEUS-CADVISOR
; then
235 sg docker
-c "docker pull google/cadvisor:${PROMETHEUS_CADVISOR_TAG}" || FATAL
"cannot get prometheus cadvisor docker image"
238 if [ -z "$TO_REBUILD" ] ||
echo $TO_REBUILD |
grep -q GRAFANA
; then
239 sg docker
-c "docker pull grafana/grafana:${GRAFANA_TAG}" || FATAL
"cannot get grafana docker image"
240 sg docker
-c "docker pull kiwigrid/k8s-sidecar:${KIWIGRID_K8S_SIDECAR_TAG}" || FATAL
"cannot get kiwigrid k8s-sidecar docker image"
243 if [ -z "$TO_REBUILD" ] ||
echo $TO_REBUILD |
grep -q NBI ||
echo $TO_REBUILD |
grep -q KEYSTONE-DB
; then
244 sg docker
-c "docker pull mariadb:${KEYSTONEDB_TAG}" || FATAL
"cannot get keystone-db docker image"
247 if [ -z "$TO_REBUILD" ] ||
echo $TO_REBUILD |
grep -q RO
; then
248 sg docker
-c "docker pull mysql:5" || FATAL
"cannot get mysql docker image"
251 list_of_modules
="MON NBI KEYSTONE RO LCM NG-UI osmclient"
252 if [ -n "$INSTALL_NGSA" ]; then
253 list_of_modules
="${list_of_modules} Airflow Webhook"
255 list_of_modules
="${list_of_modules} POL"
257 if [ -n "$INSTALL_PLA" ]; then
258 list_of_modules
="${list_of_modules} PLA"
260 echo "Pulling OSM docker images for the following modules: ${list_of_modules}"
261 for module
in ${list_of_modules}; do
262 module_lower
=${module,,}
263 module_tag
="${OSM_DOCKER_TAG}"
264 if [ -n "${MODULE_DOCKER_TAG}" ] && echo $TO_REBUILD |
grep -q $module ; then
265 module_tag
="${MODULE_DOCKER_TAG}"
267 echo "Pulling ${DOCKER_REGISTRY_URL}${DOCKER_USER}/${module_lower}:${module_tag} docker image"
268 sg docker
-c "docker pull ${DOCKER_REGISTRY_URL}${DOCKER_USER}/${module_lower}:${module_tag}" || FATAL
"cannot pull $module docker image"
271 echo "Finished pulling docker images"
272 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of
function
275 function generate_docker_images
() {
276 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of
function
277 echo "Generating docker images"
278 _build_from
=$COMMIT_ID
279 [ -z "$_build_from" ] && _build_from
="latest"
280 echo "OSM Docker images generated from $_build_from"
281 LWTEMPDIR
="$(mktemp -d -q --tmpdir "installosmlight.XXXXXX
")"
282 trap 'rm -rf "${LWTEMPDIR}"' EXIT
283 for module
in MON POL NBI KEYSTONE RO LCM NG-UI PLA
; do
284 if [ -z "$TO_REBUILD" ] ||
echo $TO_REBUILD |
grep -q ${module} ; then
285 module_lower
=${module,,}
286 if [ $module == "PLA" -a ! -n "$INSTALL_PLA" ]; then
289 git
-C ${LWTEMPDIR} clone https
://osm.etsi.org
/gerrit
/osm
/$module
290 git
-C ${LWTEMPDIR}/${module} checkout ${COMMIT_ID}
291 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"
294 if [ -z "$TO_REBUILD" ] ||
echo $TO_REBUILD |
grep -q osmclient
; then
295 BUILD_ARGS
+=(--build-arg REPOSITORY
="$REPOSITORY")
296 BUILD_ARGS
+=(--build-arg RELEASE
="$RELEASE")
297 BUILD_ARGS
+=(--build-arg REPOSITORY_KEY
="$REPOSITORY_KEY")
298 BUILD_ARGS
+=(--build-arg REPOSITORY_BASE
="$REPOSITORY_BASE")
299 sg docker
-c "docker build -t ${DOCKER_USER}/osmclient ${BUILD_ARGS[@]} -f $OSM_DEVOPS/docker/osmclient ."
301 echo "Finished generation of docker images"
302 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of
function
305 function cmp_overwrite
() {
306 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of
function
309 if ! $
(cmp "${file1}" "${file2}" >/dev
/null
2>&1); then
310 if [ -f "${file2}" ]; then
311 ask_user
"The file ${file2} already exists. Overwrite (y/N)? " n && cp -b ${file1} ${file2}
313 cp -b ${file1} ${file2}
316 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
319 #deploys osm pods and services
320 function deploy_osm_services() {
321 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
322 # helm is already installed as part of install_kubeadm_cluster.sh
324 # Generate helm values to be passed with -f osm-values.yaml
325 sudo mkdir -p ${OSM_HELM_WORK_DIR}
326 sudo bash -c "cat << EOF > ${OSM_HELM_WORK_DIR}/osm-values.yaml
328 pubkey: \"${OSM_VCA_PUBKEY}\"
331 # Generate helm values to be passed with --set
333 # OSM_HELM_OPTS="${OSM_HELM_OPTS} --set nbi.useOsmSecret
=false
"
334 OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.image.repositoryBase=${DOCKER_REGISTRY_URL}${DOCKER_USER}"
335 OSM_HELM_OPTS="${OSM_HELM_OPTS} --set mysql.dbHostPath
=${OSM_NAMESPACE_VOL}"
336 OSM_HELM_OPTS="${OSM_HELM_OPTS} --set mon.config.OS_NOTIFIER_URI
=http
://${OSM_DEFAULT_IP}:8662"
337 OSM_HELM_OPTS="${OSM_HELM_OPTS} --set vca.
host=${OSM_VCA_HOST}"
338 OSM_HELM_OPTS="${OSM_HELM_OPTS} --set vca.secret
=${OSM_VCA_SECRET}"
339 OSM_HELM_OPTS="${OSM_HELM_OPTS} --set vca.cacert
=${OSM_VCA_CACERT}"
340 [ -n "$OSM_VCA_APIPROXY" ] && OSM_HELM_OPTS="${OSM_HELM_OPTS} --set lcm.config.OSMLCM_VCA_APIPROXY
=${OSM_VCA_APIPROXY}"
341 [ ! "$OSM_DOCKER_TAG" == "13" ] && OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.image.tag
=${OSM_DOCKER_TAG}"
342 [ -n "${INSTALL_NGSA}" ] || OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.oldServiceAssurance
=true
"
344 echo "helm
-n $OSM_NAMESPACE install $OSM_NAMESPACE $OSM_DEVOPS/installers
/helm
/osm
-f ${OSM_HELM_WORK_DIR}/osm-values.yaml
${OSM_HELM_OPTS}"
345 helm -n $OSM_NAMESPACE install $OSM_NAMESPACE $OSM_DEVOPS/installers/helm/osm -f ${OSM_HELM_WORK_DIR}/osm-values.yaml ${OSM_HELM_OPTS}
347 # Override existing values.yaml with the final values.yaml used to install OSM
348 helm -n $OSM_NAMESPACE get values $OSM_NAMESPACE | sudo tee -a ${OSM_HELM_WORK_DIR}/osm-values.yaml
349 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
352 #deploy charmed services
353 function deploy_charmed_services() {
354 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
355 juju add-model $OSM_NAMESPACE $OSM_VCA_K8S_CLOUDNAME
356 juju deploy ch:mongodb-k8s -m $OSM_NAMESPACE
357 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
360 function install_osm_ngsa_service() {
361 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
362 NGSA_OPTS="-d ${OSM_HELM_WORK_DIR} -D ${OSM_DEVOPS} -t ${OSM_DOCKER_TAG} -U ${DOCKER_USER} ${DEBUG_INSTALL}"
363 [ -n "${DOCKER_REGISTRY_URL}" ] && NGSA_OPTS="${NGSA_OPTS} -r ${DOCKER_REGISTRY_URL}"
364 $OSM_DEVOPS/installers/install_ngsa.sh ${NGSA_OPTS} || \
365 FATAL_TRACK install_osm_ngsa_service "install_ngsa.sh failed
"
366 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
369 function add_local_k8scluster() {
370 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
371 /usr/bin/osm --all-projects vim-create \
372 --name _system-osm-vim \
373 --account_type dummy \
374 --auth_url http://dummy \
375 --user osm --password osm --tenant osm \
376 --description "dummy
" \
377 --config '{management_network_name: mgmt}'
378 /usr/bin/osm --all-projects k8scluster-add \
379 --creds ${HOME}/.kube/config \
380 --vim _system-osm-vim \
381 --k8s-nets '{"net1
": null}' \
383 --description "OSM Internal Cluster
" \
385 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
388 function configure_apt_proxy() {
389 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
391 OSM_APT_PROXY_FILE="/etc
/apt
/apt.conf.d
/osm-apt
"
392 echo "Configuring apt proxy
in file ${OSM_APT_PROXY_FILE}"
393 if [ ! -f ${OSM_APT_PROXY_FILE} ]; then
394 sudo bash -c "cat <<EOF > ${OSM_APT_PROXY}
395 Acquire::http { Proxy \"${OSM_APT_PROXY}\"; }
398 sudo sed -i "s|Proxy.
*|Proxy
\"${OSM_APT_PROXY}\"; }|
" ${OSM_APT_PROXY_FILE}
400 sudo apt-get update || FATAL "Configured apt proxy
, but couldn
't run 'apt-get update
'. Check ${OSM_APT_PROXY_FILE}"
401 track prereq apt_proxy_configured_ok
402 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
405 function ask_proceed() {
406 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
408 [ -z "$ASSUME_YES" ] && ! ask_user "The installation will do the following
409 1. Install and configure LXD
412 4. Disable swap space
413 5. Install and initialize Kubernetes
415 Do you want to proceed (Y/n)? " y && echo "Cancelled!" && exit 1
417 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
420 function check_osm_behind_proxy() {
421 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
423 export OSM_BEHIND_PROXY=""
424 export OSM_PROXY_ENV_VARIABLES=""
425 [ -n "${http_proxy}" ] && OSM_BEHIND_PROXY="y" && echo "http_proxy=${http_proxy}" && OSM_PROXY_ENV_VARIABLES="${OSM_PROXY_ENV_VARIABLES} http_proxy"
426 [ -n "${https_proxy}" ] && OSM_BEHIND_PROXY="y" && echo "https_proxy=${https_proxy}" && OSM_PROXY_ENV_VARIABLES="${OSM_PROXY_ENV_VARIABLES} https_proxy"
427 [ -n "${HTTP_PROXY}" ] && OSM_BEHIND_PROXY="y" && echo "HTTP_PROXY=${HTTP_PROXY}" && OSM_PROXY_ENV_VARIABLES="${OSM_PROXY_ENV_VARIABLES} HTTP_PROXY"
428 [ -n "${HTTPS_PROXY}" ] && OSM_BEHIND_PROXY="y" && echo "https_proxy=${HTTPS_PROXY}" && OSM_PROXY_ENV_VARIABLES="${OSM_PROXY_ENV_VARIABLES} HTTPS_PROXY"
429 [ -n "${no_proxy}" ] && echo "no_proxy=${no_proxy}" && OSM_PROXY_ENV_VARIABLES="${OSM_PROXY_ENV_VARIABLES} no_proxy"
430 [ -n "${NO_PROXY}" ] && echo "NO_PROXY=${NO_PROXY}" && OSM_PROXY_ENV_VARIABLES="${OSM_PROXY_ENV_VARIABLES} NO_PROXY"
432 echo "OSM_BEHIND_PROXY=${OSM_BEHIND_PROXY}"
433 echo "OSM_PROXY_ENV_VARIABLES=${OSM_PROXY_ENV_VARIABLES}"
435 if [ -n "${OSM_BEHIND_PROXY}" ]; then
436 [ -z "$ASSUME_YES" ] && ! ask_user "
437 The following env variables have been found for the current user:
438 ${OSM_PROXY_ENV_VARIABLES}.
440 This suggests that this machine is behind a proxy and a special configuration is required.
441 The installer will install Docker CE, LXD and Juju to work behind a proxy using those
444 Take into account that the installer uses apt, curl, wget, docker, lxd, juju and snap.
445 Depending on the program, the env variables to work behind a proxy might be different
446 (e.g. http_proxy vs HTTP_PROXY).
448 For that reason, it is strongly recommended that at least http_proxy, https_proxy, HTTP_PROXY
449 and HTTPS_PROXY are defined.
451 Finally, some of the programs (apt, snap) those programs are run as sudoer, requiring that
452 those env variables are also set for root user. If you are not sure whether those variables
453 are configured for the root user, you can stop the installation now.
455 Do you want to proceed with the installation (Y/n)? " y && echo "Cancelled!" && exit 1
457 echo "This machine is not behind a proxy"
460 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
463 function find_devops_folder() {
464 if [ -z "$OSM_DEVOPS" ]; then
465 if [ -n "$TEST_INSTALLER" ]; then
466 echo -e "\nUsing local devops repo for OSM installation"
467 OSM_DEVOPS="$(dirname $(realpath $(dirname $0)))"
469 echo -e "\nCreating temporary dir for OSM installation"
470 OSM_DEVOPS="$(mktemp -d -q --tmpdir "installosm.XXXXXX")"
471 trap 'rm -rf "$OSM_DEVOPS"' EXIT
472 git clone https://osm.etsi.org/gerrit/osm/devops.git $OSM_DEVOPS
477 function install_osm() {
478 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
482 # TODO: move this under start
483 [ -n "$DOCKER_REGISTRY_URL" ] && parse_docker_registry_url
485 check_osm_behind_proxy
487 check_packages "git wget curl tar snapd"
489 sudo snap install jq || FATAL "Could not install jq (snap package). Make sure that snap works"
493 track start release $RELEASE none none docker_tag $OSM_DOCKER_TAG none none installation_type $OSM_INSTALLATION_TYPE none none
495 track checks checkingroot_ok
496 [ "$USER" == "root" ] && FATAL "You are running the installer as root. The installer is prepared to be executed as a normal user with sudo privileges."
497 track checks noroot_ok
500 track checks proceed_ok
502 echo "Installing OSM"
504 echo "Determining IP address of the interface with the default route"
505 [ -z "$OSM_DEFAULT_IF" ] && OSM_DEFAULT_IF=$(ip route list|awk '$1=="default" {print
$5; exit}')
506 [ -z "$OSM_DEFAULT_IF" ] && OSM_DEFAULT_IF=$(route -n |awk '$1~
/^
0.0.0.0/ {print
$8; exit}')
507 [ -z "$OSM_DEFAULT_IF" ] && FATAL "Not possible to determine the interface with the default route 0.0.0.0"
508 OSM_DEFAULT_IP=`ip -o -4 a s ${OSM_DEFAULT_IF} |awk '{split($4,a
,"/"); print a
[1]; exit}'`
509 [ -z "$OSM_DEFAULT_IP" ] && FATAL "Not possible to determine the IP address of the interface with the default route"
511 # configure apt proxy
512 [ -n "$APT_PROXY_URL" ] && configure_apt_proxy $APT_PROXY_URL
514 # if no host is passed in, we need to install lxd, unless explicilty asked not to
515 if [ -z "$OSM_VCA_HOST" ] && [ -z "$INSTALL_NOLXD" ] && [ -z "$LXD_CLOUD_FILE" ]; then
516 LXD_INSTALL_OPTS="-D ${OSM_DEVOPS} -i ${OSM_DEFAULT_IF} ${DEBUG_INSTALL}"
517 [ -n "${OSM_BEHIND_PROXY}" ] && LXD_INSTALL_OPTS="${LXD_INSTALL_OPTS} -P"
518 $OSM_DEVOPS/installers/install_lxd.sh ${LXD_INSTALL_OPTS} || FATAL_TRACK lxd "install_lxd.sh failed"
521 track prereq prereqok_ok
523 if [ ! -n "$INSTALL_NODOCKER" ]; then
524 DOCKER_CE_OPTS="-D ${OSM_DEVOPS} ${DEBUG_INSTALL}"
525 [ -n "${DOCKER_PROXY_URL}" ] && DOCKER_CE_OPTS="${DOCKER_CE_OPTS} -p ${DOCKER_PROXY_URL}"
526 [ -n "${OSM_BEHIND_PROXY}" ] && DOCKER_CE_OPTS="${DOCKER_CE_OPTS} -P"
527 $OSM_DEVOPS/installers/install_docker_ce.sh ${DOCKER_CE_OPTS} || FATAL_TRACK docker_ce "install_docker_ce.sh failed"
530 track docker_ce docker_ce_ok
532 echo "Creating folders for installation"
533 [ ! -d "$OSM_WORK_DIR" ] && sudo mkdir -p $OSM_WORK_DIR
534 sudo cp -b $OSM_DEVOPS/installers/kubeadm-config.yaml $OSM_WORK_DIR/kubeadm-config.yaml
536 $OSM_DEVOPS/installers/install_kubeadm_cluster.sh -i ${OSM_DEFAULT_IP} -d ${OSM_WORK_DIR} -D ${OSM_DEVOPS} ${DEBUG_INSTALL} || \
537 FATAL_TRACK k8scluster "install_kubeadm_cluster.sh failed"
538 track k8scluster k8scluster_ok
540 JUJU_OPTS="-D ${OSM_DEVOPS} -s ${OSM_NAMESPACE} -i ${OSM_DEFAULT_IP} ${DEBUG_INSTALL} ${INSTALL_NOJUJU} ${INSTALL_CACHELXDIMAGES}"
541 [ -n "${OSM_VCA_HOST}" ] && JUJU_OPTS="$JUJU_OPTS -H ${OSM_VCA_HOST}"
542 [ -n "${LXD_CLOUD_FILE}" ] && JUJU_OPTS="$JUJU_OPTS -l ${LXD_CLOUD_FILE}"
543 [ -n "${LXD_CRED_FILE}" ] && JUJU_OPTS="$JUJU_OPTS -L ${LXD_CRED_FILE}"
544 [ -n "${CONTROLLER_NAME}" ] && JUJU_OPTS="$JUJU_OPTS -K ${CONTROLLER_NAME}"
545 [ -n "${OSM_BEHIND_PROXY}" ] && JUJU_OPTS="${JUJU_OPTS} -P"
546 $OSM_DEVOPS/installers/install_juju.sh ${JUJU_OPTS} || FATAL_TRACK juju "install_juju.sh failed"
550 # Deploy OSM services
551 [ -z "$DOCKER_NOBUILD" ] && pull_docker_images
552 [ -z "$DOCKER_NOBUILD" ] && [ -z "$PULL_IMAGES" ] && generate_docker_images
553 track docker_images docker_images_ok
555 deploy_charmed_services
556 track deploy_osm deploy_mongodb_ok
558 track deploy_osm deploy_osm_services_k8s_ok
559 if [ -n "$INSTALL_K8S_MONITOR" ]; then
560 # install OSM MONITORING
561 install_k8s_monitoring
562 track deploy_osm install_k8s_monitoring_ok
564 if [ -n "$INSTALL_NGSA" ]; then
565 # optional NGSA install
566 install_osm_ngsa_service
567 track deploy_osm install_osm_ngsa_ok
570 [ -z "$INSTALL_NOHOSTCLIENT" ] && install_osmclient
571 track osmclient osmclient_ok
573 echo -e "Checking OSM health state..."
574 $OSM_DEVOPS/installers/osm_health.sh -s ${OSM_NAMESPACE} -k || \
575 (echo -e "OSM is not healthy, but will probably converge to a healthy state soon." && \
576 echo -e "Check OSM status with: kubectl -n ${OSM_NAMESPACE} get all" && \
577 track healthchecks osm_unhealthy didnotconverge)
578 track healthchecks after_healthcheck_ok
581 track final_ops add_local_k8scluster_ok
583 arrange_docker_default_network_policy
585 wget -q -O- https://osm-download.etsi.org/ftp/osm-13.0-thirteen/README2.txt &> /dev/null
588 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
592 function install_to_openstack() {
593 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
596 FATAL "OpenStack installer requires a valid external network name"
599 # Install Pip for Python3
600 sudo apt install -y python3-pip python3-venv
601 sudo -H LC_ALL=C python3 -m pip install -U pip
603 # Create a venv to avoid conflicts with the host installation
604 python3 -m venv $OPENSTACK_PYTHON_VENV
606 source $OPENSTACK_PYTHON_VENV/bin/activate
608 # Install Ansible, OpenStack client and SDK, latest openstack version supported is Train
609 python -m pip install -U wheel
610 python -m pip install -U "python-openstackclient<=4.0.2" "openstacksdk>=0.12.0,<=0.36.2" "ansible>=2.10,<2.11"
612 # Install the Openstack cloud module (ansible>=2.10)
613 ansible-galaxy collection install openstack.cloud
615 export ANSIBLE_CONFIG="$OSM_DEVOPS/installers/openstack/ansible.cfg"
617 OSM_INSTALLER_ARGS="${REPO_ARGS[@]}"
619 ANSIBLE_VARS="external_network_name=$2 setup_volume=$3 server_name=$OPENSTACK_VM_NAME"
621 if [ -n "$OPENSTACK_SSH_KEY_FILE" ]; then
622 ANSIBLE_VARS+=" key_file=$OPENSTACK_SSH_KEY_FILE"
625 if [ -n "$OPENSTACK_USERDATA_FILE" ]; then
626 ANSIBLE_VARS+=" userdata_file=$OPENSTACK_USERDATA_FILE"
629 # Execute the Ansible playbook based on openrc or clouds.yaml
632 ansible-playbook -e installer_args="\"$OSM_INSTALLER_ARGS\"" -e "$ANSIBLE_VARS" \
633 $OSM_DEVOPS/installers/openstack/site.yml
635 ansible-playbook -e installer_args="\"$OSM_INSTALLER_ARGS\"" -e "$ANSIBLE_VARS" \
636 -e cloud_name=$1 $OSM_DEVOPS/installers/openstack/site.yml
642 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
646 function arrange_docker_default_network_policy() {
647 echo -e "Fixing firewall so docker and LXD can share the same host without affecting each other."
648 sudo iptables -I DOCKER-USER -j ACCEPT
649 sudo iptables-save | sudo tee /etc/iptables/rules.v4
650 sudo ip6tables-save | sudo tee /etc/iptables/rules.v6
653 function install_k8s_monitoring() {
654 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
655 # install OSM monitoring
656 sudo chmod +x $OSM_DEVOPS/installers/k8s/*.sh
657 sudo $OSM_DEVOPS/installers/k8s/install_osm_k8s_monitoring.sh || FATAL_TRACK install_k8s_monitoring "k8s/install_osm_k8s_monitoring.sh failed"
658 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
661 function dump_vars(){
662 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
663 echo "APT_PROXY_URL=$APT_PROXY_URL"
664 echo "DEVELOP=$DEVELOP"
665 echo "DEBUG_INSTALL=$DEBUG_INSTALL"
666 echo "DOCKER_NOBUILD=$DOCKER_NOBUILD"
667 echo "DOCKER_PROXY_URL=$DOCKER_PROXY_URL"
668 echo "DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL"
669 echo "DOCKER_USER=$DOCKER_USER"
670 echo "INSTALL_CACHELXDIMAGES=$INSTALL_CACHELXDIMAGES"
671 echo "INSTALL_FROM_SOURCE=$INSTALL_FROM_SOURCE"
672 echo "INSTALL_K8S_MONITOR=$INSTALL_K8S_MONITOR"
673 echo "INSTALL_LIGHTWEIGHT=$INSTALL_LIGHTWEIGHT"
674 echo "INSTALL_LXD=$INSTALL_LXD"
675 echo "INSTALL_NGSA=$INSTALL_NGSA"
676 echo "INSTALL_NODOCKER=$INSTALL_NODOCKER"
677 echo "INSTALL_NOJUJU=$INSTALL_NOJUJU"
678 echo "INSTALL_NOLXD=$INSTALL_NOLXD"
679 echo "INSTALL_ONLY=$INSTALL_ONLY"
680 echo "INSTALL_PLA=$INSTALL_PLA"
681 echo "INSTALL_TO_OPENSTACK=$INSTALL_TO_OPENSTACK"
682 echo "INSTALL_VIMEMU=$INSTALL_VIMEMU"
683 echo "NO_HOST_PORTS=$NO_HOST_PORTS"
684 echo "OPENSTACK_PUBLIC_NET_NAME=$OPENSTACK_PUBLIC_NET_NAME"
685 echo "OPENSTACK_OPENRC_FILE_OR_CLOUD=$OPENSTACK_OPENRC_FILE_OR_CLOUD"
686 echo "OPENSTACK_ATTACH_VOLUME=$OPENSTACK_ATTACH_VOLUME"
687 echo "OPENSTACK_SSH_KEY_FILE"="$OPENSTACK_SSH_KEY_FILE"
688 echo "OPENSTACK_USERDATA_FILE"="$OPENSTACK_USERDATA_FILE"
689 echo "OPENSTACK_VM_NAME"="$OPENSTACK_VM_NAME"
690 echo "OSM_DEVOPS=$OSM_DEVOPS"
691 echo "OSM_DOCKER_TAG=$OSM_DOCKER_TAG"
692 echo "OSM_HELM_WORK_DIR=$OSM_HELM_WORK_DIR"
693 echo "OSM_NAMESPACE=$OSM_NAMESPACE"
694 echo "OSM_VCA_HOST=$OSM_VCA_HOST"
695 echo "OSM_VCA_PUBKEY=$OSM_VCA_PUBKEY"
696 echo "OSM_VCA_SECRET=$OSM_VCA_SECRET"
697 echo "OSM_WORK_DIR=$OSM_WORK_DIR"
698 echo "PULL_IMAGES=$PULL_IMAGES"
699 echo "RECONFIGURE=$RECONFIGURE"
700 echo "RELEASE=$RELEASE"
701 echo "REPOSITORY=$REPOSITORY"
702 echo "REPOSITORY_BASE=$REPOSITORY_BASE"
703 echo "REPOSITORY_KEY=$REPOSITORY_KEY"
704 echo "SHOWOPTS=$SHOWOPTS"
705 echo "TEST_INSTALLER=$TEST_INSTALLER"
706 echo "TO_REBUILD=$TO_REBUILD"
707 echo "UNINSTALL=$UNINSTALL"
708 echo "UPDATE=$UPDATE"
709 echo "Install from specific refspec (-b): $COMMIT_ID"
710 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
713 function parse_docker_registry_url() {
714 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
715 DOCKER_REGISTRY_USER=$(echo "$DOCKER_REGISTRY_URL" | awk '{split($1,a
,"@"); split(a
[1],b
,":"); print b
[1]}')
716 DOCKER_REGISTRY_PASSWORD=$(echo "$DOCKER_REGISTRY_URL" | awk '{split($1,a
,"@"); split(a
[1],b
,":"); print b
[2]}')
717 DOCKER_REGISTRY_URL=$(echo "$DOCKER_REGISTRY_URL" | awk '{split($1,a
,"@"); print a
[2]}')
718 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
722 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
723 echo "** Trapped CTRL-C"
724 FATAL "User stopped the installation"
725 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
738 INSTALL_FROM_SOURCE=""
742 INSTALL_K8S_MONITOR=""
746 LXD_REPOSITORY_BASE="https://osm-download.etsi.org/repository/osm/lxd"
747 LXD_REPOSITORY_PATH=""
748 INSTALL_LIGHTWEIGHT="y"
749 INSTALL_TO_OPENSTACK=""
750 OPENSTACK_OPENRC_FILE_OR_CLOUD=""
751 OPENSTACK_PUBLIC_NET_NAME=""
752 OPENSTACK_ATTACH_VOLUME="false"
753 OPENSTACK_SSH_KEY_FILE=""
754 OPENSTACK_USERDATA_FILE=""
755 OPENSTACK_VM_NAME="server-osm"
756 OPENSTACK_PYTHON_VENV="$HOME/.virtual-envs/osm"
762 INSTALL_NOHOSTCLIENT=""
763 INSTALL_CACHELXDIMAGES=""
768 OSM_VCA_CLOUDNAME="localhost"
769 OSM_VCA_K8S_CLOUDNAME="k8scloud"
773 REPOSITORY_KEY="OSM%20ETSI%20Release%20Key.gpg"
774 REPOSITORY_BASE="https://osm-download.etsi.org/repository/osm/debian"
775 OSM_WORK_DIR="/etc/osm"
776 OSM_HELM_WORK_DIR="${OSM_WORK_DIR}/helm"
777 OSM_HOST_VOL="/var/lib/osm"
778 OSM_NAMESPACE_VOL="${OSM_HOST_VOL}/${OSM_NAMESPACE}"
779 OSM_DOCKER_TAG=latest
780 DOCKER_USER=opensourcemano
783 KIWIGRID_K8S_SIDECAR_TAG="1.15.6"
784 PROMETHEUS_TAG=v2.28.1
786 PROMETHEUS_NODE_EXPORTER_TAG=0.18.1
787 PROMETHEUS_CADVISOR_TAG=latest
789 OSM_DATABASE_COMMONKEY=
790 ELASTIC_VERSION=6.4.2
791 ELASTIC_CURATOR_VERSION=5.5.4
792 POD_NETWORK_CIDR=10.244.0.0/16
793 K8S_MANIFEST_DIR="/etc/kubernetes/manifests"
794 RE_CHECK='^
[a-z0-9
]([-a-z0-9]*[a-z0-9
])?$
'
798 OSM_INSTALLATION_TYPE="Default"
800 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; do
803 APT_PROXY_URL=${OPTARG}
810 REPOSITORY="${OPTARG}"
811 REPO_ARGS+=(-r "$REPOSITORY")
814 REPOSITORY_KEY="${OPTARG}"
815 REPO_ARGS+=(-k "$REPOSITORY_KEY")
818 REPOSITORY_BASE="${OPTARG}"
819 REPO_ARGS+=(-u "$REPOSITORY_BASE")
823 REPO_ARGS+=(-R "$RELEASE")
826 OSM_DEVOPS="${OPTARG}"
830 [ "${OPTARG}" == "k8s_monitor" ] && INSTALL_K8S_MONITOR="y" && continue
831 [ "${OPTARG}" == "ng-sa" ] && INSTALL_NGSA="y" && continue
834 INSTALL_TO_OPENSTACK="y"
835 if [ -n "${OPTARG}" ]; then
836 OPENSTACK_OPENRC_FILE_OR_CLOUD="${OPTARG}"
838 echo -e "Invalid argument for -O : ' $OPTARG'\n" >&2
843 OPENSTACK_SSH_KEY_FILE="${OPTARG}"
846 OPENSTACK_USERDATA_FILE="${OPTARG}"
849 OPENSTACK_PUBLIC_NET_NAME="${OPTARG}"
852 [ "${OPTARG}" == "NG-UI" ] && TO_REBUILD="$TO_REBUILD NG-UI" && continue
853 [ "${OPTARG}" == "NBI" ] && TO_REBUILD="$TO_REBUILD NBI" && continue
854 [ "${OPTARG}" == "LCM" ] && TO_REBUILD="$TO_REBUILD LCM" && continue
855 [ "${OPTARG}" == "RO" ] && TO_REBUILD="$TO_REBUILD RO" && continue
856 [ "${OPTARG}" == "MON" ] && TO_REBUILD="$TO_REBUILD MON" && continue
857 [ "${OPTARG}" == "POL" ] && TO_REBUILD="$TO_REBUILD POL" && continue
858 [ "${OPTARG}" == "PLA" ] && TO_REBUILD="$TO_REBUILD PLA" && continue
859 [ "${OPTARG}" == "osmclient" ] && TO_REBUILD="$TO_REBUILD osmclient" && continue
860 [ "${OPTARG}" == "KAFKA" ] && TO_REBUILD="$TO_REBUILD KAFKA" && continue
861 [ "${OPTARG}" == "MONGO" ] && TO_REBUILD="$TO_REBUILD MONGO" && continue
862 [ "${OPTARG}" == "PROMETHEUS" ] && TO_REBUILD="$TO_REBUILD PROMETHEUS" && continue
863 [ "${OPTARG}" == "PROMETHEUS-CADVISOR" ] && TO_REBUILD="$TO_REBUILD PROMETHEUS-CADVISOR" && continue
864 [ "${OPTARG}" == "KEYSTONE-DB" ] && TO_REBUILD="$TO_REBUILD KEYSTONE-DB" && continue
865 [ "${OPTARG}" == "GRAFANA" ] && TO_REBUILD="$TO_REBUILD GRAFANA" && continue
866 [ "${OPTARG}" == "NONE" ] && TO_REBUILD="$TO_REBUILD NONE" && continue
869 OSM_VCA_HOST="${OPTARG}"
872 OSM_VCA_SECRET="${OPTARG}"
875 OSM_NAMESPACE="${OPTARG}" && [[ ! "${OPTARG}" =~ $RE_CHECK ]] && echo "Namespace $OPTARG is invalid. Regex used for validation is $RE_CHECK" && exit 0
878 OSM_DOCKER_TAG="${OPTARG}"
879 REPO_ARGS+=(-t "$OSM_DOCKER_TAG")
882 DOCKER_USER="${OPTARG}"
885 OSM_VCA_PUBKEY=$(cat ${OPTARG})
888 OSM_VCA_APIPROXY="${OPTARG}"
891 LXD_CLOUD_FILE="${OPTARG}"
894 LXD_CRED_FILE="${OPTARG}"
897 CONTROLLER_NAME="${OPTARG}"
900 DOCKER_REGISTRY_URL="${OPTARG}"
903 DOCKER_PROXY_URL="${OPTARG}"
906 MODULE_DOCKER_TAG="${OPTARG}"
909 [ "${OPTARG}" == "help" ] && usage && exit 0
910 [ "${OPTARG}" == "source" ] && INSTALL_FROM_SOURCE="y" && PULL_IMAGES="" && continue
911 [ "${OPTARG}" == "debug" ] && DEBUG_INSTALL="--debug" && continue
912 [ "${OPTARG}" == "develop" ] && DEVELOP="y" && continue
913 [ "${OPTARG}" == "uninstall" ] && UNINSTALL="y" && continue
914 [ "${OPTARG}" == "update" ] && UPDATE="y" && continue
915 [ "${OPTARG}" == "reconfigure" ] && RECONFIGURE="y" && continue
916 [ "${OPTARG}" == "test" ] && TEST_INSTALLER="y" && continue
917 [ "${OPTARG}" == "lxdinstall" ] && INSTALL_LXD="y" && continue
918 [ "${OPTARG}" == "nolxd" ] && INSTALL_NOLXD="y" && continue
919 [ "${OPTARG}" == "nodocker" ] && INSTALL_NODOCKER="y" && continue
920 [ "${OPTARG}" == "showopts" ] && SHOWOPTS="y" && continue
921 [ "${OPTARG}" == "nohostports" ] && NO_HOST_PORTS="y" && continue
922 [ "${OPTARG}" == "nojuju" ] && INSTALL_NOJUJU="--nojuju" && continue
923 [ "${OPTARG}" == "nodockerbuild" ] && DOCKER_NOBUILD="y" && continue
924 [ "${OPTARG}" == "nohostclient" ] && INSTALL_NOHOSTCLIENT="y" && continue
925 [ "${OPTARG}" == "pullimages" ] && continue
926 [ "${OPTARG}" == "k8s_monitor" ] && INSTALL_K8S_MONITOR="y" && continue
927 [ "${OPTARG}" == "charmed" ] && CHARMED="y" && OSM_INSTALLATION_TYPE="Charmed" && continue
928 [ "${OPTARG}" == "bundle" ] && continue
929 [ "${OPTARG}" == "k8s" ] && continue
930 [ "${OPTARG}" == "lxd" ] && continue
931 [ "${OPTARG}" == "lxd-cred" ] && continue
932 [ "${OPTARG}" == "microstack" ] && continue
933 [ "${OPTARG}" == "overlay" ] && continue
934 [ "${OPTARG}" == "only-vca" ] && continue
935 [ "${OPTARG}" == "small-profile" ] && continue
936 [ "${OPTARG}" == "vca" ] && continue
937 [ "${OPTARG}" == "ha" ] && continue
938 [ "${OPTARG}" == "tag" ] && continue
939 [ "${OPTARG}" == "registry" ] && continue
940 [ "${OPTARG}" == "pla" ] && INSTALL_PLA="y" && continue
941 [ "${OPTARG}" == "old-sa" ] && INSTALL_NGSA="" && continue
942 [ "${OPTARG}" == "ng-sa" ] && INSTALL_NGSA="y" && continue
943 [ "${OPTARG}" == "volume" ] && OPENSTACK_ATTACH_VOLUME="true" && continue
944 [ "${OPTARG}" == "nocachelxdimages" ] && continue
945 [ "${OPTARG}" == "cachelxdimages" ] && INSTALL_CACHELXDIMAGES="--cachelxdimages" && continue
946 echo -e "Invalid option: '--$OPTARG'\n" >&2
950 echo "Option -$OPTARG requires an argument" >&2
954 echo -e "Invalid option: '-$OPTARG'\n" >&2
969 source $OSM_DEVOPS/common/all_funcs
971 [ -z "${DEBUG_INSTALL}" ] || DEBUG Debug is on
972 [ -n "$SHOWOPTS" ] && dump_vars && exit 0
974 # Uninstall if "--uninstall"
975 if [ -n "$UNINSTALL" ]; then
976 if [ -n "$CHARMED" ]; then
977 ${OSM_DEVOPS}/installers/charmed_uninstall.sh -R $RELEASE -r $REPOSITORY -u $REPOSITORY_BASE -D $OSM_DEVOPS -t $DOCKER_TAG "$@" || \
978 FATAL_TRACK charmed_uninstall "charmed_uninstall.sh failed"
980 ${OSM_DEVOPS}/installers/uninstall_osm.sh "$@" || \
981 FATAL_TRACK community_uninstall "uninstall_osm.sh failed"
987 # Charmed installation
988 if [ -n "$CHARMED" ]; then
989 sudo snap install jq || FATAL "Could not install jq (snap package). Make sure that snap works"
990 export OSM_TRACK_INSTALLATION_ID="$(date +%s)-$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16)"
991 track start release $RELEASE none none docker_tag $OSM_DOCKER_TAG none none installation_type $OSM_INSTALLATION_TYPE none none
992 ${OSM_DEVOPS}/installers/charmed_install.sh --tag $OSM_DOCKER_TAG "$@" || \
993 FATAL_TRACK charmed_install "charmed_install.sh failed"
994 wget -q -O- https://osm-download.etsi.org/ftp/osm-13.0-thirteen/README2.txt &> /dev/null
995 track end installation_type $OSM_INSTALLATION_TYPE
1000 # Installation to Openstack
1001 if [ -n "$INSTALL_TO_OPENSTACK" ]; then
1002 install_to_openstack $OPENSTACK_OPENRC_FILE_OR_CLOUD $OPENSTACK_PUBLIC_NET_NAME $OPENSTACK_ATTACH_VOLUME
1007 # Community_installer
1009 [ -n "$TO_REBUILD" ] && [ "$TO_REBUILD" != " NONE" ] && echo $TO_REBUILD | grep -q NONE && FATAL "Incompatible option: -m NONE cannot be used with other -m options"
1010 [ -n "$TO_REBUILD" ] && [ "$TO_REBUILD" == " PLA" ] && [ -z "$INSTALL_PLA" ] && FATAL "Incompatible option: -m PLA cannot be used without --pla option"
1011 # if develop, we force master
1012 [ -z "$COMMIT_ID" ] && [ -n "$DEVELOP" ] && COMMIT_ID="master"
1013 OSM_NAMESPACE_VOL="${OSM_HOST_VOL}/${OSM_NAMESPACE}"
1014 [ -n "$INSTALL_ONLY" ] && [ -n "$INSTALL_K8S_MONITOR" ] && install_k8s_monitoring
1015 [ -n "$INSTALL_ONLY" ] && [ -n "$INSTALL_NGSA" ] && install_osm_ngsa_service
1016 [ -n "$INSTALL_ONLY" ] && echo -e "\nDONE" && exit 0
1018 #Installation starts here
1019 wget -q -O- https://osm-download.etsi.org/ftp/osm-13.0-thirteen/README.txt &> /dev/null
1020 export OSM_TRACK_INSTALLATION_ID="$(date +%s)-$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16)"