5 from api import ApiResource
6 from yardstick.common.utils import result_handler
7 from yardstick.common.utils import source_env
8 from yardstick.common import constants as consts
10 LOG = logging.getLogger(__name__)
11 LOG.setLevel(logging.DEBUG)
14 class V2Images(ApiResource):
17 return self._dispatch_post()
19 def load_image(self, args):
20 thread = threading.Thread(target=self._load_images)
22 return result_handler(consts.API_SUCCESS, {})
24 def _load_images(self):
25 LOG.info('source openrc')
26 source_env(consts.OPENRC)
28 LOG.info('clean images')
29 cmd = [consts.CLEAN_IMAGES_SCRIPT]
30 p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
32 _, err = p.communicate()
34 LOG.error('clean image failed: %s', err)
36 LOG.info('load images')
37 cmd = [consts.LOAD_IMAGES_SCRIPT]
38 p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
40 _, err = p.communicate()
42 LOG.error('load image failed: %s', err)