2015-03-06 15:59:59 +04:00
|
|
|
#!/bin/bash -xe
|
|
|
|
|
|
|
|
CUR_IMAGE=none
|
|
|
|
|
2015-06-03 18:35:36 +03:00
|
|
|
check_error_code() {
|
|
|
|
if [ "$1" != "0" -o ! -f "$2" ]; then
|
|
|
|
echo "$2 image isn't build"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup_image() {
|
|
|
|
local plugin=$1
|
|
|
|
local os=$2
|
|
|
|
if [ "$ZUUL_PIPELINE" == "check" -o "$ZUUL_BRANCH" != "master" ]; then
|
|
|
|
delete_image "$CUR_IMAGE"
|
|
|
|
else
|
|
|
|
delete_image ${plugin}_${os}
|
|
|
|
rename_image "$CUR_IMAGE" ${plugin}_${os}
|
|
|
|
fi
|
2015-03-06 15:59:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
delete_image() {
|
2016-06-14 15:55:17 +03:00
|
|
|
id=$(openstack image list | grep -w $1 | awk '{print $2}')
|
2015-09-21 13:17:41 +03:00
|
|
|
if [ -n "$id" ]; then
|
2016-06-14 15:55:17 +03:00
|
|
|
openstack image delete $id
|
2015-09-21 13:17:41 +03:00
|
|
|
fi
|
2015-03-06 15:59:59 +04:00
|
|
|
}
|
|
|
|
|
2015-06-03 18:35:36 +03:00
|
|
|
failure() {
|
|
|
|
local reason=$1
|
|
|
|
echo "$reason"
|
|
|
|
print_python_env
|
|
|
|
delete_image "$CUR_IMAGE"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
register_new_image() {
|
|
|
|
local image_name=$1
|
|
|
|
local image_properties=$2
|
2016-06-27 18:45:12 +03:00
|
|
|
openstack image create $image_name --file $image_name.qcow2 --disk-format qcow2 --container-format bare --property '_sahara_tag_ci'='True' $image_properties
|
2015-06-03 18:35:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
rename_image() {
|
|
|
|
# 1 - source image, 2 - target image
|
2016-06-14 15:55:17 +03:00
|
|
|
id=$(openstack image list | grep -w $1 | awk '{print $2}')
|
|
|
|
openstack image set "$id" --name $2
|
2015-06-03 18:35:36 +03:00
|
|
|
}
|
|
|
|
|
2015-03-06 15:59:59 +04:00
|
|
|
upload_image() {
|
|
|
|
local plugin=$1
|
|
|
|
local username=$2
|
|
|
|
local image=$3
|
|
|
|
delete_image "$image"
|
|
|
|
case "$plugin" in
|
2015-08-04 15:19:12 +03:00
|
|
|
vanilla_2.7.1)
|
|
|
|
image_properties="--property _sahara_tag_2.7.1=True --property _sahara_tag_vanilla=True --property _sahara_username=${username}"
|
|
|
|
;;
|
2015-08-07 19:59:05 +03:00
|
|
|
ambari_2.1)
|
2015-08-23 12:51:34 +03:00
|
|
|
image_properties="--property _sahara_tag_2.2=True --property _sahara_tag_2.3=True --property _sahara_tag_ambari=True --property _sahara_username=${username}"
|
2015-08-07 19:59:05 +03:00
|
|
|
;;
|
2016-09-07 18:05:38 +03:00
|
|
|
ambari_2.2)
|
|
|
|
image_properties="--property _sahara_tag_2.4=True --property _sahara_tag_2.3=True --property _sahara_tag_ambari=True --property _sahara_username=${username}"
|
|
|
|
;;
|
2016-06-20 13:18:16 +03:00
|
|
|
cdh_5.5.0)
|
2016-02-17 13:38:12 +03:00
|
|
|
image_properties="--property _sahara_tag_5.5.0=True --property _sahara_tag_cdh=True --property _sahara_username=${username}"
|
2016-06-20 13:18:16 +03:00
|
|
|
;;
|
|
|
|
cdh_5.7.0)
|
|
|
|
image_properties="--property _sahara_tag_5.7.0=True --property _sahara_tag_cdh=True --property _sahara_username=${username}"
|
2016-02-17 13:38:12 +03:00
|
|
|
;;
|
2016-12-27 11:20:26 +00:00
|
|
|
cdh_5.9.0)
|
|
|
|
image_properties="--property _sahara_tag_5.9.0=True --property _sahara_tag_cdh=True --property _sahara_username=${username}"
|
|
|
|
;;
|
2016-09-05 18:33:40 +03:00
|
|
|
spark_1.6.0)
|
2016-02-05 17:18:36 +03:00
|
|
|
image_properties="--property _sahara_tag_spark=True --property _sahara_tag_1.6.0=True --property _sahara_username=${username}"
|
|
|
|
;;
|
2017-04-05 12:55:59 +04:00
|
|
|
spark_2.1.0)
|
|
|
|
image_properties="--property _sahara_tag_spark=True --property _sahara_tag_2.1.0=True --property _sahara_username=${username}"
|
|
|
|
;;
|
2016-09-05 18:33:40 +03:00
|
|
|
mapr_5.1.0.mrv2)
|
2016-03-09 16:13:56 +03:00
|
|
|
image_properties="--property _sahara_tag_mapr=True --property _sahara_tag_5.1.0.mrv2=True --property _sahara_username=${username}"
|
|
|
|
;;
|
2016-09-05 18:33:40 +03:00
|
|
|
mapr_5.2.0.mrv2)
|
|
|
|
image_properties="--property _sahara_tag_mapr=True --property _sahara_tag_5.2.0.mrv2=True --property _sahara_username=${username}"
|
|
|
|
;;
|
2016-07-07 16:58:00 +03:00
|
|
|
storm_1.0.1)
|
|
|
|
image_properties="--property _sahara_tag_storm=True --property _sahara_tag_1.0.1=True --property _sahara_username=${username}"
|
|
|
|
;;
|
2017-04-04 11:46:22 +04:00
|
|
|
storm_1.1.0)
|
|
|
|
image_properties="--property _sahara_tag_storm=True --property _sahara_tag_1.1.0=True --property _sahara_username=${username}"
|
|
|
|
;;
|
2015-03-06 15:59:59 +04:00
|
|
|
esac
|
|
|
|
register_new_image "$image" "$image_properties"
|
|
|
|
CUR_IMAGE="$image"
|
|
|
|
}
|