创建 StyleBook 以将文件上传到 NetScaler Console

Last published : Oct 06, 2026
NetScaler Application Delivery Management (NetScaler Console) StyleBook 允许您创建 NetScaler 配置,其中可能包括通过使用 NetScaler Console GUI 或 API 将任何类型的文件从本地文件系统上传到 NetScaler 实例。这些文件可以是示例证书文件或地理位置文件。您还可以指定上传这些文件的目录。

StyleBook 配置

以下是一个 StyleBook 示例,描述了如何将地理位置文件上传到 NetScaler 实例。地理文件通常用于 GSLB 配置中,以根据地理位置定义静态邻近性:

构建您的 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 Console
 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)
注意
此示例中使用的参数类型为文件。您可以将此 StyleBook 导入 NetScaler Console 并使用它来上传地理位置文件。
此 StyleBook 要求文件已存在于 NetScaler Console 中(例如,您已经使用 scp 等实用程序将其复制到 NetScaler Console)。 如果您想通过 NetScaler Console 将文件上传到 NetScaler,而无需先将其复制到 NetScaler Console 文件系统,您可以构建一个包含两个“字符串”参数的 StyleBook,一个用于指定要在 NetScaler 上使用的文件名,另一个用于指定文件内容,并在 upload-file-comp 组件中使用这两个参数。以下是上传地理位置文件的另一种 StyleBook:

构建您的 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)

创建用于上传文件的配置

以下过程在选定的 NetScaler 实例上创建配置,该配置将使用上述第一个 StyleBook 上传地理位置文件。
创建用于上传文件的配置:
  1. 在 NetScaler Console 中,导航到 应用程序 > 配置,然后单击 新建。“选择 StyleBook”页面显示 NetScaler Console 中所有可用的 StyleBook。向下滚动并选择您导入的 StyleBook。
    StyleBook 参数显示为一个用户界面页面,允许您输入此 StyleBook 中定义的所有参数的值。
  2. 在基本负载均衡器设置部分中输入负载均衡器的名称和虚拟 IP 地址。
  3. 在 位置文件 部分,输入文件的名称或位置。
    注意
    确保在 NetScaler Console 中,文件仅位于当前租户的文件夹下。使用任何文件传输协议将文件复制到 NetScaler Console 文件系统。
  4. 在访问目标实例之前,系统可能会要求您提供用户凭据。
  5. 选择需要创建配置的目标 NetScaler 实例,然后单击 创建。
注意
我们建议您选择 试运行 以检查在实例上执行实际配置之前在目标实例上创建的配置对象。
当配置包创建成功后,文件将保存在 NetScaler 实例文件系统的以下位置:/var/netscaler/inbuilt_db/
注意
您还可以单击刷新图标,将 NetScaler Console 中最近发现的 NetScaler 实例添加到此窗口中可用的实例列表中。

使用 NetScaler Console API 创建配置包

您还可以使用 NetScaler Console API 创建一个配置包,将文件上传到选定的 NetScaler 实例。有关如何使用 API 的更多信息,请参阅 如何使用 API 创建配置以上传任何文件类型。