summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeriyasamy Palanisamy <periyasamy.palanisamy@ericsson.com>2017-10-12 11:43:05 +0200
committerPeriyasamy Palanisamy <periyasamy.palanisamy@ericsson.com>2017-10-12 11:43:05 +0200
commite7693b748e16f6013b5dddf6eb5ebcf9d0bb0a3d (patch)
treed8cf3bc400e570a858ef51e40f7158d7d13e9a12
parent82ed8bd94b47d583485dac265b35c6aba6aa4f18 (diff)
make CommonConfig as singleton
* It is not necessary to instantiate CommonConfig object from each testcase and can be made as singleton Change-Id: I99d995486fbd88ea8a77ec7bd9e41a55047ebaca Signed-off-by: Periyasamy Palanisamy <periyasamy.palanisamy@ericsson.com>
-rw-r--r--sdnvpn/lib/config.py68
1 files changed, 41 insertions, 27 deletions
diff --git a/sdnvpn/lib/config.py b/sdnvpn/lib/config.py
index c3f6b22..99e5d00 100644
--- a/sdnvpn/lib/config.py
+++ b/sdnvpn/lib/config.py
@@ -21,34 +21,48 @@ class CommonConfig(object):
"""
Common configuration parameters across testcases
"""
+ class __CommonConfig:
+ """
+ Inner class used to make CommonConfig as singleton
+ """
+
+ def __init__(self):
+ self.config_file = pkg_resources.resource_filename(
+ 'sdnvpn', 'test/functest/config.yaml')
+ self.keyfile_path = pkg_resources.resource_filename(
+ 'sdnvpn', 'artifacts/id_rsa')
+ self.test_db = CONST.results_test_db_url
+ self.quagga_setup_script_path = pkg_resources.resource_filename(
+ 'sdnvpn', 'artifacts/quagga_setup.sh')
+ self.line_length = 90 # length for the summary table
+ self.vm_boot_timeout = 180
+ self.default_flavor = ft_utils.get_parameter_from_yaml(
+ "defaults.flavor", self.config_file)
+ 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)
+ # 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,
+ "ubuntu-16.04-server-cloudimg-amd64-disk1.img")
+ self.custom_flavor_name = 'm1.custom'
+ self.custom_flavor_ram = 1024
+ self.custom_flavor_disk = 10
+ self.custom_flavor_vcpus = 1
+
+ commonCfgInstance = None
+
def __init__(self):
- self.config_file = pkg_resources.resource_filename(
- 'sdnvpn', 'test/functest/config.yaml')
- self.keyfile_path = pkg_resources.resource_filename(
- 'sdnvpn', 'artifacts/id_rsa')
- self.test_db = CONST.results_test_db_url
- self.quagga_setup_script_path = pkg_resources.resource_filename(
- 'sdnvpn', 'artifacts/quagga_setup.sh')
- self.line_length = 90 # length for the summary table
- self.vm_boot_timeout = 180
- self.default_flavor = ft_utils.get_parameter_from_yaml(
- "defaults.flavor", self.config_file)
- 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)
- # 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,
- "ubuntu-16.04-server-cloudimg-amd64-disk1.img")
- self.custom_flavor_name = 'm1.custom'
- self.custom_flavor_ram = 1024
- self.custom_flavor_disk = 10
- self.custom_flavor_vcpus = 1
+ if not CommonConfig.commonCfgInstance:
+ CommonConfig.commonCfgInstance = CommonConfig.__CommonConfig()
+
+ def __getattr__(self, name):
+ return getattr(self.commonCfgInstance, name)
class TestcaseConfig(object):