1 ##############################################################################
2 # Copyright (c) 2017 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 def set_doctor_driver_conf(ssh_client, restart_cmd):
10 cg_set_cmd = '''#!/bin/bash
11 co_conf=/etc/congress/congress.conf
12 co_conf_bak=/etc/congress/congress.conf.bak
13 co_entry="congress.datasources.doctor_driver.DoctorDriver"
14 if sudo grep -e "^drivers.*$co_entry" $co_conf; then
15 echo "NOTE: congress is configured as we needed"
17 echo "modify the congress config"
18 sudo cp $co_conf $co_conf_bak
19 sudo sed -i -e "/^drivers/s/$/,$co_entry/" $co_conf
24 ret, output = ssh_client.ssh(cg_set_cmd)
26 raise Exception('Do the congress command in controller node failed....'
27 'ret=%s, cmd=%s, output=%s' % (ret, cg_set_cmd, output))
30 def restore_doctor_driver_conf(ssh_client, restart_cmd):
31 cg_restore_cmd = '''#!/bin/bash
32 co_conf=/etc/congress/congress.conf
33 co_conf_bak=/etc/congress/congress.conf.bak
34 if [ -e $co_conf_bak ]; then
35 echo "restore the congress config"
36 sudo cp $co_conf_bak $co_conf
40 echo "Do not need to restore the congress config"
44 ret, output = ssh_client.ssh(cg_restore_cmd)
46 raise Exception('Do the congress command in controller node failed....'
47 'ret=%s, cmd=%s, output=%s' % (ret, cg_restore_cmd, output))