Browse Source

Merge "Update sript to use Glare backend"

changes/22/389222/1
Jenkins 2 years ago
parent
commit
f751601a8b
1 changed files with 45 additions and 9 deletions
  1. 45
    9
      tools/prepare_packages.sh

+ 45
- 9
tools/prepare_packages.sh View File

@@ -3,12 +3,12 @@
3 3
 # function for checking directories
4 4
 function check_dir () {
5 5
     if [[ -z "$1" ]]; then
6
-        echo "No directory name provided."
6
+        echo "ERROR: No directory name provided."
7 7
         exit
8 8
     fi
9 9
 
10 10
     if [[ ! -d "${1}" ]]; then
11
-        echo "Folder '${1}' doesn't exist."
11
+        echo "ERROR: Folder '${1}' doesn't exist."
12 12
         exit
13 13
     fi
14 14
 }
@@ -19,6 +19,10 @@ destination_dir="."
19 19
 refresh_existing_packages=false
20 20
 upload=false
21 21
 build_packages=true
22
+action_for_dependency='s'
23
+
24
+HOST='example.com'
25
+DEP_OPTS='s a u'
22 26
 
23 27
 help_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 39
   upload packages options (they require muranoclient installation):
36 40
     -U  upload new packages to specified tenant from directory specified with -d option
37 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 45
     -e  name of environment, which will be created
39 46
 
40 47
 For using muranoclient please also specify necessary credentials in environment:
41 48
     export OS_USERNAME=user
42 49
     export OS_PASSWORD=password
43 50
     export OS_TENANT_NAME=tenant
44
-    export OS_AUTH_URL=http://auth.example.com:5000/v2.0
45
-    export MURANO_URL=http://murano.example.com:8082/
51
+
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
 
47 64
 Examples
48 65
 --------
@@ -59,13 +76,21 @@ Upload existing packages without building them:
59 76
 ./tools/prepare_packages.sh -S -U -d $destination_dir
60 77
 "
61 78
 
62
-while getopts ':hUSs:d:p:e:' option; do
79
+while getopts ':hUSs:d:p:e:a:H:' option; do
63 80
   case "$option" in
64 81
     h) echo "$help_string"
65 82
        exit
66 83
        ;;
84
+    H) HOST=$OPTARG
85
+       ;;
67 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 94
     r) refresh_existing_packages=true
70 95
        ;;
71 96
     s) source_dir=$OPTARG
@@ -91,7 +116,7 @@ done
91 116
 if [ -f "${DIR}/default_packages_list.sh" ]; then
92 117
     if [ -z "${DEFAULT_PACKAGES_LIST}" ]; then
93 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 120
    fi
96 121
 fi
97 122
 
@@ -119,7 +144,7 @@ if $build_packages || $upload ; then
119 144
         destination_dir="$(pwd)/$destination_dir"
120 145
     fi
121 146
 else
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."
123 148
 fi
124 149
 
125 150
 
@@ -153,10 +178,21 @@ fi
153 178
 # Follow part uses Murano client, so let's
154 179
 # check, that muranoclient is available
155 180
 if ! 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
183
+fi
184
+
185
+if [ "$HOST" = 'example.com' ] ; then
186
+    echo "ERROR: please specify correct HOST (option -H) to get access to Openstack APIs"
157 187
     exit 1
158 188
 fi
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 196
 # upload packages
161 197
 if $upload ; then
162 198
     # to have ability upload one package independently we need to remove it
@@ -165,7 +201,7 @@ if $upload ; then
165 201
         filename="$(find "$destination_dir" -maxdepth 1 -name "*$d*")"
166 202
         pkg_id=$(murano package-list --owned | grep "$d" | awk '{print $2}')
167 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 205
     done
170 206
 fi
171 207
 

Loading…
Cancel
Save