dont forget to set SFA_CM_SLICE_PREFIX
[sfa.git] / config / gen-sfa-cm-config.py
1 #!/usr/bin/python
2 import os
3 import sys
4 sys.path.append('/usr/share/plc_api')
5 from sfa.util.config import Config as SfaConfig
6 from PLC.Config import Config as PlcConfig
7
8 sfa_config = SfaConfig()
9 plc_config = PlcConfig()
10 all_vars = ['SFA_CONFIG_DIR', 'SFA_DATA_DIR', 'SFA_INTERFACE_HRN',
11             'SFA_CM_SLICE_PREFIX', 'SFA_REGISTRY_HOST', 'SFA_REGISTRY_PORT', 
12             'SFA_AGGREGATE_HOST', 'SFA_AGGREGATE_PORT', 
13             'SFA_SM_HOST', 'SFA_SM_PORT',
14             'SFA_CM_ENABLED', 'SFA_CM_HOST', 'SFA_CM_PORT']
15 defaults = {
16     'SFA_CM_ENABLED': '1',
17     'SFA_CM_HOST': 'localhost',
18     'SFA_CM_PORT': '12346',
19     'SFA_CM_SLICE_PREFIX': plc_config.PLC_SLICE_PREFIX
20     }
21      
22 const_dict = {}
23 for key in all_vars:
24     value = ""        
25     if key in defaults:
26         value = defaults[key]
27     elif hasattr(sfa_config, key):
28         value = getattr(sfa_config, key)
29     const_dict[key] = value
30
31 filename = sfa_config.config_path + os.sep + 'sfa_component_config'
32 conffile = open(filename, 'w')
33 format='%s="%s"\n'
34
35 for var in all_vars:
36     conffile.write(format % (var, const_dict[var]))
37
38 conffile.close() 
39     
40