Software Development Kit (SDK) and API Discussions

Cant get 'up-ports' to print

mason_als
3,182 Views

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

1 ACCEPTED SOLUTION

francoisbnc
3,100 Views

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'])

 

View solution in original post

2 REPLIES 2

francoisbnc
3,101 Views

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'])

 

mason_als
3,086 Views

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. 

Public