Skip to content

Commit

Permalink
Merge branch 'fix/openstack-daily-image-upload' into stable/0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Capuccini committed Apr 3, 2018
2 parents 637bd09 + ccf0adf commit 48ee506
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 33 deletions.
71 changes: 40 additions & 31 deletions bin/image-create-openstack.sh
Expand Up @@ -30,42 +30,51 @@ image_id="$(printf '%s' "$image_list" |
awk -F "|" '{print $2;}' |
tr -d '[:space:]')"

# If it doesn't exist then download it
if [ -z "$image_id" ]; then
echo "Image not present in OpenStack"
echo "Downloading image to local /tmp/"
curl "$KN_IMAGE_BUCKET_URL/$file_name" \
-o "/tmp/$file_name" \
--connect-timeout 30 \
--max-time 1800

echo "Download md5 sum file"
curl "$KN_IMAGE_BUCKET_URL/$file_name.md5" \
-o "/tmp/$file_name.md5" \
--connect-timeout 30 \
--max-time 1800

echo "Check md5 sum"
md5only=$(cut -f1 -d ' ' "/tmp/$file_name.md5")
printf '%s' "$md5only /tmp/$file_name" | md5sum -c
else
echo "File exists - no need to download"
# If it exist then exit here
if [ -n "$image_id" ]; then
echo "file exists - no need to upload, exit image-upload script"
exit 0
fi

# If it didn't exist then upload it
if [ -z "$image_id" ]; then
echo "Uploading image"
glance image-create \
--file "/tmp/$file_name" \
--disk-format qcow2 \
--min-disk 20 \
--container-format bare \
--name "$KN_IMAGE_NAME" \
--progress
# If it doesn't exist then download it
echo "Image not present in OpenStack"
echo "Downloading image to local /tmp/"
curl "$KN_IMAGE_BUCKET_URL/$file_name" \
-o "/tmp/$file_name" \
--connect-timeout 30 \
--max-time 1800

echo "Download md5 sum file"
curl "$KN_IMAGE_BUCKET_URL/$file_name.md5" \
-o "/tmp/$file_name.md5" \
--connect-timeout 30 \
--max-time 1800

# Verify md5sum of downloaded file
echo "Check md5 sum"
md5result=$(
cd /tmp
md5sum -c "$file_name.md5"
)
if [[ "$md5result" != *": OK"* ]]; then
echo >&2 "Wrong checksum of downloaded image."
echo >&2 "Something might have failed on file transfer."
echo >&2 "Please try again."
exit 1
else
echo "file exists - no need to upload"
echo "Checksum of downloaded image OK"
fi

# Upload image
echo "Uploading image"
glance image-create \
--file "/tmp/$file_name" \
--disk-format qcow2 \
--min-disk 20 \
--container-format bare \
--name "$KN_IMAGE_NAME" \
--progress

echo "Verify md5 of present/uploaded image..."
echo "List images available in OpenStack..."
image_list="$(glance image-list)"
Expand Down
4 changes: 2 additions & 2 deletions playbooks/roles/traefik-test/tasks/test-page.yml
@@ -1,5 +1,5 @@
---
- name: "test endpoint"
- name: "test endpoint: http://{{cheese}}.{{cheese_domain_name}}"
command: >
curl --silent --head
-H "host: {{cheese}}.{{cheese_domain_name}}"
Expand All @@ -9,7 +9,7 @@
retries: 5
delay: 30

- name: "test page"
- name: "test page: http://{{cheese}}.{{cheese_domain_name}}"
action: >
uri
url=http://{{cheese}}.{{cheese_domain_name}}
Expand Down
1 change: 1 addition & 0 deletions templates/terraform.tfvars.azure-template
Expand Up @@ -33,6 +33,7 @@ node_vm_size = "Standard_DS2_v2"
# cloudflare_email = "your-cloudflare-email"
# cloudflare_token = "your-cloudflare-token"
# cloudflare_domain = "your-domain-name"
# cloudflare_subdomain = "your-subdomain-name"

# Cloudflare proxy (optional)
# cloudflare_proxied = "true"
Expand Down

0 comments on commit 48ee506

Please sign in to comment.