1 ##############################################################################
2 # Copyright (c) 2018 ZTE Corporation and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 from six.moves import configparser
14 def set_drivers_config():
15 co_base = "/var/lib/config-data/puppet-generated/congress"
16 if not os.path.isdir(co_base):
18 co_conf = co_base + "/etc/congress/congress.conf"
19 co_conf_bak = co_base + "/etc/congress/congress.conf.bak"
20 doctor_driver = "congress.datasources.doctor_driver.DoctorDriver"
21 config_modified = False
23 config = configparser.ConfigParser()
25 drivers = config.get('DEFAULT', 'drivers')
27 if doctor_driver not in drivers:
28 config_modified = True
29 drivers += ',' + doctor_driver
31 config.set('DEFAULT', 'drivers', drivers)
34 shutil.copyfile(co_conf, co_conf_bak)
35 with open(co_conf, 'w') as configfile:
36 config.write(configfile)