Re: [ovirt-users] configuring bonding on host

2016-05-10 Thread Fabrice Bacchella

> Le 10 mai 2016 à 09:55, Alona Kaplan  a écrit :
> 
> 
> 
> You should modify the already existing network_attachment.
> Here, since you don't pass the existing attachment 'id', we're trying to 
> create a new attachment.
> Since you didn't remove the old one, we get two attachments for the same 
> network. The old one is still attached to 'eth0', that's why you get the 
> error.
> 
> You have to specify the attachment 'id' on the attachment you're updating and 
> it should work.

That's quite logical. Thank you.
___
Users mailing list
Users@ovirt.org
http://lists.ovirt.org/mailman/listinfo/users


Re: [ovirt-users] configuring bonding on host

2016-05-10 Thread Alona Kaplan


- Original Message -
> From: "Fabrice Bacchella" <fabrice.bacche...@orange.fr>
> To: "Juan Hernández" <jhern...@redhat.com>
> Cc: "users" <users@ovirt.org>
> Sent: Monday, May 9, 2016 1:46:22 PM
> Subject: Re: [ovirt-users] configuring bonding on host
> 
> 
> 
> 
> 
> 
> 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
> > 
> > 
> > 

You should modify the already existing network_attachment.
Here, since you don't pass the existing attachment 'id', we're trying to create 
a new attachment.
Since you didn't remove the old one, we get two attachments for the same 
network. The old one is still attached to 'eth0', that's why you get the error.

You have to specify the attachment 'id' on the attachment you're updating and 
it should work.

> > 
> > ovirtmgmt
> > 
> > 
> > bond0
> > 
> > 
> > 
> > 
> > dhcp
> > 
> > 
> > 
> > 
> > 
> > 
> > bond0
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > eth0
> > 
> > 
> > eth1
> > 
> > 
> > 
> > 
> > 
> > 
> 
> 
> 
> ___
> Users mailing list
> Users@ovirt.org
> http://lists.ovirt.org/mailman/listinfo/users
> 
___
Users mailing list
Users@ovirt.org
http://lists.ovirt.org/mailman/listinfo/users


Re: [ovirt-users] configuring bonding on host

2016-05-09 Thread Fabrice Bacchella
> 
> 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
> 
> 
> 
> 
> ovirtmgmt
> 
> 
> bond0
> 
> 
> 
> 
> dhcp
> 
> 
> 
> 
> 
> 
> bond0
> 
> 
> 
> 
> 
> 
> 
> 
> eth0
> 
> 
> eth1
> 
> 
> 
> 
> 
> 


___
Users mailing list
Users@ovirt.org
http://lists.ovirt.org/mailman/listinfo/users


Re: [ovirt-users] configuring bonding on host

2016-05-09 Thread Fabrice Bacchella

> Le 7 mai 2016 à 22:49, Fabrice Bacchella  a 
> écrit :
> 
> 
>> Le 7 mai 2016 à 18:18, Juan Hernández  a écrit :
>> 
>> On 05/06/2016 05:20 PM, Fabrice Bacchella wrote:
>>> I'm following the example given
>>> in http://www.ovirt.org/develop/api/pythonapi/ for bonding interfaces.
>>> 
> 
>>> What am I missing ?
>>> 
>> 
>> The example that you mention describes the old and deprecated
>> /hosts/{host:id}/nics/setupnetworks action, but you are sending the
>> request to /hosts/{host:id}/setupnetworks, which just ignores the
>> "host_nics" elements that you are sending. There is an example of how to
>> use the newer action here:
>> 
>> 
>> https://jhernand.fedorapeople.org/ovirt-api-explorer/#/services/host/methods/setup-networks
> 
> Ok.I got it.
> 
> The samples says:  host.nics.setupnetworks(...)
> And my code says:  host.setupnetworks(...)
> 
> But why does it silently ignore it ? Shouldn't it throw me an error ?

Very funny, now that my call to /hosts/{host:id}/setupnetworks is better (using 
modified_...), I'm getting an error message. So a totally wrong call throws 
nothing and an almost wrong message return some thing. That is not really 
consistent.
___
Users mailing list
Users@ovirt.org
http://lists.ovirt.org/mailman/listinfo/users


Re: [ovirt-users] configuring bonding on host

2016-05-07 Thread Fabrice Bacchella

> Le 7 mai 2016 à 18:18, Juan Hernández  a écrit :
> 
> On 05/06/2016 05:20 PM, Fabrice Bacchella wrote:
>> I'm following the example given
>> in http://www.ovirt.org/develop/api/pythonapi/ for bonding interfaces.
>> 

>> What am I missing ?
>> 
> 
> The example that you mention describes the old and deprecated
> /hosts/{host:id}/nics/setupnetworks action, but you are sending the
> request to /hosts/{host:id}/setupnetworks, which just ignores the
> "host_nics" elements that you are sending. There is an example of how to
> use the newer action here:
> 
> 
> https://jhernand.fedorapeople.org/ovirt-api-explorer/#/services/host/methods/setup-networks

Ok.I got it.

The samples says:  host.nics.setupnetworks(...)
And my code says:  host.setupnetworks(...)

But why does it silently ignore it ? Shouldn't it throw me an error ?

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.

___
Users mailing list
Users@ovirt.org
http://lists.ovirt.org/mailman/listinfo/users


Re: [ovirt-users] configuring bonding on host

2016-05-07 Thread Juan Hernández
On 05/06/2016 05:20 PM, Fabrice Bacchella wrote:
> I'm following the example given
> in http://www.ovirt.org/develop/api/pythonapi/ for bonding interfaces.
> 
> I'm checking that the network is a plain configuration,
> exporting /api/hosts//nics return :
> 
>  href="/api/hosts/db240f83-9266-4892-a6d2-8ac406cadfb1/nics/958c40cd-9ddb-4548-8bd8-79f454021c35"
> id="958c40cd-9ddb-4548-8bd8-79f454021c35">
> 
>  href="/api/hosts/db240f83-9266-4892-a6d2-8ac406cadfb1/nics/958c40cd-9ddb-4548-8bd8-79f454021c35/attach"
> rel="attach"/>
>  href="/api/hosts/db240f83-9266-4892-a6d2-8ac406cadfb1/nics/958c40cd-9ddb-4548-8bd8-79f454021c35/detach"
> rel="detach"/>
> 
> eth1
>  href="/api/hosts/db240f83-9266-4892-a6d2-8ac406cadfb1/nics/958c40cd-9ddb-4548-8bd8-79f454021c35/statistics"
> rel="statistics"/>
>  href="/api/hosts/db240f83-9266-4892-a6d2-8ac406cadfb1/nics/958c40cd-9ddb-4548-8bd8-79f454021c35/labels"
> rel="labels"/>
>  href="/api/hosts/db240f83-9266-4892-a6d2-8ac406cadfb1/nics/958c40cd-9ddb-4548-8bd8-79f454021c35/networkattachments"
> rel="networkattachments"/>
>  id="db240f83-9266-4892-a6d2-8ac406cadfb1"/>
> 
> 
> none
> 
> down
> 
> 1500
> false
> 
> 
>  href="/api/hosts/db240f83-9266-4892-a6d2-8ac406cadfb1/nics/87a274e8-9633-45df-9205-1d188bd3ee4c"
> id="87a274e8-9633-45df-9205-1d188bd3ee4c">
> 
>  href="/api/hosts/db240f83-9266-4892-a6d2-8ac406cadfb1/nics/87a274e8-9633-45df-9205-1d188bd3ee4c/attach"
> rel="attach"/>
>  href="/api/hosts/db240f83-9266-4892-a6d2-8ac406cadfb1/nics/87a274e8-9633-45df-9205-1d188bd3ee4c/detach"
> rel="detach"/>
> 
> eth0
>  href="/api/hosts/db240f83-9266-4892-a6d2-8ac406cadfb1/nics/87a274e8-9633-45df-9205-1d188bd3ee4c/statistics"
> rel="statistics"/>
>  href="/api/hosts/db240f83-9266-4892-a6d2-8ac406cadfb1/nics/87a274e8-9633-45df-9205-1d188bd3ee4c/labels"
> rel="labels"/>
>  href="/api/hosts/db240f83-9266-4892-a6d2-8ac406cadfb1/nics/87a274e8-9633-45df-9205-1d188bd3ee4c/networkattachments"
> rel="networkattachments"/>
>  id="db240f83-9266-4892-a6d2-8ac406cadfb1"/>
>  id="f429c46c-fed4-4c88-a000-36c021f5d633"/>
> 
>  address="10.83.17.24"/>
> dhcp
> 100
> 
> up
> 
> 9000
> true
> false
> 
> 
> 
> I send my configuration and get :
> 
>> POST /api/hosts/db240f83-9266-4892-a6d2-8ac406cadfb1/setupnetworks
> HTTP/1.1
> ...
>> my configuration
> 
> < HTTP/1.1 200 OK
> 
> < 
> < 
> < 
> < 
> < bond0
> < 
> < ovirtmgmt
> < 
> <  gateway="10.83.31.254"/>
> < 
> < 
> < 
> < 
> < 
> < 
> < 
> < 
> < eth0
> < 
> < 
> < none
> < 9000
> < 
> < 
> < eth1
> < 
> < 
> < none
> < 9000
> < 
> < 
> < 
> < static
> < 9000
> < true
> < 
> < 
> < true
> < false
> <  id="859bc27c-2060-4349-a0f5-dc1dd6333e6c"/>
> < 
> < complete
> < 
> < 
> 
> 
> So every thing is fine, I applied my configuration.
> 
> But in the log, I get :
> 2016-05-06 17:13:22,481 INFO
>  [org.ovirt.engine.core.bll.network.host.HostSetupNetworksCommand]
> (default task-20) [30e54e04] Lock Acquired to object
> 'EngineLock:{exclusiveLocks='[db240f83-9266-4892-a6d2-8ac406cadfb1=  ACTION_TYPE_FAILED_SETUP_NETWORKS_IN_PROGRESS>]',
> sharedLocks='null'}'
> 2016-05-06 17:13:22,555
> INFO  [org.ovirt.engine.core.bll.network.host.HostSetupNetworksCommand]
> (default task-20) [30e54e04] Running command: HostSetupNetworksCommand
> internal: false. Entities affected :  ID:
> db240f83-9266-4892-a6d2-8ac406cadfb1 Type: VDSAction group
> CONFIGURE_HOST_NETWORK with role type ADMIN
> 2016-05-06 17:13:22,555
> INFO  [org.ovirt.engine.core.bll.network.host.HostSetupNetworksCommand]
> (default task-20) [30e54e04] No changes were detected in setup networks
> for host 'nb0101' (ID: 'db240f83-9266-4892-a6d2-8ac406cadfb1')
> 2016-05-06 17:13:22,563
> INFO  [org.ovirt.engine.core.bll.network.host.HostSetupNetworksCommand]
> (default task-20) [30e54e04] Lock freed to object
> 'EngineLock:{exclusiveLocks='[db240f83-9266-4892-a6d2-8ac406cadfb1=  ACTION_TYPE_FAILED_SETUP_NETWORKS_IN_PROGRESS>]',
> sharedLocks='null'}'
> 
> And indeed my configuration is not changed.
> 
> What am I missing ?
> 

The example that you mention describes the old and deprecated
/hosts/{host:id}/nics/setupnetworks action, but you are sending the
request to