GET /api/provisioning_templates
列出预配模板

GET /api/operatingsystems/:operatingsystem_id/provisioning_templates
列出每个操作系统的预配模板

GET /api/locations/:location_id/provisioning_templates
列出每个位置的预配模板

GET /api/organizations/:organization_id/provisioning_templates
列出每个机构的预配模板

示例

GET /api/provisioning_templates
200
{
  "total": 14,
  "subtotal": 14,
  "page": 1,
  "per_page": 20,
  "search": null,
  "sort": {
    "by": null,
    "order": null
  },
  "results": [
    {
      "snippet": false,
      "audit_comment": null,
      "created_at": "2019-09-11 14:57:07 UTC",
      "updated_at": "2019-09-11 14:57:07 UTC",
      "id": 1007981701,
      "name": "centos5_3_pxelinux",
      "template_kind_id": 452984334,
      "template_kind_name": "PXELinux"
    },
    {
      "snippet": false,
      "audit_comment": null,
      "created_at": "2019-09-11 14:57:07 UTC",
      "updated_at": "2019-09-11 14:57:07 UTC",
      "id": 698706415,
      "name": "iPXE Dummy Menu",
      "template_kind_id": 698706415,
      "template_kind_name": "iPXE"
    },
    {
      "snippet": false,
      "audit_comment": null,
      "created_at": "2019-09-11 14:57:07 UTC",
      "updated_at": "2019-09-11 14:57:07 UTC",
      "id": 718456980,
      "name": "Locked Template",
      "template_kind_id": 983253650,
      "template_kind_name": "provision"
    },
    {
      "snippet": false,
      "audit_comment": null,
      "created_at": "2019-09-11 14:57:07 UTC",
      "updated_at": "2019-09-11 14:57:07 UTC",
      "id": 104314179,
      "name": "MyFinish",
      "template_kind_id": 550103832,
      "template_kind_name": "finish"
    },
    {
      "snippet": false,
      "audit_comment": null,
      "created_at": "2019-09-11 14:57:07 UTC",
      "updated_at": "2019-09-11 14:57:07 UTC",
      "id": 981457253,
      "name": "MyScript",
      "template_kind_id": 478250810,
      "template_kind_name": "script"
    },
    {
      "snippet": false,
      "audit_comment": null,
      "created_at": "2019-09-11 14:57:07 UTC",
      "updated_at": "2019-09-11 14:57:07 UTC",
      "id": 943779058,
      "name": "MyString",
      "template_kind_id": 698706415,
      "template_kind_name": "iPXE"
    },
    {
      "snippet": false,
      "audit_comment": null,
      "created_at": "2019-09-11 14:57:07 UTC",
      "updated_at": "2019-09-11 14:57:07 UTC",
      "id": 269958254,
      "name": "MyString2",
      "template_kind_id": 983253650,
      "template_kind_name": "provision"
    },
    {
      "snippet": false,
      "audit_comment": null,
      "created_at": "2019-09-11 14:57:07 UTC",
      "updated_at": "2019-09-11 14:57:07 UTC",
      "id": 684651467,
      "name": "PXE Default Menu",
      "template_kind_id": 710512633,
      "template_kind_name": null
    },
    {
      "snippet": false,
      "audit_comment": null,
      "created_at": "2019-09-11 14:57:07 UTC",
      "updated_at": "2019-09-11 14:57:07 UTC",
      "id": 554905648,
      "name": "PXEGrub2 global default",
      "template_kind_id": 701398793,
      "template_kind_name": "PXEGrub2"
    },
    {
      "snippet": false,
      "audit_comment": null,
      "created_at": "2019-09-11 14:57:07 UTC",
      "updated_at": "2019-09-11 14:57:07 UTC",
      "id": 131565194,
      "name": "PXEGrub Dummy Menu",
      "template_kind_id": 131565194,
      "template_kind_name": "PXEGrub"
    },
    {
      "snippet": false,
      "audit_comment": null,
      "created_at": "2019-09-11 14:57:07 UTC",
      "updated_at": "2019-09-11 14:57:07 UTC",
      "id": 824224502,
      "name": "PXEGrub global default",
      "template_kind_id": 131565194,
      "template_kind_name": "PXEGrub"
    },
    {
      "snippet": false,
      "audit_comment": null,
      "created_at": "2019-09-11 14:57:07 UTC",
      "updated_at": "2019-09-11 14:57:07 UTC",
      "id": 821548108,
      "name": "PXELinux default local boot",
      "template_kind_id": 452984334,
      "template_kind_name": "PXELinux"
    },
    {
      "snippet": false,
      "audit_comment": null,
      "created_at": "2019-09-11 14:57:07 UTC",
      "updated_at": "2019-09-11 14:57:07 UTC",
      "id": 352050261,
      "name": "PXELinux global default",
      "template_kind_id": 452984334,
      "template_kind_name": "PXELinux"
    },
    {
      "snippet": false,
      "audit_comment": null,
      "created_at": "2019-09-11 14:57:07 UTC",
      "updated_at": "2019-09-11 14:57:07 UTC",
      "id": 56083308,
      "name": "suse_pxelinux",
      "template_kind_id": 452984334,
      "template_kind_name": "PXELinux"
    }
  ]
}

参数

参数名字 描述
operatingsystem_id
选填

操作系统 ID

Validations:

  • Must be a String

location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

search
选填

过滤结果

Validations:

  • Must be a String

order
选填

排序项和顺序,例如 ‘id DESC’

Validations:

  • Must be a String

page
选填

页号,从 1 开始

Validations:

  • Must be a number.

per_page
选填

每页中显示的返回结果数

Validations:

  • Must be a number.

搜索字段

字段名 类型 可能的值
default_template true, false
environment string
hostgroup string
kind string
location string
location_id integer
locked true, false
name string
operatingsystem string
organization string
organization_id integer
snippet true, false
template text
vendor string

GET /api/provisioning_templates/:id
显示预配模板详情

示例

GET /api/provisioning_templates/1007981701-centos5_3_pxelinux
200
{
  "template": "default linux~label linux~kernel <%= @kernel %>~append initrd=<%= @initrd %> ks=<%= foreman_url(\"kickstart\")%> ksdevice=bootif network kssendmac",
  "locked": false,
  "snippet": false,
  "audit_comment": null,
  "created_at": "2019-09-11 14:57:07 UTC",
  "updated_at": "2019-09-11 14:57:07 UTC",
  "id": 1007981701,
  "name": "centos5_3_pxelinux",
  "template_kind_id": 452984334,
  "template_kind_name": "PXELinux",
  "template_combinations": [],
  "operatingsystems": [
    {
      "id": 309172073,
      "name": "centos",
      "title": "centos 5.3"
    },
    {
      "id": 1073012828,
      "name": "Redhat",
      "title": "RHEL 6.1"
    },
    {
      "id": 331303656,
      "name": "Ubuntu",
      "title": "Ubuntu 10.10"
    }
  ],
  "os_default_templates": [
    {
      "id": 281110143,
      "provisioning_template_id": 1007981701,
      "provisioning_template_name": "centos5_3_pxelinux",
      "template_kind_id": 710512633,
      "template_kind_name": null,
      "operatingsystem_id": 1073012828,
      "operatingsystem_name": "RHEL 6.1",
      "config_template_id": 1007981701,
      "config_template_name": "centos5_3_pxelinux"
    },
    {
      "id": 638205575,
      "provisioning_template_id": 1007981701,
      "provisioning_template_name": "centos5_3_pxelinux",
      "template_kind_id": 710512633,
      "template_kind_name": null,
      "operatingsystem_id": 331303656,
      "operatingsystem_name": "Ubuntu 10.10",
      "config_template_id": 1007981701,
      "config_template_name": "centos5_3_pxelinux"
    }
  ],
  "locations": [],
  "organizations": []
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.


POST /api/provisioning_templates
创建预配模板

示例

POST /api/provisioning_templates
{
  "provisioning_template": {
    "template": "This is a test template",
    "template_kind_id": 131565194,
    "name": "new_template"
  }
}
201
{
  "template": "This is a test template",
  "locked": false,
  "snippet": false,
  "audit_comment": null,
  "created_at": "2019-09-11 14:57:19 UTC",
  "updated_at": "2019-09-11 14:57:19 UTC",
  "id": 1007981787,
  "name": "new_template",
  "template_kind_id": 131565194,
  "template_kind_name": "PXEGrub",
  "template_combinations": [],
  "operatingsystems": [],
  "os_default_templates": [],
  "locations": [],
  "organizations": []
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

provisioning_template
必填

Validations:

  • Must be a Hash

provisioning_template[name]
必填

模板名称

Validations:

  • Must be a String

provisioning_template[template]
必填

Validations:

  • Must be a String

provisioning_template[snippet]
选填 , 允许空值

Validations:

  • Must be one of: true, false, 1, 0.

provisioning_template[audit_comment]
选填 , 允许空值

Validations:

  • Must be a String

provisioning_template[template_kind_id]
选填 , 允许空值

与片段无关

Validations:

  • Must be a number.

provisioning_template[template_combinations_attributes]
选填 , 允许空值

模板组合阵列(hostgroup_id, environment_id)

Validations:

  • Must be an array of any type

provisioning_template[operatingsystem_ids]
选填 , 允许空值

与该模板关联的操作系统 ID 阵列

Validations:

  • Must be an array of any type

provisioning_template[locked]
选填 , 允许空值

是否已锁定该模板进行编辑

Validations:

  • Must be one of: true, false, 1, 0.

provisioning_template[location_ids]
选填 , 允许空值

使用给定 id 替换位置

Validations:

  • Must be an array of any type

provisioning_template[organization_ids]
选填 , 允许空值

使用给定 id 替换机构

Validations:

  • Must be an array of any type


POST /api/provisioning_templates/import
导入预配模板

示例

POST /api/provisioning_templates/import
{
  "provisioning_template": {
    "name": "taxonomy override test name",
    "template": "<%#\nkind: PXELinux\nname: taxonomy override test name\nmodel: ProvisioningTemplate\norganizations:\n - org432\nlocations:\n - loc339\n%>\ntest",
    "organization_ids": [
      447626449
    ],
    "location_ids": [
      447626450
    ]
  },
  "options": {
    "associate": "new"
  }
}
201
{
  "id": 1007981788,
  "name": "taxonomy override test name",
  "template": "<%#\nkind: PXELinux\nname: taxonomy override test name\nmodel: ProvisioningTemplate\norganizations:\n - org432\nlocations:\n - loc339\n%>\ntest",
  "snippet": false,
  "template_kind_id": 452984334,
  "created_at": "2019-09-11T14:57:19.599Z",
  "updated_at": "2019-09-11T14:57:19.599Z",
  "locked": false,
  "default": false,
  "vendor": null,
  "os_family": null
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

provisioning_template
必填

Validations:

  • Must be a Hash

provisioning_template[name]
选填

模板名称

Validations:

  • Must be a String

provisioning_template[template]
选填

包括元数据的模板内容

Validations:

  • Must be a String

provisioning_template[location_ids]
选填 , 允许空值

使用给定 id 替换位置

Validations:

  • Must be an array of any type

provisioning_template[organization_ids]
选填 , 允许空值

使用给定 id 替换机构

Validations:

  • Must be an array of any type

options
选填

Validations:

  • Must be a Hash

options[force]
选填 , 允许空值

在您希望更新锁定的模板时使用

Validations:

  • Must be one of: true, false, 1, 0.

options[associate]
选填 , 允许空值

确定模板何时应基于元数据关联对象,new 表示只在创建新模板时,always 表示同时适用于新模板和的只进行更新的现有模板,never 表示忽略元数据

Validations:

  • Must be one of: new, always, never.

options[lock]
选填 , 允许空值

锁定导入的模板(默认为 false)

Validations:

  • Must be one of: true, false, 1, 0.

options[default]
选填 , 允许空值

把模块设为默认意味着它将自动与新创建的组织和位置相关联(默认为 false)

Validations:

  • Must be one of: true, false, 1, 0.


PUT /api/provisioning_templates/:id
更新预配模板

示例

PUT /api/provisioning_templates/1007981701-centos5_3_pxelinux
{
  "provisioning_template": {
    "name": ""
  }
}
422
{
  "error": {
    "id": 1007981701,
    "errors": {
      "name": [
        "can't be blank"
      ]
    },
    "full_messages": [
      "Name can't be blank"
    ]
  }
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.

provisioning_template
必填

Validations:

  • Must be a Hash

provisioning_template[name]
选填

模板名称

Validations:

  • Must be a String

provisioning_template[template]
选填

Validations:

  • Must be a String

provisioning_template[snippet]
选填 , 允许空值

Validations:

  • Must be one of: true, false, 1, 0.

provisioning_template[audit_comment]
选填 , 允许空值

Validations:

  • Must be a String

provisioning_template[template_kind_id]
选填 , 允许空值

与片段无关

Validations:

  • Must be a number.

provisioning_template[template_combinations_attributes]
选填 , 允许空值

模板组合阵列(hostgroup_id, environment_id)

Validations:

  • Must be an array of any type

provisioning_template[operatingsystem_ids]
选填 , 允许空值

与该模板关联的操作系统 ID 阵列

Validations:

  • Must be an array of any type

provisioning_template[locked]
选填 , 允许空值

是否已锁定该模板进行编辑

Validations:

  • Must be one of: true, false, 1, 0.

provisioning_template[location_ids]
选填 , 允许空值

使用给定 id 替换位置

Validations:

  • Must be an array of any type

provisioning_template[organization_ids]
选填 , 允许空值

使用给定 id 替换机构

Validations:

  • Must be an array of any type


GET /api/provisioning_templates/revision

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

version
选填

模板版本

Validations:

  • Must be a String


DELETE /api/provisioning_templates/:id
删除预配模板

示例

DELETE /api/provisioning_templates/1007981701-centos5_3_pxelinux
{
  "provisioning_template": {}
}
422
{
  "error": {
    "id": 1007981701,
    "errors": {
      "base": [
        "centos5_3_pxelinux is used by Redhat 6.1 - ",
        "centos5_3_pxelinux is used by Ubuntu 10.10 - "
      ]
    },
    "full_messages": [
      "centos5_3_pxelinux is used by Redhat 6.1 - ",
      "centos5_3_pxelinux is used by Ubuntu 10.10 - "
    ]
  }
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.


POST /api/provisioning_templates/build_pxe_default
更新所有配置 TFTP 服务器的默认 PXE 菜单

示例

POST /api/provisioning_templates/build_pxe_default
{
  "provisioning_template": {}
}
200
{
  "message": "PXE files for templates PXEGrub2 global default, PXELinux global default, and PXEGrub global default have been deployed to all Smart Proxies"
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer


POST /api/provisioning_templates/:id/clone
克隆预配模板

示例

POST /api/provisioning_templates/1007981701-centos5_3_pxelinux/clone
{
  "provisioning_template": {
    "name": "MyClone"
  }
}
201
{
  "id": 1007981786,
  "name": "MyClone",
  "template": "default linux~label linux~kernel <%= @kernel %>~append initrd=<%= @initrd %> ks=<%= foreman_url(\"kickstart\")%> ksdevice=bootif network kssendmac",
  "snippet": false,
  "template_kind_id": 452984334,
  "created_at": "2019-09-11T14:57:18.901Z",
  "updated_at": "2019-09-11T14:57:18.901Z",
  "locked": false,
  "default": false,
  "vendor": null,
  "os_family": null
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.

provisioning_template
必填

Validations:

  • Must be a Hash

provisioning_template[name]
必填

模板名称

Validations:

  • Must be a String


GET /api/provisioning_templates/:id/export
导出置备模板到 ERB

示例

GET /api/provisioning_templates/1007981701-centos5_3_pxelinux/export
200
default linux~label linux~kernel <%= @kernel %>~append initrd=<%= @initrd %> ks=<%= foreman_url("kickstart")%> ksdevice=bootif network kssendmac
<%#
name: centos5_3_pxelinux
snippet: false
model: ProvisioningTemplate
kind: PXELinux
oses:
- centos
- Redhat
- Ubuntu
%>

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.