The transition to NetApp MS Azure AD B2C is complete. If you missed the pre-registration, you will be invited to reigister at next log in.
Please note that access to your NetApp data may take up to 1 hour.
To learn more, read the FAQ and watch the video.
Need assistance? Complete this form and select “Registration Issue” as the Feedback Category.

Software Development Kit (SDK) and API Discussions

Cant get 'up-ports' to print

mason_als

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

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

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

mason_als

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. 

Announcements
NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public