InfluxDB add authentication support 93/8093/1
authorQiLiang <liangqi1@huawei.com>
Tue, 26 Jan 2016 08:55:00 +0000 (08:55 +0000)
committerqi liang <liangqi1@huawei.com>
Wed, 27 Jan 2016 01:12:32 +0000 (01:12 +0000)
JIRA: YARDSTICK-212

Change-Id: I6b669800160268db70b5c9e43cbbc053576ec4b5
Signed-off-by: QiLiang <liangqi1@huawei.com>
(cherry picked from commit 20b3b5fa5e1ecd8a6b68980d365f82034f69df6d)

etc/yardstick/yardstick.conf.sample
yardstick/dispatcher/influxdb.py

index edbd5bc..f4eff05 100644 (file)
@@ -25,3 +25,5 @@
 # timeout = 5
 # target = http://127.0.0.1:8086
 # db_name = yardstick
+# username = root
+# password = root
index a094816..f61912d 100644 (file)
@@ -30,6 +30,12 @@ influx_dispatcher_opts = [
     cfg.StrOpt('db_name',
                default='yardstick',
                help='The database name to store test results.'),
+    cfg.StrOpt('username',
+               default='root',
+               help='The user name to access database.'),
+    cfg.StrOpt('password',
+               default='root',
+               help='The user password to access database.'),
     cfg.IntOpt('timeout',
                default=5,
                help='The max time in seconds to wait for a request to '
@@ -50,6 +56,8 @@ class InfluxdbDispatcher(DispatchBase):
         self.timeout = CONF.dispatcher_influxdb.timeout
         self.target = CONF.dispatcher_influxdb.target
         self.db_name = CONF.dispatcher_influxdb.db_name
+        self.username = CONF.dispatcher_influxdb.username
+        self.password = CONF.dispatcher_influxdb.password
         self.influxdb_url = "%s/write?db=%s" % (self.target, self.db_name)
         self.raw_result = []
         self.case_name = ""
@@ -146,6 +154,7 @@ class InfluxdbDispatcher(DispatchBase):
             LOG.debug('Test result line format : %s' % line)
             res = requests.post(self.influxdb_url,
                                 data=line,
+                                auth=(self.username, self.password),
                                 timeout=self.timeout)
             if res.status_code != 204:
                 LOG.error('Test result posting finished with status code'