Hi Micheal,<div><br></div><div>After updating the sdk I see change in documentation for hostnic addition and see bonding as a optional parameter, but I dont see it behaving it that way. When I try running the code to create and add NIC with Static IP assigned, I am facing same error where it is asking for bonding parameter and failing due to the same. </div>
<div><br></div><div>Also, I made sure I removed the previous sdk and ensured my program is using the latest sdk.</div><div><br></div><div>The error that I get is mentioned below :</div><div><br></div><div><div><b><i>Traceback (most recent call last):</i></b></div>
<div><b><i> File "rtest.py", line 51, in <module></i></b></div><div><b><i> host.nics.add(params.HostNIC(name = new_hostnic_name, network=network, boot_protocol = 'static', ip= new_ip))</i></b></div>
<div><b><i> File "/usr/lib/python2.6/site-packages/ovirtsdk/infrastructure/brokers.py", line 2393, in add</i></b></div><div><b><i> body=ParseHelper.toXml(hostnic))</i></b></div><div><b><i> File "/usr/lib/python2.6/site-packages/ovirtsdk/infrastructure/proxy.py", line 117, in add</i></b></div>
<div><b><i> return self.request('POST', url, body, headers)</i></b></div><div><b><i> File "/usr/lib/python2.6/site-packages/ovirtsdk/infrastructure/proxy.py", line 128, in request</i></b></div><div>
<b><i> last=last)</i></b></div>
<div><b><i> File "/usr/lib/python2.6/site-packages/ovirtsdk/infrastructure/proxy.py", line 154, in __doRequest</i></b></div><div><b><i> raise RequestError, response</i></b></div><div><b><i>ovirtsdk.infrastructure.errors.RequestError:</i></b></div>
<div><b><i>status: 400</i></b></div><div><b><i>reason: Bad Request</i></b></div><div><b><i>detail: HostNIC [<a href="http://bonding.slaves.id">bonding.slaves.id</a>|name] required for add</i></b></div></div><div><b><i><br>
</i></b></div><div><b><i><br></i></b></div><div>The piece of code that I am using to do this is :</div><div><br></div><div><div><i>hostid = 0</i></div><div><i>address = ip_start</i></div><div><i>new_hostnic_name = 'em3.'+str(vlanId)</i></div>
<div><i>for host in hosts :</i></div><div><i> if <a href="http://host.cluster.id">host.cluster.id</a> == <a href="http://cluster.id">cluster.id</a> :</i></div><div><i> hostid = hostid + 1</i></div><div><i> add_splits = address.split('.')</i></div>
<div><i> add_splits[3] = str(200 + hostid)</i></div><div><i> address= '.'.join(add_splits)</i></div><div><i> new_ip = params.IP(address = address , netmask = '255.255.255.0' )</i></div>
<div><i> <b> host.nics.add(params.HostNIC(name = new_hostnic_name, network=network, boot_protocol = 'static', ip= new_ip))</b></i></div><div><i><br></i></div><div><i> host.commitnetconfig()</i></div>
</div>
<div><i><br></i></div><div><br></div><div>My requirement is that I do not want to using bonding while addition of a new NIC to the host, Also , I want to add the ip address to the new NIC at the time of creation itself.</div>
<div><br></div><div><br></div><div>Regards,</div><div>Rahul.</div><div><br></div><div><br></div><div><br><br><div class="gmail_quote">On Fri, Jul 6, 2012 at 12:33 PM, Rahul Upadhyaya <span dir="ltr"><<a href="mailto:rakrup@gmail.com" target="_blank">rakrup@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><br></div>Thanks Michael,<div><br></div><div>I had a older version of the python-binding which had bonding in #1 as a compulsory parameter... Seeing your options I updated the sdk and now the error is resolved. I see bonding as an optional param.</div>
<div><br></div><div>Regards,</div><div>Rahul.</div><div><br><br><div class="gmail_quote"><div class="im">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Michael Pasternak</b> <span dir="ltr"><<a href="mailto:mpastern@redhat.com" target="_blank">mpastern@redhat.com</a>></span><br>
</div><div class="im">
Date: Thu, Jul 5, 2012 at 7:22 PM<br>Subject: Re: [Users] HostNic Addition with IP Address<br>To: Rahul Upadhyaya <<a href="mailto:rakrup@gmail.com" target="_blank">rakrup@gmail.com</a>><br>Cc: <a href="mailto:users@ovirt.org" target="_blank">users@ovirt.org</a><br>
<br><br><br></div><div><div class="h5">
Hi Rahul,<br>
<br>
#1 is the right place for doing this, see method __doc__ [1]<br>
#2 used for attaching network to NIC, see __doc__ is [2]<br>
<br>
* note all methods in sdk well documented describing what<br>
parameters-holder to use and how to fill it.<br>
<br>
[1]<br>
'''<br>
@type HostNIC:<br>
<br>
@param <a href="http://hostnic.network.id" target="_blank">hostnic.network.id</a>|name: string<br>
@param <a href="http://hostnic.name" target="_blank">hostnic.name</a>: string<br>
[@param hostnic.bonding.slaves.host_nic: collection]<br>
{<br>
[@ivar <a href="http://host_nic.id" target="_blank">host_nic.id</a>|name: string]<br>
}<br>
[@param hostnic.bonding.options.option: collection]<br>
{<br>
[@ivar <a href="http://option.name" target="_blank">option.name</a>: string]<br>
[@ivar option.value: string]<br>
[@ivar type: string]<br>
}<br>
[@param hostnic.ip.gateway: string]<br>
[@param hostnic.boot_protocol: string]<br>
[@param hostnic.mac: string]<br>
[@param hostnic.ip.address: string]<br>
[@param hostnic.ip.netmask: string]<br>
<br>
@return HostNIC:<br>
'''<br>
<br>
[2]<br>
'''<br>
@type Action:<br>
<br>
@param <a href="http://action.network.id" target="_blank">action.network.id</a>|name: string<br>
[@param action.async: boolean]<br>
[@param action.grace_period.expiry: long]<br>
<br>
@return Response:<br>
'''<br>
<div><div><br>
On 07/05/2012 03:00 PM, Rahul Upadhyaya wrote:<br>
> Hi Folks,<br>
><br>
> I am facing issues while adding NIC with Static I.P. to host using the oVirt Python-Bindings. There are two api's<br>
><br>
> 1) HostNics.add :Here it requires binding param for interface bonding as a compulsory param. I dont want to bond more than one interfaces for a network<br>
> while creating network each time.<br>
><br>
> 2) HostNic.attach: This lets me attach the NIC but does not let me put static IP address to it as soon as I add it. I am using a workaround of updating<br>
> the NIC with the IP information, but it requires me to put all the hosts on maintenance and shut-down all the running VMs which again is not the best way of doing it.<br>
><br>
><br>
> Is it not supported by the API that at the time of addition of the hostNIC we can specify the IP address or is it something that I am missing ?<br>
> Also,I see that this operation is supported from the manager UI .<br>
><br>
><br>
> --<br>
> Regards,<br>
> Rahul<br>
> =======================================================<br>
><br>
><br>
><br>
</div></div>> _______________________________________________<br>
> Users mailing list<br>
> <a href="mailto:Users@ovirt.org" target="_blank">Users@ovirt.org</a><br>
> <a href="http://lists.ovirt.org/mailman/listinfo/users" target="_blank">http://lists.ovirt.org/mailman/listinfo/users</a><br>
<span><font color="#888888"><br>
<br>
--<br>
<br>
Michael Pasternak<br>
RedHat, ENG-Virtualization R&D<br>
</font></span></div></div></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br>Regards,<br>Rahul<div>=======================================================</div><br>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Regards,<br>Rahul<div>=======================================================</div><br>
</div>