blob: 9af8284aed98e62660c1ae8e9c5df9625518a72d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
#!/bin/bash
# Copyright (C) 2019 by Samsung Electronics Co., Ltd.
#
# This software is the confidential and proprietary information of Samsung Electronics co., Ltd.
# ("Confidential Information"). You shall not disclose such Confidential Information and shall use
# it only in accordance with the terms of the license agreement you entered into with Samsung.
set -e
BLUEPRINTS_DIR=${BLUEPRINTS_DIR:-blueprints}
DEPLOYMENT_ID_PREFIX=${DEPLOYMENT_ID_PREFIX:-"samsung"}
declare -a rapp_blueprint_files=(
${BLUEPRINTS_DIR}/k8s-datacollector.yaml
${BLUEPRINTS_DIR}/k8s-sleepingcelldetector.yaml
)
# Define deployment id names for rapps
declare -a rapp_deployment_ids=(
rapp-datacollector
rapp-sleepingcelldetector
)
exec_over_rapps() {
local action_func=$1
local rapp_filter=$2
for i in "${!rapp_blueprint_files[@]}"
do
if [[ "${DEPLOYMENT_ID_PREFIX}_${rapp_deployment_ids[$i]}" == *"$rapp_filter"* ]]; then
$action_func ${rapp_blueprint_files[$i]} ${rapp_deployment_ids[$i]}
fi
done
}
operation=$1
case "$operation" in
-h|--help|help|?|"")
echo "Script usage:"
echo "$0 deploy - Deploy rapp(s)"
echo "$0 undeploy - Undeploy rapp(s)"
echo "$0 redeploy - Redeploy rapp(s)"
echo "$0 list - List rapps properties"
echo
echo "BLUEPRINTS_DIR and DEPLOYMENT_ID_PREFIX variables can be exported to override default value."
echo "BLUEPRINTS_DIR default value is 'blueprints'."
echo "DEPLOYMENT_ID_PREFIX is a string prefixed to given deployment_id in the deploy operation."
echo "In other operations prefixed form is used. DEPLOYMENT_ID_PREFIX default value is 'samsung'."
;;
deploy)
rapp_filter=$2
# Create inputs. Currently the only input to be provided is database password and that is only
# applicable for datacollector r-app at the moment;
. ./inputs_database_password.sh
deployment_inputs="database_password=${DATABASE_PASSWORD}"
do_deploy() {
local blueprint_file=$1
local deployment_id=$2
if [[ "${deployment_id}" != "rapp-datacollector" ]]; then
deployment_inputs=""
fi
./dcae.sh deploy "${blueprint_file}" "${deployment_id}" "${DEPLOYMENT_ID_PREFIX}" "${deployment_inputs}"
}
exec_over_rapps do_deploy ${rapp_filter}
./dcae.sh list
;;
undeploy)
rapp_filter=$2
do_undeploy() {
local blueprint_file=$1
local deployment_id=$2
./dcae.sh undeploy ${DEPLOYMENT_ID_PREFIX}_${deployment_id}
./dcae.sh delete $(basename ${blueprint_file} | cut -d'.' -f1)
}
exec_over_rapps do_undeploy ${rapp_filter}
./dcae.sh list
;;
redeploy)
rapp_filter=$2
deployment_inputs_key_value=$3
do_redeploy() {
local blueprint_file=$1
local deployment_id=$2
./dcae.sh redeploy "${blueprint_file}" "${DEPLOYMENT_ID_PREFIX}_${deployment_id}" "${deployment_inputs_key_value}"
}
exec_over_rapps do_redeploy ${rapp_filter}
./dcae.sh list
;;
get_deployment_input)
property=$2
rapp_filter=$3
do_input() {
local blueprint_file=$1
local deployment_id=$2
local full_id=${DEPLOYMENT_ID_PREFIX}_${deployment_id}
echo "${full_id}" "$(./dcae.sh get_deployment_input ${full_id} ${property})"
}
exec_over_rapps do_input ${rapp_filter}
;;
*)
echo "Wrong usage, check '$0 -h'" >&2
exit 1
;;
esac
|