GET /api/hosts/:host_id/interfaces
列出主机的所有接口

GET /api/domains/:domain_id/interfaces
列出域的所有接口

GET /api/subnets/:subnet_id/interfaces
列出子网的所有接口

示例

GET /api/hosts/host368/interfaces
200
{
  "total": 3,
  "subtotal": 3,
  "page": 1,
  "per_page": 20,
  "search": null,
  "sort": {
    "by": null,
    "order": null
  },
  "results": [
    {
      "subnet_id": null,
      "subnet_name": null,
      "subnet6_id": null,
      "subnet6_name": null,
      "domain_id": null,
      "domain_name": null,
      "created_at": "2019-11-07 08:37:16 UTC",
      "updated_at": "2019-11-07 08:37:16 UTC",
      "managed": true,
      "identifier": null,
      "id": 53,
      "name": "host368",
      "ip": null,
      "ip6": null,
      "mac": null,
      "mtu": null,
      "fqdn": "host368",
      "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-11-07 08:37:16 UTC",
      "updated_at": "2019-11-07 08:37:16 UTC",
      "managed": true,
      "identifier": "eth184",
      "id": 54,
      "name": null,
      "ip": "0.0.0.38",
      "ip6": null,
      "mac": "00:33:45:ab:00:4e",
      "mtu": null,
      "fqdn": null,
      "primary": false,
      "provision": false,
      "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-11-07 08:37:16 UTC",
      "updated_at": "2019-11-07 08:37:16 UTC",
      "managed": true,
      "identifier": "eth185",
      "id": 55,
      "name": null,
      "ip": "0.0.0.39",
      "ip6": null,
      "mac": "00:33:45:ab:00:4f",
      "mtu": null,
      "fqdn": null,
      "primary": false,
      "provision": false,
      "type": "bond",
      "mode": "balance-rr",
      "attached_devices": "",
      "bond_options": "",
      "virtual": true
    }
  ]
}

参数

参数名字 描述
location_id
选填

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
选填

Set the current organization context for the request

Validations:

  • Must be a Integer

host_id
必填

主机 ID 或名称

Validations:

  • Must be a String

domain_id
选填

域 ID 或名称

Validations:

  • Must be a String

subnet_id
选填

子网 ID 或名称

Validations:

  • Must be a String

page
选填

页号,从 1 开始

Validations:

  • Must be a number.

per_page
选填

每页中显示的返回结果数

Validations:

  • Must be a number.


GET /api/hosts/:host_id/interfaces/:id
显示主机接口

示例

GET /api/hosts/host369/interfaces/57
200
{
  "subnet_id": null,
  "subnet_name": null,
  "subnet6_id": null,
  "subnet6_name": null,
  "domain_id": null,
  "domain_name": null,
  "created_at": "2019-11-07 08:37:16 UTC",
  "updated_at": "2019-11-07 08:37:16 UTC",
  "managed": true,
  "identifier": "eth186",
  "id": 57,
  "name": null,
  "ip": "0.0.0.40",
  "ip6": null,
  "mac": "00:33:45:ab:00:50",
  "mtu": null,
  "fqdn": null,
  "primary": false,
  "provision": false,
  "type": "interface",
  "virtual": false
}

参数

参数名字 描述
location_id
选填

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
选填

Set the current organization context for the request

Validations:

  • Must be a Integer

host_id
必填

主机 ID 或名称

Validations:

  • Must be a String

id
必填

接口 ID 或名称

Validations:

  • Must be a String


POST /api/hosts/:host_id/interfaces
在主机中创建接口

示例

POST /api/hosts/26/interfaces
{
  "interface": {
    "name": "谚喪駏篬庿濱麢鐨耼孞",
    "ip": "10.0.1.1",
    "mac": "AA:AA:AA:AA:AA:AA",
    "username": "foo",
    "password": "bar",
    "provider": "IPMI",
    "type": "bmc",
    "ip6": "2001:db8::1"
  }
}
422
{
  "error": {
    "id": null,
    "errors": {
      "name": [
        "hostname can contain only lowercase letters, numbers, dashes and dots according to RFC921, RFC952 and RFC1123"
      ]
    },
    "full_messages": [
      "Name hostname can contain only lowercase letters, numbers, dashes and dots according to RFC921, RFC952 and RFC1123"
    ]
  }
}

参数

参数名字 描述
location_id
选填

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
选填

Set the current organization context for the request

Validations:

  • Must be a Integer

host_id
必填

主机 ID 或名称

Validations:

  • Must be a String

interface
必填

接口信息

Validations:

  • Must be a Hash

interface[mac]
选填 , 允许空值

接口的 MAC 地址。在裸机中管理的接口需要这个地址。

Validations:

  • Must be a String

interface[ip]
选填 , 允许空值

接口的 IPv4 地址

Validations:

  • Must be a String

interface[ip6]
选填 , 允许空值

接口的 IPv6 地址

Validations:

  • Must be a String

interface[type]
选填 , 允许空值

接口类型,例如:bmc。默认为 interface

Validations:

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

interface[name]
选填 , 允许空值

接口 DNS 名称

Validations:

  • Must be a String

interface[subnet_id]
选填 , 允许空值

IPv4 接口的 Foreman 子网 ID

Validations:

  • Must be a number.

interface[subnet6_id]
选填 , 允许空值

IPv6 接口的 Foreman 子网 ID

Validations:

  • Must be a number.

interface[domain_id]
选填 , 允许空值

接口的 Foreman 域 ID。所管理主机中的主接口需要这个选项。

Validations:

  • Must be a number.

interface[identifier]
选填 , 允许空值

设备标识符,例如:eth0 或者 eth1.1。

Validations:

  • Must be a String

interface[managed]
选填 , 允许空值

这个接口应由 DHCP 管理还是由 DNS 智能代理服务器管理?是否应在预配过程中对其进行配置?

Validations:

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

interface[primary]
选填 , 允许空值

是否应该使用这个接口构建该主机的 FQDN?每台管理的主机都需要有一个主接口。

Validations:

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

interface[provision]
选填 , 允许空值

这个接口是否应该用于 PXELinux 的 TFTP(或基于映象主机的 SSH)?每台管理的主机需要有一个预配接口。

Validations:

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

interface[username]
选填 , 允许空值

仅用于 BMC 接口

Validations:

  • Must be a String

interface[password]
选填 , 允许空值

仅用于 BMC 接口

Validations:

  • Must be a String

interface[provider]
选填 , 允许空值

接口提供者,例如 IPMI。仅用于 BMC 接口。

Validations:

  • Must be one of: IPMI, SSH.

interface[virtual]
选填 , 允许空值

别名或 VLAN 失败

Validations:

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

interface[tag]
选填 , 允许空值

VLAN 标签,这个属性优先于子网 VLAN ID。仅用于虚拟接口。

Validations:

  • Must be a String

interface[mtu]
选填 , 允许空值

MTU,这个属性优先于子网 MTU。

Validations:

  • Must be a Integer

interface[attached_to]
选填 , 允许空值

这个接口所属接口识别符,例如:eth1。仅用于虚拟接口。

Validations:

  • Must be a String

interface[mode]
选填 , 允许空值

接口的捆绑模式,例如:balance-rr。仅用于捆绑接口。

Validations:

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

interface[attached_devices]
选填 , 允许空值

附加接口的识别符,例如:['eth1', 'eth2']。对于捆绑的接口,那些是从属接口。仅用于捆绑和桥接接口。

Validations:

  • Must be an array of any type

interface[bond_options]
选填 , 允许空值

使用空格分隔的选项,例如:miimon=100。仅用于捆绑接口。

Validations:

  • Must be a String

interface[compute_attributes]
选填 , 允许空值

该接口的附加计算资源具体属性。

Validations:

  • Must be a Hash


PUT /api/hosts/:host_id/interfaces/:id
更新主机接口

示例

PUT /api/hosts/host360/interfaces/30
{
  "interface": {
    "name": "test.foreman.com",
    "ip": "10.0.1.1",
    "mac": "AA:AA:AA:AA:AA:AA",
    "username": "foo",
    "password": "bar",
    "provider": "IPMI",
    "ip6": "2001:db8::1"
  }
}
200
{
  "subnet_id": null,
  "subnet_name": null,
  "subnet6_id": null,
  "subnet6_name": null,
  "domain_id": null,
  "domain_name": null,
  "created_at": "2019-11-07 08:37:15 UTC",
  "updated_at": "2019-11-07 08:37:15 UTC",
  "managed": true,
  "identifier": "eth169",
  "id": 30,
  "name": "test.foreman.com",
  "ip": "10.0.1.1",
  "ip6": "2001:db8::1",
  "mac": "aa:aa:aa:aa:aa:aa",
  "mtu": null,
  "fqdn": "test.foreman.com",
  "primary": false,
  "provision": false,
  "type": "interface",
  "virtual": false
}

参数

参数名字 描述
location_id
选填

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
选填

Set the current organization context for the request

Validations:

  • Must be a Integer

host_id
必填

主机 ID 或名称

Validations:

  • Must be a String

id
必填

接口 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.

interface
必填

接口信息

Validations:

  • Must be a Hash

interface[mac]
选填 , 允许空值

接口的 MAC 地址。在裸机中管理的接口需要这个地址。

Validations:

  • Must be a String

interface[ip]
选填 , 允许空值

接口的 IPv4 地址

Validations:

  • Must be a String

interface[ip6]
选填 , 允许空值

接口的 IPv6 地址

Validations:

  • Must be a String

interface[type]
选填 , 允许空值

接口类型,例如:bmc。默认为 interface

Validations:

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

interface[name]
选填 , 允许空值

接口 DNS 名称

Validations:

  • Must be a String

interface[subnet_id]
选填 , 允许空值

IPv4 接口的 Foreman 子网 ID

Validations:

  • Must be a number.

interface[subnet6_id]
选填 , 允许空值

IPv6 接口的 Foreman 子网 ID

Validations:

  • Must be a number.

interface[domain_id]
选填 , 允许空值

接口的 Foreman 域 ID。所管理主机中的主接口需要这个选项。

Validations:

  • Must be a number.

interface[identifier]
选填 , 允许空值

设备标识符,例如:eth0 或者 eth1.1。

Validations:

  • Must be a String

interface[managed]
选填 , 允许空值

这个接口应由 DHCP 管理还是由 DNS 智能代理服务器管理?是否应在预配过程中对其进行配置?

Validations:

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

interface[primary]
选填 , 允许空值

是否应该使用这个接口构建该主机的 FQDN?每台管理的主机都需要有一个主接口。

Validations:

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

interface[provision]
选填 , 允许空值

这个接口是否应该用于 PXELinux 的 TFTP(或基于映象主机的 SSH)?每台管理的主机需要有一个预配接口。

Validations:

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

interface[username]
选填 , 允许空值

仅用于 BMC 接口

Validations:

  • Must be a String

interface[password]
选填 , 允许空值

仅用于 BMC 接口

Validations:

  • Must be a String

interface[provider]
选填 , 允许空值

接口提供者,例如 IPMI。仅用于 BMC 接口。

Validations:

  • Must be one of: IPMI, SSH.

interface[virtual]
选填 , 允许空值

别名或 VLAN 失败

Validations:

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

interface[tag]
选填 , 允许空值

VLAN 标签,这个属性优先于子网 VLAN ID。仅用于虚拟接口。

Validations:

  • Must be a String

interface[mtu]
选填 , 允许空值

MTU,这个属性优先于子网 MTU。

Validations:

  • Must be a Integer

interface[attached_to]
选填 , 允许空值

这个接口所属接口识别符,例如:eth1。仅用于虚拟接口。

Validations:

  • Must be a String

interface[mode]
选填 , 允许空值

接口的捆绑模式,例如:balance-rr。仅用于捆绑接口。

Validations:

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

interface[attached_devices]
选填 , 允许空值

附加接口的识别符,例如:['eth1', 'eth2']。对于捆绑的接口,那些是从属接口。仅用于捆绑和桥接接口。

Validations:

  • Must be an array of any type

interface[bond_options]
选填 , 允许空值

使用空格分隔的选项,例如:miimon=100。仅用于捆绑接口。

Validations:

  • Must be a String

interface[compute_attributes]
选填 , 允许空值

该接口的附加计算资源具体属性。

Validations:

  • Must be a Hash


DELETE /api/hosts/:host_id/interfaces/:id
删除主机接口

示例

DELETE /api/hosts/32/interfaces/45
{
  "interface": {}
}
422
{
  "error": {
    "id": 45,
    "errors": {
      "primary": [
        "can't delete primary interface of managed host"
      ],
      "provision": [
        "can't delete provision interface of managed host"
      ]
    },
    "full_messages": [
      "Primary can't delete primary interface of managed host",
      "Provision can't delete provision interface of managed host"
    ]
  }
}

参数

参数名字 描述
location_id
选填

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
选填

Set the current organization context for the request

Validations:

  • Must be a Integer

host_id
必填

主机 ID 或名称

Validations:

  • Must be a String

id
必填

接口 ID

Validations:

  • Must be a String