Example #1
0
    def execute(session, request):
        try:
            from rally import api as rally_api
        except ImportError:
            rally_api = None

        try:
            from rally.cli.commands import task as rally_task
        except ImportError:
            rally_task = None

        if rally_api is None or rally_task is None:
            LOG.warning('Failed to import Rally')
        else:
            temp_dict = json.loads(request)
            key = temp_dict.keys()
            if not temp_dict['syntaxcheck']:
                key.remove('syntaxcheck')
                file_path = './' + key[0] + '.json'
                with open(file_path, 'w') as make_file:
                    json.dump(temp_dict[key[0]], make_file)

                rally_task.TaskCommands().start(rally_api.API(),
                                                file_path,
                                                tags=['Vitrage', key[0]])
                os.remove(file_path)

            else:
                key.remove('syntaxcheck')
                file_path = './' + key[0] + '.json'
                with open(file_path, 'w') as make_file:
                    json.dump(temp_dict[key[0]], make_file)
                rally_task.TaskCommands().validate(rally_api.API(), file_path)

                os.remove(file_path)
Example #2
0
    def getinfo(session, request=None):
        filters = {}
        try:
            try:
                from rally import api as rally_api
            except ImportError:
                rally_api = None

            try:
                from rally.cli.commands import task as rally_task
            except ImportError:
                rally_task = None

            if rally_api is None or rally_task is None:
                raise ImportError

            task_list = []
            filters["tags"] = ['Vitrage']
            rally_tasklist = rally_api.API().task.list(**filters)

            for l_value in rally_tasklist:
                task_list.append(l_value['uuid'])

            out_path = './static/dashboard/project/' \
                       'components/actions/vitrage.html'
            if task_list:
                rally_task.TaskCommands().report(rally_api.API(),
                                                 task_list,
                                                 out=out_path)
        except ImportError:
            LOG.warning('Failed to import Rally')
Example #3
0
    def setUp(self):
        super(TaskCommandsTestCase, self).setUp()
        self.task = task.TaskCommands()
        self.fake_api = fakes.FakeAPI()

        with mock.patch("rally.api.API.check_db_revision"):
            self.real_api = api.API()
Example #4
0
    def abort(self):
        try:
            rally_api.Task.abort(self.rally_task.task["uuid"])
        except RallyException as e:
            LOGGER.exception(e)
        finally:
            self.runner_thread.join()
            self.checker_thread.join()
        res = rally_api.Task.get_detailed(self.rally_task.task["uuid"])
        self.times = len(res["results"][0]["data"]["raw"])

        # This will print standard rally report
        task_cli.TaskCommands().detailed(task_id=self.rally_task.task['uuid'])
        self.observer.tell({'msg': 'loader_finished', "times": self.times})
Example #5
0
    def check(self):
        while True:
            statuses = [
                rally_consts.TaskStatus.FINISHED,
                rally_consts.TaskStatus.FAILED
            ]
            task_status = self.rally_task.get_status(
                self.rally_task.task['uuid'])

            if task_status in statuses:
                self.observer.tell({'msg': 'loader_finished'})
                # This will print standard rally report
                task_cli.TaskCommands().detailed(
                    task_id=self.rally_task.task['uuid'])
                break
            elif task_status == rally_consts.TaskStatus.ABORTED:
                break
            time.sleep(2.0)
Example #6
0
def start(requestdict):
    """Starts Rally testing.

    Args:
        requestdict: A dictionary that is used to execute the Rally testing.

    Returns:
        None.
    """
    LOG.debug("plugin_rally.py start()")
    try:
        from rally import api as rally_api
    except ImportError:
        rally_api = None

    try:
        from rally.cli.commands import task as rally_task
    except ImportError:
        rally_task = None

    if rally_api is None or rally_task is None:
        LOG.warning('Failed to import Rally')

    else:
        LOG.warning(requestdict)
        temp_dict = json.loads(requestdict)
        key = temp_dict.keys()
        # if not temp_dict['syntaxcheck']:
        #     key.remove('syntaxcheck')
        file_path = './' + key[0] + '.json'
        LOG.warning(file_path)
        with open(file_path, 'w') as make_file:
            json.dump(temp_dict, make_file)

        rally_task.TaskCommands().start(rally_api.API(),
                                        file_path,
                                        tags=['Vitrage', key[0]])
        os.remove(file_path)
Example #7
0
 def setUp(self):
     super(TaskCommandsTestCase, self).setUp()
     self.task = task.TaskCommands()
Example #8
0
    def __init__(self, observer, openrc, inventory, **params):
        super(RallyLoader, self).__init__(observer, openrc, inventory,
                                          **params)

        self.scenario_file = os.path.abspath(
            os.path.join(RallyLoader.scenarios_path, params['scenario_file']))

        # TODO (dratushnyy) fallback to default path only if file not found
        self.scenario_args_file = params.get('scenario_args_file', None)
        if self.scenario_args_file:
            self.scenario_args_file = os.path.abspath(
                os.path.join(RallyLoader.scenarios_path,
                             self.scenario_args_file))

        self.start_delay = params['start_delay']
        self.deployment_name = params['deployment_name']
        self.deployment_config = {
            "type": "ExistingCloud",
            "admin": {
                "username": openrc["username"],
                "password": openrc["password"],
                "tenant_name": openrc["tenant_name"]
            },
            "auth_url": openrc["auth_url"],
            "region_name": openrc["region_name"],
            "https_insecure": openrc['https_insecure'],
            "https_cacert": openrc["https_cacert"]
        }
        self.scenario_args = params.get('scenario_args', None)
        # Need to be set to None to avoid exception in stop() method
        self.rally_task = None

        load_rally_plugins()
        if params.get('db'):
            db_connection = RallyLoader.conn_template.format(
                user=params["db"]["user"],
                passwd=params["db"]["pass"],
                host=params["db"]["host"],
                db_name=params["db"]["name"])

            db_options.set_defaults(CONF, connection=db_connection)
        try:
            rally_api.Deployment.get(self.deployment_name)
        except DBNonExistentTable as e:
            db.schema_create()
        except DeploymentNotFound as e:
            try:
                rally_api.Deployment.create(config=self.deployment_config,
                                            name=self.deployment_name)
            except ValidationError as e:
                LOGGER.exception(e)
                raise e
        except OperationalError as e:
            LOGGER.exception(e)
            raise e

        # Since there is no api method to do this - using cli
        deployment_cli.DeploymentCommands().use(self.deployment_name)
        # Using rally task cli to load and validate task
        # TODO check is API support this?
        try:
            self.scenario_config = task_cli.TaskCommands().\
                _load_and_validate_task(self.scenario_file,
                                        json.dumps(self.scenario_args),
                                        self.scenario_args_file,
                                        self.deployment_name)
        except Exception as e:
            LOGGER.exception(e)
            raise e