def _auto_configure_disk(session, vdi_ref, new_gb):
 if (new_gb == 0):
  LOG.debug('Skipping auto_config_disk as destination size is 0GB')
  return
 with vdi_attached(session, vdi_ref, read_only=False) as dev:
  partitions = _get_partitions(dev)
  if (len(partitions) != 1):
   reason = _('Disk must have only one partition.')
   raise exception.CannotResizeDisk(reason=reason)
  (num, start, old_sectors, fstype, name, flags) = partitions[0]
  if (fstype not in ('ext3', 'ext4')):
   reason = _('Disk contains a filesystem we are unable to resize: %s')
   raise exception.CannotResizeDisk(reason=(reason % fstype))
  if (num != 1):
   reason = _('The only partition should be partition 1.')
   raise exception.CannotResizeDisk(reason=reason)
  new_sectors = ((new_gb * units.Gi) / SECTOR_SIZE)
  _resize_part_and_fs(dev, start, old_sectors, new_sectors, flags)

def _auto_configure_disk ( session , vdi_ref , new_gb ) : if ( new_gb == 0 ) : LOG . debug ( 'Skipping auto_config_disk as destination size is 0GB' ) return with vdi_attached ( session , vdi_ref , read_only = False ) as dev : partitions = _get_partitions ( dev ) if ( len ( partitions ) != 1 ) : reason = _ ( 'Disk must have only one partition.' ) raise exception . CannotResizeDisk ( reason = reason ) ( num , start , old_sectors , fstype , name , flags ) = partitions [ 0 ] if ( fstype not in ( 'ext3' , 'ext4' ) ) : reason = _ ( 'Disk contains a filesystem we are unable to resize: %s' ) raise exception . CannotResizeDisk ( reason = ( reason % fstype ) ) if ( num != 1 ) : reason = _ ( 'The only partition should be partition 1.' ) raise exception . CannotResizeDisk ( reason = reason ) new_sectors = ( ( new_gb * units . Gi ) / SECTOR_SIZE ) _resize_part_and_fs ( dev , start , old_sectors , new_sectors , flags )
partition and resize fs to match the size specified by flavors .