diff options
author | Vratko Polak <vrpolak@cisco.com> | 2020-01-17 12:26:47 +0100 |
---|---|---|
committer | Vratko Polak <vrpolak@cisco.com> | 2020-01-17 11:46:46 +0000 |
commit | 2b1bb67116b4933aafb1f5f4b48aa5b806c504c0 (patch) | |
tree | 27c54bac0da1e691d17d786a5ae35d2eff7bfbfc /resources | |
parent | 16907d6eda6688814be7d10d6897e399a4f77eef (diff) |
Fix reservation if connect fails
Change-Id: I136cc51cbd5a01451e04a39c5d8e5554d6d39305
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
(cherry picked from commit 1b9d4210b9b466fedab3a5891ec16a34e67a78ee)
Diffstat (limited to 'resources')
-rwxr-xr-x | resources/tools/scripts/topo_reservation.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/resources/tools/scripts/topo_reservation.py b/resources/tools/scripts/topo_reservation.py index e0f39c76e9..213fa636df 100755 --- a/resources/tools/scripts/topo_reservation.py +++ b/resources/tools/scripts/topo_reservation.py @@ -100,9 +100,10 @@ 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 # Before critical section, output can be outdated already. print(u"Diagnostic commands:") # -d and * are to suppress "total <size>", see https://askubuntu.com/a/61190 @@ -111,7 +112,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(f"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 +123,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 |