X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Ftools%2Fscripts%2Ftopo_reservation.py;h=021c60a6b6fe7682b87b22c6c376cce121a61160;hb=f70df02d586490633b925358041c4dfafd99a118;hp=e0f39c76e926149de346bd2b540b87ecffa9959e;hpb=b55e324d526e5b05baef015c3614b9743c955992;p=csit.git diff --git a/resources/tools/scripts/topo_reservation.py b/resources/tools/scripts/topo_reservation.py index e0f39c76e9..021c60a6b6 100755 --- a/resources/tools/scripts/topo_reservation.py +++ b/resources/tools/scripts/topo_reservation.py @@ -100,9 +100,11 @@ def main(): # store additional data (time, client_ID, ..) within reservation directory. if args.cancel: ret, _, err = exec_cmd(node, f"rm -r {RESERVATION_DIR}") - if ret: + # If connection is refused, ret==None. + if ret != 0: print(f"Cancellation unsuccessful:\n{err!r}") - return ret + return 1 + return 0 # Before critical section, output can be outdated already. print(u"Diagnostic commands:") # -d and * are to suppress "total ", see https://askubuntu.com/a/61190 @@ -111,7 +113,10 @@ def main(): # Entering critical section. ret, _, _ = exec_cmd(node, f"mkdir '{RESERVATION_DIR}'") # Critical section is over. - if ret: + if ret is None: + print(u"Failed to connect to testbed.") + return 1 + if ret != 0: _, stdo, _ = exec_cmd(node, f"ls '{RESERVATION_DIR}'/*") print(f"Testbed already reserved by:\n{stdo}") return 2 @@ -119,7 +124,7 @@ def main(): print(u"Reservation success, writing additional info to reservation dir.") ret, _, err = exec_cmd( node, f"touch '{RESERVATION_DIR}/{args.runtag}'") - if ret: + if ret != 0: print(f"Writing test run info failed, but continuing anyway:\n{err!r}") return 0