[ovirt-users] python sdk v3 host nic issues

Huan He (huhe) huhe at cisco.com
Fri Aug 5 18:08:06 UTC 2016


Hi,

I tried the host nic and bond sample code in http://www.ovirt.org/develop/api/pythonapi/. In gui, I am able to create bond and vlan network without issues.

here is my code



if __name__ == '__main__':

    url = 'https://huhe-rhev-m.cisco.com/ovirt-engine/api'

    usr = 'admin at internal'

    pwd = 'nbv12345'

    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


> <action>

>     <host_nics>

>         <host_nic>

>             <name>bond0</name>

>             <network>

>                 <name>ovirtmgmt</name>

>             </network>

>             <ip netmask="255.255.255.0" gateway="20.200.10.254" address="20.200.10.172"/>

>             <bonding>

>                 <options>

>                     <option name="miimon" value="100"/>

>                     <option name="mode" value="1"/>

>                     <option name="primary" value="enp6s0"/>

>                 </options>

>                 <slaves>

>                     <host_nic>

>                         <name>enp6s0</name>

>                         <network/>

>                         <ip netmask="" gateway="" address=""/>

>                         <boot_protocol>none</boot_protocol>

>                     </host_nic>

>                     <host_nic>

>                         <name>enp7s0</name>

>                         <network/>

>                         <ip netmask="" gateway="" address=""/>

>                         <boot_protocol>none</boot_protocol>

>                     </host_nic>

>                     <host_nic>

>                         <name>enp8s0</name>

>                         <network/>

>                         <ip netmask="" gateway="" address=""/>

>                         <boot_protocol>none</boot_protocol>

>                     </host_nic>

>                     <host_nic>

>                         <name>enp9s0</name>

>                         <network/>

>                         <ip netmask="" gateway="" address=""/>

>                         <boot_protocol>none</boot_protocol>

>                     </host_nic>

>                 </slaves>

>             </bonding>

>             <boot_protocol>static</boot_protocol>

>             <override_configuration>1</override_configuration>

>         </host_nic>

>         <host_nic>

>             <name>bond0.101</name>

>             <network>

>                 <name>my_vm_db</name>

>             </network>

>         </host_nic>

>     </host_nics>

>     <check_connectivity>1</check_connectivity>

>     <force>0</force>

> </action>

< 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 <module>

    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:


Any idea what is wrong? It is ovirt v3


Thanks,

Huan


<http://www.ovirt.org/develop/api/pythonapi/><http://www.ovirt.org/develop/api/pythonapi/><http://www.ovirt.org/develop/api/pythonapi/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/users/attachments/20160805/e9e5e69a/attachment-0001.html>


More information about the Users mailing list