Now that we have defined our requirements for the tool, we can clearly see how to organize our script:
• All functions that make SOAP calls need to be defined in a separate module. This module can be imported by various scripts, which could make use of the same functions.
• It would be good to define one class containing methods for accessing web services, so that anyone could simply inherit from this class and extend with additional functionality.
• The tool will consist of two distinct parts—one to read statistical data and the other to control services..
Mapping this to source code, we are going to have the following files and modules:
1. Our own library NSLib.py, which is going to contain definitions for the following:
• The NSLibError exception class. Whenever we encounter any unrecoverable issues, we will raise this exception.
• The NSSoapApi class. This is the root class and implements methods common to all Netscaler SOAP API objects: initialization and login.
• The NSStatApi class, which inherits the NSSoapApi class. This class implements all methods that deal with statistics gathering and monitoring. It only performs calls defined by Statistics WSDL.
• The NSConfigApi class which inherits NSSoapApi class. This class implements all methods that deal with loadbalancer configuration and calls methods defined by Configuration WSDL.
2. ns_stat. py. This file uses NSStatApi from NSLib and in the actual script that implements our statistic gathering tasks. This is the script we will be calling from the command line.
3. ns_conf. py. This file uses NSConfigApi from NSLib and is the actual script that implements our load balancer configuration tasks. This is the script we will be calling from the command line.
4. ns_config. py. This is our configuration script that contains all definitions we need to establish communication with the load balancer. See detailed description below.
Was this article helpful?