commit 4db899cc0d01bd1e63b11742068ea7f3b94cfa63
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Apr 24 10:56:01 2015 +0200
Config: add configuration of PerfRepo access
Having the perfrepo access information in a configuration file means
that python tasks that use PerfRepo are more portable don't have to
contain usernames and passwords.
You can now call the connect_PerfRepo() method without arguments, it
will use what you've set in the configuration file.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
install/lnst-ctl.conf.in | 6 ++++++
lnst-ctl.conf | 5 +++++
lnst/Common/Config.py | 20 ++++++++++++++++++++
lnst/Controller/Task.py | 15 +++++++++++----
4 files changed, 42 insertions(+), 4 deletions(-)
---
diff --git a/install/lnst-ctl.conf.in b/install/lnst-ctl.conf.in
index 4d31483..ad0efc1 100644
--- a/install/lnst-ctl.conf.in
+++ b/install/lnst-ctl.conf.in
@@ -55,3 +55,9 @@ log_dir = @ctl_logs_dir@
# dynamic interface configuration. This feature is mostly used by LNST
# developers when testing new features.
allow_virtual = True
+
+# Optional section for configuring access to a PerfRepo instance
+#[perfrepo]
+#url =
+#username =
+#password =
diff --git a/lnst-ctl.conf b/lnst-ctl.conf
index d9a28e3..cc2e6b3 100644
--- a/lnst-ctl.conf
+++ b/lnst-ctl.conf
@@ -12,3 +12,8 @@ test_module_dirs = ./test_modules
log_dir = ./Logs
xslt_url =
http://www.lnst-project.org/files/result_xslt/xml_to_html.xsl
allow_virtual = True
+
+[perfrepo]
+url =
+username =
+password =
diff --git a/lnst/Common/Config.py b/lnst/Common/Config.py
index fd43742..e6b600b 100644
--- a/lnst/Common/Config.py
+++ b/lnst/Common/Config.py
@@ -82,6 +82,26 @@ class Config():
"name" : "allow_virtual"
}
+ self._options['perfrepo'] = dict()
+ self._options['perfrepo']['url'] = {\
+ "value" : "",
+ "additive" : False,
+ "action" : self.optionPlain,
+ "name" : "url"
+ }
+ self._options['perfrepo']['username'] = {\
+ "value" : "",
+ "additive" : False,
+ "action" : self.optionPlain,
+ "name" : "username"
+ }
+ self._options['perfrepo']['password'] = {\
+ "value" : "",
+ "additive" : False,
+ "action" : self.optionPlain,
+ "name" : "password"
+ }
+
self.colours_scheme()
def slave_init(self):
diff --git a/lnst/Controller/Task.py b/lnst/Controller/Task.py
index be6b5cc..034dc5f 100644
--- a/lnst/Controller/Task.py
+++ b/lnst/Controller/Task.py
@@ -14,6 +14,7 @@ from lnst.Controller.PerfRepo import PerfRepoRESTAPI
from lnst.Controller.PerfRepo import PerfRepoTestExecution
from lnst.Controller.PerfRepo import PerfRepoValue
from lnst.Common.Utils import dot_to_dict, dict_to_dot, list_to_dot
+from lnst.Common.Config import lnst_config
# The handle to be imported from each task
ctl = None
@@ -102,9 +103,15 @@ class ControllerAPI(object):
"""
return self._ctl._get_alias(alias)
- def connect_PerfRepo(self, hostname, username, password):
+ def connect_PerfRepo(self, url=None, username=None, password=None):
if not self._perf_repo_api.connected():
- self._perf_repo_api.connect(hostname, username, password)
+ if url is None:
+ url = lnst_config.get_option("perfrepo", "url")
+ if username is None:
+ url = lnst_config.get_option("perfrepo", "username")
+ if password is None:
+ url = lnst_config.get_option("perfrepo", "password")
+ self._perf_repo_api.connect(url, username, password)
return self._perf_repo_api
def get_configuration(self):
@@ -454,8 +461,8 @@ class PerfRepoAPI(object):
def connected(self):
return self._rest_api is not None
- def connect(self, hostname, username, password):
- self._rest_api = PerfRepoRESTAPI(hostname, username, password)
+ def connect(self, url, username, password):
+ self._rest_api = PerfRepoRESTAPI(url, username, password)
def new_result(self, testUid, name):
result = PerfRepoResult(testUid, name)