Support jinja2 in rally.ui.utils

Use pkgutil to get base templates path.
Move ci templates to rally.ui package.
Remove cli functionality and use rally.ui directly in CI code.

Change-Id: If88ba2ed851eb9796ef5fae84398b1c185dbab0c
This commit is contained in:
Sergey Skripnick 2015-11-02 11:47:47 +02:00
parent 02f7059e13
commit 69a52cdde7
2 changed files with 38 additions and 2 deletions

View File

@ -63,8 +63,7 @@ rally show keypairs
rally -v --rally-debug task start --task $TASK $TASK_ARGS rally -v --rally-debug task start --task $TASK $TASK_ARGS
mkdir -p rally-plot/extra mkdir -p rally-plot/extra
python $BASE/new/rally/rally/ui/utils.py render\ python $BASE/new/rally/tests/ci/render.py ci/index.mako > rally-plot/extra/index.html
tests/ci/rally-gate/index.mako > rally-plot/extra/index.html
cp $TASK rally-plot/task.txt cp $TASK rally-plot/task.txt
tar -czf rally-plot/plugins.tar.gz -C $RALLY_PLUGINS_DIR . tar -czf rally-plot/plugins.tar.gz -C $RALLY_PLUGINS_DIR .
rally task results | python -m json.tool > rally-plot/results.json rally task results | python -m json.tool > rally-plot/results.json

37
tests/ci/render.py Normal file
View File

@ -0,0 +1,37 @@
# Copyright 2015: Mirantis Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import print_function
import re
import sys
from rally.ui import utils
HELP_MESSAGE = (
"Usage:\n\t"
"render.py ci/template.mako"
"[<key-1>=<value-1> <key-2>=<value-2> ...]\n\n\t"
"Where key-1,value-1 and key-2,value-2 are key pairs of template.")
if __name__ == "__main__":
args = sys.argv
if (len(args) < 1 or not all(re.match("^[^=]+=[^=]+$",
arg) for arg in args[2:])):
print(HELP_MESSAGE, file=sys.stderr)
sys.exit(1)
render_kwargs = dict([arg.split("=") for arg in args[2:]])
print(utils.get_template(args[1]).render(**render_kwargs))