Create a StyleBook to upload files

Feb 26, 2018

NetScaler MAS StyleBooks allow you to create NetScaler configurations that could include among other things uploading files of any type from your local filesystem to the NetScaler instance, by using the NetScaler MAS GUI or the APIs.

StyleBook configuration

The example StyleBook provided below describes how to upload a geo-location file on the NetScaler instance. Geo files are used typically in GSLB configurations for defining static-proximity based on geo location.

name: upload-geolocations
namespace: com.citrix.adc.stylebooks.samples
version: "1.0"
display-name: GeoLocation File Upload
description: This StyleBook is used to upload a geolocation file to Citrix ADC
schema-version: "1.0"

import-stylebooks:
-
 namespace: netscaler.nitro.config
 version: "11.1"
 prefix: ns

parameters:
-
 name: locationfile
 label: Location File
 description: The system file path of the geolocation file on Citrix ADM
 type: file
 required: true

components:
-
 name: upload-file-comp
 type: ns::systemfile
 properties:
    filename: $parameters.locationfile.filename
    filelocation: "/var/netscaler/inbuilt_db/"
    filecontent: base64.encode($parameters.locationfile.contents)

Note

The parameter used in this example is of type “file.” You can import this StyleBook in NetScaler MAS and use it to upload geolocation files.

This StyleBook requires that the file to be already present in NetScaler MAS (for example, you would have already copied it to NetScaler MAS using a utility like scp).

Note

You can also upload a file to NetScaler instances through NetScaler MAS without first copying it to the NetScaler MAS filesystem. You can build a StyleBook that has two “string” parameters:

  • one parameter for specifying the file name to be used on the NetScaler instance.
  • other parameter to specify the contents of the file.

Use these two parameters in the upload-file-comp components. This alternative StyleBook is shown below:

name: upload-geolocations-alt
namespace: com.citrix.adc.stylebooks.samples
version: "1.0"
display-name: GeoLocation File Upload
description: This StyleBook is used to upload a geolocation file to Citrix ADC
schema-version: "1.0"

import-stylebooks:
 -
  namespace: netscaler.nitro.config
  version: "11.1"
  prefix: ns

parameters:
 -
  name: filename
  label: Location Filename
  description: The name of the location file on the Citrix ADC
  type: string
  required: true
 -
  name: filecontents
  label: Location File Contents
  description: The contents of the location file
  type: string
  required: true

components:
 -
  name: upload-file-comp
  type: ns::systemfile
  properties:
   filename: $parameters.filename
   filelocation: "/var/Citrix ADC/inbuilt_db/"
   filecontent: base64.encode($parameters.filecontents)

Creating configurations to upload files

The following procedure creates a configuration on a selected NetScaler instance that would upload a geolocation file using the first StyleBook described above.

To create a configuration for uploading files

  1. In NetScaler MAS, navigate to Applications > Configuration, and click Create New. The Choose StyleBook page displays all the StyleBooks that are available in your NetScaler MAS. Scroll down and select the StyleBook that you imported.

    The StyleBook parameters appear as a user-interface page that allows you to enter the values for all the parameters defined in this StyleBook.

  2. Enter the name of the load balancer and the virtual IP address in the basic load balancer settings section.

  3. In Location File section, enter the name or location of the file.

    Note

    Ensure that in NetScaler MAS, the file is located under the current tenant’s folder only. Use any file transfer protocol to copy the file to NetScaler MAS file system.

    You might be asked to provide your user credentials before you access the target instances.

  4. Select the target NetScaler instance on which the configuration needs to be created, and click Create.

    Note

    Citrix recommends that you select Dry Run to check the configuration objects that are created on the target instance before you execute the actual configuration on the instance.

    When the creation of the configpack is successful, the file is saved on the NetScaler instance file system under the location: /var/netscaler/inbuilt_db/

Note

You can also click the refresh icon to add recently discovered NetScaler instances in NetScaler MAS to the available list of instances in this window.

Using the NetScaler MAS API to create a configpack

You can also use the NetScaler MAS API to create a configpack that uploads files to the selected NetScaler instance. For more information on how to use APIs, see How to Use API to Create Configurations to Upload Any File Type.

Version

Create a StyleBook to upload files