Switch from CONST to CONF 45/52445/2
authorCédric Ollivier <cedric.ollivier@orange.com>
Thu, 22 Feb 2018 07:41:11 +0000 (08:41 +0100)
committerCédric Ollivier <cedric.ollivier@orange.com>
Thu, 22 Feb 2018 07:43:36 +0000 (08:43 +0100)
CONST is not the right Functest object to get config data.

Change-Id: I764a0a2a24447c941d1e726f3116593b29dd1c1e
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
sdnvpn/lib/config.py
sdnvpn/lib/gather_logs.py

index f512a7d..f3d8da4 100644 (file)
@@ -11,7 +11,7 @@ import yaml
 import logging
 import pkg_resources
 
-from functest.utils.constants import CONST
+from functest.utils import config
 import functest.utils.functest_utils as ft_utils
 
 logger = logging.getLogger('sdnvpn_test_config')
@@ -40,17 +40,20 @@ class CommonConfig(object):
             self.default_flavor_ram = 512
             self.default_flavor_disk = 1
             self.default_flavor_vcpus = 1
-            self.image_filename = CONST.openstack_image_file_name
-            self.image_format = CONST.openstack_image_disk_format
-            self.image_path = '{0}/{1}'.format(CONST.dir_functest_images,
-                                               self.image_filename)
+            self.image_filename = getattr(
+                config.CONF, 'openstack_image_file_name')
+            self.image_format = getattr(
+                config.CONF, 'openstack_image_disk_format')
+            self.image_path = '{0}/{1}'.format(
+                getattr(config.CONF, 'dir_functest_images'),
+                self.image_filename)
             # This is the ubuntu image used by sfc
             # Basically vanilla ubuntu + some scripts in there
             # We can use it to setup a quagga instance
             # TODO does functest have an ubuntu image somewhere?
             self.ubuntu_image_name = "sdnvpn-ubuntu"
             self.ubuntu_image_path = '{0}/{1}'.format(
-                CONST.dir_functest_images,
+                getattr(config.CONF, 'dir_functest_images'),
                 "ubuntu-16.04-server-cloudimg-amd64-disk1.img")
             self.custom_flavor_name = 'm1.custom'
             self.custom_flavor_ram = 1024
index ed95fac..b1c3c81 100644 (file)
@@ -19,7 +19,7 @@ import inspect
 
 import sdnvpn.lib.utils as test_utils
 import functest.utils.functest_utils as ft_utils
-from functest.utils.constants import CONST
+from functest.utils import config
 
 LIB_PATH = os.path.dirname(
     os.path.abspath(inspect.getfile(inspect.currentframe())))
@@ -44,10 +44,9 @@ def gather_logs(name):
             'tar -xzvf /tmp/log_output-%s.tar.gz --strip-components=1'
             % node.get_dict()['name'])
 
-    ft_utils.execute_command_raise('cd %s;tar czvf sdnvpn-logs-%s.tar.gz'
-                                   ' /tmp/sdnvpn-logs/'
-                                   % (CONST.__getattribute__('dir_results'),
-                                      name))
+    ft_utils.execute_command_raise(
+        'cd %s;tar czvf sdnvpn-logs-%s.tar.gz /tmp/sdnvpn-logs/' % (
+            getattr(config.CONF, 'dir_results'), name))
 
 
 if __name__ == '__main__':