components/openstack/nova/files/solariszones/driver.py
changeset 7652 8ea2de474b66
parent 7593 3f5b9ebe028b
child 7799 e35d3ee6d1b8
equal deleted inserted replaced
7651:70c0daa6928d 7652:8ea2de474b66
  1149         downloading = image + '.downloading'
  1149         downloading = image + '.downloading'
  1150 
  1150 
  1151         with lockutils.lock('glance-image-%s' % iref):
  1151         with lockutils.lock('glance-image-%s' % iref):
  1152             if os.path.isfile(downloading):
  1152             if os.path.isfile(downloading):
  1153                 LOG.debug(_('Cleaning partial download of %s' % iref))
  1153                 LOG.debug(_('Cleaning partial download of %s' % iref))
  1154                 os.unlink(image)
       
  1155                 os.unlink(downloading)
  1154                 os.unlink(downloading)
  1156 
  1155 
  1157             elif os.path.exists(image):
  1156             elif os.path.exists(image):
  1158                 LOG.debug(_("Using existing, cached Glance image: id %s")
  1157                 LOG.debug(_("Using existing, cached Glance image: id %s")
  1159                           % iref)
  1158                           % iref)
  1160                 return image
  1159                 return image
  1161 
  1160 
  1162             LOG.debug(_("Fetching new Glance image: id %s") % iref)
  1161             LOG.debug(_("Fetching new Glance image: id %s") % iref)
  1163             try:
  1162             try:
  1164                 # touch the empty .downloading file
  1163                 images.fetch(context, iref, downloading, instance['user_id'],
  1165                 with open(downloading, 'w'):
       
  1166                     pass
       
  1167                 images.fetch(context, iref, image, instance['user_id'],
       
  1168                              instance['project_id'])
  1164                              instance['project_id'])
  1169                 os.unlink(downloading)
  1165                 os.rename(downloading, image)
  1170                 return image
  1166                 return image
  1171             except Exception as reason:
  1167             except Exception as reason:
  1172                 LOG.exception(_("Unable to fetch Glance image: id %s: %s")
  1168                 LOG.exception(_("Unable to fetch Glance image: id %s: %s")
  1173                               % (iref, reason))
  1169                               % (iref, reason))
  1174                 raise
  1170                 raise