<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 </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='[]', bootProtocol='DHCP', address='null', netmask='null', gateway='null'}]', <br class="">removedNetworks='[]', <br class="">bonds='[Bond:{id='ffcfe313-7607-4347-b797-aa9c3260e221', name='bond0', vdsId='null', networkName='ovirtmgmt', bootProtocol='DHCP', address='null', subnet='null', gateway='null', mtu='9000', bridged='true', type='2', networkImplementationDetails='null', qos='null', macAddress='null', bondOptions='mode=4 miimon=100', labels='null', slaves='[eth0, eth1]'}]', </font><div class=""><font face="Menlo" class="">removedBonds='[Bond:{id='ffcfe313-7607-4347-b797-aa9c3260e221', name='bond0', vdsId='null', networkName='ovirtmgmt', bootProtocol='DHCP', address='null', subnet='null', gateway='null', mtu='9000', bridged='true', type='2', networkImplementationDetails='null', qos='null', macAddress='null', bondOptions='mode=4 miimon=100', labels='null', slaves='[eth0, eth1]'}]'}),<br class=""></font><br class=""><div class=""> 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', None)<br class="">nics = []<br class="">for if_name in kwargs['interfaces']:<br class=""> nic = params.HostNIC(name=if_name)<br class=""> if mtu is not None:<br class=""> nic.set_mtu(mtu)<br class=""> nics.append(nic)<br class=""><br class="">bonding = params.Bonding(<br class=""> slaves=params.Slaves(host_nic=nics),<br class=""> options=params.Options(<br class=""> option=map(lambda (x, y): params.Option(name=x, value=y), kwargs.pop('bond_options', {}).iteritems() )<br class=""> )<br class="">)<br class=""><br class="">bonded_if = params.HostNIC(name=bond_name, bonding=bonding)<br class=""><br class="">if mtu is not None:<br class=""> bonded_if.set_mtu(mtu)<br class=""><br class="">ip = kwargs.pop('ip', None)<br class="">gateway = kwargs.pop('gateway', None)<br class="">if ip is not None:<br class=""> ip = unicode(ip)<br class=""> ip_addr = ipaddress.ip_address(ip.split('/')[0])<br class=""> ip_net = ipaddress.ip_network(ip, strict=False)<br class=""> ip_conf = params.IP(address=str(ip_addr),<br class=""> netmask=str(ip_net).split('/')[0])<br class=""> if gateway is not None:<br class=""> ip_conf.set_gateway(gateway)<br class=""> ip_assignment = params.IpAddressAssignment(assignment_method="static", ip=ip_conf)<br class="">elif kwargs.pop('dhcp', False):<br class=""> ip_assignment = params.IpAddressAssignment(assignment_method="dhcp", ip=params.IP())<br class=""><br class="">bonded_network = params.NetworkAttachment(network=params.Network(name=kwargs['network']),<br class=""> host_nic=params.HostNIC(name=bond_name),<br class=""> ip_address_assignments=params.IpAddressAssignments([ip_assignment]))<br class=""><br class="">return self.broker.setupnetworks(params.Action(modified_bonds = params.HostNics(host_nic = [bonded_if]),<br class=""> modified_network_attachments = params.NetworkAttachments(network_attachment=[bonded_network]),<br class=""> )<br class=""> )</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="">> 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="">> <action></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <modified_network_attachments></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <network_attachment></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <network></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <name>ovirtmgmt</name></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> </network></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <host_nic></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <name>bond0</name></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> </host_nic></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <ip_address_assignments></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <ip_address_assignment></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <ip/></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <assignment_method>dhcp</assignment_method></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> </ip_address_assignment></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> </ip_address_assignments></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> </network_attachment></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> </modified_network_attachments></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <modified_bonds></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <host_nic></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <name>bond0</name></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <bonding></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <options></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <option name="miimon" value="100"/></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <option name="mode" value="4"/></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <option name="xmit_hash_policy" value="2+3"/></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> </options></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <slaves></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <host_nic></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <name>eth0</name></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> </host_nic></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <host_nic></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> <name>eth1</name></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> </host_nic></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> </slaves></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> </bonding></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> </host_nic></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> </modified_bonds></font></div><div style="margin: 0px;" class=""><font face="Menlo" class="">> </action></font></div></div><div class=""><font face="Menlo" class=""><br class=""></font></div><br class=""></div></div></body></html>