Greetings,
I just ran into an interesting problem:
In Qapp, when I script a GDT Variable to check if a another GDT Table or Table Variable is empty, it does not work using pythonic way. How can I get to check if a Table Attribute (list) is empty or not without coming up with other creative solutions? Basically, the Attribute (list) or Table appears to never be empty despite containing no data.
BID Table has _device, id and mac_limit attributes.
GDT Table has attribute “note” that I use for scripting.
When I check if BID Table (list) or BID.bid attribute (list) is empty is doesn’t return true for empty using pythonic way:
#Check if BID.bid (list) is empty:
if not $BID.bid:
$cell = “PASSED: Bridge-Domains are not configured”.
Although empty, it doesn’t match and continues to go through next else statement: The value returned is “None”.
In the note, I run the following script:
try:
if $mpls_ldp is None:
$cell = "NOT APPLICABLE: Device is not a PE Device."
else:
if not $BID.bid:
$cell = "PASSED: Bridge-Domains are not configured."
else:
code = 0
result = ]
rc = $BID.GetRowCount()
for x in range(rc):
if $BID.mac_limit x] is None:
code = code + 1
result.append("FAILED: " + str($BID.bidx]) + " does not have a MAC address limit configured.")
if code == 0:
$cell = "PASSED: All Bridge-Domains have a MAC address limit configured."
else:
$cell = '\n'.join(result)
except:
$cell = "NOT REVIEWED: Unable to validate configuration."
Qapp with BID Table having content:
BID Table without content:
GDT Table, note variable showing “NONE” from $BID.bid attribute (list) output, despite being empty:
Code: