NetApp Community Update
This site will enter Read Only mode on July 23 as we prepare to move to a new platform. You will still be able to view content, but posting and replying will be temporarily disabled.
We're excited to launch our new Community experience on July 30 and more information will follow soon.
Stay connected during the transition - Join our Discord community today.

Software Development Kit (SDK) and API Discussions

Cant get 'up-ports' to print

mason_als
4,750 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
4,668 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
4,669 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
4,654 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