示例

POST /api/hosts
{
  "host": {
    "name": "testhost11",
    "environment_id": 334344675,
    "domain_id": 22495316,
    "ptable_id": 1007981711,
    "medium_id": 980190962,
    "architecture_id": 501905019,
    "operatingsystem_id": 1073012828,
    "puppet_proxy_id": 182953976,
    "compute_resource_id": 980190962,
    "root_pass": "xybxa6JUkz63w",
    "location_id": 255093256,
    "organization_id": 447626438,
    "interfaces_attributes": {
      "1": {
        "primary": true,
        "ip": "10.0.0.20",
        "mac": "00:11:22:33:44:00"
      },
      "2": {
        "type": "bmc",
        "provider": "IPMI",
        "mac": "00:11:22:33:44:01"
      },
      "3": {
        "mac": "00:11:22:33:44:02",
        "_destroy": 1
      }
    }
  }
}
201
{
  "ip": "10.0.0.20",
  "ip6": null,
  "environment_id": 334344675,
  "environment_name": "production",
  "last_report": null,
  "mac": "00:11:22:33:44:00",
  "realm_id": null,
  "realm_name": null,
  "sp_mac": "00:11:22:33:44:01",
  "sp_ip": null,
  "sp_name": null,
  "domain_id": 22495316,
  "domain_name": "mydomain.net",
  "architecture_id": 501905019,
  "architecture_name": "x86_64",
  "operatingsystem_id": 1073012828,
  "operatingsystem_name": "RHEL 6.1",
  "subnet_id": null,
  "subnet_name": null,
  "subnet6_id": null,
  "subnet6_name": null,
  "sp_subnet_id": null,
  "ptable_id": 1007981711,
  "ptable_name": "ptable8",
  "medium_id": 980190962,
  "medium_name": "CentOS 5.4",
  "pxe_loader": "Grub UEFI",
  "build": false,
  "comment": null,
  "disk": null,
  "installed_at": null,
  "model_id": null,
  "hostgroup_id": null,
  "owner_id": 135138680,
  "owner_name": "Admin User",
  "owner_type": "User",
  "enabled": true,
  "managed": true,
  "use_image": null,
  "image_file": "",
  "uuid": null,
  "compute_resource_id": 980190962,
  "compute_resource_name": "bigcompute",
  "compute_profile_id": null,
  "compute_profile_name": null,
  "capabilities": [
    "build",
    "image",
    "new_volume"
  ],
  "provision_method": "build",
  "certname": "testhost11.mydomain.net",
  "image_id": null,
  "image_name": null,
  "created_at": "2019-09-11 14:31:57 UTC",
  "updated_at": "2019-09-11 14:31:57 UTC",
  "last_compile": null,
  "global_status": 0,
  "global_status_label": "Warning",
  "uptime_seconds": null,
  "organization_id": 447626438,
  "organization_name": "Organization 1",
  "location_id": 255093256,
  "location_name": "Location 1",
  "puppet_status": 0,
  "model_name": null,
  "configuration_status": 0,
  "configuration_status_label": "No reports",
  "build_status": 0,
  "build_status_label": "Installed",
  "name": "testhost11.mydomain.net",
  "id": 95,
  "puppet_proxy_id": 182953976,
  "puppet_proxy_name": "Puppetmaster Proxy",
  "puppet_ca_proxy_id": 182953976,
  "puppet_ca_proxy_name": "Puppetmaster Proxy",
  "puppet_proxy": {
    "name": "Puppetmaster Proxy",
    "id": 182953976,
    "url": "http://else.where:4567"
  },
  "puppet_ca_proxy": {
    "name": "Puppetmaster Proxy",
    "id": 182953976,
    "url": "http://else.where:4567"
  },
  "hostgroup_name": null,
  "hostgroup_title": null,
  "parameters": [],
  "all_parameters": [
    {
      "priority": null,
      "created_at": "2019-09-11 14:31:50 UTC",
      "updated_at": "2019-09-11 14:31:50 UTC",
      "id": 716195090,
      "name": "os1",
      "parameter_type": null,
      "value": "os1"
    },
    {
      "priority": null,
      "created_at": "2019-09-11 14:31:50 UTC",
      "updated_at": "2019-09-11 14:31:50 UTC",
      "id": 665394701,
      "name": "parameter",
      "parameter_type": null,
      "value": "value1"
    },
    {
      "priority": null,
      "created_at": "2019-09-11 14:31:50 UTC",
      "updated_at": "2019-09-11 14:31:50 UTC",
      "id": 513706444,
      "name": "loc_param",
      "parameter_type": null,
      "value": "abc"
    },
    {
      "priority": null,
      "created_at": "2019-09-11 14:31:50 UTC",
      "updated_at": "2019-09-11 14:31:50 UTC",
      "id": 32400255,
      "name": "org_param",
      "parameter_type": null,
      "value": "xyz"
    },
    {
      "priority": null,
      "created_at": "2019-09-11 14:31:50 UTC",
      "updated_at": "2019-09-11 14:31:50 UTC",
      "id": 636252244,
      "name": "test",
      "parameter_type": null,
      "value": "myvalue"
    }
  ],
  "interfaces": [
    {
      "subnet_id": null,
      "subnet_name": null,
      "subnet6_id": null,
      "subnet6_name": null,
      "domain_id": 22495316,
      "domain_name": "mydomain.net",
      "created_at": "2019-09-11 14:31:57 UTC",
      "updated_at": "2019-09-11 14:31:57 UTC",
      "managed": true,
      "identifier": null,
      "id": 101,
      "name": "testhost11.mydomain.net",
      "ip": "10.0.0.20",
      "ip6": null,
      "mac": "00:11:22:33:44:00",
      "mtu": null,
      "fqdn": "testhost11.mydomain.net",
      "primary": true,
      "provision": true,
      "type": "interface",
      "virtual": false
    },
    {
      "subnet_id": null,
      "subnet_name": null,
      "subnet6_id": null,
      "subnet6_name": null,
      "domain_id": null,
      "domain_name": null,
      "created_at": "2019-09-11 14:31:57 UTC",
      "updated_at": "2019-09-11 14:31:57 UTC",
      "managed": true,
      "identifier": null,
      "id": 102,
      "name": null,
      "ip": null,
      "ip6": null,
      "mac": "00:11:22:33:44:01",
      "mtu": null,
      "fqdn": null,
      "primary": false,
      "provision": false,
      "type": "bmc",
      "username": null,
      "password": null,
      "provider": "IPMI",
      "virtual": false
    }
  ],
  "puppetclasses": [],
  "config_groups": [],
  "all_puppetclasses": [],
  "permissions": {
    "view_hosts": true,
    "create_hosts": true,
    "edit_hosts": true,
    "destroy_hosts": true,
    "build_hosts": true,
    "power_hosts": true,
    "console_hosts": true,
    "ipmi_boot_hosts": true,
    "puppetrun_hosts": true
  }
}

參數

參數名字 描述
location_id
選填

位置範圍

Validations:

  • Must be a Integer

organization_id
選填

組織範圍

Validations:

  • Must be a Integer

host
必填

Validations:

  • Must be a Hash

host[name]
必填

Validations:

  • Must be a String

host[location_id]
必填

Validations:

  • Must be a number.

host[organization_id]
必填

Validations:

  • Must be a number.

host[environment_id]
選填 , 允許空值

若主機是個受管理的主機,並且值不是由主機群組所繼承的話便需要

Validations:

  • Must be a String

host[ip]
選填 , 允許空值

若是使用一個含有 DHCP 協定的子網路則不需要

Validations:

  • Must be a String

host[mac]
選填 , 允許空值

屬於裸機的受管理主機需要,若是虛擬機器則不需要

Validations:

  • Must be a String

host[architecture_id]
選填 , 允許空值

若主機是個受管理的主機,並且值不是由主機群組所繼承的話便需要

Validations:

  • Must be a number.

host[domain_id]
選填 , 允許空值

若主機是個受管理的主機,並且值不是由主機群組所繼承的話便需要

Validations:

  • Must be a number.

host[realm_id]
選填 , 允許空值

Validations:

  • Must be a number.

host[puppet_proxy_id]
選填 , 允許空值

Puppet 代理 ID

Validations:

  • Must be a number.

host[puppet_ca_proxy_id]
選填 , 允許空值

Puppet CA 代理 ID

Validations:

  • Must be a number.

host[puppetclass_ids]
選填 , 允許空值

Validations:

  • Must be an array of any type

host[config_group_ids]
選填 , 允許空值

IDs of associated config groups

Validations:

  • Must be an array of any type

host[operatingsystem_id]
選填 , 允許空值

若主機是個受管理的主機,並且值不是由主機群組所繼承的話便需要

Validations:

  • Must be a String

host[medium_id]
選填 , 允許空值

若不是基於映像檔的佈建,而主機受管理並且值並非由主機群組所繼承的話便需要

Validations:

  • Must be a String

host[pxe_loader]
選填 , 允許空值

DHCP filename option (Grub2/PXELinux by default)

Validations:

  • Must be one of: None, PXELinux BIOS, PXELinux UEFI, Grub UEFI, Grub2 BIOS, Grub2 ELF, Grub2 UEFI, Grub2 UEFI SecureBoot, Grub2 UEFI HTTP, Grub2 UEFI HTTPS, Grub2 UEFI HTTPS SecureBoot, iPXE Embedded, iPXE UEFI HTTP, iPXE Chain BIOS, iPXE Chain UEFI.

host[ptable_id]
選填 , 允許空值

若主機是個受管理的主機,並且尚未定義自訂分割區的話便需要

Validations:

  • Must be a number.

host[subnet_id]
選填 , 允許空值

若主機是個受管理的主機,並且值不是由主機群組所繼承的話便需要

Validations:

  • Must be a number.

host[compute_resource_id]
選填 , 允許空值

nil 代表主機為裸機

Validations:

  • Must be a number.

host[root_pass]
選填 , 允許空值

若主機是個受管理的主機,並且值不是由主機群組或是設定中的預設密碼所繼承的話便需要

Validations:

  • Must be a String

host[model_id]
選填 , 允許空值

Validations:

  • Must be a number.

host[hostgroup_id]
選填 , 允許空值

Validations:

  • Must be a number.

host[owner_id]
選填 , 允許空值

Validations:

  • Must be a number.

host[owner_type]
選填 , 允許空值

主機的擁有者類型

Validations:

  • Must be one of: User, Usergroup.

host[image_id]
選填 , 允許空值

Validations:

  • Must be a number.

host[host_parameters_attributes]
選填 , 允許空值

主機參數(陣列或索引過的雜湊)

Validations:

  • Must be an Array of nested elements

host[host_parameters_attributes][name]
必填

參數名稱

Validations:

  • Must be a String

host[host_parameters_attributes][value]
必填

參數值

Validations:

  • Must be a String

host[build]
選填 , 允許空值

Validations:

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

host[enabled]
選填 , 允許空值

在 Foreman 回報中包含這部主機

Validations:

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

host[provision_method]
選填 , 允許空值

The method used to provision the host.

Validations:

  • Must be one of: build, image.

host[managed]
選填 , 允許空值

True/False 標記代表主機是否受管理。請注意:這個值也能決定是否需要數個參數

Validations:

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

host[progress_report_id]
選填 , 允許空值

用來追蹤協調流程任務狀態的 UUID,GET /api/orchestration/:UUID/tasks

Validations:

  • Must be a String

host[comment]
選填 , 允許空值

有關於這部主機的額外資訊

Validations:

  • Must be a String

host[capabilities]
選填 , 允許空值

Validations:

  • Must be a String

host[compute_profile_id]
選填 , 允許空值

Validations:

  • Must be a number.

host[interfaces_attributes]
選填 , 允許空值

主機的網路介面。

Validations:

  • Must be an Array of nested elements

host[interfaces_attributes][mac]
選填 , 允許空值

介面卡的 MAC 位址。在空機上的管理介面所需。

Validations:

  • Must be a String

host[interfaces_attributes][ip]
選填 , 允許空值

IPv4 address of interface

Validations:

  • Must be a String

host[interfaces_attributes][ip6]
選填 , 允許空值

IPv6 address of interface

Validations:

  • Must be a String

host[interfaces_attributes][type]
選填 , 允許空值

介面卡類型,例如 bmc。預設值為 interface

Validations:

  • Must be one of: interface, bmc, bond, bridge.

host[interfaces_attributes][name]
選填 , 允許空值

介面的 DNS 名稱

Validations:

  • Must be a String

host[interfaces_attributes][subnet_id]
選填 , 允許空值

Foreman subnet ID of IPv4 interface

Validations:

  • Must be a number.

host[interfaces_attributes][subnet6_id]
選填 , 允許空值

Foreman subnet ID of IPv6 interface

Validations:

  • Must be a number.

host[interfaces_attributes][domain_id]
選填 , 允許空值

介面卡的 Foreman 區域 ID。在受管理主機上的主介面所需。

Validations:

  • Must be a number.

host[interfaces_attributes][identifier]
選填 , 允許空值

裝置辨識子,例如 eth0 或 eth1.1

Validations:

  • Must be a String

host[interfaces_attributes][managed]
選填 , 允許空值

這個介面卡是否應該透過 DHCP 和 DNS 智慧型代理伺服器管理,以及它是否應該在佈建時進行配置?

Validations:

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

host[interfaces_attributes][primary]
選填 , 允許空值

這介面是否要用來建立主機的 FQDN?每個受管理的主機需要有一組主介面。

Validations:

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

host[interfaces_attributes][provision]
選填 , 允許空值

這介面是否要給 PXELinux 的 TFTP(或映像檔為主的 SSH)使用?每個受管理的主機需要有一個佈建介面。

Validations:

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

host[interfaces_attributes][username]
選填 , 允許空值

僅適用於 BMC 介面卡。

Validations:

  • Must be a String

host[interfaces_attributes][password]
選填 , 允許空值

僅適用於 BMC 介面卡。

Validations:

  • Must be a String

host[interfaces_attributes][provider]
選填 , 允許空值

介面卡供應者,例如 IPMI。僅適用於 BMC 介面卡。

Validations:

  • Must be one of: IPMI, SSH.

host[interfaces_attributes][virtual]
選填 , 允許空值

別名或 VLAN 裝置

Validations:

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

host[interfaces_attributes][tag]
選填 , 允許空值

VLAN 標籤,這個屬性擁有比子網路 VLAN ID 更高的優先權。僅適用於虛擬介面卡。

Validations:

  • Must be a String

host[interfaces_attributes][mtu]
選填 , 允許空值

MTU, this attribute has precedence over the subnet MTU.

Validations:

  • Must be a Integer

host[interfaces_attributes][attached_to]
選填 , 允許空值

辨識此介面卡的辨識子,例如 eth1。僅適用於虛擬介面卡。

Validations:

  • Must be a String

host[interfaces_attributes][mode]
選填 , 允許空值

介面的綁定模式,例如 balance-rr。僅用於綁定介面。

Validations:

  • Must be one of: balance-rr, active-backup, balance-xor, broadcast, 802.3ad, balance-tlb, balance-alb.

host[interfaces_attributes][attached_devices]
選填 , 允許空值

相關連介面的識別子,例如['eth1', 'eth2']。對於綁定介面來說,這些是從屬的。僅用於綁定與橋接介面。

Validations:

  • Must be an array of any type

host[interfaces_attributes][bond_options]
選填 , 允許空值

以空格區隔開的選項,例如 miimon=100。僅適用於 bond 介面卡。

Validations:

  • Must be a String

host[interfaces_attributes][compute_attributes]
選填 , 允許空值

該介面的額外運算資源特定的屬性。

Validations:

  • Must be a Hash

host[compute_attributes]
選填 , 允許空值

額外運算資源特定的屬性。

Validations:

  • Must be a Hash