Log_dir bug fix&Add function of test_ip init
[bottlenecks.git] / utils / parser.py
index 7b1f4e2..a9098a9 100644 (file)
@@ -14,6 +14,7 @@ Second is reading config file.'''
 
 import os
 import yaml
+from pyroute2 import IPDB
 
 
 class Parser():
@@ -82,6 +83,16 @@ class Parser():
         # TO-DO add cli parameters to stack_config.
         return test_cfg, stack_cfg
 
+    @staticmethod
+    def ip_parser(ip_type):
+        with IPDB() as ip:
+            GATEWAY_IP = ip.routes['default'].gateway
+        if ip_type is "dashboard":
+            TEST_IP = GATEWAY_IP + ":9200"
+        elif ip_type is "yardstick_test_ip":
+            TEST_IP = GATEWAY_IP + ":8888"
+        return TEST_IP
+
 
 class HeatTemplate_Parser():
     """parser a Heat template and a method to deploy template to a stack"""
@@ -282,4 +293,3 @@ class HeatTemplate_Parser():
 
     def get_template_date(self):
         return self.heat_date
-