--Apple-Mail=_E2A5EEF3-9834-4A44-ABBB-E25AFFEA67AD
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=windows-1252
=20
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.
=20
Ok, I started to play with the right setupnetworks, and I'm getting =
strange results.
When I try to transform an eth0 attachement to a bond attachement, I get=20=
Cannot setup Networks. Network Interface 'eth0' cannot become slave, =
there's network 'ovirtmgmt' attached to it.
I tried to have a look at the command that the UI send and don't get it. =
It says :
networks=3D'[HostNetwork:{defaultRoute=3D'true', bonding=3D'true', =
networkName=3D'ovirtmgmt', nicName=3D'bond0', vlan=3D'null',
mtu=3D'9000',=
vmNetwork=3D'true', stp=3D'false', properties=3D'[]', =
bootProtocol=3D'DHCP', address=3D'null', netmask=3D'null', =
gateway=3D'null'}]',=20
removedNetworks=3D'[]',=20
bonds=3D'[Bond:{id=3D'ffcfe313-7607-4347-b797-aa9c3260e221', =
name=3D'bond0', vdsId=3D'null', networkName=3D'ovirtmgmt', =
bootProtocol=3D'DHCP', address=3D'null', subnet=3D'null', =
gateway=3D'null', mtu=3D'9000', bridged=3D'true',
type=3D'2', =
networkImplementationDetails=3D'null', qos=3D'null',
macAddress=3D'null', =
bondOptions=3D'mode=3D4 miimon=3D100', labels=3D'null',
slaves=3D'[eth0, =
eth1]'}]',=20
removedBonds=3D'[Bond:{id=3D'ffcfe313-7607-4347-b797-aa9c3260e221', =
name=3D'bond0', vdsId=3D'null', networkName=3D'ovirtmgmt', =
bootProtocol=3D'DHCP', address=3D'null', subnet=3D'null', =
gateway=3D'null', mtu=3D'9000', bridged=3D'true',
type=3D'2', =
networkImplementationDetails=3D'null', qos=3D'null',
macAddress=3D'null', =
bondOptions=3D'mode=3D4 miimon=3D100', labels=3D'null',
slaves=3D'[eth0, =
eth1]'}]'}),
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
My code is :
bond_name =3D kwargs['bond_name']
mtu =3D kwargs.pop('mtu', None)
nics =3D []
for if_name in kwargs['interfaces']:
nic =3D params.HostNIC(name=3Dif_name)
if mtu is not None:
nic.set_mtu(mtu)
nics.append(nic)
bonding =3D params.Bonding(
slaves=3Dparams.Slaves(host_nic=3Dnics),
options=3Dparams.Options(
option=3Dmap(lambda (x, y): params.Option(name=3Dx, value=3Dy), =
kwargs.pop('bond_options', {}).iteritems() )
)
)
bonded_if =3D params.HostNIC(name=3Dbond_name, bonding=3Dbonding)
if mtu is not None:
bonded_if.set_mtu(mtu)
ip =3D kwargs.pop('ip', None)
gateway =3D kwargs.pop('gateway', None)
if ip is not None:
ip =3D unicode(ip)
ip_addr =3D ipaddress.ip_address(ip.split('/')[0])
ip_net =3D ipaddress.ip_network(ip, strict=3DFalse)
ip_conf =3D params.IP(address=3Dstr(ip_addr),
netmask=3Dstr(ip_net).split('/')[0])
if gateway is not None:
ip_conf.set_gateway(gateway)
ip_assignment =3D =
params.IpAddressAssignment(assignment_method=3D"static", ip=3Dip_conf)
elif kwargs.pop('dhcp', False):
ip_assignment =3D =
params.IpAddressAssignment(assignment_method=3D"dhcp", ip=3Dparams.IP())
bonded_network =3D =
params.NetworkAttachment(network=3Dparams.Network(name=3Dkwargs['network']=
),
=
host_nic=3Dparams.HostNIC(name=3Dbond_name),
=
ip_address_assignments=3Dparams.IpAddressAssignments([ip_assignment]))
return self.broker.setupnetworks(params.Action(modified_bonds =3D =
params.HostNics(host_nic =3D [bonded_if]),
=
modified_network_attachments =3D =
params.NetworkAttachments(network_attachment=3D[bonded_network]),
)
)
And it generates :
POST /api/hosts/db240f83-9266-4892-a6d2-8ac406cadfb1/setupnetworks =
HTTP/1.1
<action>
<modified_network_attachments>
<network_attachment>
<network>
<name>ovirtmgmt</name>
</network>
<host_nic>
<name>bond0</name>
</host_nic>
<ip_address_assignments>
<ip_address_assignment>
<ip/>
<assignment_method>dhcp</assignment_method>
</ip_address_assignment>
</ip_address_assignments>
</network_attachment>
</modified_network_attachments>
<modified_bonds>
<host_nic>
<name>bond0</name>
<bonding>
<options>
<option name=3D"miimon" value=3D"100"/>
<option name=3D"mode" value=3D"4"/>
<option name=3D"xmit_hash_policy"
value=3D"2+3"/>
</options>
<slaves>
<host_nic>
<name>eth0</name>
</host_nic>
<host_nic>
<name>eth1</name>
</host_nic>
</slaves>
</bonding>
</host_nic>
</modified_bonds>
</action>
--Apple-Mail=_E2A5EEF3-9834-4A44-ABBB-E25AFFEA67AD
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=windows-1252
<html><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
-webkit-line-break: after-white-space;" class=3D""><blockquote =
type=3D"cite" class=3D""><br
class=3D""></blockquote><blockquote =
type=3D"cite" class=3D"">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=3D""><br =
class=3D""></blockquote><div class=3D""><br
class=3D""></div>Ok, I =
started to play with the right setupnetworks, and I'm getting strange =
results.<div class=3D""><br class=3D""></div><div
class=3D"">When I try =
to transform an eth0 attachement to a bond attachement, I =
get </div><div class=3D""><br
class=3D""></div><div class=3D""><font =
face=3D"Menlo" class=3D"">Cannot setup Networks. Network Interface
=
'eth0' cannot become slave, there's network 'ovirtmgmt' attached to =
it.</font></div><div class=3D""><br
class=3D""></div><div class=3D"">I =
tried to have a look at the command that the UI send and don't get it. =
It says :</div><div class=3D""><br
class=3D""></div><font face=3D"Menlo" =
class=3D"">networks=3D'[HostNetwork:{defaultRoute=3D'true', =
bonding=3D'true', networkName=3D'ovirtmgmt', nicName=3D'bond0', =
vlan=3D'null', mtu=3D'9000', vmNetwork=3D'true',
stp=3D'false', =
properties=3D'[]', bootProtocol=3D'DHCP',
address=3D'null', =
netmask=3D'null', gateway=3D'null'}]', <br =
class=3D"">removedNetworks=3D'[]', <br =
class=3D"">bonds=3D'[Bond:{id=3D'ffcfe313-7607-4347-b797-aa9c3260e221',
=
name=3D'bond0', vdsId=3D'null', networkName=3D'ovirtmgmt', =
bootProtocol=3D'DHCP', address=3D'null', =
subnet=3D'null', gateway=3D'null', mtu=3D'9000',
bridged=3D'true', =
type=3D'2', networkImplementationDetails=3D'null', qos=3D'null',
=
macAddress=3D'null', bondOptions=3D'mode=3D4 miimon=3D100', =
labels=3D'null', slaves=3D'[eth0,
eth1]'}]', </font><div =
class=3D""><font face=3D"Menlo" =
class=3D"">removedBonds=3D'[Bond:{id=3D'ffcfe313-7607-4347-b797-aa9c3260e2=
21', name=3D'bond0', vdsId=3D'null',
networkName=3D'ovirtmgmt', =
bootProtocol=3D'DHCP', address=3D'null', subnet=3D'null',
=
gateway=3D'null', mtu=3D'9000', bridged=3D'true',
type=3D'2', =
networkImplementationDetails=3D'null', qos=3D'null',
macAddress=3D'null', =
bondOptions=3D'mode=3D4 miimon=3D100', labels=3D'null', =
slaves=3D'[eth0, eth1]'}]'}),<br
class=3D""></font><br class=3D""><div =
class=3D""> 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=3D""><br
class=3D""></div><div =
class=3D"">My code is :</div><div class=3D""><br
class=3D""></div><div =
class=3D""><font face=3D"Menlo"
class=3D"">bond_name =3D =
kwargs['bond_name']<br class=3D"">mtu =3D =
kwargs.pop('mtu', None)<br class=3D"">nics =3D []<br
=
class=3D"">for if_name in kwargs['interfaces']:<br
=
class=3D""> nic =3D params.HostNIC(name=3Dif_name)<br
=
class=3D""> if mtu is
not None:<br =
class=3D""> nic.set_mtu(mtu)<br
=
class=3D""> nics.append(nic)<br
class=3D""><br =
class=3D"">bonding =3D params.Bonding(<br
class=3D""> =
slaves=3Dparams.Slaves(host_nic=3Dnics),<br
class=3D""> =
options=3Dparams.Options(<br class=3D"">
=
option=3Dmap(lambda (x, y): =
params.Option(name=3Dx, value=3Dy), kwargs.pop('bond_options', =
{}).iteritems() )<br class=3D""> )<br
class=3D"">)<br =
class=3D""><br class=3D"">bonded_if =3D =
params.HostNIC(name=3Dbond_name, bonding=3Dbonding)<br
class=3D""><br=
class=3D"">if mtu is not None:<br
class=3D""> =
bonded_if.set_mtu(mtu)<br class=3D""><br
class=3D"">ip =3D =
kwargs.pop('ip', None)<br class=3D"">gateway =3D =
kwargs.pop('gateway', None)<br
class=3D"">if ip is =
not None:<br class=3D""> ip
=3D unicode(ip)<br =
class=3D""> ip_addr =3D =
ipaddress.ip_address(ip.split('/')[0])<br class=3D"">
=
ip_net =3D ipaddress.ip_network(ip, strict=3DFalse)<br =
class=3D""> ip_conf =3D
params.IP(address=3Dstr(ip_addr),<br =
class=3D"">
=
=
netmask=3Dstr(ip_net).split('/')[0])<br
class=3D""> =
if gateway is not None:<br
class=3D""> =
ip_conf.set_gateway(gateway)<br
class=3D""> =
ip_assignment =3D =
params.IpAddressAssignment(assignment_method=3D"static", ip=3Dip_conf=
)<br
class=3D"">elif kwargs.pop('dhcp', False):<br =
class=3D""> ip_assignment =3D =
params.IpAddressAssignment(assignment_method=3D"dhcp", ip=3Dparams.IP=
())<br class=3D""><br class=3D"">bonded_network =3D =
params.NetworkAttachment(network=3Dparams.Network(name=3Dkwargs['network']=
),<br class=3D"">
=
=
host_nic=3Dparams.HostNIC(name=3Dbond_name),<br =
class=3D"">
=
=
=
ip_address_assignments=3Dparams.IpAddressAssignments([ip_assig=
nment]))<br class=3D""><br =
class=3D"">return self.broker.setupnetworks(params.Action(modified_bo=
nds =3D params.HostNics(host_nic =3D [bonded_if]),<br =
class=3D"">
=
=
=
modified_network_attachments =3D =
params.NetworkAttachments(network_attachment=3D[bonded_network]),<br =
class=3D"">
=
=
)<br
class=3D""> =
=
)</font></div><div
class=3D""><font =
face=3D"Menlo" class=3D""><br
class=3D""></font></div><div class=3D"">And =
it generates :</div><div class=3D""><br
class=3D""></div><div =
class=3D""><div style=3D"margin: 0px;"
class=3D""><font face=3D"Menlo" =
class=3D"">> POST =
/api/hosts/db240f83-9266-4892-a6d2-8ac406cadfb1/setupnetworks =
HTTP/1.1</font></div><div class=3D""><div
style=3D"margin: 0px;" =
class=3D""><font face=3D"Menlo" class=3D"">>
=
<action></font></div><div style=3D"margin: 0px;"
class=3D""><font =
face=3D"Menlo" class=3D"">> =
<modified_network_attachments></font></div><div
style=3D"margin: =
0px;" class=3D""><font face=3D"Menlo"
class=3D"">> =
<network_attachment></font></div><div
style=3D"margin:=
0px;" class=3D""><font face=3D"Menlo"
class=3D"">> =
<network></font></div><div =
style=3D"margin: 0px;" class=3D""><font face=3D"Menlo"
class=3D"">> =
=
<name>ovirtmgmt</name></font></div><div
style=3D"margin: =
0px;" class=3D""><font face=3D"Menlo"
class=3D"">> =
</network></font></div><div =
style=3D"margin: 0px;" class=3D""><font face=3D"Menlo"
class=3D"">> =
=
<host_nic></font></div><div style=3D"margin: 0px;"
class=3D""><font =
face=3D"Menlo" class=3D"">>
=
<name>bond0</name></font></div><div =
style=3D"margin: 0px;" class=3D""><font face=3D"Menlo"
class=3D"">> =
=
</host_nic></font></div><div style=3D"margin: 0px;"
class=3D""><font=
face=3D"Menlo" class=3D"">>
=
<ip_address_assignments></font></div><div
style=3D"margin: =
0px;" class=3D""><font face=3D"Menlo"
class=3D"">> =
=
<ip_address_assignment></font></div><div
style=3D"margin: 0px;" =
class=3D""><font face=3D"Menlo" class=3D"">>
=
=
<ip/></font></div><div style=3D"margin: 0px;"
class=3D""><font =
face=3D"Menlo" class=3D"">>
=
=
<assignment_method>dhcp</assignment_method></font></div><div
=
style=3D"margin: 0px;" class=3D""><font face=3D"Menlo"
class=3D"">> =
=
</ip_address_assignment></font></div><div
style=3D"margin: 0px;" =
class=3D""><font face=3D"Menlo" class=3D"">>
=
</ip_address_assignments></font></div><div =
style=3D"margin: 0px;" class=3D""><font face=3D"Menlo"
class=3D"">> =
</network_attachment></font></div><div =
style=3D"margin: 0px;" class=3D""><font face=3D"Menlo"
class=3D"">> =
</modified_network_attachments></font></div><div =
style=3D"margin: 0px;" class=3D""><font face=3D"Menlo"
class=3D"">> =
<modified_bonds></font></div><div
style=3D"margin: =
0px;" class=3D""><font face=3D"Menlo"
class=3D"">> =
<host_nic></font></div><div
style=3D"margin: 0px;" =
class=3D""><font face=3D"Menlo" class=3D"">>
=
<name>bond0</name></font></div><div =
style=3D"margin: 0px;" class=3D""><font face=3D"Menlo"
class=3D"">> =
=
<bonding></font></div><div style=3D"margin: 0px;"
class=3D""><font =
face=3D"Menlo" class=3D"">>
=
<options></font></div><div
style=3D"margin: 0px;" =
class=3D""><font face=3D"Menlo" class=3D"">>
=
<option =
name=3D"miimon" value=3D"100"/></font></div><div
style=3D"margin: =
0px;" class=3D""><font face=3D"Menlo"
class=3D"">> =
<option =
name=3D"mode" value=3D"4"/></font></div><div
style=3D"margin: 0px;" =
class=3D""><font face=3D"Menlo" class=3D"">>
=
<option =
name=3D"xmit_hash_policy"
value=3D"2+3"/></font></div><div =
style=3D"margin: 0px;" class=3D""><font face=3D"Menlo"
class=3D"">> =
=
</options></font></div><div style=3D"margin: 0px;"
class=3D""><font =
face=3D"Menlo" class=3D"">>
=
<slaves></font></div><div
style=3D"margin: 0px;" =
class=3D""><font face=3D"Menlo" class=3D"">>
=
=
<host_nic></font></div><div style=3D"margin: 0px;"
class=3D""><font =
face=3D"Menlo" class=3D"">>
=
=
<name>eth0</name></font></div><div
style=3D"margin: 0px;" =
class=3D""><font face=3D"Menlo" class=3D"">>
=
=
</host_nic></font></div><div style=3D"margin: 0px;"
class=3D""><font=
face=3D"Menlo" class=3D"">>
=
<host_nic></font></div><div =
style=3D"margin: 0px;" class=3D""><font face=3D"Menlo"
class=3D"">> =
=
<name>eth1</name></font></div><div =
style=3D"margin: 0px;" class=3D""><font face=3D"Menlo"
class=3D"">> =
=
</host_nic></font></div><div style=3D"margin: 0px;"
class=3D""><font=
face=3D"Menlo" class=3D"">>
=
</slaves></font></div><div
style=3D"margin: =
0px;" class=3D""><font face=3D"Menlo"
class=3D"">> =
</bonding></font></div><div =
style=3D"margin: 0px;" class=3D""><font face=3D"Menlo"
class=3D"">> =
</host_nic></font></div><div =
style=3D"margin: 0px;" class=3D""><font face=3D"Menlo"
class=3D"">> =
</modified_bonds></font></div><div
style=3D"margin: =
0px;" class=3D""><font face=3D"Menlo"
class=3D"">> =
</action></font></div></div><div
class=3D""><font face=3D"Menlo" =
class=3D""><br class=3D""></font></div><br =
class=3D""></div></div></body></html>=
--Apple-Mail=_E2A5EEF3-9834-4A44-ABBB-E25AFFEA67AD--