From 4b0777509ed3d1c94423931af1a303f3e9eb77fd Mon Sep 17 00:00:00 2001 From: kimpaller Date: Tue, 29 Oct 2024 11:30:35 +0800 Subject: [PATCH] tasks: set device status to verbose and fix return Signed-off-by: kimpaller --- nebula/tasks.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/nebula/tasks.py b/nebula/tasks.py index f48165e..288fc65 100644 --- a/nebula/tasks.py +++ b/nebula/tasks.py @@ -1529,6 +1529,7 @@ def enable_board( "yamlfilename": "Path to yaml config file. Default: /etc/default/nebula", "board_name": "Name of DUT design (Ex: zynq-zc706-adv7511-fmcdaq2). Require for multi-device config files", "load_config": "Load configuration parameters from yamlfilename. Default: true", + "fail_if_inactive": "Raise exception if board is not active", } ) def board_status( @@ -1540,8 +1541,9 @@ def board_status( yamlfilename="/etc/default/nebula", board_name=None, load_config=True, + fail_if_inactive=False, ): - """Get device status. Returns -1 if not active""" + """Get device status.""" nb = nebula.netbox( ip=netbox_ip, port=netbox_port, @@ -1553,10 +1555,10 @@ def board_status( ) device = nebula.NetboxDevice(nb) log.info(f"{board_name} status is {device.status()}") - if device.status() != "active": - return -1 - else: - return 0 + if fail_if_inactive: + if device.status != "Active": + raise Exception(f"{board_name} not Active") + return netbox = Collection("netbox")