Browse code

exit cleanup in functions

we should always use die instead of exit so that we know why we
failed.

Also remove instances where exit is called after die, as that is
a noop.

Change-Id: I8e08cce63d35c503c36ff1e09805f3db427d082d

Sean Dague authored on 2013/10/22 20:30:47
Showing 1 changed files
... ...
@@ -580,7 +580,8 @@ function git_clone {
580 580
     if echo $GIT_REF | egrep -q "^refs"; then
581 581
         # If our branch name is a gerrit style refs/changes/...
582 582
         if [[ ! -d $GIT_DEST ]]; then
583
-            [[ "$ERROR_ON_CLONE" = "True" ]] && exit 1
583
+            [[ "$ERROR_ON_CLONE" = "True" ]] && \
584
+                die $LINENO "Cloning not allowed in this configuration"
584 585
             git clone $GIT_REMOTE $GIT_DEST
585 586
         fi
586 587
         cd $GIT_DEST
... ...
@@ -588,7 +589,8 @@ function git_clone {
588 588
     else
589 589
         # do a full clone only if the directory doesn't exist
590 590
         if [[ ! -d $GIT_DEST ]]; then
591
-            [[ "$ERROR_ON_CLONE" = "True" ]] && exit 1
591
+            [[ "$ERROR_ON_CLONE" = "True" ]] && \
592
+                die $LINENO "Cloning not allowed in this configuration"
592 593
             git clone $GIT_REMOTE $GIT_DEST
593 594
             cd $GIT_DEST
594 595
             # This checkout syntax works for both branches and tags
... ...
@@ -612,8 +614,7 @@ function git_clone {
612 612
             elif [[ -n "`git show-ref refs/remotes/origin/$GIT_REF`" ]]; then
613 613
                 git_update_remote_branch $GIT_REF
614 614
             else
615
-                echo $GIT_REF is neither branch nor tag
616
-                exit 1
615
+                die $LINENO "$GIT_REF is neither branch nor tag"
617 616
             fi
618 617
 
619 618
         fi
... ...
@@ -1562,7 +1563,6 @@ function _ping_check_novanet() {
1562 1562
         else
1563 1563
             die $LINENO "[Fail] Could ping server"
1564 1564
         fi
1565
-        exit 1
1566 1565
     fi
1567 1566
 }
1568 1567
 
... ...
@@ -1575,7 +1575,6 @@ function get_instance_ip(){
1575 1575
     if [[ $ip = "" ]];then
1576 1576
         echo "$nova_result"
1577 1577
         die $LINENO "[Fail] Coudn't get ipaddress of VM"
1578
-        exit 1
1579 1578
     fi
1580 1579
     echo $ip
1581 1580
 }