API Documentation

Python interface interacting with a Citrix NetScaler application delivery controller, utilizing the SOAP API to execute commands.

Special thanks to Allen Sanabria (asanabria@linuxdynasty.org) for the initial work on getting the API working with python-suds.

Original post: http://tinyurl.com/yl4o6vq

class netscaler.API(host=None, wsdl_url=None, soap_url=None, wsdl='NSConfig.wsdl', autosave=True, **kwargs)

Pass any kwargs to init that you would to the suds.client.Client constructor. A little bit of magic is performed with the ImportDoctor to cover missing types used in the WSDL.

  • If you specify wsdl, this file will be pulled from the default http URL
  • If you specify wsdl_url, it will override the wsdl file. Local
file://” URLs work just fine.
  • If you do not specify autosave, it will be enabled by default for volatile operations.

To save time for re-usable code, it is a good idea subclassing this to create methods for commonly used commands in your application. Example:

class MyAPI(netscaler.API):

    def change_password(self, username, newpass):
        return self.run("setsystemuser_password",
            username=username, password=newpass)
is_readonly(cmd)

Validates whether a command is read-only based on READONLY_COMMANDS

login()

Performs API login.

logout()

Performs API logout.

run(command, **kwargs)

Runs the equivalent of self.client.service.command(**kwargs).

Will perform login() if self.logged_in == False. Will perform save() on volatile operations if self.autosave == True.

save()

Saves NS Config.

exception netscaler.InteractionError

Generic API error