Subscribe
Accepted Solution

Cant get 'up-ports' to print

[ Edited ]

Writig this in Python 2. Im trying to print the up ports to print, but they show up as None. It should print out 4 ports. 

Ontap 9.1, API 110

 

2 For loops

 

out = server.invoke("net-port-ifgrp-get","ifgrp-name","a0a","node","tsccfs05n01a")
test = out.child_get("attributes")
test_list = test.children_get()
for mlag in test_list:
	port = mlag.child_get('ports').children_get()
	for status in port:
		up = port.child_get_string('lif-bindable')
		print "UP: " , up

 

 

 

Ouput:

UP: None
UP: None
UP: None
UP: None

 

When i try to do it with only one for loop:

 

out = server.invoke("net-port-ifgrp-get","ifgrp-name","a0a","node","tsccfs05n01a  )
test = out.child_get("attributes")
test_list = test.children_get()
for mlag in out.child_get("attributes").children_get():
	port = mlag.child_get('up-ports').child_get_string('lif-bindable')
	print "Port: " + port

 

Output:

Port: e0e

Re: Cant get 'up-ports' to print

[ Edited ]

As there are no child under array, you cannot access value with standard child_get

 

But this one works,

test = out.child_get("attributes")
test_list = test.children_get()
for mlag in test_list:
ports = mlag.child_get('ports').children_get()
ifgrp = mlag.child_get_string('ifgrp-name')
for port in ports:
print("UP: ", port.element['content'])

 

Re: Cant get 'up-ports' to print

Thank you, that seems to have worked. Appreicate it. I do have a quick question, is the port.element['content'] a netapp api function or python function. I did not see that in the Netapp Api documentation.