14.7.2.3. 网络接口网络附件
14.7.2.3.1. 网络接口网络附件 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
主机上的每个网络接口都公开一个
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
|
定义网络的自定义属性键。
每个属性 都包含 name 和 value 子元素。
| |
reported_configurations
|
complex
|
网络附加的配置属性的只读列表。当网络附加包含未提交的网络配置时,
in_sync 布尔值为 false。每个 reported_configuration 包含 名称,expected_value,actual_value, 和 in_sync 子元素。
|
|
例 14.16. 网络接口卡中网络附加定义的 XML 表示
<network_attachment href="/ovirt-engine/api/hosts/00000000-0000-0000-0000-000000000000/nics/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>static</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>
</network_attachment>
将网络附加到网卡时,需要使用
id 或 name 的 network 元素。
例 14.17. 将网络附加到主机网卡
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
<networkattachment>
<network id="00000000-0000-0000-0000-000000000000"/>
</networkattachment>
ip_address_assignments 和 properties 元素是创建后的 updatable。
例 14.18. 修改网络附加
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
<networkattachment>
<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>
</networkattachment>
使用网络附加上的
DELETE 请求从网卡中分离网络。
例 14.19. 从主机网络接口卡中分离网络
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 节 “提交主机网络配置操作”。


