[ovirt-users] OVirt SDK python ip problem

rein ovirt-user at dvrhss.nl
Fri Mar 4 12:02:48 UTC 2016


Hi All,

I have an issue with the python ovirt sdk.
I made a script that creates a new host, hypervisor, in the ovirt environment.
The host is created and is put in maintenance state.
So far it works, but then i try to create the networks on the new host and there i got an error.
>  
> Creating the host:
>  
>     try:
>         if api.hosts.add(pHst):
>             print("Host was added successfully")
>             print("Waiting for host, {}, to reach the 'up' or 'non operational' status").format(host)
>             while api.hosts.get(name = host).status.state != 'up' and api.hosts.get(name = host).status.state != 'non_operational':
>                 sleep(1)
>             sleep(5)
>             print("Host, {}, is '{}'").format(host)
>  
>     except Exception as e:
>         print("Failed to install Host: {}").format(str(e))
>         return None
>  
>     Host = api.hosts.get(name = host)
>  
>     Host.deactivate()
>     sleep(5)
>     address, netmask = getDefaultAddress(api, oc, DC, host)
>     if address is not None:

> So far all's well.
> Then the part for the network...
>  
>         rc = setBondAndDefVLan(api, oc, DC, cluster, host, address, netmask)
>         if rc is not None:
>             Host.update()
>             Host.activate()
>  
> ---
>  
> def setBondParams(api, oc, DC, host):
>     nic0 = params.HostNIC(name          = oc.nic1,
>                           network       = params.Network(),
>                           boot_protocol = 'none',
>                           ip            = params.IP(
>                                                     address = '',
>                                                     netmask = '',
>                                                     gateway = '',
>                                                    ),
>                          )
>     nic1 = params.HostNIC(name          = oc.nic2,
>                           network       = params.Network(),
>                           boot_protocol = 'none',
>                           ip            = params.IP(
>                                                     address = '',
>                                                     netmask = '',
>                                                     gateway = '',
>                                                    ),
>                          )
>     
>     bond = params.Bonding(slaves  = params.Slaves(host_nic = [
>                                                               nic0,
>                                                               nic1,
>                                                              ]),
>                           options = params.Options(option = [
>                                                              params.Option(name  = 'miimon',
>                                                                            value = '100'),
>                                                              params.Option(name  = 'mode',
>                                                                            value = '4'),
>                                                             ])
>                          )
>  
>     team = params.HostNIC(name                   = 'bond0',
>                           boot_protocol          = 'none',
>                           ip                     = params.IP(
>                                                              address = '',
>                                                              netmask = '',
>                                                              gateway = '',
>                                                             ),
>                           override_configuration = 1,
>                           bonding                = bond)
>     return team
>  
>  
> def setDefVLanParams(api, oc, DC, cluster, host, address, netmask):
>     defvlan = oc.defaultvlan
>     clusterNW = api.clusters.get(cluster).networks.get(name = defvlan)
>     vlan = params.HostNIC(name                   = "bond0.{}".format(clusterNW.vlan.id),
>                           network                = params.Network(name = defvlan),
>                           boot_protocol          = 'none',
>                           ip                     = params.IP(
>                                                              address = address,
>                                                              netmask = netmask,
>                                                              gateway = ''
>                                                             ),
>                           override_configuration = 1,
>                          )
>     return vlan
>  
>  
> def setBondAndDefVLan(api, oc, DC, cluster, host, address, netmask):
>     try:
>         Host = api.hosts.get(name = host)
>     except Exception as e:
>         print("Could not find host {}, this is extremly wrong!\n{}").format(host, str(e))
>         return None
>  
>     team = setBondParams(api, oc, DC, Host)
>     vlan = setDefVLan(api, oc, DC, cluster, Host, address, netmask)
>  
>     try:
>         Host.nics.setupnetworks(params.Action(force = 0,
>                                               check_connectivity = 0,
>                                               host_nics = params.HostNics(host_nic = [
>                                                                                       team, 
>                                                                                       vlan,
>                                                                                      ])
>                                              ),
>                                )
>     except Exception as e:
>         print("Could not setup a management interface for host {}.\n--\n{}\n--").format(host, str(e))
>         return None
>  
>     return host
>  
>  
> The setting for oc.nic1 is 'eno1' and oc.nic2 is 'eno2'.
> This part of the script times out on "Host.nics.setupnetworks(...) with:
>  
> "Host was added successfully"
> "Waiting for host, X, to reach the 'up' or 'non operational' status"
> "Host, X, is 'non_operational'"
>  
> "Could not setup a management interface for host X."
> "--"
>  
> "status: 400"
> "reason: Bad Request"
> "detail: Network error during communication with the Host."
> "--"
>  
> The problem with the communication is that on the new host X all the ip configuration is gone.
> The question i have is "Why is the ip configuration gone?"
> What am i donig wrong here?

> ->Rein.

(vanaf BigI)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/users/attachments/20160304/e227b22b/attachment-0001.html>


More information about the Users mailing list