14.7. sub-Collections
14.7.1. Host Network Attachments Sub-Collection 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
network_attachments 子集合表示主机的网络配置。每个 network_attachment 元素代表附加到主机的网络,包含以下元素:
|
元素
|
类型
|
Description
|
Properties
|
|---|---|---|---|
network id=
|
GUID
|
对主机附加到的网络的引用。
|
|
host_nic id=
|
GUID
|
对网络附加到的主机网络接口的引用。
|
|
ip_address_assignments
|
complex
|
网络的 IP 配置。每个
ip_address_assignment 包含 assignment_method 和 ip address= netmask= gateway= 子元素。
| |
属性
|
complex
| ||
reported_configurations
|
complex
|
网络附加的配置属性的只读列表。当网络附加与数据中心的逻辑网络定义不同步时,
in_sync 布尔值为 false。每个 reported_configuration 包含 名称,expected_value,actual_value, 和 in_sync 子元素。
|
|
host id=
|
GUID
|
对主机的引用。
|
|
例 14.9. 主机上网络附加的 XML 表示
<network_attachment href="/ovirt-engine/api/hosts/00000000-0000-0000-0000-000000000000/networkattachments/00000000-0000-0000-0000-000000000000" id="00000000-0000-0000-0000-000000000000">
<network href="/ovirt-engine/api/networks/00000000-0000-0000-0000-000000000009" id="00000000-0000-0000-0000-000000000009"/>
<host_nic href="/ovirt-engine/api/hosts/00000000-0000-0000-0000-000000000000/nics/00000000-0000-0000-0000-000000000000" id="00000000-0000-0000-0000-000000000000"/>
<ip_address_assignments>
<ip_address_assignment>
<ip address="XX.XX.XX.XX" netmask="255.255.255.0" gateway="XX.XX.XX.XX"/>
<assignment_method>dhcp</assignment_method>
</ip_address_assignment>
</ip_address_assignments>
<reported_configurations>
<in_sync>true</in_sync>
<reported_configuration>
<name>mtu</name>
<expected_value>1500</expected_value>
<actual_value>1500</actual_value>
<in_sync>true</in_sync>
</reported_configuration>
<reported_configuration>
<name>bridged</name>
<expected_value>true</expected_value>
<actual_value>true</actual_value>
<in_sync>true</in_sync>
</reported_configuration>
<reported_configuration>
<name>vlan</name>
<in_sync>true</in_sync>
</reported_configuration>
<reported_configuration>
<name>boot_protocol</name>
<expected_value>DHCP</expected_value>
<actual_value>DHCP</actual_value>
<in_sync>true</in_sync>
</reported_configuration>
</reported_configurations>
<host href="/ovirt-engine/api/hosts/f59a29cd-587d-48a3-b72a-db537eb21957" id="f59a29cd-587d-48a3-b72a-db537eb21957"/>
</network_attachment>
将网络附加到主机时,需要使用
id 或 name 的 网络和 host_nic 元素。host_nic ID 可以引用未使用的网络接口卡或绑定。
例 14.10. 将网络附加到主机
POST /ovirt-engine/api/hosts/00000000-0000-0000-0000-000000000000/nics/00000000-0000-0000-0000-000000000000/networkattachments HTTP/1.1
Accept: application/xml
Content-type: application/xml
<network_attachment>
<network id="00000000-0000-0000-0000-000000000000"/>
<host_nic id="00000000-0000-0000-0000-000000000000"/>
</network_attachment>
host_nic、ip_address_assignments 和 properties 元素是创建后的 updatable。更改 host_nic ID 将网络移动到不同的网络接口卡。
例 14.11. 修改主机网络附加
PUT /ovirt-engine/api/hosts/00000000-0000-0000-0000-000000000000/nics/00000000-0000-0000-0000-000000000000/networkattachments/00000000-0000-0000-0000-000000000000 HTTP/1.1
Accept: application/xml
Content-type: application/xml
<network_attachment>
<host_nic id="00000000-0000-0000-0000-000000000000"/>
<ip_address_assignments>
<ip_address_assignment>
<ip address="XX.XX.XX.XX" netmask="255.255.255.0" gateway="XX.XX.XX.XX"/>
<assignment_method>static</assignment_method>
</ip_address_assignment>
</ip_address_assignments>
<properties>
<property>
<name>bridge_opts</name>
<value>
forward_delay=1500 group_fwd_mask=0x0 multicast_snooping=1
</value>
</property>
</properties>
</network_attachment>
在网络附加上使用
DELETE 请求从主机分离网络。
例 14.12. 从主机中分离网络
DELETE /ovirt-engine/api/hosts/00000000-0000-0000-0000-000000000000/nics/00000000-0000-0000-0000-000000000000/networkattachments/00000000-0000-0000-0000-000000000000 HTTP/1.1
Accept: application/xml
Content-type: application/xml
HTTP/1.1 204 No Content
重要
必须明确提交对网络附加配置的更改。请参阅 第 14.8.8 节 “提交主机网络配置操作”。


