aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKubi <jean.gaoliang@huawei.com>2016-11-28 12:23:11 +0000
committerGerrit Code Review <gerrit@opnfv.org>2016-11-28 12:23:11 +0000
commitb96aaa76f29044ce64b8a194436f430a86334b78 (patch)
treeb86d1a32e3a7772c1ac80710e68c80feebb091be
parent8264f8cfd71ac8bacd5a4cce2206cbdc2f76a707 (diff)
parente5b312fc2d09346c75be9e0df2aa9eb20ee4529f (diff)
Merge "ArgsAlreadyParsedError: arguments already parsed: cannot register CLI option"
-rw-r--r--yardstick/cmd/cli.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/yardstick/cmd/cli.py b/yardstick/cmd/cli.py
index 3896ce47c..ee8d1c529 100644
--- a/yardstick/cmd/cli.py
+++ b/yardstick/cmd/cli.py
@@ -66,6 +66,7 @@ class YardstickCLI():
}
def __init__(self):
+ self.opts = []
self._version = 'yardstick version %s ' % \
get_distribution('yardstick').version
@@ -111,7 +112,12 @@ class YardstickCLI():
title="Command categories",
help="Available categories",
handler=parser)
- CONF.register_cli_opt(category_opt)
+ self._register_opt(category_opt)
+
+ def _register_opt(self, opt):
+
+ CONF.register_cli_opt(opt)
+ self.opts.append(opt)
def _load_cli_config(self, argv):
@@ -143,6 +149,11 @@ class YardstickCLI():
func = CONF.category.func
func(CONF.category, task_id=task_id)
+ def _clear_config_opts(self):
+
+ CONF.clear()
+ CONF.unregister_opts(self.opts)
+
def main(self, argv): # pragma: no cover
'''run the command line interface'''
self._register_cli_opt()
@@ -153,6 +164,8 @@ class YardstickCLI():
self._dispath_func_notask()
+ self._clear_config_opts()
+
def api(self, argv, task_id): # pragma: no cover
'''run the api interface'''
self._register_cli_opt()
@@ -162,3 +175,5 @@ class YardstickCLI():
self._handle_global_opts()
self._dispath_func_task(task_id)
+
+ self._clear_config_opts()