How to Perform Multiple Operations on NetScaler Using Single NITRO API Call

How to Perform Multiple Operations on NetScaler Using Single NITRO API Call

book

Article ID: CTX219929

calendar_today

Updated On:

Description

This article describes how to perform multiple operations on NetScaler appliance using single NITRO API call.

Background

One of the most basic sets of API operations used frequently by administrators is one that creates a set of lbvservers, services, and service groups, and adds the necessary bindings. This and similar tasks used to require multiple NITRO API commands, because the NITRO API did not support bulk configuration. Customers needed an API that could reduce network traffic by optimizing the execution of multiple tasks.

NetScaler release 11.1 introduced an API resource called macroapi, with which you can configure heterogeneous resources with a single API command.


Instructions

Points to Remember

  • Only homogenous operations are supported in a single macroapi request. For example, multiple load balancing virtual servers can be created (POST method) but cannot be updated (PUT method) or deleted (DELETE method) in the same macroapi request.
  • NITRO handles each request in an atomic manner.
  • Failures can be handled by using the X-NITRO-ONERROR http header, which specifies what to do when any of the calls in the bulk request fails. Possible options are continue, exit (the default), and rollback (for ADD or BIND operations only).
  • To delete multiple resources when using MACRO API, you must use the POST HTTP method with an action=remove query parameter in the request URL

Request for Creation Using NetScaler NITRO API Call

Add 2 lbvservers, 5 services, and 1 service group, add members to the service group, bind service(s) to the lbvserver(s) and bind the service group to lbvserver(s).

URL: http://<NSIP>/nitro/v1/config/macroapi
HTTP Method: POST
Request Headers
Content-Type: application/json
X-NITRO-ONERROR: exit
Payload:

{ "lbvserver": [

{"name":"lbvserver1","servicetype":"http"},

{"name":"lbvserver2","servicetype":"http"} ],

"service":
[
{"name":"service1", "servername":"10.102.216.115", "port":"80", "servicetype":"http"}, {"name":"service2","servername":"10.102.216.108", "port":"80","servicetype":"http"},

{"name":"service3","servername":"10.102.216.109", "port":"80","servicetype":"http"}, {"name":"service4","servername":"10.102.216.54", "port":"80","servicetype":"http"}, {"name":"service5","servername":"10.102.216.175", "port":"80","servicetype":"http"} ],

"lbvserver_service_binding":
[
{"name":"lbvserver1", "servicename":"service1"}, {"name":"lbvserver1", "servicename":"service2"}, {"name":"lbvserver1", "servicename":"service3"}, {"name":"lbvserver2", "servicename":"service4"}, {"name":"lbvserver2", "servicename":"service5"} ],

"serviceGroup": [

{ "servicegroupname": "servicegroup1", "servicetype": "HTTP" } ],

"servicegroup_servicegroupmember_binding": [

{ "servername":"10.105.157.72","servicegroupname":"servicegroup1","port":"80"},

{ "servername":"10.105.157.246","servicegroupname":"servicegroup1","port":"80"} ],

"lbvserver_servicegroup_binding": [

{ "name":"lbvserver1", "servicegroupname":"servicegroup1" } ]

}

Request for Update Using NetScaler NITRO API Call

Update lbmethod for 2 lbvservers and timeout for servicegroup

URL: http://<NSIP>/nitro/v1/config/macroapi
HTTP Method: PUT
Request Headers Content-Type: application/json
X-NITRO-ONERROR: exit
Payload: 
{ 
"lbvserver": 
[ 
{"name":"lbvserver1","lbmethod":"roundrobin"}, 
{"name":"lbvserver2","lbmethod":"roundrobin"} 
], 
"serviceGroup": 
[ 
{ "servicegroupname": "servicegroup1",
 "svrtimeout": "10" } 
] 
}

Request for Deletion Using NetScaler NITRO API Call

Delete 2 lbvservers, 5 services and 1 servicegroup

URL: http://<NSIP>/nitro/v1/config/macroapi?action=remove
HTTP Method: POST
Request Headers
Content-Type: application/json
X-NITRO-ONERROR: exit
Payload:
{
"lbvserver":
[
{"name":"lbvserver1"},
{"name":"lbvserver2"}
],
"service":
[
{"name":"service1"},
{"name":"service2"},
{"name":"service3"},
{"name":"service4"},
{"name":"service5"}
],
"serviceGroup":
[
{ "servicegroupname": "servicegroup1"}
]
}

Issue/Introduction

This article describes how to perform multiple operations on NetScaler appliance using single NITRO API call.

Additional Information

Citrix Documentation - Handle Multiple NITRO Calls in a Single Request