Dynamic configuration and execution NetScaler using HTTP callout and NITRO

8:51 PM
Dynamic configuration and execution NetScaler using HTTP callout and NITRO -

HTTP callout

An HTTP legend is an HTTP request that the device generates and sends an external application when certain criteria are met in the evaluation of policies. The information is retrieved from the server can be analyzed and used to make a decision.

When the NetScaler (configured with http legend in the policies / actions) receives a client request or server response, the Policy Evaluation and hold briefly sends an HTTP request to the HTTP legend officer using the parameters configured for the specified HTTP legend. Upon receipt of the response, the device inspects the specified part of the answer, and then either performs an action or evaluates the next policy, according to the assessment of the response of the HTTP callout agent evaluates to TRUE or FALSE , respectively. Here is the flow HTTPCallout for configuring demand side

How HTTPCallout works

API NITRO

protocol nitro NetScaler allows you to configure and monitor the programming NetScaler appliance.
Nitro exposes its functionality through Representational State Transfer (REST) ​​interfaces.

for details on API nitro, Please checkout the blogs

NITRO API: Fun on HTTP

NITRO API: Dynamic behavior using HTTP requests

HTTPCallout and Netscaler reminder

Similar to external servers, HTTPCallout can call a vserver http or MIP or SNIP. If there is a SNIP or MIP with management access is enabled, HTTPCallouts can call the device administration utilities. By accessing the API using NITRO callout we can achieve runtime configurations.

Steps to make it work

  • Create SNIP with an internal IP address and enable access management.
  • Create a http legend
  • Update httpcallout parameters with SNIP and NITRO http requests
  • Create actions / policies to call the legend
  • Bind the policy to make it active.

When using

  • for the allocation of resources based Time / charge. What of the application have a peak load at a particular time. We can have a legend to link additional services on demand depending on the application's throughput and the number of connections. Once the condition becomes normal (again by checking the well put or other attributes), we can remove some of the services.
  • in due cache flush time. We can monitor the cache memory usage of the group and on the basis that we can clear some content groups
  • Dynamic updating the dataset. The data sets as patset can be updated on the fly. For example, the new user names on a website (one that records to a website) can be added patset which holds the username configured to allow valid.
  • And much more on the basis of conditional dynamic configuration changes.

Example 1

separate certain services based on the connection details

say we want to disassociate a service or services based on the group number of input connections. If the connections are less than 1000 remove a service group / service of a vserver lb

Status :. Number of connection to the vserver "VSERVER1" is less than 1000

action : Remove the service "SVC2" of vserver

configuration:

add ip 255.255.255.0 1.1.1.1 kind SNIP -mgmtAccess ENABLED
add political httpCallout unbind_service
set policy httpCallout unbind_service -IPAddress 1.1.1.1 -port 80 -hostExpr " nitro.callout.net " '-returnType BOOL -httpMethod POST -urlStemExpr" "/ nitro / v1 / config " "-headers Content-type (" application / x-www-urlencoded form ")" -Settings object (authorization ( "Basic bnNyb20Om5zcm9vdA ==)" { "params " { "action ": " unbind"}, "lbvserver_service_binding " { "name ": "VSERVER1 " "serviceName ": "SVC2 "}} ") -resultExpr q / HTTP.RES .Body (1000) .AFTER_STR (" Message ": " "). BEFORE_STR ( "" "). EQ (" Done ") /

add responder political call_unbind_service" SYS.VSERVER ( "VSERVER1 "). CONNECTIONS.LT (1000) && SYS.HTTP_CALLOUT (unbind_service) "NOOP
bind lb vserver VSERVER1 -policyName call_unbind_service -priority 100 NEXT -gotoPriorityExpression

Authorization header is anything but coded base64 username password using the basic authentication type.
demand real Callout

POST / nitro / v1 / config HTTP / 1.1 r n
Content-Type: application / x-www-form-urlencoded r n
host: callback.callout.net r n
Accept: * / * r nContent-Length: 109 r n
authorization: Basic bnNyb20Om5zcm9vdA == r n
r n
= {object "params": { "action", "unbind"}, "lbvserver_service_binding": { "name" "VSERVER1", "serviceName": "SVC2"}}

legend response

HTTP / 1.1 0 OK r n
Date: Fri, 2 Aug 2011 9:16:50 GMT r n
server: Apache r n
Expires: Thurs November 19, 1981 8:52:00 GMT r n
Cache-Control: no-store, no-cache, must-revalidate, post-check = 0, pre-check = 0 r nPragma: no-cache r n
Content-Length: 64 r n
Content-Type: application / json; charset = utf-8 r n
r n
{ "errorcode": 0, "message": "done"}

Similarly a different caption can help to link the service / servicegroup back if treatment vserver peaked.

Example 2

Clear cache on contentGroup default when day changes

Status: When the date changes

action clear the cache in contentGroup default

We need to store the sys date somewhere and compare it with the current date . If it has changed we need to remove the cover. currently there is no way to store data in NetScaler. But even using nitro + callout we can store in the political comment section.

So here's what we need

  • A legend to set the system date in comment the policy parameters
  • A legend to clear the cache
  • a legend for the stored dates
  • a policy to check the current sys date is changed from memory.

Configuration

add political sys_date term "SYS.TIME.DAY + " - "SYS.TIME.MONTH + + "- " + SYS.TIME.YEAR "
add political httpCallout store_system_time
add political httpCallout flush_cache
add political httpCallout get_stored_time

define httpCallout store_system_time policy - IPAddress 1.1.1.1 -port 80 -returnType BOOL - HTTPMethod POST -hostExpr "" callback.callout.net "" -urlStemExpr "" / nitro / v1 / config "" -headers Content-type ( "application / x -www-form-urlencoded ") authorization (" "the subject of) (" Basic bnNyb20Om5zcm9vdA == { "params " { "action ": "set "} "responderpolicy " { "name ": "check_date ", "comment ": "" + sys_date + ""}} ") -resultExpr q / HTTP.RES.BODY (1000) .AFTER_STR (" Message "" ") BEFORE_STR (" "") .EQ ( "Done") /

set policy httpCallout flush_cache -IPAddress 1.1.1.1 -port 80 -returnType. BOOL POST -hostExpr -httpMethod "" callback.callout.net "" -urlStemExpr "" / nitro / v1 / config "" -headers Content-type ( "-form-urlencoded x-www / application") object -Settings authorization ( "bnNyb20Om5zcm9vdA Basic ==") ( "{" params "{" action ": " flush "} " cachecontentgroup "{" name ": " default "}}") -resultExpr q / HTTP.RES.BODY (1000) .AFTER_STR ( "Message " ""). BEFORE_STR ( "" "). EQ (" Done ") /

set policy httpCallout get_stored_time -IPAddress 1.1 .1.1 -port 80 -returnType TEXT -hostExpr" "callback. callout.net "" -urlStemExpr "" / nitro / v1 / config / responderpolicy / check_date "" -headers authorization ( "bnNyb20Om5zcm9vdA Basic ==") -resultExpr q / HTTP.RES.BODY (1000) .AFTER_STR ( "comment " "" ( "") ALT "0" /
add responder check_date policy "(from sys_date = SYS .HTTP_CALLOUT (get_stored_time))" NOOP
add political machine) BEFORE_STR! ". set_date "SYS.HTTP_CALLOUT (store_system_time)" NOOP
add responder political flush_cache "SYS.HTTP_CALLOUT (flush_cache)" NOOP
add responder policylabel flushcache_and_setdate
bind answering policylabel flush_cache flushcache_and_setdate 1 NEXT
answering bind policylabel flushcache_and_setdate set_date 2 END
bind lb vserver vsvrLB -policyName check_date -priority 1 -gotoPriorityExpression END -invoke policylabel flushcache_and_setdate

Previous
Next Post »
0 Komentar