From e65e059852fa45f53810c9d47296f2938b502510 Mon Sep 17 00:00:00 2001
From: Daneyon Hansen <danehans@cisco.com>
Date: Tue, 12 May 2015 15:24:12 -0700
Subject: [PATCH] Improves Heat Demo Functionality

Previously, the Heat demo suffered from the following limitations:

1. The number of Nova instances to spawn and the image flavor were
   hard coded in the Heat template.

2. No outputs existed. This required users to run nova-list to
   obtain the IP's of VMs.

3. No documentation existed.

This patch addresses the above limitations.

Change-Id: I495aa9c73a91200c01cecc1719ee5532c1f6c9cb
---
 demos/heat/README.md     | 13 +++++++++++++
 demos/heat/launch        |  4 +++-
 demos/heat/steak-rg.yaml | 19 ++++++++++++++++++-
 demos/heat/steak.yaml    | 14 +++++++++++++-
 4 files changed, 47 insertions(+), 3 deletions(-)
 create mode 100644 demos/heat/README.md

diff --git a/demos/heat/README.md b/demos/heat/README.md
new file mode 100644
index 0000000000..78236ac1f8
--- /dev/null
+++ b/demos/heat/README.md
@@ -0,0 +1,13 @@
+A Kolla Demo using Heat
+=======================
+
+By default, the launch script will spawn 3 Nova instances on a
+Neutron network created from the tools/init-runonce script. Edit
+the VM_COUNT parameter in the launch script if you would like to
+spawn a different amount of Nova instances. Edit the IMAGE_FLAVOR
+if you would like to launch images using a flavor other than
+m1.tiny.
+
+Then run the script:
+
+    $ ./launch
diff --git a/demos/heat/launch b/demos/heat/launch
index d46e69f1d0..768b69eb03 100755
--- a/demos/heat/launch
+++ b/demos/heat/launch
@@ -1,3 +1,5 @@
+VM_COUNT=3
+IMAGE_FLAVOR=m1.small
 PUBLIC_NET_ID=$(neutron net-list | grep public | awk '{print $2}')
 DEMO_NET_ID=$(neutron net-list | grep demo | awk '{print $2}')
 DEMO_SUBNET_ID=$(neutron net-list | grep demo | awk '{print $6}')
@@ -6,4 +8,4 @@ echo Public net id is $PUBLIC_NET_ID
 echo Demo net id is $DEMO_NET_ID
 echo Demo subnet id is $DEMO_SUBNET_ID
 
-heat stack-create steak --template-file steak-rg.yaml --parameters="public_net_id=$PUBLIC_NET_ID;demo_net_id=$DEMO_NET_ID;demo_subnet_id=$DEMO_SUBNET_ID"
+heat stack-create steak --template-file steak-rg.yaml --parameters="vm_count=$VM_COUNT;image_flavor=$IMAGE_FLAVOR;public_net_id=$PUBLIC_NET_ID;demo_net_id=$DEMO_NET_ID;demo_subnet_id=$DEMO_SUBNET_ID"
diff --git a/demos/heat/steak-rg.yaml b/demos/heat/steak-rg.yaml
index 8ecd3f3da9..4c0a1db936 100644
--- a/demos/heat/steak-rg.yaml
+++ b/demos/heat/steak-rg.yaml
@@ -13,14 +13,31 @@ parameters:
     type: string
     description: uuid of a subnet on the fixed network to use for creating ports
 
+  vm_count:
+    type: string
+    description: Number of VMs to launch
+
+  image_flavor:
+    type: string
+    description: Image flavor to use when launching VMs
+
 resources:
   steak:
     type: OS::Heat::ResourceGroup
     properties:
-      count: 2
+      count:
+        get_param: vm_count
       resource_def:
         type: steak.yaml
         properties:
+          image_flavor: {get_param: image_flavor}
           public_net_id: {get_param: public_net_id}
           demo_net_id: {get_param: demo_net_id}
           demo_subnet_id: {get_param: demo_subnet_id}
+
+outputs:
+  eth0:
+    value: {get_attr: [steak, eth0]}
+
+  float:
+    value: {get_attr: [steak, float]}
diff --git a/demos/heat/steak.yaml b/demos/heat/steak.yaml
index 37fad0eb67..9b9bd9fc70 100644
--- a/demos/heat/steak.yaml
+++ b/demos/heat/steak.yaml
@@ -13,13 +13,18 @@ parameters:
     type: string
     description: uuid of a subnet on the fixed network to use for creating ports
 
+  image_flavor:
+    type: string
+    description: Number of VMs to launch
+
 resources:
   steak_node:
     type: "OS::Nova::Server"
     properties:
       key_name: mykey
       image: cirros
-      flavor: m1.small
+      flavor:
+        get_param: image_flavor
       networks:
         - port:
             get_resource: steak_node_eth0
@@ -40,3 +45,10 @@ resources:
         get_param: public_net_id
       port_id:
         get_resource: steak_node_eth0
+
+outputs:
+  eth0:
+    value: {get_attr: [steak_node_eth0, fixed_ips, 0, ip_address]}
+
+  float:
+    value: {get_attr: [steak_node_floating, floating_ip_address]}
-- 
GitLab