Create a StyleBook to upload files to NetScaler ADM
NetScaler Application Delivery Management (NetScaler ADM) StyleBooks allow you to create NetScaler configurations that might include among other things while uploading files of any type from your local filesystem to the NetScaler instance, by using the NetScaler ADM GUI or the APIs. These files can be the example certificate files or geolocation files. You can also specify the directory to upload these files.
StyleBook configuration
The following is an example StyleBook that describes how to upload a geo-location file on the NetScaler instance. The geo files are used typically in GSLB configurations for defining static-proximity based on the geo location:
Build your StyleBook -1
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 NetScaler
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 NetScaler 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)
<!--NeedCopy-->
Note
The parameter used in this example is of a type file. You can import this StyleBook in NetScaler ADM and use it to upload geolocation files.
This StyleBook requires the file to be already present in NetScaler ADM (for example, you would have already copied it to NetScaler ADM using a utility like scp). If you want to upload a file to NetScalers through NetScaler ADM without first copying it to the NetScaler ADM filesystem, you can build a StyleBook that has two “string” parameters, one is for specifying the file name to be used on the NetScaler and the other to specify the contents of the file, and use these two parameters in the upload-file-comp components. The following is an alternative StyleBook to upload a geo-location file:
Build your StyleBook - 2
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 NetScaler
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 NetScaler
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/NetScaler/inbuilt_db/"
filecontent: base64.encode($parameters.filecontents)
<!--NeedCopy-->
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:
-
In NetScaler ADM, navigate to Applications > Configuration, and click Create New. The Choose StyleBook page displays all the StyleBooks that are available in your NetScaler ADM. 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.
-
Enter the name of the load balancer and the virtual IP address in the basic load balancer settings section.
- In Location File section, enter the name or location of the file.
Note
Ensure that in NetScaler ADM the file is located under the current tenant’s folder only. Use any file transfer protocol to copy the file to NetScaler ADM file system.
-
You might be asked to provide your user credentials before you access the target instances.
- 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 configuration pack 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 ADM to the available list of instances in this window.
Using the NetScaler ADM API to create a configuration pack
You can also use the NetScaler ADM API to create a configuration pack 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.