Interface HostService.SetupNetworksRequest

  • All Superinterfaces:
    Request<HostService.SetupNetworksRequest,​HostService.SetupNetworksResponse>
    Enclosing interface:
    HostService

    public static interface HostService.SetupNetworksRequest
    extends Request<HostService.SetupNetworksRequest,​HostService.SetupNetworksResponse>
    This method is used to change the configuration of the network interfaces of a host. For example, if you have a host with three network interfaces `eth0`, `eth1` and `eth2` and you want to configure a new bond using `eth0` and `eth1`, and put a VLAN on top of it. Using a simple shell script and the `curl` command line HTTP client that can be done as follows: [source] ---- #!/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 ' bond0 eth1 eth2 myvlan bond0 static
    192.168.122.10
    255.255.255.0
    1.1.1.1 2.2.2.2
    ' \ "${url}/hosts/1ff7a191-2f3b-4eff-812b-9f91a30c3acc/setupnetworks" ---- NOTE: This is valid for version 4 of the API. In previous versions some elements were represented as XML attributes instead of XML elements. In particular the `options` and `ip` elements were represented as follows: [source,xml] ---- ---- The same thing can be done using the Python SDK with the following code: [source,python] ---- # 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() ---- IMPORTANT: To make sure that the network configuration has been saved in the host, and that it will be applied when the host is rebooted, remember to call <>. IMPORTANT: Since {engine-name} 4.3, it is possible to also specify `commit_on_success` in the <> request, in which case the new configuration is automatically saved in the {hypervisor-name} upon completing the setup and re-establishing connectivity between the {hypervisor-name} and {engine-name}, and without waiting for a separate <> request.