NetScaler Automating with NITRO RESTful Services Setting Recommendations and best practices for a generic implementation of a NetScaler appliance

9:03 PM
NetScaler Automating with NITRO RESTful Services Setting Recommendations and best practices for a generic implementation of a NetScaler appliance -

Introduction

Lately, I was able to work with NetScaler some awareness want to increase and down some general knowledge of this vital function NetScaler programmatically via the API NITRO NetScaler and I have. The purpose of this article is not necessarily here to show the full intricacies of NITRO, but I want some ways to share, and maybe you start on the path of NetScaler automation! The NetScaler NITRO API is a RESTful service within the NetScaler life that you can interact with it by changing configuration or statistics to obtain the device from. NITRO is in a variety of languages ​​and SDKs available. Whether your favorite language is Python, Java, C #, Perl, or plain HTTP calls using the REST interface, we have a way to interact with the NetScaler. Each NITRO SDK is. Your respective NetScaler on the Download tab on the right corner available

NetScaler NITRO SDKs
NetScaler NITRO SDKs
done The purpose of NITRO SDKs in any programming language of NITRO API RESTful interface and allows you to work with them through standard methods of interaction in each respective language. While this article interaction via simple HTTP calls goes to show via the REST interface, you might think the entire application in Python or Java write. Even if you would your code in Java or Python to write the code to be translated to the respective REST call, as shown below.
NITRO RESTful Services
NITRO RESTful Services

Use Case

For the first blog in this series, I wanted to present to Citrix Support -Article that you may be familar with. The CTX products are we NITRO be handling the recommended settings and best practices for a generic implementation of a NetScaler appliance. A colleague colleague here in Citrix Consulting and I talked about this support article often over several NetScalers implementation and we were thinking about how to make it fast and simple to do so. We both ended quickly NITRO.

The tool

Before we begin NetScaler NITRO we need to have a method to do this interaction. As already mentioned, you can use Java or Python, or other languages, but I want to show the barebones of how NITRO communicates with NetScaler. We will use HTTP GETs, PUTs, posts and other methods to address the NetScaler. This type of communication can HTTP clients such as curl, wget, or more frequently is done browser extensions. I have to work and have the Google Chrome extension POSTMAN grown like. POSTMAN is an extension that you add chromium, the REST can intercept and even create requests to APIs. Here you can see my POSTMAN Setup.
POSTMAN

  • In this screenshot you can see my collections in the left column to see that. A number of questions, which I collected together
  • on the main window you are able, the HTTP POST request, to see that I do. With URL parameters, header am given the body and payload
  • You can also use the response of the body to see the header, and other data from the NetScaler after I clicked on the Send button

POSTMAN up and running all you need two Google install Chrome extensions do is

  • Postman - .. REST client (Packaged app)
  • Postman Interceptor

Best practices via REST

  1. the first step with NetScaler via REST in the interaction log. For this we need to create a login request.
    NITRO Login
    NITRO Login
    • URL: http://192.168.1.50/nitro/v1/config Register /
    • type: POST
    • header:
      • content-type: application / vnd.com.citrix.netscaler .login + json
    • data - RAW:
       { "login": { "username": "nsroot", "password", "nsroot" "timeout": 00}} 

    here you can see how the connection is made to NITRO. We enter a URL to resource NITRO / Nitro / v1 / config / login. Enter the header, while ensuring that the login method to close and we would like to communicate via json. Finally, the data are a login block with the user name, a password and the timeout of the connection set. If all goes well, the NetScaler is a stand of 201 Reply Posted indicating that all is well and NITRO_AUTO_TOKEN will be created for you. You can see this token in the cookie of the reaction in POSTMAN.

    NITRO Login Auth Token
    NITRO Login Auth token
    It is important to be aware of this cookie, as all future communication with NITRO it must include. Fortunately POSTMAN handles that automatically and we do not have to worry about for us.

  2. The second step is to be the current modes enabled. This is not necessarily a part of the CTX products, but it is understood to be a good how to do something like this on NITRO. You can get this knowledge features and functionality to take and apply to other things as LBVServers about NITRO.
    NITRO: Get Modes
    NITRO: Get modes
    • URL: http://192.168.1.50/nitro/ v1 / config / nsmode
    • type: GET
    • header:
      • content-type: application / vnd.com. citrix .netscaler.nsmode + json

    Confirm the URL and type. Since this is a GET, we need no payload or data to specify. Check out the header and make sure that they comply with the procedure we ask nsmode. This is important. Compare the header here on the header in step one. These headers are always match your method that you use, are when they interact with NITRO. In the screenshot above you shows the reaction of NetScaler that the FR see L3, USIP, edge, ect .. modes are activated.

  3. This begins the first step in the CTX products. Enable modes
    NITRO: Enable Modes
    • URL :. http://192.168.1.50/nitro/v1/config/nsmode?action=enable
    • Type: POST
    • URL params:
      • action: enable
    • header:
      • content-Type: application / vnd.com.citrix.netscaler .nsmode + json
    • data - RAW:
       { "nsmode": { "mode": [              "FR",              "L3",              "USIP",              "Edge",              "USNIP",              "PMTUD"          ]}} 

    be sure to confirm the URL params set in this HTTP POST. The content-type corresponds to the method that we carry out, as in step two. If all goes well, our response should be a status of 0 OK.

  4. We also need to disable some modes. We are almost the same as before, to disable just us the action flip.
    • URL: http://192.168.1.50/nitro/v1/config/nsmode?action=disable
    • Type: POST
    • URL params:
      • action: disable
    • header:
      • content Type: application / json vnd.com.citrix.netscaler.nsmode +
    • data - RAW:
       { "nsmode": { "mode": [              "L2",              "RISE_APBR",              "RISE_RHI",              "BridgeBPDUs",              "SRADV",              "DRADV",              "IRADV",              "SRADV6",              "DRADV6",              "CKA",              "TCPB",              "MBF"          ]}} 

    As previously, if all is well, our response status, a 0 will be OK.

  5. In my screenshots above I like the Get modes run function again to verify that our amendments through. See to step two if you need help, this has reentered.
  6. The next step in the CTX item is a couple of different functions to configure. In this example, I take advantage of NITRO bulk methods, so I do a few things at once. You can see immediately be treated in the data area of ​​the request this via several methods. Be sure that each method and configuration of the CTX products for NITRO call down to up
    NITRO: Best Practices Config
    • URL :. http://192.168.1.50/nitro/v1 / config /
    • Type: put
    • header:
      • content-Type: application / vnd.com.citrix. NetScaler + json
    • data - RAW:
       { "nstcpparam": { "ws", "ACTIVE", "bag", "ACTIVE" "Nagle": "ACTIVE"}, "rnatparam": { "tcpproxy": "ACTIVE"}, "nsparam": { "cookie version": "1"}, "nshttpparam": { "dropinvalreqs": "ACTIVE"} "snmpalarm": { "trapname": "CPU usage", "threshold": 95 "normal value": 35, "Heavy": "Informational", "state", "ACTIVE", "Logging": "ENABLED"} "snmpalarm": { "trapname": "MEMORY", "threshold": 95 "normal value": 35, "severity", "Critical", "State", "enabled", "Logging": "eNABLED"}} 

    you may have noticed that the content-type header nor matches our method in the URL, in this case, nothing. We also use such compositions to put such methods snmpalarm things nsparam and nstcpparam everything at once. If you want, you can request multiple calls to the same URL cleavage using form data into individual segments. IE) handling only the nstcpparam, runs it, and then move to the next. Since we contains a bulk method here NITRO responds with a status of 0 OK and the reply text do details on each method we use. In the screenshot you can see a way to the details in the body.

  7. The next step in the CTX products is to disable interfaces that are down. To do this we must first find out what interfaces are down. We can make a GET NITRO use request for the
    NITRO: Get down interfaces
    • URL: http://192.168.1.50/nitro/v1/config/interface?filter=state: Disabled
    • type: GET
    • header:
      • content-type: application / vnd.com.citrix.netscaler. Interface + json
    • URL params:
      • Filter: State: disabled

    the first thing they remember that the content-Type header - it must match the URL request - in our case interface. Next, we introduce a way to our response filtering. We want to obtain only interfaces that are disabled, so we close the filter with param state: disabled. Finally, check out the answer text in my screenshot. Here you can see the device ID, device name and other information on this particular interface. The device ID is important because we will use it in the next step.

  8. Now we have to disable the interfaces that are down. Remember that the device ID? They are here with
    NITRO: Disable Interface
    • URL :. http://192.168.1.50/nitro/v1/config/Interface?action=disable
    • [1945014Typ] POST
    • URL params:
      • action: disable
    • header
      • content-Type: application / vnd.com.citrix.netscaler.Interface + json
    • data - RAW:
       { "interface": { "id": [              "1/1"          ]}} 

    remember that the content-Type. Also be aware, the action in the URL params we disable the port so we set to disable it. Finally, check the data. Here we give this device ID. If we had more, we could list them all here. if there are, as usual, no problems with NITRO 0 OK will respond.

  9. The final step in the CTX products would be disable HA monitoring for the specific interface.
    NITRO: Disable HA Mon
    • URL: http://192.168.1.50/nitro/v1/config/
    • Type: put
    • header
      • content-Type: application / json vnd.com.citrix.netscaler +
    • data - RAW:
       { "interface": { "id": "1/1", "hamonitor": "OFF"}} 

    Be the content- Type aware through the uRL method adaptation and the data.

  10. we are now done with the Best Practices Guide, and we should save our configuration. Lets get to it
    NITRO: Save Config
    • URL: http://192.168.1.50/nitro/v1/config/nsconfig?action=save
    • type: POST
    • header:
      • content-type: application / json vnd.com.citrix.netscaler.nsconfig +
    • URL params:
      • action: save
    • data - RAW:
       { "nsconfig": {}} 

    Whatever it be the content-type aware, check your params - we save this time and the data. The NetScaler responds with a 0 OK if all is well.

  11. Finally, should the final step in a NITRO interaction is logged.
    NITRO: Logout
    • URL: http://192.168.1.50/nitro/v1/config/logout
    • Type: POST
    • header:
      • content-Type: application / json vnd.com.citrix.netscaler.logout +
    • data - RAW:
       { "logout": {}} 

    remember, this header! The NetScaler responds with a 201 created when you initiate a logoff.

Conclusion

I hope this helps you on your way to an automated NetScaler move. If you have any feedback or questions, please free to posting them in the comments. Also I will continue on the way of adding some additional NetScaler NITRO blog posts in the future in this series. If you please post large applications or anything that you want to see happen over NITRO below! Speaking! All my POSTMAN configuration for this specific item is in the following resources. To get up and running, all you need to do is to install two Google Chrome Extensions (one and two), import my collection in POSTMAN, and change the IP addresses to your NSIP.

resources

My POSTMAN Collection

https://www.getpostman.com/collections/94ff021b2ccc854922ba

cURL with the NetScaler Nitro REST API

/ blogs / 2014/02 / 04 / using-curl-with-the-NetScaler nitro rest api /

Previous
Next Post »
0 Komentar