summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-10-18 11:36:30 +0000
committerGerrit Code Review <review@openstack.org>2016-10-18 11:36:30 +0000
commitf751601a8bb62ac3edc0e4bdb2605ca762e7fd92 (patch)
treeeaa03d0dbef04eddaf6d8b93805f696c55133b0a
parentfd29027e2d93f9a0fc51710939eec346ca32262b (diff)
parent82fe2a61175be5af6cc8b0b5e7722558a946786b (diff)
Merge "Update sript to use Glare backend"
-rwxr-xr-xtools/prepare_packages.sh54
1 files changed, 45 insertions, 9 deletions
diff --git a/tools/prepare_packages.sh b/tools/prepare_packages.sh
index d6960b9..c03e7df 100755
--- a/tools/prepare_packages.sh
+++ b/tools/prepare_packages.sh
@@ -3,12 +3,12 @@
3# function for checking directories 3# function for checking directories
4function check_dir () { 4function check_dir () {
5 if [[ -z "$1" ]]; then 5 if [[ -z "$1" ]]; then
6 echo "No directory name provided." 6 echo "ERROR: No directory name provided."
7 exit 7 exit
8 fi 8 fi
9 9
10 if [[ ! -d "${1}" ]]; then 10 if [[ ! -d "${1}" ]]; then
11 echo "Folder '${1}' doesn't exist." 11 echo "ERROR: Folder '${1}' doesn't exist."
12 exit 12 exit
13 fi 13 fi
14} 14}
@@ -19,6 +19,10 @@ destination_dir="."
19refresh_existing_packages=false 19refresh_existing_packages=false
20upload=false 20upload=false
21build_packages=true 21build_packages=true
22action_for_dependency='s'
23
24HOST='example.com'
25DEP_OPTS='s a u'
22 26
23help_string="$(basename "$0") [-h] [-s source_dir] [-d destination_dir] [-p package_name] -- script to build packages for downloading to Murano 27help_string="$(basename "$0") [-h] [-s source_dir] [-d destination_dir] [-p package_name] -- script to build packages for downloading to Murano
24 28
@@ -35,14 +39,27 @@ where:
35 upload packages options (they require muranoclient installation): 39 upload packages options (they require muranoclient installation):
36 -U upload new packages to specified tenant from directory specified with -d option 40 -U upload new packages to specified tenant from directory specified with -d option
37 if this option is set, old packages will be removed from tenant and new will be imported instead. 41 if this option is set, old packages will be removed from tenant and new will be imported instead.
42 -H Ip address of the Openstack used in endpoints
43 -a Default action when a dependency package already
44 exists: (s)kip, (u)pdate, (a)bort. Default value is: (s)kip.
38 -e name of environment, which will be created 45 -e name of environment, which will be created
39 46
40For using muranoclient please also specify necessary credentials in environment: 47For using muranoclient please also specify necessary credentials in environment:
41 export OS_USERNAME=user 48 export OS_USERNAME=user
42 export OS_PASSWORD=password 49 export OS_PASSWORD=password
43 export OS_TENANT_NAME=tenant 50 export OS_TENANT_NAME=tenant
44 export OS_AUTH_URL=http://auth.example.com:5000/v2.0 51
45 export MURANO_URL=http://murano.example.com:8082/ 52 To use non default backend please export follow option.
53 Default value is defined in /etc/murano/murano.conf
54
55 export MURANO_PACKAGES_SERVICE=glare
56
57 Follow endpoints will be set automatially, with provided $HOST (variable mentioned with -H option),
58 if they are not exported already:
59
60 export GLARE_URL=http://$HOST:9494/
61 export OS_AUTH_URL=http://$HOST:5000/v2.0
62 export MURANO_URL=http://$HOST:8082/
46 63
47Examples 64Examples
48-------- 65--------
@@ -59,13 +76,21 @@ Upload existing packages without building them:
59./tools/prepare_packages.sh -S -U -d $destination_dir 76./tools/prepare_packages.sh -S -U -d $destination_dir
60" 77"
61 78
62while getopts ':hUSs:d:p:e:' option; do 79while getopts ':hUSs:d:p:e:a:H:' option; do
63 case "$option" in 80 case "$option" in
64 h) echo "$help_string" 81 h) echo "$help_string"
65 exit 82 exit
66 ;; 83 ;;
84 H) HOST=$OPTARG
85 ;;
67 e) env_name=$OPTARG 86 e) env_name=$OPTARG
68 ;; 87 ;;
88 a) action_for_dependency=$OPTARG
89 if ! [[ $DEP_OPTS =~ $OPTARG ]] ; then
90 echo "ERROR: action should be one of the '$DEP_OPTS'."
91 exit 1
92 fi
93 ;;
69 r) refresh_existing_packages=true 94 r) refresh_existing_packages=true
70 ;; 95 ;;
71 s) source_dir=$OPTARG 96 s) source_dir=$OPTARG
@@ -91,7 +116,7 @@ done
91if [ -f "${DIR}/default_packages_list.sh" ]; then 116if [ -f "${DIR}/default_packages_list.sh" ]; then
92 if [ -z "${DEFAULT_PACKAGES_LIST}" ]; then 117 if [ -z "${DEFAULT_PACKAGES_LIST}" ]; then
93 source "${DIR}/default_packages_list.sh" 118 source "${DIR}/default_packages_list.sh"
94 echo "Packages list has been imported from default_packages_list.sh file" 119 echo "INFO: Packages list has been imported from default_packages_list.sh file"
95 fi 120 fi
96fi 121fi
97 122
@@ -119,7 +144,7 @@ if $build_packages || $upload ; then
119 destination_dir="$(pwd)/$destination_dir" 144 destination_dir="$(pwd)/$destination_dir"
120 fi 145 fi
121else 146else
122 echo "NOTE: Packages will not be built or uploaded. Use options -S or -U to change it." 147 echo "INFO: Packages will not be built or uploaded. So remove -S or use -U to make any action."
123fi 148fi
124 149
125 150
@@ -153,10 +178,21 @@ fi
153# Follow part uses Murano client, so let's 178# Follow part uses Murano client, so let's
154# check, that muranoclient is available 179# check, that muranoclient is available
155if ! hash murano 2>/dev/null; then 180if ! hash murano 2>/dev/null; then
156 echo "Murano client is not available, please install it if you want to use it." 181 echo "INFO: Murano client is not available, please install it if you want to use it."
182 exit 1
183fi
184
185if [ "$HOST" = 'example.com' ] ; then
186 echo "ERROR: please specify correct HOST (option -H) to get access to Openstack APIs"
157 exit 1 187 exit 1
158fi 188fi
159 189
190# check and define endpoints
191
192: "${MURANO_URL:?MURANO_URL is not set. Try to execute command: export MURANO_URL=http://$HOST:8082/}"
193: "${GLARE_URL:?GLARE_URL is not set. Try to execute command: export GLARE_URL=http=http://$HOST:9494/}"
194: "${OS_AUTH_URL:?OS_AUTH_URL is not set. Try to execute command: export OS_AUTH_URL=http=http://$HOST:5000/v2.0}"
195
160# upload packages 196# upload packages
161if $upload ; then 197if $upload ; then
162 # to have ability upload one package independently we need to remove it 198 # to have ability upload one package independently we need to remove it
@@ -165,7 +201,7 @@ if $upload ; then
165 filename="$(find "$destination_dir" -maxdepth 1 -name "*$d*")" 201 filename="$(find "$destination_dir" -maxdepth 1 -name "*$d*")"
166 pkg_id=$(murano package-list --owned | grep "$d" | awk '{print $2}') 202 pkg_id=$(murano package-list --owned | grep "$d" | awk '{print $2}')
167 murano package-delete "$pkg_id" 203 murano package-delete "$pkg_id"
168 murano package-import "$filename" --exists-action s 204 murano package-import "$filename" --exists-action s --dep-exists-action $action_for_dependency
169 done 205 done
170fi 206fi
171 207