From 85d509ed28f4d10b24b08b2d40800175518439d1 Mon Sep 17 00:00:00 2001 From: Aqsa Date: Thu, 21 Jan 2016 23:34:52 -0800 Subject: [PATCH] Function to upload OpenWRT image during Tacker devstack installation Adding this function will automatically download the openwrt image and upload it to glance when the tacker plugin is enabled in the local.conf file. Change-Id: Ib56baff820104bf5a26d882f2ff8e12a18a44d7f Closes-Bug: #1517672 --- devstack/lib/tacker | 22 ++++++++++++++++++++++ devstack/plugin.sh | 3 +++ 2 files changed, 25 insertions(+) diff --git a/devstack/lib/tacker b/devstack/lib/tacker index dd5aedc9c..78973b753 100644 --- a/devstack/lib/tacker +++ b/devstack/lib/tacker @@ -341,6 +341,28 @@ function tacker_horizon_install { restart_apache_server } +function tacker_create_openwrt_image { + local image_url=https://downloads.openwrt.org/chaos_calmer/15.05/x86/kvm_guest/openwrt-15.05-x86-kvm_guest-combined-ext4.img.gz + local image image_fname image_name + + image_fname=`basename "$image_url"` + if [[ $image_url != file* ]]; then + if [[ ! -f $FILES/$image_fname || "$(stat -c "%s" $FILES/$image_fname)" = "0" ]]; then + wget --progress=dot:giga -c $image_url -O $FILES/$image_fname + if [[ $? -ne 0 ]]; then + echo "Not found: $image_url" + return + fi + fi + image="$FILES/${image_fname}" + fi + disk_format=raw + container_format=bare + image_name="OpenWRT" + openstack --os-cloud=devstack-admin image create $image_name --public --container-format=$container_format --disk-format $disk_format < <(zcat --force "${image}") + glance image-list | grep OpenWRT | awk {print$2} +} + function tacker_create_initial_network { # create necessary networks # prepare network diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 7af7a4a82..6757a67e5 100755 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -32,6 +32,9 @@ if is_service_enabled tacker; then tacker_horizon_install echo_summary "Setup initial tacker network" tacker_create_initial_network + echo_summary "Upload OpenWrt image" + tacker_create_openwrt_image + fi if [[ "$1" == "unstack" ]]; then