Copy to ClipboardCopied!Toggle word wrapToggle overflow
同样的操作也可使用 Python SDK 及以下代码完成:
Find the service that manages the collection of hosts:
Find the host:
Find the service that manages the host:
Configure the network adding a bond with two slaves and attaching it to a
network with an static IP address:
After modifying the network configuration it is very important to make it
persistent:
# 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()
Copy to ClipboardCopied!Toggle word wrapToggle overflow
由于 Red Hat Virtualization Manager 4.3,也可以在 setupnetworks 请求中指定 commit_on_success,在这种情况下,新配置会在完成设置并重新建立 {hypervisor-name} 和 Red Hat Virtualization Manager 之间的连接后自动保存在 {hypervisor-name} 和 Red Hat Virtualization Manager,且无需等待单独的 commitnetconfig 请求。
指定在完成设置并重新建立 {hypervisor-name} 和 Red Hat Virtualization Manager 之间的连接后,是否会在 {hypervisor-name} 和 Red Hat Virtualization Manager 中自动保存配置,且不会等待单独的 commitnetconfig 请求。
指定在完成设置并重新建立 {hypervisor-name} 和 Red Hat Virtualization Manager 之间的连接后,是否会在 {hypervisor-name} 和 Red Hat Virtualization Manager 中自动保存配置,且不会等待单独的 commitnetconfig 请求。默认值为 false,这意味着配置不会自动保存。