<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><blockquote type="cite" class=""><br class=""></blockquote><blockquote type="cite" class="">I think I will soon have more questions about what is a modified or removed object when creating bond, but I will need to play a little more with it.<br class=""><br class=""></blockquote><div class=""><br class=""></div>Ok, I started to play with the right setupnetworks, and I'm getting strange results.<div class=""><br class=""></div><div class="">When I try to transform an eth0 attachement to a bond attachement, I get&nbsp;</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">Cannot setup Networks. Network Interface 'eth0' cannot become slave, there's network 'ovirtmgmt' attached to it.</font></div><div class=""><br class=""></div><div class="">I tried to have a look at the command that the UI send and don't get it. It says :</div><div class=""><br class=""></div><font face="Menlo" class="">networks='[HostNetwork:{defaultRoute='true', bonding='true', networkName='ovirtmgmt', nicName='bond0', vlan='null', mtu='9000', vmNetwork='true', stp='false', properties='[]',&nbsp;bootProtocol='DHCP', address='null', netmask='null', gateway='null'}]',&nbsp;<br class="">removedNetworks='[]',&nbsp;<br class="">bonds='[Bond:{id='ffcfe313-7607-4347-b797-aa9c3260e221', name='bond0', vdsId='null', networkName='ovirtmgmt', bootProtocol='DHCP', address='null', subnet='null',&nbsp;gateway='null', mtu='9000', bridged='true', type='2', networkImplementationDetails='null', qos='null', macAddress='null', bondOptions='mode=4 miimon=100', labels='null',&nbsp;slaves='[eth0, eth1]'}]',&nbsp;</font><div class=""><font face="Menlo" class="">removedBonds='[Bond:{id='ffcfe313-7607-4347-b797-aa9c3260e221', name='bond0', vdsId='null', networkName='ovirtmgmt', bootProtocol='DHCP',&nbsp;address='null', subnet='null', gateway='null', mtu='9000', bridged='true', type='2', networkImplementationDetails='null', qos='null', macAddress='null', bondOptions='mode=4&nbsp;miimon=100', labels='null', slaves='[eth0, eth1]'}]'}),<br class=""></font><br class=""><div class="">&nbsp;What I'm doing is quite close, there is a modified network and modified bond. But what about the removedBonds ? They was no bonding before that</div><div class=""><br class=""></div><div class="">My code is :</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">bond_name = kwargs['bond_name']<br class="">mtu = kwargs.pop('mtu',&nbsp;None)<br class="">nics = []<br class="">for&nbsp;if_name&nbsp;in&nbsp;kwargs['interfaces']:<br class="">&nbsp; &nbsp; nic = params.HostNIC(name=if_name)<br class="">&nbsp; &nbsp;&nbsp;if&nbsp;mtu&nbsp;is not&nbsp;None:<br class="">&nbsp; &nbsp; &nbsp; &nbsp; nic.set_mtu(mtu)<br class="">&nbsp; &nbsp; nics.append(nic)<br class=""><br class="">bonding = params.Bonding(<br class="">&nbsp; &nbsp;&nbsp;slaves=params.Slaves(host_nic=nics),<br class="">&nbsp; &nbsp;&nbsp;options=params.Options(<br class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;option=map(lambda&nbsp;(x, y): params.Option(name=x,&nbsp;value=y), kwargs.pop('bond_options', {}).iteritems() )<br class="">&nbsp; &nbsp; )<br class="">)<br class=""><br class="">bonded_if = params.HostNIC(name=bond_name,&nbsp;bonding=bonding)<br class=""><br class="">if&nbsp;mtu&nbsp;is not&nbsp;None:<br class="">&nbsp; &nbsp; bonded_if.set_mtu(mtu)<br class=""><br class="">ip = kwargs.pop('ip',&nbsp;None)<br class="">gateway = kwargs.pop('gateway',&nbsp;None)<br class="">if&nbsp;ip&nbsp;is not&nbsp;None:<br class="">&nbsp; &nbsp; ip =&nbsp;unicode(ip)<br class="">&nbsp; &nbsp; ip_addr = ipaddress.ip_address(ip.split('/')[0])<br class="">&nbsp; &nbsp; ip_net = ipaddress.ip_network(ip,&nbsp;strict=False)<br class="">&nbsp; &nbsp; ip_conf = params.IP(address=str(ip_addr),<br class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;netmask=str(ip_net).split('/')[0])<br class="">&nbsp; &nbsp;&nbsp;if&nbsp;gateway&nbsp;is not&nbsp;None:<br class="">&nbsp; &nbsp; &nbsp; &nbsp; ip_conf.set_gateway(gateway)<br class="">&nbsp; &nbsp; ip_assignment = params.IpAddressAssignment(assignment_method="static",&nbsp;ip=ip_conf)<br class="">elif&nbsp;kwargs.pop('dhcp',&nbsp;False):<br class="">&nbsp; &nbsp; ip_assignment = params.IpAddressAssignment(assignment_method="dhcp",&nbsp;ip=params.IP())<br class=""><br class="">bonded_network = params.NetworkAttachment(network=params.Network(name=kwargs['network']),<br class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;host_nic=params.HostNIC(name=bond_name),<br class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;ip_address_assignments=params.IpAddressAssignments([ip_assignment]))<br class=""><br class="">return&nbsp;self.broker.setupnetworks(params.Action(modified_bonds&nbsp;= params.HostNics(host_nic&nbsp;= [bonded_if]),<br class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;modified_network_attachments&nbsp;= params.NetworkAttachments(network_attachment=[bonded_network]),<br class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;)<br class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;)</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class="">And it generates :</div><div class=""><br class=""></div><div class=""><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; POST /api/hosts/db240f83-9266-4892-a6d2-8ac406cadfb1/setupnetworks HTTP/1.1</font></div><div class=""><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &lt;action&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &lt;modified_network_attachments&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &lt;network_attachment&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;network&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;name&gt;ovirtmgmt&lt;/name&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/network&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;host_nic&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;name&gt;bond0&lt;/name&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/host_nic&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;ip_address_assignments&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;ip_address_assignment&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;ip/&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;assignment_method&gt;dhcp&lt;/assignment_method&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/ip_address_assignment&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/ip_address_assignments&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/network_attachment&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &lt;/modified_network_attachments&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &lt;modified_bonds&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &lt;host_nic&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;name&gt;bond0&lt;/name&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;bonding&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;options&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option name="miimon" value="100"/&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option name="mode" value="4"/&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;option name="xmit_hash_policy" value="2+3"/&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/options&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;slaves&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;host_nic&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;name&gt;eth0&lt;/name&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/host_nic&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;host_nic&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;name&gt;eth1&lt;/name&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/host_nic&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/slaves&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/bonding&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/host_nic&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &nbsp; &nbsp; &lt;/modified_bonds&gt;</font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">&gt; &lt;/action&gt;</font></div></div><div class=""><font face="Menlo" class=""><br class=""></font></div><br class=""></div></div></body></html>