diff --git a/ironic/common/glance_service/base_image_service.py b/ironic/common/glance_service/base_image_service.py index 526a9150c8..a6eea191d9 100644 --- a/ironic/common/glance_service/base_image_service.py +++ b/ironic/common/glance_service/base_image_service.py @@ -17,10 +17,12 @@ import functools import logging -import shutil +import os import sys import time +import sendfile + from glanceclient import client import six.moves.urllib.parse as urlparse @@ -209,14 +211,8 @@ class BaseImageService(object): url = urlparse.urlparse(location) if url.scheme == "file": with open(url.path, "r") as f: - #TODO(ghe): Use system call for downloading files. - # Bug #1199522 - - # FIXME(jbresnah) a system call to cp could have - # significant performance advantages, however we - # do not have the path to files at this point in - # the abstraction. - shutil.copyfileobj(f, data) + filesize = os.path.getsize(f.name) + sendfile.sendfile(data.fileno(), f.fileno(), 0, filesize) return image_chunks = self.call(method, image_id) diff --git a/requirements.txt b/requirements.txt index defa1608c7..dbbc5de337 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,6 +18,7 @@ python-neutronclient>=2.3.4,<3 python-glanceclient>=0.9.0 python-keystoneclient>=0.8.0 stevedore>=0.14 +pysendfile==2.0.0 websockify>=0.5.1,<0.6 oslo.config>=1.2.0 oslo.rootwrap