X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=utils%2Finfra_setup%2Frunner%2Fyardstick.py;h=616bcc521d7c992e88fe453e9ad5aac446134782;hb=adf6a02bae295455f584ebab762592dd57e2422c;hp=104cdfae1549e63a9c7ae71fa6c18fcf9c806110;hpb=9c22cd768a161ec0eab4da24f40a4c626275c746;p=bottlenecks.git diff --git a/utils/infra_setup/runner/yardstick.py b/utils/infra_setup/runner/yardstick.py index 104cdfae..616bcc52 100644 --- a/utils/infra_setup/runner/yardstick.py +++ b/utils/infra_setup/runner/yardstick.py @@ -15,15 +15,42 @@ At present, This file contain the following function: 4.how the process of task.''' import sys +import os import time import requests import json +import urllib import utils.logger as logger +from utils.parser import Parser as config +import utils.env_prepare.stack_prepare as env headers = {"Content-Type": "application/json"} LOG = logger.Logger(__name__).getLogger() +def yardstick_image_prepare(): + if not os.path.exists(config.bottlenecks_config["yardstick_image_dir"]): + urllib.urlretrieve(config.bottlenecks_config["image_url"], + config.bottlenecks_config["yardstick_image_dir"]) + env.prepare_image(config.bottlenecks_config["yardstick_image_name"], + config.bottlenecks_config["yardstick_image_dir"]) + + +def yardstick_command_parser(debug, cidr, outfile, parameter): + cmd = "yardstick" + if debug: + cmd += " -d" + cmd += " task start " + cmd += str(cidr) + cmd += " --output-file " + outfile + image_name = config.bottlenecks_config["yardstick_image_name"] + parameter["image_name"] = image_name + print parameter + if parameter is not None: + cmd += " --task-args " + '"' + str(parameter) + '"' + return cmd + + def Get_Reply(test_config, task_id, time_test=1): reply_url = ("http://%s/yardstick/results?task_id=%s" % (test_config['yardstick_test_ip'], task_id)) @@ -64,11 +91,28 @@ def Create_Incluxdb(con_dic): test_dict = { "action": "createInfluxDBContainer", } - requests.post( + responce = requests.post( base_url, data=json.dumps(test_dict), headers=headers) + ask_data = json.loads(responce.text) + task_id = ask_data["result"]["task_id"] LOG.info("waiting for creating InfluxDB") time.sleep(30) - LOG.info("Done, creating InflxDB Container") + return task_id + + +def yardstick_env_prepare(con_dic): + base_url = ("http://%s/yardstick/env/action" + % (con_dic['yardstick_test_ip'])) + test_dict = { + "action": "prepareYardstickEnv", + } + LOG.info("waiting for yardstick environment prepare") + reponse = requests.post( + base_url, data=json.dumps(test_dict), headers=headers) + ask_data = json.loads(reponse.text) + task_id = ask_data["result"]["task_id"] + LOG.info("Done, yardstick environment prepare complete!") + return task_id def find_condition(con_dic):