[ovirt-users] configuring bonding on host
Fabrice Bacchella
fabrice.bacchella at orange.fr
Mon May 9 06:46:22 EDT 2016
>
> 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.
>
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
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='[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'}]',
removedNetworks='[]',
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]'}]',
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]'}]'}),
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 = kwargs['bond_name']
mtu = kwargs.pop('mtu', None)
nics = []
for if_name in kwargs['interfaces']:
nic = params.HostNIC(name=if_name)
if mtu is not None:
nic.set_mtu(mtu)
nics.append(nic)
bonding = params.Bonding(
slaves=params.Slaves(host_nic=nics),
options=params.Options(
option=map(lambda (x, y): params.Option(name=x, value=y), kwargs.pop('bond_options', {}).iteritems() )
)
)
bonded_if = params.HostNIC(name=bond_name, bonding=bonding)
if mtu is not None:
bonded_if.set_mtu(mtu)
ip = kwargs.pop('ip', None)
gateway = kwargs.pop('gateway', None)
if ip is not None:
ip = unicode(ip)
ip_addr = ipaddress.ip_address(ip.split('/')[0])
ip_net = ipaddress.ip_network(ip, strict=False)
ip_conf = params.IP(address=str(ip_addr),
netmask=str(ip_net).split('/')[0])
if gateway is not None:
ip_conf.set_gateway(gateway)
ip_assignment = params.IpAddressAssignment(assignment_method="static", ip=ip_conf)
elif kwargs.pop('dhcp', False):
ip_assignment = params.IpAddressAssignment(assignment_method="dhcp", ip=params.IP())
bonded_network = params.NetworkAttachment(network=params.Network(name=kwargs['network']),
host_nic=params.HostNIC(name=bond_name),
ip_address_assignments=params.IpAddressAssignments([ip_assignment]))
return self.broker.setupnetworks(params.Action(modified_bonds = params.HostNics(host_nic = [bonded_if]),
modified_network_attachments = params.NetworkAttachments(network_attachment=[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="miimon" value="100"/>
> <option name="mode" value="4"/>
> <option name="xmit_hash_policy" value="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>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/users/attachments/20160509/85a82ccb/attachment-0001.html>
More information about the Users
mailing list