5 sys.path.append('/usr/share/plc_api')
6 from sfa.util.config import Config as SfaConfig
7 from PLC.Config import Config as PlcConfig
9 sfa_config = SfaConfig()
10 plc_config = PlcConfig()
11 default_host = socket.gethostbyname(socket.gethostname())
12 all_vars = ['SFA_CONFIG_DIR', 'SFA_DATA_DIR', 'SFA_INTERFACE_HRN',
13 'SFA_CM_SLICE_PREFIX', 'SFA_REGISTRY_HOST', 'SFA_REGISTRY_PORT',
14 'SFA_AGGREGATE_HOST', 'SFA_AGGREGATE_PORT',
15 'SFA_SM_HOST', 'SFA_SM_PORT',
16 'SFA_CM_ENABLED', 'SFA_CM_HOST', 'SFA_CM_PORT', 'SFA_CM_TYPE', 'SFA_CM_SLICE_PREFIX',
20 'SFA_CM_ENABLED': '1',
21 'SFA_CM_HOST': 'localhost',
22 'SFA_CM_PORT': '12346',
23 'SFA_CM_SLICE_PREFIX': plc_config.PLC_SLICE_PREFIX,
25 'SFA_API_LOGLEVEL': '0'
29 'SFA_REGISTRY_HOST': default_host,
30 'SFA_AGGREGATE_HOST': default_host,
31 'SFA_SM_HOST': default_host,
40 elif hasattr(sfa_config, key):
41 value = getattr(sfa_config, key)
42 # sfa_config may specify localhost instead of a resolvalbe host or ip
43 # if so replace this with the host's address
44 if key in host_defaults and value in ['localhost', '127.0.0.1']:
45 value = host_defaults[key]
46 const_dict[key] = value
48 filename = sfa_config.config_path + os.sep + 'sfa_component_config'
49 conffile = open(filename, 'w')
53 conffile.write(format % (var, const_dict[var]))