def get_image(img_id): img = images.provider(settings.settings()) loc = img.get(img_id) if loc is None: abort(404) with open(loc, 'r') as fd: return fd.read()
def get_volume_from_image(self, image, prefix='', resize=''): img = images.provider(settings.settings()) vol = images.volume_provider(settings.settings()) try: src_img = img.get(image) return vol.copyFrom(src_img, prefix=prefix, resize=resize) except Exception as e: print ('ERROR: %s' % (e)) return ''
def image_id(img_id): img = images.provider(settings.settings()) loc = img.get(img_id) if loc is None: abort(404) res = { 'image': img_id, 'location': loc, 'uri': url_for('get_image', img_id=img_id, _external=True), } if loc.lower().endswith('.img'): res['type'] = 'img' elif loc.lower().endswith('.iso'): res['type'] = 'iso' elif loc.lower().endswith('.ext2'): res['type'] = 'ext2' return jsonify(res)
def image(): img = images.provider(settings.settings()) return jsonify({'images': img.list()})
def get_cdrom_image(self, image): img = images.provider(settings.settings()) try: return img.get(image) except: return ''