Browse code

Merge "Use DEFAULT_INSTANCE_TYPE in exercises"

Jenkins authored on 2012/01/04 03:32:04
Showing 3 changed files
... ...
@@ -30,7 +30,8 @@ SECGROUP=euca_secgroup
30 30
 euca-add-group -d description $SECGROUP
31 31
 
32 32
 # Launch it
33
-INSTANCE=`euca-run-instances -g $SECGROUP -t m1.tiny $IMAGE | grep INSTANCE | cut -f2`
33
+DEFAULT_INSTANCE_TYPE=${DEFAULT_INSTANCE_TYPE:-m1.tiny}
34
+INSTANCE=`euca-run-instances -g $SECGROUP -t $DEFAULT_INSTANCE_TYPE $IMAGE | grep INSTANCE | cut -f2`
34 35
 
35 36
 # Assure it has booted within a reasonable time
36 37
 if ! timeout $RUNNING_TIMEOUT sh -c "while ! euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done"; then
... ...
@@ -67,12 +67,16 @@ nova secgroup-create $SECGROUP "test_secgroup description"
67 67
 # List of flavors:
68 68
 nova flavor-list
69 69
 
70
-# and grab the first flavor in the list to launch
71
-FLAVOR=`nova flavor-list | head -n 4 | tail -n 1 | cut -d"|" -f2`
70
+DEFAULT_INSTANCE_TYPE=${DEFAULT_INSTANCE_TYPE:-m1.tiny}
71
+INSTANCE_TYPE=`nova flavor-list | grep $DEFAULT_INSTANCE_TYPE | cut -d"|" -f2`
72
+if [[ -z "$INSTANCE_TYPE" ]]; then
73
+    # grab the first flavor in the list to launch if default doesn't exist
74
+   INSTANCE_TYPE=`nova flavor-list | head -n 4 | tail -n 1 | cut -d"|" -f2`
75
+fi
72 76
 
73 77
 NAME="myserver"
74 78
 
75
-nova boot --flavor $FLAVOR --image $IMAGE $NAME --security_groups=$SECGROUP
79
+nova boot --flavor $INSTANCE_TYPE --image $IMAGE $NAME --security_groups=$SECGROUP
76 80
 
77 81
 # Testing
78 82
 # =======
... ...
@@ -52,10 +52,10 @@ IMAGE=`glance -A $TOKEN index | egrep ami | head -1 | cut -d" " -f1`
52 52
 # List of instance types:
53 53
 nova flavor-list
54 54
 
55
-INSTANCE_NAME=${DEFAULT_INSTANCE_TYPE:-m1.tiny}
56
-INSTANCE_TYPE=`nova flavor-list | grep $INSTANCE_NAME | cut -d"|" -f2`
57
-if [[ -z "`nova flavor-list | grep $INSTANCE_NAME | cut -d"|" -f2`" ]]; then
58
-    # and grab the first flavor in the list to launch
55
+DEFAULT_INSTANCE_TYPE=${DEFAULT_INSTANCE_TYPE:-m1.tiny}
56
+INSTANCE_TYPE=`nova flavor-list | grep $DEFAULT_INSTANCE_TYPE | cut -d"|" -f2`
57
+if [[ -z "$INSTANCE_TYPE" ]]; then
58
+    # grab the first flavor in the list to launch if default doesn't exist
59 59
    INSTANCE_TYPE=`nova flavor-list | head -n 4 | tail -n 1 | cut -d"|" -f2`
60 60
 fi
61 61