From 5f8eab808605394f2d33aacfef2fbb44852caaa8 Mon Sep 17 00:00:00 2001 From: kimpaller Date: Tue, 29 Oct 2024 11:08:12 +0800 Subject: [PATCH] tasks: set device status to verbose and fix return Signed-off-by: kimpaller --- nebula/tasks.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/nebula/tasks.py b/nebula/tasks.py index dca8436..a809170 100644 --- a/nebula/tasks.py +++ b/nebula/tasks.py @@ -9,6 +9,7 @@ import nebula logging.getLogger().setLevel(logging.WARNING) +log = logging.getLogger(__name__) class MyFilter(logging.Filter): @@ -1529,6 +1530,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 +1542,9 @@ def board_status( yamlfilename="/etc/default/nebula", board_name=None, load_config=True, + fail_if_inactive=False, ): - """Get device status""" + """Get device status.""" nb = nebula.netbox( ip=netbox_ip, port=netbox_port, @@ -1552,7 +1555,11 @@ def board_status( load_config=load_config, ) device = nebula.NetboxDevice(nb) - return device.status() + log.info(f"{board_name} status is {device.status()}") + if fail_if_inactive: + if not str(device.status()) == "Active": + raise Exception(f"{board_name} not Active") + return netbox = Collection("netbox")