def _wait_for_vhd_coalesce(session, instance, sr_ref, vdi_ref, vdi_uuid_list):
 if (len(vdi_uuid_list) == 1):
  LOG.debug('Old chain is single VHD, coalesce not possible.', instance=instance)
  return
 parent_vdi_uuid = vdi_uuid_list[1]
 if (_count_children(session, parent_vdi_uuid, sr_ref) > 1):
  LOG.debug('Parent has other children, coalesce is unlikely.', instance=instance)
  return
 max_attempts = CONF.xenserver.vhd_coalesce_max_attempts
 good_parent_uuids = vdi_uuid_list[1:]
 for i in range(max_attempts):
  _scan_sr(session, sr_ref)
  parent_uuid = _get_vhd_parent_uuid(session, vdi_ref)
  if (parent_uuid and (parent_uuid not in good_parent_uuids)):
   LOG.debug('Parent %(parent_uuid)s not yet in parent list %(good_parent_uuids)s, waiting for coalesce...', {'parent_uuid': parent_uuid, 'good_parent_uuids': good_parent_uuids}, instance=instance)
  else:
   LOG.debug('Coalesce detected, because parent is: %s', parent_uuid, instance=instance)
   return
  greenthread.sleep(CONF.xenserver.vhd_coalesce_poll_interval)
 msg = (_('VHD coalesce attempts exceeded (%d), giving up...') % max_attempts)
 raise exception.NovaException(msg)

def _wait_for_vhd_coalesce ( session , instance , sr_ref , vdi_ref , vdi_uuid_list ) : if ( len ( vdi_uuid_list ) == 1 ) : LOG . debug ( 'Old chain is single VHD, coalesce not possible.' , instance = instance ) return parent_vdi_uuid = vdi_uuid_list [ 1 ] if ( _count_children ( session , parent_vdi_uuid , sr_ref ) > 1 ) : LOG . debug ( 'Parent has other children, coalesce is unlikely.' , instance = instance ) return max_attempts = CONF . xenserver . vhd_coalesce_max_attempts good_parent_uuids = vdi_uuid_list [ 1 : ] for i in range ( max_attempts ) : _scan_sr ( session , sr_ref ) parent_uuid = _get_vhd_parent_uuid ( session , vdi_ref ) if ( parent_uuid and ( parent_uuid not in good_parent_uuids ) ) : LOG . debug ( 'Parent %(parent_uuid)s not yet in parent list %(good_parent_uuids)s, waiting for coalesce...' , { 'parent_uuid' : parent_uuid , 'good_parent_uuids' : good_parent_uuids } , instance = instance ) else : LOG . debug ( 'Coalesce detected, because parent is: %s' , parent_uuid , instance = instance ) return greenthread . sleep ( CONF . xenserver . vhd_coalesce_poll_interval ) msg = ( _ ( 'VHD coalesce attempts exceeded (%d), giving up...' ) % max_attempts ) raise exception . NovaException ( msg )
spin until the parent vhd is coalesced into one of the vdis in the list vdi_uuid_list is a list of acceptable final parent vdis for vdi_ref; once the parent of vdi_ref is in vdi_uuid_chain we consider the coalesce over .