From 52fb69a4acb49d7e4f52989a7cc71f4f01074098 Mon Sep 17 00:00:00 2001 From: rawal Date: Mon, 26 Apr 2021 17:27:04 -0400 Subject: [PATCH] return none if pdu controller hosts not defined in inventory --- tests/common/plugins/pdu_controller/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/common/plugins/pdu_controller/__init__.py b/tests/common/plugins/pdu_controller/__init__.py index 76fa4f78340..80f9225a6e5 100644 --- a/tests/common/plugins/pdu_controller/__init__.py +++ b/tests/common/plugins/pdu_controller/__init__.py @@ -18,6 +18,11 @@ def pdu_controller(duthosts, enum_rand_one_per_hwsku_hostname, conn_graph_facts, duthost = duthosts[enum_rand_one_per_hwsku_hostname] inv_mgr = duthost.host.options["inventory_manager"] pdu_host_list = inv_mgr.get_host(duthost.hostname).get_vars().get("pdu_host") + if not pdu_host_list: + logging.info("No 'pdu_host' is defined in inventory file for '%s'. Unable to create pdu_controller" % + duthost.hostname) + yield None + return pdu_hosts = {} for ph in pdu_host_list.split(','): var_list = inv_mgr.get_host(ph).get_vars()