Application Delivery Management

创建样本以将文件上载到 Citrix ADM

Citrix Application Delivery Management (Citrix ADM) 样书允许您在使用 Citrix ADM GUI 或 API 将任何类型的文件从本地文件系统上载到 Citrix ADC 实例时创建 Citrix ADC 配置,其中可能包括其他配置。这些文件可以是示例证书文件或地理定位文件。您也可以指定上载这些文件的目录。

样书配置

以下是样书示例,描述了如何在 Citrix ADC 实例上上载地理位置文件。地理文件通常用于 GSLB 配置中,用于根据地理位置定义静态邻近:

创建您的样书-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 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)
<!--NeedCopy-->

**注

意**此示例中使用的参数是类型文件。您可以在 Citrix ADM 中导入此样本并使用它上载地理定位文件。

这本样书要求该文件已经存在于 Citrix ADM 中(例如,您已经使用像 scp 这样的实用工具将其复制到 Citrix ADM 了)。

如果要通过 Citrix ADM 将文件上载到 Citrix ADC 而不首先将其复制到 Citrix ADM 文件系统,则可以构建一个样本,其中包含两个“string”参数,一个用于指定要在 Citrix ADC 上使用的文件名,另一个用于指定文件,然后在上载文件组件中使用这两个参数。以下是上载地理位置文件的替代样书:

创建您的样书-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 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)
<!--NeedCopy-->

创建用于上载文件的配置

以下过程在选定的 Citrix ADC 实例上创建配置,该配置将使用上述第一本样书上载地理定位文件。

要创建上载文件的配置,请执行以下操作:

  1. 在 Citrix ADM 中,导航到“应用程序”>“配置”,然后单击“新建”。“选择样书”页面显示您的 Citrix ADM 中所有可用的样书。向下滚动并选择您导入的样书。

    样书参数显示为用户界面页面,允许您输入此样书中定义的所有参数的值。

  2. 在基本负载平衡器设置部分中输入负载平衡器的名称和虚拟 IP 地址。

  3. 在“位置文件”部分中,输入文件的名称或位置。

    注意:

    确保在 Citrix ADM 中,文件仅位于当前租户的文件夹下。使用任何文件传输协议将文件复制到 Citrix ADM 文件系统。

  4. 在访问目标实例之前,可能会要求您提供用户凭据。

  5. 选择需要在其上创建配置的目标 Citrix ADC 实例,然后单击 创建”。

注意:

Citrix 建议您选择干运行以检查在目标实例上创建的配置对象,然后再对实例执行实际配置。

成功创建配置包后,文件将保存在 Citrix ADC 实例文件系统中的位置:/var/netscaler/inbuilt_db/

注意

您还可以单击刷新图标,将 Citrix ADM 中最近发现的 Citrix ADC 实例添加到此窗口中的可用实例列表中。

使用 Citrix ADM API 创建配置包

您还可以使用 Citrix ADM API 创建用于将文件上载到选定的 Citrix ADC 实例的配置包。有关如何使用 API 的更多信息,请 参阅如何使用 API 创建配置以上载任何文件类型。

创建样本以将文件上载到 Citrix ADM