fix trove image addition

the previous addition to trove was done in a way that it was not
possible to discover from nodepool. This fixes our ability to do
that, especially with non-default on services.

Change-Id: I8ca682354e0d4e2eb9cf05f40c6dd783de1c6355
diff --git a/lib/trove b/lib/trove
index 401ab78..98ab56d 100644
--- a/lib/trove
+++ b/lib/trove
@@ -36,7 +36,6 @@
 TROVE_DATASTORE_TYPE=${TROVE_DATASTORE_TYPE:-"mysql"}
 TROVE_DATASTORE_VERSION=${TROVE_DATASTORE_VERSION:-"5.5"}
 TROVE_DATASTORE_PACKAGE=${TROVE_DATASTORE_PACKAGE:-"mysql-server-5.5"}
-TROVE_GUEST_IMAGE_URL=${TROVE_GUEST_IMAGE_URL:-"http://tarballs.openstack.org/trove/images/ubuntu_mysql.qcow2/ubuntu_mysql.qcow2"}
 
 # Support entry points installation of console scripts
 if [[ -d $TROVE_DIR/bin ]]; then
diff --git a/stackrc b/stackrc
index 840f3ac..174049c 100644
--- a/stackrc
+++ b/stackrc
@@ -35,17 +35,19 @@
 #  # Optional, to enable tempest configuration as part of devstack
 #  enable_service tempest
 
-# core compute (glance / keystone / nova (+ nova-network))
-ENABLED_SERVICES=g-api,g-reg,key,n-api,n-crt,n-obj,n-cpu,n-net,n-cond,n-sch,n-novnc,n-xvnc,n-cauth
-# cinder
-ENABLED_SERVICES+=,c-sch,c-api,c-vol
-# heat
-ENABLED_SERVICES+=,h-eng,h-api,h-api-cfn,h-api-cw
-# dashboard
-ENABLED_SERVICES+=,horizon
-# additional services
-ENABLED_SERVICES+=,rabbit,tempest,mysql
-
+# this allows us to pass ENABLED_SERVICES
+if [[ -z "$ENABLED_SERVICES" ]]; then
+    # core compute (glance / keystone / nova (+ nova-network))
+    ENABLED_SERVICES=g-api,g-reg,key,n-api,n-crt,n-obj,n-cpu,n-net,n-cond,n-sch,n-novnc,n-xvnc,n-cauth
+    # cinder
+    ENABLED_SERVICES+=,c-sch,c-api,c-vol
+    # heat
+    ENABLED_SERVICES+=,h-eng,h-api,h-api-cfn,h-api-cw
+    # dashboard
+    ENABLED_SERVICES+=,horizon
+    # additional services
+    ENABLED_SERVICES+=,rabbit,tempest,mysql
+fi
 
 # Tell Tempest which services are available.  The default is set here as
 # Tempest falls late in the configuration sequence.  This differs from
@@ -361,6 +363,19 @@
             ;;
     esac
 fi
+
+# Trove needs a custom image for it's work
+if [[ "$ENABLED_SERVICES" =~ 'tr-api' ]]; then
+    case "$VIRT_DRIVER" in
+        libvirt|baremetal|ironic)
+            TROVE_GUEST_IMAGE_URL=${TROVE_GUEST_IMAGE_URL:-"http://tarballs.openstack.org/trove/images/ubuntu_mysql.qcow2/ubuntu_mysql.qcow2"}
+            IMAGE_URLS+=",${TROVE_GUEST_IMAGE_URL}"
+            ;;
+        *)
+            ;;
+    esac
+fi
+
 # Staging Area for New Images, have them here for at least 24hrs for nodepool
 # to cache them otherwise the failure rates in the gate are too high
 PRECACHE_IMAGES=$(trueorfalse False $PRECACHE_IMAGES)
diff --git a/tools/image_list.sh b/tools/image_list.sh
index f9a4e2f..0bb49ab 100755
--- a/tools/image_list.sh
+++ b/tools/image_list.sh
@@ -10,7 +10,7 @@
 DRIVERS="openvz ironic libvirt vsphere xenserver dummy"
 
 # Extra variables to trigger getting additional images.
-ENABLED_SERVICES=h-api
+export ENABLED_SERVICES="h-api,tr-api"
 HEAT_FETCHED_TEST_IMAGE="Fedora-i386-20-20131211.1-sda"
 PRECACHE_IMAGES=True