From 5d9ca9d3a1dddbc5fdb1d701f8264aa6b0f3afe9 Mon Sep 17 00:00:00 2001
From: Eduardo Gonzalez <dabarren@gmail.com>
Date: Tue, 24 Jan 2017 14:51:48 +0000
Subject: [PATCH] Custom init-runonce values

Change-Id: Ibff560ffa7023e9629e8ea1762121c595c3fb3f4
---
 tools/init-runonce | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/tools/init-runonce b/tools/init-runonce
index 05aa1ecf46..cb14762132 100755
--- a/tools/init-runonce
+++ b/tools/init-runonce
@@ -5,6 +5,13 @@
 # configures networking and nova quotas to allow 40 m1.small instances
 # to be created.
 
+IMAGE_URL=http://download.cirros-cloud.net/0.3.4/
+IMAGE=cirros-0.3.4-x86_64-disk.img
+IMAGE_NAME=cirros
+EXT_NET_CIDR='10.0.2.0/24'
+EXT_NET_RANGE='start=10.0.2.150,end=10.0.2.199'
+EXT_NET_GATEWAY='10.0.2.1'
+
 # Sanitize language settings to avoid commands bailing out
 # with "unsupported locale setting" errors.
 unset LANG
@@ -12,9 +19,9 @@ unset LANGUAGE
 LC_ALL=C
 export LC_ALL
 for i in curl openstack; do
-    if [[ ! $(type $i 2>/dev/null) ]]; then
-        if [ "$i" == 'curl' ]; then
-            echo "Please install $i before proceeding"
+    if [[ ! $(type ${i} 2>/dev/null) ]]; then
+        if [ "${i}" == 'curl' ]; then
+            echo "Please install ${i} before proceeding"
         else
             echo "Please install python-${i}client before proceeding"
         fi
@@ -38,21 +45,19 @@ if openstack image list | grep -q cirros; then
 fi
 
 echo Downloading glance image.
-IMAGE_URL=http://download.cirros-cloud.net/0.3.4/
-IMAGE=cirros-0.3.4-x86_64-disk.img
-if ! [ -f "$IMAGE" ]; then
-    curl -L -o ./$IMAGE $IMAGE_URL/$IMAGE
+if ! [ -f "${IMAGE}" ]; then
+    curl -L -o ./${IMAGE} ${IMAGE_URL}/${IMAGE}
 fi
 echo Creating glance image.
 openstack image create --disk-format qcow2 --container-format bare --public \
-    --file ./$IMAGE cirros
+    --file ./${IMAGE} ${IMAGE_NAME}
 
 echo Configuring neutron.
 openstack network create --external --provider-physical-network physnet1 \
     --provider-network-type flat public1
 openstack subnet create --no-dhcp \
-    --allocation-pool start=10.0.2.150,end=10.0.2.199 --network public1 \
-    --subnet-range 10.0.2.0/24 --gateway 10.0.2.1 public1-subnet
+    --allocation-pool ${EXT_NET_RANGE} --network public1 \
+    --subnet-range ${EXT_NET_CIDR} --gateway ${EXT_NET_GATEWAY} public1-subnet
 
 openstack network create --provider-network-type vxlan demo-net
 openstack subnet create --subnet-range 10.0.0.0/24 --network demo-net \
@@ -89,13 +94,13 @@ ADMIN_USER_ID=$(openstack user list | awk '/ admin / {print $2}')
 ADMIN_PROJECT_ID=$(openstack project list | awk '/ admin / {print $2}')
 
 # 40 instances
-openstack quota set --instances 40 $ADMIN_PROJECT_ID
+openstack quota set --instances 40 ${ADMIN_PROJECT_ID}
 
 # 40 cores
-openstack quota set --cores 40 $ADMIN_PROJECT_ID
+openstack quota set --cores 40 ${ADMIN_PROJECT_ID}
 
 # 96GB ram
-openstack quota set --ram 96000 $ADMIN_PROJECT_ID
+openstack quota set --ram 96000 ${ADMIN_PROJECT_ID}
 
 # add default flavors, if they don't already exist
 if ! openstack flavor list | grep -q m1.tiny; then
@@ -115,7 +120,7 @@ Done.
 To deploy a demo instance, run:
 
 openstack server create \\
-    --image cirros \\
+    --image ${IMAGE_NAME} \\
     --flavor m1.tiny \\
     --key-name mykey \\
     --nic net-id=${DEMO_NET_ID} \\