6.87.14. setupnetworks POST
이 방법은 호스트의 네트워크 인터페이스 구성을 변경하는 데 사용됩니다.
예를 들어 세 개의 네트워크 인터페이스 eth0,eth1 및 eth2 가 있고 eth0 및 eth1 을 사용하여 새 본딩을 구성하고 VLAN을 맨 위에 배치한다고 가정하겠습니다. 다음과 같이 수행할 수 있는 간단한 쉘 스크립트 및 curl 명령줄 HTTP 클라이언트를 사용합니다.
#!/bin/sh -ex
url="https://engine.example.com/ovirt-engine/api"
user="admin@internal"
password="..."
curl \
--verbose \
--cacert /etc/pki/ovirt-engine/ca.pem \
--user "${user}:${password}" \
--request POST \
--header "Version: 4" \
--header "Content-Type: application/xml" \
--header "Accept: application/xml" \
--data '
<action>
<modified_bonds>
<host_nic>
<name>bond0</name>
<bonding>
<options>
<option>
<name>mode</name>
<value>4</value>
</option>
<option>
<name>miimon</name>
<value>100</value>
</option>
</options>
<slaves>
<host_nic>
<name>eth1</name>
</host_nic>
<host_nic>
<name>eth2</name>
</host_nic>
</slaves>
</bonding>
</host_nic>
</modified_bonds>
<modified_network_attachments>
<network_attachment>
<network>
<name>myvlan</name>
</network>
<host_nic>
<name>bond0</name>
</host_nic>
<ip_address_assignments>
<assignment_method>static</assignment_method>
<ip_address_assignment>
<ip>
<address>192.168.122.10</address>
<netmask>255.255.255.0</netmask>
</ip>
</ip_address_assignment>
</ip_address_assignments>
<dns_resolver_configuration>
<name_servers>
<name_server>1.1.1.1</name_server>
<name_server>2.2.2.2</name_server>
</name_servers>
</dns_resolver_configuration>
</network_attachment>
</modified_network_attachments>
</action>
' \
"${url}/hosts/1ff7a191-2f3b-4eff-812b-9f91a30c3acc/setupnetworks"
이는 API 버전 4에 적용됩니다. 이전 버전에서는 일부 요소가 XML 요소 대신 XML 속성으로 표시되었습니다. 특히 옵션 및 ip 요소가 다음과 같이 표시되었습니다.
<options name="mode" value="4"/>
<options name="miimon" value="100"/>
<ip address="192.168.122.10" netmask="255.255.255.0"/>
Python SDK를 사용하면 다음 코드로 동일한 작업을 수행할 수 있습니다.
# Find the service that manages the collection of hosts:
hosts_service = connection.system_service().hosts_service()
# Find the host:
host = hosts_service.list(search='name=myhost')[0]
# Find the service that manages the host:
host_service = hosts_service.host_service(host.id)
# Configure the network adding a bond with two slaves and attaching it to a
# network with an static IP address:
host_service.setup_networks(
modified_bonds=[
types.HostNic(
name='bond0',
bonding=types.Bonding(
options=[
types.Option(
name='mode',
value='4',
),
types.Option(
name='miimon',
value='100',
),
],
slaves=[
types.HostNic(
name='eth1',
),
types.HostNic(
name='eth2',
),
],
),
),
],
modified_network_attachments=[
types.NetworkAttachment(
network=types.Network(
name='myvlan',
),
host_nic=types.HostNic(
name='bond0',
),
ip_address_assignments=[
types.IpAddressAssignment(
assignment_method=types.BootProtocol.STATIC,
ip=types.Ip(
address='192.168.122.10',
netmask='255.255.255.0',
),
),
],
dns_resolver_configuration=types.DnsResolverConfiguration(
name_servers=[
'1.1.1.1',
'2.2.2.2',
],
),
),
],
)
# After modifying the network configuration it is very important to make it
# persistent:
host_service.commit_net_config()
네트워크 구성이 호스트에 저장되었는지 확인하고 호스트가 재부팅될 때 적용되도록 하려면 commitnetconfig 를 호출해야 합니다.
| 이름 | 유형 | direction | 요약 |
|---|---|---|---|
|
| in | 작업을 비동기적으로 수행해야 하는지 여부를 나타냅니다. | |
|
| in | ||
|
| in | ||
|
| in | ||
|
| in | ||
|
| in | ||
|
| in | ||
|
| in | ||
|
| in | ||
|
| in |