[Users] bonding setup with python sdk

Michael Pasternak mpastern at redhat.com
Wed Feb 13 11:28:47 UTC 2013


Louis,

what is your sdk version? (make sure you have latest)
here is your code (from http://kermit.fr/lofic/snipper/16/) with couple of comments inline

#!/usr/bin/python
from ovirtsdk.api import API
from ovirtsdk.xml import params

RHEVM='10.0.1.251'
PORT='443'
LOGIN='admin at internal'
PASSWORD='nottherealpw'

from ovirtsdk.api import API
from ovirtsdk.xml import params

baseurl = "https://%s:%s" % (RHEVM,PORT)
api = API(url=baseurl, username=LOGIN, password=PASSWORD, insecure=True)

nic0 = params.HostNIC(name = 'eth0', network = params.Network(), boot_protocol='none', ip=params.IP(address='', netmask='', gateway=''))
nic1 = params.HostNIC(name = 'eth4', network = None)

==> this is ^ not correct, network should be overridden by the 'params.Network()'
    (moti already submitted a patch preventing such syntax in the backend)

===> does both eth0/eth4 exist on your host?

# bond0 definition on top of eth0 and eth4
bond = params.Bonding(
   slaves = params.Slaves(host_nic = [ nic0, nic1 ]),
            options = params.Options(
                        option = [
                          params.Option(name = 'miimon', value = '100'),
                          params.Option(name = 'mode', value = '1'),
                          params.Option(name = 'primary', value = 'eth0')]
                        )
                      )

# Configure the management network on top of the bond
managementNetwork = params.HostNIC(network = params.Network(name = 'rhevm'),
                      name = 'bond0',
                      boot_protocol = 'static',
                          ip = params.IP(
                          address = '10.0.1.212',
                          netmask = '255.255.255.0',
                          gateway = '10.0.1.253'),
                      override_configuration = 1,
                      bonding = bond)

# Now apply the configuration
host = api.hosts.get('h1')
	
host.nics.setupnetworks(params.Action(force = 0,
                                      check_connectivity = 1,
                                      host_nics = params.HostNics(host_nic = [ managementNetwork ])))


On 02/13/2013 12:27 PM, Louis Coilliot wrote:
> Thanks.
> 
> The proper link is :
> http://motiasayag.wordpress.com/2013/02/13/creating-networks-on-top-of-a-bond/
> 
> Is it supposed to work for RHEV 3.1 ?
> 
> I get :
> 
> Traceback (most recent call last):
>   File "./setbond.py", line 46, in <module>
>     host_nics = params.HostNics(host_nic = [ managementNetwork ])))
>   File "/usr/lib/python2.6/site-packages/ovirtsdk/infrastructure/brokers.py",
> line 2659, in setupnetworks
>     headers={"Correlation-Id":correlation_id})
>   File "/usr/lib/python2.6/site-packages/ovirtsdk/infrastructure/proxy.py",
> line 129, in request
>     last=last)
>   File "/usr/lib/python2.6/site-packages/ovirtsdk/infrastructure/proxy.py",
> line 158, in __doRequest
>     raise RequestError, response
> ovirtsdk.infrastructure.errors.RequestError:
> status: 400
> reason: Bad Request
> detail: Entity not found: null
> 
> From this test script :
> http://kermit.fr/lofic/snipper/16/
> 
> Louis Coilliot
> 
> 2013/2/13 Michael Pasternak <mpastern at redhat.com>:
>>
>> Moti,
>>
>> Can you please add your setupnetworks example for bonds to the sdk wiki? (and post it on this thread)
>>
>> thanks.
>>
>> On 02/12/2013 06:40 PM, Louis Coilliot wrote:
>>> Hello,
>>>
>>> do you have examples or hints on setting the bonding of some NICS on
>>> hypervisor hosts ? With the python SDK ?
>>>
>>> Thanks in advance.
>>>
>>> Louis Coilliot
>>> _______________________________________________
>>> Users mailing list
>>> Users at ovirt.org
>>> http://lists.ovirt.org/mailman/listinfo/users
>>
>>
>> --
>>
>> Michael Pasternak
>> RedHat, ENG-Virtualization R&D
>> _______________________________________________
>> Users mailing list
>> Users at ovirt.org
>> http://lists.ovirt.org/mailman/listinfo/users


-- 

Michael Pasternak
RedHat, ENG-Virtualization R&D



More information about the Users mailing list