Software Development Kit (SDK) and API Discussions

python + SDK vserver info gives a error.

RaghavaCheruku
1,374 Views

cat vserver_info1.py

#!/usr/bin/env python3

import sys

sys.path.append("/opt/netapp-manageability-sdk-9.4/lib/python/NetApp")

from NaServer import *

from getpass import getpass

 

def vserver_info(s):

    t1 = NaElement("vserver-get-iter")

    out = s.invoke_elem(t1)

    if (out.results_status() == "failed"):

        print("Error:\n")

        print(out.sprintf())

        sys.exit(1)

    #print(out.sprintf())

     

    info = dict()

    info = out.child_get("attributes-list")

    for info1 in info.children_get():

        print("vserver-Name: %s" % info1.child_get_string("vserver-name"))

        print("vserver-type: %s" % info1.child_get_string("vserver-type"))

        print("vserver state %s" % info1.child_get_string("state"))

        print("vserver-ipspace: %s" % info1.child_get_string("ipspace"))

        print("vserver root volume%s" % info1.child_get_string("root-volume"))

        print("vserver language: %s" % info1.child_get_string("language"))

        print("Vserver snapshot policy: %s" % info1.child_get_string("snapshot-policy"))

        pro = dict()

        pro = info1.child_get("allowed-protocols")

        for pro1 in pro.children_get():

            print("protocol enabled: %s" % pro1.child_get_string("protocol"))

 

def main():

 

    s = NaServer(filer, 1, 3)

    resp = s.set_style('LOGIN')

 

    if (resp and resp.results_errno() != 0):

        r = resp.results_reason()

        print("Failed to set authentication style " + r + "\n")

        sys.exit(2)

 

    s.set_admin_user(user, pw)

    resp = s.set_transport_type('HTTPS')

 

    if (resp and resp.results_errno() != 0):

        r = resp.results_reason()

        print("Unable to set HTTP transport " + r + "\n")

        sys.exit(2)

 

    vserver_info(s)

 

#args = len(sys.argv) - 1

 

#if (args < 2):

#    print_usage()

 

#filer = sys.argv[1]

#user = sys.argv[2]

#pw = getpass("please end the password :")

 

filer = 'netapp-bb98.labx.mo.sap.corp'

user = 'admin'

pw = 'netapp123'

 

main()

############################################################

when I execute the program,

#python3 vserver_info1.py

vserver-Name: Cluster

vserver-type: system

vserver state None

vserver-ipspace: Cluster

vserver root volumeNone

vserver language: None

Vserver snapshot policy: none

Traceback (most recent call last):

  File "vserver_info1.py", line 65, in <module>

    main()

  File "vserver_info1.py", line 50, in main

    vserver_info(s)

  File "vserver_info1.py", line 29, in vserver_info

    for pro1 in pro.children_get():

AttributeError: 'NoneType' object has no attribute 'children_get'

############################################################

can someone help me to understand whats wrong here.  how to fix the issue.

 

regards

Raghava.

0 REPLIES 0
Public