I'm trying to gather interface details for a Palo Alto network device; however, when I return a tuple, it is returning the last element of the for loops.
#find interface using palo sdk
def check_interface(hostname):
show_interface_all = connect_to_fw(hostname).op('show interface "all"', xml=True) # func called from some other func
interface_jason = xmltodict.parse(show_interface_all)
for int_details in interface_jason["response"]["result"]["hw"]["entry"]:
for i in interface_jason["response"]["result"]["ifnet"]["entry"]:
zone = i["zone"]
ip =i["ip"]
break
int =int_details["name"]
state = int_details["state"]
result_1 = (int,state,ip,zone) # tuple
return result_1
Expected output of this would be:
('ethernet1/3', 'down', '192.168.2.1/30', DMZ)
('ethernet1/4', 'down', '192.168.2.1/30', trust)
('ethernet1/7', 'up', '192.168.2.1/30', untrust)
Hhowever I'm getting only a single value which is the last value of the loop:
('ethernet1/3', 'down', '192.168.2.1/30', DMZ)
How do I fix it?