<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px;">
<div style="font-family: Calibri, sans-serif;">Hi,</div>
<div style="font-family: Calibri, sans-serif;"><br>
</div>
<div>I tried the host nic and bond sample code in <a href="http://www.ovirt.org/develop/api/pythonapi">http://www.ovirt.org/develop/api/pythonapi</a>/. In gui, I am able to create bond and vlan network without issues.</div>
<div><br>
</div>
<div>here is my code</div>
<div><br>
</div>
<div><br>
</div>
<div>
<p style="margin: 0px; font-family: Menlo;">if __name__ == '__main__':</p>
<p style="margin: 0px; font-family: Menlo;"> url = 'https://huhe-rhev-m.cisco.com/ovirt-engine/api'</p>
<p style="margin: 0px; font-family: Menlo;"> usr = 'admin@internal'</p>
<p style="margin: 0px; font-family: Menlo;"> pwd = 'nbv12345'</p>
<p style="margin: 0px; font-family: Menlo;"> ca_file = '/home/huhe/workspace/ansible/crt/ca.der'</p>
<p style="margin: 0px; font-family: Menlo; min-height: 16px;"> </p>
<p style="margin: 0px; font-family: Menlo;"> api = API(url=url, username=usr, password=pwd, ca_file=ca_file, debug=True)</p>
<p style="margin: 0px; font-family: Menlo;"> print api.get_product_info().name</p>
<p style="margin: 0px; font-family: Menlo; min-height: 16px;"> </p>
<p style="margin: 0px; font-family: Menlo;"> nic0 = params.HostNIC(name = 'enp6s0', network = params.Network(), boot_protocol='none', ip=params.IP(address='', netmask='', gateway=''))</p>
<p style="margin: 0px; font-family: Menlo;"> nic1 = params.HostNIC(name = 'enp7s0', network = params.Network(), boot_protocol='none', ip=params.IP(address='', netmask='', gateway=''))</p>
<p style="margin: 0px; font-family: Menlo;"> nic2 = params.HostNIC(name = 'enp8s0', network = params.Network(), boot_protocol='none', ip=params.IP(address='', netmask='', gateway=''))</p>
<p style="margin: 0px; font-family: Menlo;"> nic3 = params.HostNIC(name = 'enp9s0', network = params.Network(), boot_protocol='none', ip=params.IP(address='', netmask='', gateway=''))</p>
<p style="margin: 0px; font-family: Menlo; min-height: 16px;"> </p>
<p style="margin: 0px; font-family: Menlo;"> bond = params.Bonding(</p>
<p style="margin: 0px; font-family: Menlo;"> slaves = params.Slaves(host_nic = [ nic0, nic1, nic2, nic3 ]),</p>
<p style="margin: 0px; font-family: Menlo;"> options = params.Options(</p>
<p style="margin: 0px; font-family: Menlo;"> option = [</p>
<p style="margin: 0px; font-family: Menlo;"> params.Option(name = 'miimon', value = '100'),</p>
<p style="margin: 0px; font-family: Menlo;"> params.Option(name = 'mode', value = '1'),</p>
<p style="margin: 0px; font-family: Menlo;"> params.Option(name = 'primary', value = 'enp6s0')]</p>
<p style="margin: 0px; font-family: Menlo;"> )</p>
<p style="margin: 0px; font-family: Menlo;"> )</p>
<p style="margin: 0px; font-family: Menlo; min-height: 16px;"> </p>
<p style="margin: 0px; font-family: Menlo;"> managementNetwork = params.HostNIC(network = params.Network(name = 'ovirtmgmt'),</p>
<p style="margin: 0px; font-family: Menlo;"> name = 'bond0',</p>
<p style="margin: 0px; font-family: Menlo;"> boot_protocol = 'static',</p>
<p style="margin: 0px; font-family: Menlo;"> ip = params.IP(</p>
<p style="margin: 0px; font-family: Menlo;"> address = '20.200.10.172',</p>
<p style="margin: 0px; font-family: Menlo;"> netmask = '255.255.255.0',</p>
<p style="margin: 0px; font-family: Menlo;"> gateway = '20.200.10.254'),</p>
<p style="margin: 0px; font-family: Menlo;"> override_configuration = 1,</p>
<p style="margin: 0px; font-family: Menlo;"> bonding = bond)</p>
<p style="margin: 0px; font-family: Menlo; min-height: 16px;"> </p>
<p style="margin: 0px; font-family: Menlo;"> networkName = 'my_vm_db'</p>
<p style="margin: 0px; font-family: Menlo;"> clusterNetwork = api.clusters.get('my_cluster').networks.get(name = networkName)</p>
<p style="margin: 0px; font-family: Menlo;"> vlanNetwork = params.HostNIC(network = params.Network(name = networkName), name = "bond0.%s" % clusterNetwork.vlan.id)</p>
<p style="margin: 0px; font-family: Menlo; min-height: 16px;"> </p>
<p style="margin: 0px; font-family: Menlo;"> host = api.hosts.get('host-172')</p>
<p style="margin: 0px; font-family: Menlo;"> host.nics.setupnetworks(params.Action(force = 0,</p>
<p style="margin: 0px; font-family: Menlo;"> check_connectivity = 1,</p>
<p style="margin: 0px; font-family: Menlo;"> host_nics = params.HostNics(host_nic = [ managementNetwork, </p>
<p style="margin: 0px; font-family: Menlo;"> vlanNetwork])))</p>
<p style="margin: 0px; font-family: Menlo; min-height: 16px;"> </p>
<p style="margin: 0px; font-family: Menlo;"> api.disconnect()</p>
<p style="margin: 0px; font-family: Menlo;"><br>
</p>
</div>
<div><br>
</div>
<div>The following is the console output</div>
<div><br>
</div>
<div>
<p style="margin: 0px; font-family: Menlo;">> <action></p>
<p style="margin: 0px; font-family: Menlo;">> <host_nics></p>
<p style="margin: 0px; font-family: Menlo;">> <host_nic></p>
<p style="margin: 0px; font-family: Menlo;">> <name>bond0</name></p>
<p style="margin: 0px; font-family: Menlo;">> <network></p>
<p style="margin: 0px; font-family: Menlo;">> <name>ovirtmgmt</name></p>
<p style="margin: 0px; font-family: Menlo;">> </network></p>
<p style="margin: 0px; font-family: Menlo;">> <ip netmask="255.255.255.0" gateway="20.200.10.254" address="20.200.10.172"/></p>
<p style="margin: 0px; font-family: Menlo;">> <bonding></p>
<p style="margin: 0px; font-family: Menlo;">> <options></p>
<p style="margin: 0px; font-family: Menlo;">> <option name="miimon" value="100"/></p>
<p style="margin: 0px; font-family: Menlo;">> <option name="mode" value="1"/></p>
<p style="margin: 0px; font-family: Menlo;">> <option name="primary" value="enp6s0"/></p>
<p style="margin: 0px; font-family: Menlo;">> </options></p>
<p style="margin: 0px; font-family: Menlo;">> <slaves></p>
<p style="margin: 0px; font-family: Menlo;">> <host_nic></p>
<p style="margin: 0px; font-family: Menlo;">> <name>enp6s0</name></p>
<p style="margin: 0px; font-family: Menlo;">> <network/></p>
<p style="margin: 0px; font-family: Menlo;">> <ip netmask="" gateway="" address=""/></p>
<p style="margin: 0px; font-family: Menlo;">> <boot_protocol>none</boot_protocol></p>
<p style="margin: 0px; font-family: Menlo;">> </host_nic></p>
<p style="margin: 0px; font-family: Menlo;">> <host_nic></p>
<p style="margin: 0px; font-family: Menlo;">> <name>enp7s0</name></p>
<p style="margin: 0px; font-family: Menlo;">> <network/></p>
<p style="margin: 0px; font-family: Menlo;">> <ip netmask="" gateway="" address=""/></p>
<p style="margin: 0px; font-family: Menlo;">> <boot_protocol>none</boot_protocol></p>
<p style="margin: 0px; font-family: Menlo;">> </host_nic></p>
<p style="margin: 0px; font-family: Menlo;">> <host_nic></p>
<p style="margin: 0px; font-family: Menlo;">> <name>enp8s0</name></p>
<p style="margin: 0px; font-family: Menlo;">> <network/></p>
<p style="margin: 0px; font-family: Menlo;">> <ip netmask="" gateway="" address=""/></p>
<p style="margin: 0px; font-family: Menlo;">> <boot_protocol>none</boot_protocol></p>
<p style="margin: 0px; font-family: Menlo;">> </host_nic></p>
<p style="margin: 0px; font-family: Menlo;">> <host_nic></p>
<p style="margin: 0px; font-family: Menlo;">> <name>enp9s0</name></p>
<p style="margin: 0px; font-family: Menlo;">> <network/></p>
<p style="margin: 0px; font-family: Menlo;">> <ip netmask="" gateway="" address=""/></p>
<p style="margin: 0px; font-family: Menlo;">> <boot_protocol>none</boot_protocol></p>
<p style="margin: 0px; font-family: Menlo;">> </host_nic></p>
<p style="margin: 0px; font-family: Menlo;">> </slaves></p>
<p style="margin: 0px; font-family: Menlo;">> </bonding></p>
<p style="margin: 0px; font-family: Menlo;">> <boot_protocol>static</boot_protocol></p>
<p style="margin: 0px; font-family: Menlo;">> <override_configuration>1</override_configuration></p>
<p style="margin: 0px; font-family: Menlo;">> </host_nic></p>
<p style="margin: 0px; font-family: Menlo;">> <host_nic></p>
<p style="margin: 0px; font-family: Menlo;">> <name>bond0.101</name></p>
<p style="margin: 0px; font-family: Menlo;">> <network></p>
<p style="margin: 0px; font-family: Menlo;">> <name>my_vm_db</name></p>
<p style="margin: 0px; font-family: Menlo;">> </network></p>
<p style="margin: 0px; font-family: Menlo;">> </host_nic></p>
<p style="margin: 0px; font-family: Menlo;">> </host_nics></p>
<p style="margin: 0px; font-family: Menlo;">> <check_connectivity>1</check_connectivity></p>
<p style="margin: 0px; font-family: Menlo;">> <force>0</force></p>
<p style="margin: 0px; font-family: Menlo;">> </action></p>
<p style="margin: 0px; font-family: Menlo;">< HTTP/1.1 404 Not Found</p>
<p style="margin: 0px; font-family: Menlo;">< Date: Fri, 05 Aug 2016 17:55:54 GMT</p>
<p style="margin: 0px; font-family: Menlo;">< Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.1e-fips</p>
<p style="margin: 0px; font-family: Menlo;">< Content-Length: 0</p>
<p style="margin: 0px; font-family: Menlo;">< </p>
<p style="margin: 0px; font-family: Menlo;">* Connection #0 to host huhe-rhev-m.cisco.com left intact</p>
<p style="margin: 0px; font-family: Menlo;">Traceback (most recent call last):</p>
<p style="margin: 0px; font-family: Menlo;"> File "/home/huhe/workspace/ansible/src/ovirt_hostnic.py", line 57, in <module></p>
<p style="margin: 0px; font-family: Menlo;"> vlanNetwork])))</p>
<p style="margin: 0px; font-family: Menlo;"> File "/usr/local/lib/python2.7/site-packages/ovirtsdk/infrastructure/brokers.py", line 16672, in setupnetworks</p>
<p style="margin: 0px; font-family: Menlo;"> headers={"Correlation-Id":correlation_id}</p>
<p style="margin: 0px; font-family: Menlo;"> File "/usr/local/lib/python2.7/site-packages/ovirtsdk/infrastructure/proxy.py", line 122, in request</p>
<p style="margin: 0px; font-family: Menlo;"> persistent_auth=self.__persistent_auth</p>
<p style="margin: 0px; font-family: Menlo;"> File "/usr/local/lib/python2.7/site-packages/ovirtsdk/infrastructure/connectionspool.py", line 79, in do_request</p>
<p style="margin: 0px; font-family: Menlo;"> persistent_auth)</p>
<p style="margin: 0px; font-family: Menlo;"> File "/usr/local/lib/python2.7/site-packages/ovirtsdk/infrastructure/connectionspool.py", line 156, in __do_request</p>
<p style="margin: 0px; font-family: Menlo;"> raise errors.RequestError(response_code, response_reason, response_body)</p>
<p style="margin: 0px; font-family: Menlo;">ovirtsdk.infrastructure.errors.RequestError: </p>
<p style="margin: 0px; font-family: Menlo;">status: 404</p>
<p style="margin: 0px; font-family: Menlo;">reason: Not Found</p>
<p style="margin: 0px; font-family: Menlo;">detail: </p>
<p style="margin: 0px; font-family: Menlo; min-height: 16px;"><br>
</p>
<p style="margin: 0px; font-family: Menlo; min-height: 16px;">Any idea what is wrong? It is ovirt v3</p>
<p style="margin: 0px; font-family: Menlo; min-height: 16px;"><br>
</p>
<p style="margin: 0px; font-family: Menlo; min-height: 16px;">Thanks,</p>
<p style="margin: 0px; font-family: Menlo; min-height: 16px;">Huan</p>
<p style="margin: 0px; font-family: Menlo; min-height: 16px;"><br>
</p>
</div>
<font face="Calibri,sans-serif"><a href="http://www.ovirt.org/develop/api/pythonapi/"></a><a href="http://www.ovirt.org/develop/api/pythonapi/"></a><a href="http://www.ovirt.org/develop/api/pythonapi/"></a></font>
</body>
</html>