Subscribe

How to print some aggr info in text format using API

I am trying to print the aggregate info (size and used space) in text format . Can some one help.

 

Ontap: 8.3.2 p2

 

api = NaElement("aggr-space-get-iter")

xi = NaElement("desired-attributes")
api.child_add(xi)


xi1 = NaElement("space-information")
xi.child_add(xi1)

xi1.child_add_string("aggregate","<aggregate>")
xi1.child_add_string("aggregate-size","<aggregate-size>")
xi1.child_add_string("physical-used","<physical-used>")
xi1.child_add_string("physical-used-percent","<physical-used-percent>")

xi2 = NaElement("query")
api.child_add(xi2)


xi3 = NaElement("space-information")
xi2.child_add(xi3)

xi3.child_add_string("aggregate","aggr1*")

xo = s.invoke_elem(api)
if (xo.results_status() == "failed") :
print ("Error:\n")
print (xo.sprintf())
sys.exit (1)

aggrs= xo.child_get("attributes-list").child_get("space-information").children_get()

for aggr in aggrs:
print (aggrs.child_get("aggregate"))

Getting following error,

print (aggrs.child_get("aggregate"))
AttributeError: 'list' object has no attribute 'child_get'

 

Re: How to print some aggr info in text format using API

You have to iterate through attributes-list

 

aggrs= xo.child_get("attributes-list").children_get()

for aggr in aggrs:
print ('name {} {}'.format(aggr.child_get_string("aggregate"),aggr.child_get_string("physical-used")))

 hope that help

Re: How to print some aggr info in text format using API

Worked!! Thank you very much Smiley Happy