Revision c1c235ea

b/lib/ovf.py
328 328
      schema fragment removed or empty dictionary, when root is None
329 329

  
330 330
    """
331
    if not root:
331
    if root is None:
332 332
      return {}
333 333
    results = {}
334 334
    for element in list(root):
......
398 398
    hypervisor_search = ("{%s}GanetiSection/{%s}Hypervisor" %
399 399
                         (GANETI_SCHEMA, GANETI_SCHEMA))
400 400
    hypervisor_data = self.tree.find(hypervisor_search)
401
    if not hypervisor_data:
401
    if hypervisor_data is None:
402 402
      return {"hypervisor_name": constants.VALUE_AUTO}
403 403
    results = {
404 404
      "hypervisor_name": hypervisor_data.findtext("{%s}Name" % GANETI_SCHEMA,
......
419 419
    os_search = ("{%s}GanetiSection/{%s}OperatingSystem" %
420 420
                 (GANETI_SCHEMA, GANETI_SCHEMA))
421 421
    os_data = self.tree.find(os_search)
422
    if os_data:
422
    if os_data is not None:
423 423
      results["os_name"] = os_data.findtext("{%s}Name" % GANETI_SCHEMA)
424 424
      parameters = os_data.find("{%s}Parameters" % GANETI_SCHEMA)
425 425
      results.update(self._GetDictParameters(parameters, GANETI_SCHEMA))
......
439 439
                   (OVF_SCHEMA, OVF_SCHEMA, OVF_SCHEMA))
440 440
    match_vcpus = ("{%s}ResourceType" % RASD_SCHEMA, RASD_TYPE["vcpus"])
441 441
    vcpus = self._GetElementMatchingText(find_vcpus, match_vcpus)
442
    if vcpus:
442
    if vcpus is not None:
443 443
      vcpus_count = vcpus.findtext("{%s}VirtualQuantity" % RASD_SCHEMA,
444 444
                                   default=constants.VALUE_AUTO)
445 445
    else:
......
450 450
    match_memory = ("{%s}ResourceType" % RASD_SCHEMA, RASD_TYPE["memory"])
451 451
    memory = self._GetElementMatchingText(find_memory, match_memory)
452 452
    memory_raw = None
453
    if memory:
453
    if memory is not None:
454 454
      alloc_units = memory.findtext("{%s}AllocationUnits" % RASD_SCHEMA)
455 455
      matching_units = [units for units, variants in ALLOCATION_UNITS.items()
456 456
                        if alloc_units.lower() in variants]
......
528 528
                                                         ganeti_match)
529 529

  
530 530
      ganeti_data = {}
531
      if network_ganeti_data:
531
      if network_ganeti_data is not None:
532 532
        ganeti_data["mode"] = network_ganeti_data.findtext("{%s}Mode" %
533 533
                                                           GANETI_SCHEMA)
534 534
        ganeti_data["mac"] = network_ganeti_data.findtext("{%s}MACAddress" %
......
540 540
        ganeti_data["network"] = network_ganeti_data.findtext("{%s}Net" %
541 541
                                                              GANETI_SCHEMA)
542 542
      mac_data = None
543
      if network_data:
543
      if network_data is not None:
544 544
        mac_data = network_data.findtext("{%s}Address" % RASD_SCHEMA)
545 545

  
546 546
      network_name = network_name.lower()

Also available in: Unified diff