Scripting: Automate NetScaler configurations with NITRO REST API and PowerShell - Part 1

7:50 PM
Scripting: Automate NetScaler configurations with NITRO REST API and PowerShell - Part 1 -

Part 1: Introduction and first steps

Part 2: Basic Operations and Initial ..

part 3 :. SSL certificates and storefront Load Balancing

Part 4 :. NetScaler Gateway with Storefront configuration

Part 5 :. High Availability configuration

Citrix NetScaler provides a powerful API, the configuration and statistics functionality provides. In this blog series some very powerful and easy to consume scripts with PowerShell coupled through the use of REST Web Services API version speak we produce. Feel free to look at the following documentation that you give some background information on the API:

  • NITRO API
  • REST Web Services

In part 1 of this series of blog posts, we will discuss how we wrapped the REST API with a PowerShell engine and created the first functions that start can be used.

But before we start making some introductory information

to start with a certain clarity, as part of the automation, there are no differences are when the NetScaler appliance Physical or VPX, work is the concern we would do. This includes how we interact with the NetScaler appliance, while the configurations perform and also means that we can reuse a script on both types of devices generally. The scripts (or functions) would be run from an endpoint that management address of the NetScaler can achieve, and we encourage you to secure your connection. This means that you have gone through at least very initial command line configuration on the device, which sets the management IP address (aka NSIP). The same end point at which we must run the scripts include PowerShell V3 or later, because in our examples we use cmdlets introduced in V3 as Invoke-rest Method . The information that we are in this blog about post-series are examples that to approach one of many ways represents the consumption of NITRO REST API and are not meant to be complete or comprehensive.

import sample PowerShell engine and our communication protocol

Importing the NetScaler configuration module (NetScalerConfigurationPart1 module example)

Set In PowerShell, as with many other languages, it is common to save and reuse functionality. This functionality is typically stored in the modules and to use it, we must first import them into our meeting. Of course this requires that we, the module (available below) have, and it is extracted at a known location. We can import our example module (assuming we have exported the contents to C: and remember that must match the folder name .psd1 and .psm1 filename): as follows

 import-module C:  NetScalerConfigurationPart1 

the choice of the management protocol for the web sessions (set NSMgmtProtocol example)

While we recommend a secure connection with using the API, if the NetScaler first comes online, this is not possible. For this reason, you can use the http protocol instead of https change by calling the set-NSMgmtProtocol function. Once set, this is the protocol that is used for this session (or until they are changed or reloads the PS module). This is called using:

 Set-NSMgmtProtocol protocol http 

Connecting and disconnecting of the NetScaler appliance

Connecting the NetScaler appliance and a session (Connect NSAppliance example)

When we combine founding

for NetScaler appliance, we want to create a new web application session, which we store in addition to the management address. This makes it easier, and fro this custom session object for all configuration operations passed. To connect, we need to know the management IP address or DNS name, user name and password. Here we are on our NetScaler appliance in 10.11.12.13:[1945002versucheneineVerbindung]
 $ myNSSession = Connect NSAppliance -NSAddress 10.11.12.13 -NSUserName nsroot -NSPassword nsroot 

from here we can under the different NITRO REST API configuration options with the wrapper function, which we call detail in the section.

from the NetScaler appliance disconnect (Disconnect NSAppliance example)

If we work done with the NetScaler, we can separate the Disconnect NSAppliance function by NetScaler. We simply have this custom session object and call the logout resource type of API. This can be called as follows:

 Disconnect NSAppliance -NSSession $ myNSSession 

The wrapping of NITRO REST API configuration calls (Invoke -NSNitroRestApi example)

The NetScaler NITRO REST API itself is extremely useful. However, if we wrap it with a general purpose function, we may have additional functions for specific configuration options and re-derive. These actions can then be combined into tasks that complete the configuration of the various applications. This wrapper function takes care of the connection and data manipulation. Please note that this wrapper function is only an example and it is not to worry about absolutely every application intended, but can be extended to meet additional API functionality. An example of this function is as follows:

save
 Invoke NSNitroRestApi -NSSession $ myNSSession -OperationMethod POST -ResourceType nsconfig -Action 

of Save call on the NetScaler configuration on the NetScaler appliance that object corresponds to the $ myNSSession custom web application session.

Get the sample PowerShell module (part 1)

[1945001DiesesModul] is now updated in Scripting: Automate NetScaler configurations NITRO REST API and PowerShell - Part 2

Next Coming up

note that this is the first blog post of a series. Next time we will go, for example, use cases, as we build a PowerShell engine and accompanying scripts.

Happy Scripting!

Santiago Cardenas

Citrix Solutions Lab

Disclaimer:

Code This software is provided / sample, with no representations, warranties or conditions of any kind " how it is". You can use, modify and distribute it at your own risk. CITRIX DISCLAIMS ALL WARRANTIES OF ANY KIND, EXPRESS, IMPLIED, WRITTEN, ORAL OR STATUTORY, INCLUDING WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. Without limiting the generality of the foregoing, you acknowledge and agree that (a) the software / code sample could be inaccurate, design flaws or other problems that may cause data loss or damage to property; (B) it may not be possible to make the software / sample code fully functional; and (c) Citrix may, without notice or liability to you, no longer available to make the current version and / or future versions of the software / sample code. In no case the software / code to support ultra-hazardous activities should be used, including but not limited life support or blasting activities. NEITHER CITRIX NOR ITS AFFILIATES OR AGENTS IN BREACH OF CONTRACT OR ANY OTHER LIABILITY FOR DAMAGES RESULTING FROM THE USE OF THE SOFTWARE / SAMPLE CODE, INCLUDING DIRECT, SPECIAL, CONSEQUENTIAL DAMAGES OR OTHER DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. You agree to indemnify and defend Citrix against any claims arising from the use, modification or distribution of the code created.

Previous
Next Post »
0 Komentar