Browse code

Merge "add assertions for blind grep"

Jenkins authored on 2013/12/05 09:19:49
Showing 11 changed files
... ...
@@ -67,7 +67,10 @@ exit_if_aggregate_present() {
67 67
 exit_if_aggregate_present $AGGREGATE_NAME
68 68
 
69 69
 AGGREGATE_ID=$(nova aggregate-create $AGGREGATE_NAME $AGGREGATE_A_ZONE | grep " $AGGREGATE_NAME " | get_field 1)
70
+die_if_not_set $LINENO AGGREGATE_ID "Failure creating AGGREGATE_ID for $AGGREGATE_NAME $AGGREGATE_A_ZONE"
71
+
70 72
 AGGREGATE2_ID=$(nova aggregate-create $AGGREGATE2_NAME $AGGREGATE_A_ZONE | grep " $AGGREGATE2_NAME " | get_field 1)
73
+die_if_not_set $LINENO AGGREGATE2_ID "Fail creating AGGREGATE2_ID for $AGGREGATE2_NAME $AGGREGATE_A_ZONE"
71 74
 
72 75
 # check aggregate created
73 76
 nova aggregate-list | grep -q " $AGGREGATE_NAME " || die $LINENO "Aggregate $AGGREGATE_NAME not created"
... ...
@@ -114,6 +114,7 @@ INSTANCE_TYPE=$(nova flavor-list | grep $DEFAULT_INSTANCE_TYPE | get_field 1)
114 114
 if [[ -z "$INSTANCE_TYPE" ]]; then
115 115
     # grab the first flavor in the list to launch if default doesn't exist
116 116
     INSTANCE_TYPE=$(nova flavor-list | head -n 4 | tail -n 1 | get_field 1)
117
+    die_if_not_set $LINENO INSTANCE_TYPE "Failure retrieving INSTANCE_TYPE"
117 118
 fi
118 119
 
119 120
 # Clean-up from previous runs
... ...
@@ -139,24 +139,28 @@ function foreach_tenant_net {
139 139
 
140 140
 function get_image_id {
141 141
     local IMAGE_ID=$(glance image-list | egrep " $DEFAULT_IMAGE_NAME " | get_field 1)
142
+    die_if_not_set $LINENO IMAGE_ID "Failure retrieving IMAGE_ID"
142 143
     echo "$IMAGE_ID"
143 144
 }
144 145
 
145 146
 function get_tenant_id {
146 147
     local TENANT_NAME=$1
147 148
     local TENANT_ID=`keystone tenant-list | grep " $TENANT_NAME " | head -n 1 | get_field 1`
149
+    die_if_not_set $LINENO TENANT_ID "Failure retrieving TENANT_ID for $TENANT_NAME"
148 150
     echo "$TENANT_ID"
149 151
 }
150 152
 
151 153
 function get_user_id {
152 154
     local USER_NAME=$1
153 155
     local USER_ID=`keystone user-list | grep $USER_NAME | awk '{print $2}'`
156
+    die_if_not_set $LINENO USER_ID "Failure retrieving USER_ID for $USER_NAME"
154 157
     echo "$USER_ID"
155 158
 }
156 159
 
157 160
 function get_role_id {
158 161
     local ROLE_NAME=$1
159 162
     local ROLE_ID=`keystone role-list | grep $ROLE_NAME | awk '{print $2}'`
163
+    die_if_not_set $LINENO ROLE_ID "Failure retrieving ROLE_ID for $ROLE_NAME"
160 164
     echo "$ROLE_ID"
161 165
 }
162 166
 
... ...
@@ -169,6 +173,7 @@ function get_network_id {
169 169
 function get_flavor_id {
170 170
     local INSTANCE_TYPE=$1
171 171
     local FLAVOR_ID=`nova flavor-list | grep $INSTANCE_TYPE | awk '{print $2}'`
172
+    die_if_not_set $LINENO FLAVOR_ID "Failure retrieving FLAVOR_ID for $INSTANCE_TYPE"
172 173
     echo "$FLAVOR_ID"
173 174
 }
174 175
 
... ...
@@ -234,6 +239,7 @@ function create_network {
234 234
     local TENANT_ID=$(get_tenant_id $TENANT)
235 235
     source $TOP_DIR/openrc $TENANT $TENANT
236 236
     local NET_ID=$(neutron net-create --tenant_id $TENANT_ID $NET_NAME $EXTRA| grep ' id ' | awk '{print $4}' )
237
+    die_if_not_set $LINENO NET_ID "Failure creating NET_ID for $TENANT_ID $NET_NAME $EXTRA"
237 238
     neutron subnet-create --ip_version 4 --tenant_id $TENANT_ID --gateway $GATEWAY $NET_ID $CIDR
238 239
     neutron-debug probe-create --device-owner compute $NET_ID
239 240
     source $TOP_DIR/openrc demo demo
... ...
@@ -56,6 +56,7 @@ done
56 56
 
57 57
 # Check to make sure rules were added
58 58
 SEC_GROUP_RULES=( $(nova secgroup-list-rules $SEC_GROUP_NAME | grep -v \- | grep -v 'Source Group' | cut -d '|' -f3 | tr -d ' ') )
59
+die_if_not_set $LINENO SEC_GROUP_RULES "Failure retrieving SEC_GROUP_RULES for $SEC_GROUP_NAME"
59 60
 for i in "${RULES_TO_ADD[@]}"; do
60 61
     skip=
61 62
     for j in "${SEC_GROUP_RULES[@]}"; do
... ...
@@ -118,6 +118,7 @@ INSTANCE_TYPE=$(nova flavor-list | grep $DEFAULT_INSTANCE_TYPE | get_field 1)
118 118
 if [[ -z "$INSTANCE_TYPE" ]]; then
119 119
     # grab the first flavor in the list to launch if default doesn't exist
120 120
     INSTANCE_TYPE=$(nova flavor-list | head -n 4 | tail -n 1 | get_field 1)
121
+    die_if_not_set $LINENO INSTANCE_TYPE "Failure retrieving INSTANCE_TYPE"
121 122
 fi
122 123
 
123 124
 # Clean-up from previous runs
... ...
@@ -346,6 +346,7 @@ function create_neutron_accounts() {
346 346
 
347 347
 function create_neutron_initial_network() {
348 348
     TENANT_ID=$(keystone tenant-list | grep " demo " | get_field 1)
349
+    die_if_not_set $LINENO TENANT_ID "Failure retrieving TENANT_ID for demo"
349 350
 
350 351
     # Create a small network
351 352
     # Since neutron command is executed in admin context at this point,
... ...
@@ -360,12 +361,16 @@ function create_neutron_initial_network() {
360 360
             sudo ip addr add $IP dev $OVS_PHYSICAL_BRIDGE
361 361
         done
362 362
         NET_ID=$(neutron net-create $PHYSICAL_NETWORK --tenant_id $TENANT_ID --provider:network_type flat --provider:physical_network "$PHYSICAL_NETWORK" | grep ' id ' | get_field 2)
363
+        die_if_not_set $LINENO NET_ID "Failure creating NET_ID for $PHYSICAL_NETWORK $TENANT_ID"
363 364
         SUBNET_ID=$(neutron subnet-create --tenant_id $TENANT_ID --ip_version 4 ${ALLOCATION_POOL:+--allocation-pool $ALLOCATION_POOL} --gateway $NETWORK_GATEWAY --name $PRIVATE_SUBNET_NAME $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2)
365
+        die_if_not_set $LINENO SUBNET_ID "Failure creating SUBNET_ID for $TENANT_ID"
364 366
         sudo ifconfig $OVS_PHYSICAL_BRIDGE up
365 367
         sudo route add default gw $NETWORK_GATEWAY dev $OVS_PHYSICAL_BRIDGE
366 368
     else
367 369
         NET_ID=$(neutron net-create --tenant_id $TENANT_ID "$PRIVATE_NETWORK_NAME" | grep ' id ' | get_field 2)
370
+        die_if_not_set $LINENO NET_ID "Failure creating NET_ID for $PHYSICAL_NETWORK $TENANT_ID"
368 371
         SUBNET_ID=$(neutron subnet-create --tenant_id $TENANT_ID --ip_version 4 --gateway $NETWORK_GATEWAY --name $PRIVATE_SUBNET_NAME $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2)
372
+        die_if_not_set $LINENO SUBNET_ID "Failure creating SUBNET_ID for $TENANT_ID"
369 373
     fi
370 374
 
371 375
     if [[ "$Q_L3_ENABLED" == "True" ]]; then
... ...
@@ -373,14 +378,18 @@ function create_neutron_initial_network() {
373 373
         if [[ "$Q_L3_ROUTER_PER_TENANT" == "True" ]]; then
374 374
             # create a tenant-owned router.
375 375
             ROUTER_ID=$(neutron router-create --tenant_id $TENANT_ID $Q_ROUTER_NAME | grep ' id ' | get_field 2)
376
+            die_if_not_set $LINENO ROUTER_ID "Failure creating ROUTER_ID for $TENANT_ID $Q_ROUTER_NAME"
376 377
         else
377 378
             # Plugin only supports creating a single router, which should be admin owned.
378 379
             ROUTER_ID=$(neutron router-create $Q_ROUTER_NAME | grep ' id ' | get_field 2)
380
+            die_if_not_set $LINENO ROUTER_ID "Failure creating ROUTER_ID for $Q_ROUTER_NAME"
379 381
         fi
380 382
         neutron router-interface-add $ROUTER_ID $SUBNET_ID
381 383
         # Create an external network, and a subnet. Configure the external network as router gw
382 384
         EXT_NET_ID=$(neutron net-create "$PUBLIC_NETWORK_NAME" -- --router:external=True | grep ' id ' | get_field 2)
385
+        die_if_not_set $LINENO EXT_NET_ID "Failure creating EXT_NET_ID for $PUBLIC_NETWORK_NAME"
383 386
         EXT_GW_IP=$(neutron subnet-create --ip_version 4 ${Q_FLOATING_ALLOCATION_POOL:+--allocation-pool $Q_FLOATING_ALLOCATION_POOL} --gateway $PUBLIC_NETWORK_GATEWAY --name $PUBLIC_SUBNET_NAME $EXT_NET_ID $FLOATING_RANGE -- --enable_dhcp=False | grep 'gateway_ip' | get_field 2)
387
+        die_if_not_set $LINENO EXT_GW_IP "Failure creating EXT_GW_IP"
384 388
         neutron router-gateway-set $ROUTER_ID $EXT_NET_ID
385 389
 
386 390
         if is_service_enabled q-l3; then
... ...
@@ -390,6 +399,7 @@ function create_neutron_initial_network() {
390 390
                 sudo ip addr add $EXT_GW_IP/$CIDR_LEN dev $PUBLIC_BRIDGE
391 391
                 sudo ip link set $PUBLIC_BRIDGE up
392 392
                 ROUTER_GW_IP=`neutron port-list -c fixed_ips -c device_owner | grep router_gateway | awk -F '"' '{ print $8; }'`
393
+                die_if_not_set $LINENO ROUTER_GW_IP "Failure retrieving ROUTER_GW_IP"
393 394
                 sudo route add -net $FIXED_RANGE gw $ROUTER_GW_IP
394 395
             fi
395 396
             if [[ "$Q_USE_NAMESPACE" == "False" ]]; then
... ...
@@ -526,14 +526,19 @@ function create_swift_accounts() {
526 526
     fi
527 527
 
528 528
     SWIFT_TENANT_TEST1=$(keystone tenant-create --name=swifttenanttest1 | grep " id " | get_field 2)
529
+    die_if_not_set $LINENO SWIFT_TENANT_TEST1 "Failure creating SWIFT_TENANT_TEST1"
529 530
     SWIFT_USER_TEST1=$(keystone user-create --name=swiftusertest1 --pass=testing --email=test@example.com | grep " id " | get_field 2)
531
+    die_if_not_set $LINENO SWIFT_USER_TEST1 "Failure creating SWIFT_USER_TEST1"
530 532
     keystone user-role-add --user-id $SWIFT_USER_TEST1 --role-id $ADMIN_ROLE --tenant-id $SWIFT_TENANT_TEST1
531 533
 
532 534
     SWIFT_USER_TEST3=$(keystone user-create --name=swiftusertest3 --pass=testing3 --email=test3@example.com | grep " id " | get_field 2)
535
+    die_if_not_set $LINENO SWIFT_USER_TEST3 "Failure creating SWIFT_USER_TEST3"
533 536
     keystone user-role-add --user-id $SWIFT_USER_TEST3 --role-id $ANOTHER_ROLE --tenant-id $SWIFT_TENANT_TEST1
534 537
 
535 538
     SWIFT_TENANT_TEST2=$(keystone tenant-create --name=swifttenanttest2 | grep " id " | get_field 2)
539
+    die_if_not_set $LINENO SWIFT_TENANT_TEST2 "Failure creating SWIFT_TENANT_TEST2"
536 540
     SWIFT_USER_TEST2=$(keystone user-create --name=swiftusertest2 --pass=testing2 --email=test2@example.com | grep " id " | get_field 2)
541
+    die_if_not_set $LINENO SWIFT_USER_TEST2 "Failure creating SWIFT_USER_TEST2"
537 542
     keystone user-role-add --user-id $SWIFT_USER_TEST2 --role-id $ADMIN_ROLE --tenant-id $SWIFT_TENANT_TEST2
538 543
 }
539 544
 
... ...
@@ -1080,7 +1080,9 @@ fi
1080 1080
 # Create an access key and secret key for nova ec2 register image
1081 1081
 if is_service_enabled key && is_service_enabled swift3 && is_service_enabled nova; then
1082 1082
     NOVA_USER_ID=$(keystone user-list | grep ' nova ' | get_field 1)
1083
+    die_if_not_set $LINENO NOVA_USER_ID "Failure retrieving NOVA_USER_ID for nova"
1083 1084
     NOVA_TENANT_ID=$(keystone tenant-list | grep " $SERVICE_TENANT_NAME " | get_field 1)
1085
+    die_if_not_set $LINENO NOVA_TENANT_ID "Failure retrieving NOVA_TENANT_ID for $SERVICE_TENANT_NAME"
1084 1086
     CREDS=$(keystone ec2-credentials-create --user_id $NOVA_USER_ID --tenant_id $NOVA_TENANT_ID)
1085 1087
     ACCESS_KEY=$(echo "$CREDS" | awk '/ access / { print $4 }')
1086 1088
     SECRET_KEY=$(echo "$CREDS" | awk '/ secret / { print $4 }')
... ...
@@ -5,4 +5,5 @@ set -o errexit
5 5
 
6 6
 TOP_DIR=$(cd ../../.. && pwd)
7 7
 HEAD_IP=`cat $TOP_DIR/addresses | grep HEAD | cut -d "=" -f2`
8
+die_if_not_set $LINENO HEAD_IP "Failure retrieving HEAD_IP"
8 9
 ssh stack@$HEAD_IP 'cd devstack && source openrc && cd exercises &&  ./euca.sh'
... ...
@@ -5,4 +5,5 @@ set -o errexit
5 5
 
6 6
 TOP_DIR=$(cd ../../.. && pwd)
7 7
 HEAD_IP=`cat $TOP_DIR/addresses | grep HEAD | cut -d "=" -f2`
8
+die_if_not_set $LINENO HEAD_IP "Failure retrieving HEAD_IP"
8 9
 ssh stack@$HEAD_IP 'cd devstack && source openrc && cd exercises &&  ./floating_ips.sh'
... ...
@@ -5,4 +5,5 @@ set -o errexit
5 5
 
6 6
 TOP_DIR=$(cd ../../.. && pwd)
7 7
 HEAD_IP=`cat $TOP_DIR/addresses | grep HEAD | cut -d "=" -f2`
8
+die_if_not_set $LINENO HEAD_IP "Failure retrieving HEAD_IP"
8 9
 ssh stack@$HEAD_IP 'cd devstack && source openrc && cd exercises &&  ./volumes.sh'