Have you had a good time writing Java programs and Powershell discussed in previous blogs (/ blogs / 2011/12/07 / nitro-Unleash- powerformer-the-using powershell /). The question is whether the support is limited to these selective programming languages ?? You know the answer, is it ... NITRO API can be used in a scripting languages as far as you can not HTTP-based programming base. Most scripting languages today provide built in HTTP modules to simplify scripting experience and it helps with NITRO well. With scripting languages, we do not have SDKs but you can just build a module for NITRO and use the functions in your scripts.
Let us discuss the implementation of NITRO base Perl that uses basic methods Perl module having nitro_pm. We will discuss the scripting aspect assuming you have the module with you. The module has simple functions defined as:
- ns_login
- ns_logout
- get_object
- get_stats
- print_object
- add_object
- add_bulk_object
- bind_object
- bind_bulk_object
- unbind_bulk_object
- modify_object
- delete_object
- delete_object_by_post
- delete_bulk_object
As you can see with these features, you can do most of the day to day operation and we take now a look at how you will use these functions in the script. We will do following simple tasks that put together the script:
- Log in to NetScaler
- Add vserver LB
- Get LB Details vserver
- Setting / Changing LB vserver
- Withdrawal vserver LB
- Disconnecting NetScaler
go step by step procedure on how we can accomplish. this
Step 1: relevant import libraries
- use nitro;
- use Storable qw (of dclone);
library "nitro" provides functions for creating session / termination, dealing with the LB vserver configuration, handling of the response, etc.
Step 2: Connect to the NetScaler and the creation of a session
Before any functional operation using NITRO API must have a valid established by making the connection to the session NetScaler system [
- $ session = nitro :: ns_login ($ NSIP, $ user, $ pass);
The above code provides nitro session NetScaler with the given IP address and performs login with the username and password password given. You need to analyze and process the response to check any error
Step 3 :. Adding LB vserver
session valid Once you have established, it is very easy to start with a specific configuration vserver LB
- my% lbvserver_hash = ();
- $ lbvserver_hash -> {name} = "lbvip_perl" ;.
- $ lbvserver_hash -> {} servicetype = "http";
- $ result = nitro :: add_object ($ session, "lbvserver" $ lbvserver_hash);
We create a hash LB vserver and setting various properties in the hash. The "add_object" method adds lbvserver on the created session
Step 4 :. Get details of LB vserver
Display the operation is simple and requires only simple API call
- $ result1 = nitro :: get_object ($ session, "lbvserver ") ;.
This call sends you the complete structure for the LB vserver "of lbvip1". You can analyze the results and additional data
Step 5 :. Setting / Changing LB vserver
LB vserver has several properties that you may want to change at runtime using the method "modify_object"
- my% lbvserver_hash_modify = () ;.
- $ lbvserver_hash_modify -> {name} = "lbvip_perl";
- $ lbvserver_hash_modify -> {} lbmethod = "roundrobin";
- $ lbvserver_hash_modify -> {} persistencetype = "SourceIP";
- $ result = nitro :: modify_object ($ session, "lbvserver" $ lbvserver_hash_modify) ;.
To set the properties that we define a vserver hash LB and set key corresponding> value pairs
Step 6: Remove LB vserver
Let us remove the configuration LB vserver we created in this example. It is again a simple operation with a single API call to remove the configuration
- $ result = nitro :: delete_object ($ session, "lbvserver", "lbvip_perl") ;.
We use the same session and calling the method "delete_object" to remove the LB vserver
Step 7 :. Disconnecting NetScaler
As usual logging on the session is very important and is the API
- nitro :: ns_logout ($ session ) right here;
With this, you have ensured the successful disconnection of the system. Make sure you analyze the response and ensure a successful disconnection.
0 Komentar