I am new to using Python and the NASDK and was trying to determine how to return some data from the security-config-get api. Here is some sample code I used to gather the data and the output that I can get from it. As you can see I can get the some of the data out, but I only get one of the supported ciphers. I have tried several ways to use a 'for in' loop. It does show me that there are 3 ciphers but the i have not been able to figure out how to get the 3 actual names into a variable to use for verification. I am sure whatever the answer to this is would/could be used in similar situations with other API calls. Thanks
api = NaElement("security-config-get")
xi = NaElement("desired-attributes")
api.child_add(xi)
xi1 = NaElement("security-config-info")
xi.child_add(xi1)
xi1.child_add_string("cluster-security-config-ready","<cluster-security-config-ready>")
xi1.child_add_string("interface","<interface>")
xi1.child_add_string("is-fips-enabled","<is-fips-enabled>")
xi1.child_add_string("supported-ciphers","<supported-ciphers>")
xi2 = NaElement("supported-protocols")
xi1.child_add(xi2)
xi2.child_add_string("security-supported-protocols","<security-supported-protocols>")
api.child_add_string("interface","ssl")
xo = s.invoke_elem(api)
if (xo.results_status() == "failed") :
print ("Error:\n")
print (xo.sprintf())
sys.exit (1)
print ("Received:\n")
print (xo.sprintf())
attribs = xo.child_get("attributes")
result=attribs.children_get()
for res in result:
i = res.child_get_string("interface")
f = res.child_get_string("is-fips-enabled")
c = res.child_get_string("supported-ciphers")
p1 = res.child_get("supported-protocols").child_get_string("security-supported-protocols")
print (i)
print (f)
print (c)
print (p1)
OUTPUT___________________
Received:
<results status="passed">
<attributes>
<security-config-info>
<cluster-security-config-ready>true</cluster-security-config-ready>
<interface>ssl</interface>
<is-fips-enabled>false</is-fips-enabled>
<supported-ciphers>ALL:!RC4:!LOW:!aNULL:!EXP:!eNULL</supported-ciphers>
<supported-protocols>
<security-supported-protocols>tlsv1.2</security-supported-protocols>
<security-supported-protocols>tlsv1.1</security-supported-protocols>
<security-supported-protocols>tlsv1</security-supported-protocols>
</supported-protocols>
</security-config-info>
</attributes>
</results>
ssl
false
ALL:!RC4:!LOW:!aNULL:!EXP:!eNULL
tlsv1.2