summaryrefslogtreecommitdiffstats
path: root/utils/env_prepare
diff options
context:
space:
mode:
authorliyin <liyin11@huawei.com>2018-03-07 03:47:28 +0000
committerAce Lee <liyin11@huawei.com>2018-03-12 02:21:54 +0000
commitadf6a02bae295455f584ebab762592dd57e2422c (patch)
tree04c01b98d18eed356e4adf542bbcde53b00cafde /utils/env_prepare
parent06db2e37272bb3a030c2b5f2e255ec6a61f17472 (diff)
bottlenecks offiline support
JIRA: BOTTLENECK-224 This patch for bottlenecks support offiline. By use some offiline image rather than yardstick env prepare. This will solve some problem happened in yardstick image builder. Change-Id: I62b6606570c2ea6ce365212c79777af01c47c9a6 Signed-off-by: liyin <liyin11@huawei.com>
Diffstat (limited to 'utils/env_prepare')
-rw-r--r--utils/env_prepare/stack_prepare.py38
1 files changed, 28 insertions, 10 deletions
diff --git a/utils/env_prepare/stack_prepare.py b/utils/env_prepare/stack_prepare.py
index 640afa13..98308849 100644
--- a/utils/env_prepare/stack_prepare.py
+++ b/utils/env_prepare/stack_prepare.py
@@ -14,6 +14,7 @@ from utils.logger import Logger
from utils.parser import Parser as config
import utils.infra_setup.heat.manager as utils
import utils.infra_setup.runner.docker_env as docker_env
+import utils.infra_setup.heat.manager as client_manager
LOG = Logger(__name__).getLogger()
@@ -37,16 +38,6 @@ def _prepare_env_daemon(test_yardstick):
config.bottlenecks_config["yardstick_rc_dir"])
docker_env.docker_exec_cmd(yardstick_contain,
cmd)
- file_orig = ("/home/opnfv/repos/yardstick/etc"
- "/yardstick/yardstick.conf.sample")
- file_after = "/etc/yardstick/yardstick.conf"
- cmd = "cp %s %s" % (file_orig,
- file_after)
- docker_env.docker_exec_cmd(yardstick_contain,
- cmd)
- cmd = "sed -i '12s/http/file/g' /etc/yardstick/yardstick.conf"
- docker_env.docker_exec_cmd(yardstick_contain,
- cmd)
# update the external_network
_source_file(rc_file)
@@ -105,3 +96,30 @@ def _append_external_network(rc_file):
except OSError as e:
if e.errno != errno.EEXIST:
raise
+
+
+def prepare_image(image_name, image_dir):
+ glance_client = client_manager._get_glance_client()
+ if not os.path.isfile(image_dir):
+ LOG.error("Error: file %s does not exist.", image_dir)
+ return None
+ try:
+ images = glance_client.images.list()
+ image_id = next((i.id for i in images if i.name == image_name), None)
+ if image_id is not None:
+ LOG.info("Image %s already exists.", image_name)
+ else:
+ LOG.info("Creating image '%s' from '%s'...", image_name, image_dir)
+
+ image = glance_client.images.create(
+ name=image_name, visibility="public", disk_format="qcow2",
+ container_format="bare")
+ image_id = image.id
+ with open(image_dir) as image_data:
+ glance_client.images.upload(image_id, image_data)
+ return image_id
+ except Exception: # pylint: disable=broad-except
+ LOG.error(
+ "Error [create_glance_image(glance_client, '%s', '%s')]",
+ image_name, image_dir)
+ return None