예를 들어 세 개의 네트워크 인터페이스 eth0,eth1 및 eth2 가 있고 eth0 및 eth1 을 사용하여 새 본딩을 구성하고 VLAN을 맨 위에 배치한다고 가정하겠습니다. 다음과 같이 수행할 수 있는 간단한 쉘 스크립트 및 curl 명령줄 HTTP 클라이언트를 사용합니다.
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
중요
네트워크 구성이 호스트에 저장되었는지 확인하고 호스트가 재부팅될 때 적용되도록 하려면 commitnetconfig 를 호출해야 합니다.