Select Your Language

Infrastructure and Management

Cloud Computing

Storage

Runtimes

Integration and Automation

  • Comments
  • python sdk can't configure host nic and bonding

    Posted on

    I tried to configure host nic and bonding but it failed. Not sure what is wrong. I have RHEV 4.0 beta. I am able to do it in GUI.

    Thanks,
    Huan

    The script

    if name == 'main':
    url = 'https://huhe-rhev-m.cisco.com/ovirt-engine/api'
    usr = 'admin@internal'
    pwd = 'pwd12345'
    ca_file = '/home/huhe/workspace/ansible/crt/ca.der'

    api = API(url=url, username=usr, password=pwd, ca_file=ca_file, debug=True)
    print api.get_product_info().name
    
    nic0 = params.HostNIC(name = 'enp6s0', network =  params.Network(), boot_protocol='none', ip=params.IP(address='', netmask='', gateway=''))
    nic1 = params.HostNIC(name = 'enp7s0', network =  params.Network(), boot_protocol='none', ip=params.IP(address='', netmask='', gateway=''))
    nic2 = params.HostNIC(name = 'enp8s0', network =  params.Network(), boot_protocol='none', ip=params.IP(address='', netmask='', gateway=''))
    nic3 = params.HostNIC(name = 'enp9s0', network =  params.Network(), boot_protocol='none', ip=params.IP(address='', netmask='', gateway=''))
    
    bond = params.Bonding(
       slaves = params.Slaves(host_nic = [ nic0, nic1, nic2, nic3 ]),
                options = params.Options(
                            option = [
                              params.Option(name = 'miimon', value = '100'),
                              params.Option(name = 'mode', value = '1'),
                              params.Option(name = 'primary', value = 'enp6s0')]
                            )
                          )
    
    managementNetwork = params.HostNIC(network = params.Network(name = 'ovirtmgmt'),
                          name = 'bond0',
                          boot_protocol = 'static',
                              ip = params.IP(
                              address = '20.200.10.172',
                              netmask = '255.255.255.0',
                              gateway = '20.200.10.254'),
                          override_configuration = 1,
                          bonding = bond)
    
    networkName = 'my_vm_db'
    clusterNetwork = api.clusters.get('my_cluster').networks.get(name = networkName)
    vlanNetwork = params.HostNIC(network = params.Network(name = networkName), name = "bond0.%s" % clusterNetwork.vlan.id)
    
    host = api.hosts.get('host-172')
    host.nics.setupnetworks(params.Action(force = 0,
                                          check_connectivity = 1,
                                          host_nics = params.HostNics(host_nic = [ managementNetwork, 
                                                                                   vlanNetwork])))
    
    api.disconnect()
    

    The following is the console output

    bond0

    ovirtmgmt

    enp6s0

    none

    enp7s0

    none

    enp8s0

    none

    enp9s0

    none

    static
    1

    bond0.101

    my_vm_db

    1
    0

    HTTP/1.1 404 Not Found
    Date: Fri, 05 Aug 2016 17:55:54 GMT
    Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.1e-fips
    Content-Length: 0

    * Connection #0 to host huhe-rhev-m.cisco.com left intact
    Traceback (most recent call last):
    File "/home/huhe/workspace/ansible/src/ovirt_hostnic.py", line 57, in
    vlanNetwork])))
    File "/usr/local/lib/python2.7/site-packages/ovirtsdk/infrastructure/brokers.py", line 16672, in setupnetworks
    headers={"Correlation-Id":correlation_id}
    File "/usr/local/lib/python2.7/site-packages/ovirtsdk/infrastructure/proxy.py", line 122, in request
    persistent_auth=self.__persistent_auth
    File "/usr/local/lib/python2.7/site-packages/ovirtsdk/infrastructure/connectionspool.py", line 79, in do_request
    persistent_auth)
    File "/usr/local/lib/python2.7/site-packages/ovirtsdk/infrastructure/connectionspool.py", line 156, in __do_request
    raise errors.RequestError(response_code, response_reason, response_body)
    ovirtsdk.infrastructure.errors.RequestError:
    status: 404
    reason: Not Found
    detail:

    Attachments

    by

    points

    Responses

    Red Hat LinkedIn YouTube Facebook X, formerly Twitter

    Quick Links

    Help

    Site Info

    Related Sites

    © 2026 Red Hat