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 ##############################################################################
11 def set_doctor_driver_conf(ssh_client, restart_cmd):
12 cg_set_cmd = '''#!/bin/bash
13 co_conf=/etc/congress/congress.conf
14 co_conf_bak=/etc/congress/congress.conf.bak
15 co_entry="congress.datasources.doctor_driver.DoctorDriver"
16 if sudo grep -e "^drivers.*$co_entry" $co_conf; then
17 echo "NOTE: congress is configured as we needed"
19 echo "modify the congress config"
20 sudo cp $co_conf $co_conf_bak
21 sudo sed -i -e "/^drivers/s/$/,$co_entry/" $co_conf
26 ret, output = ssh_client.ssh(cg_set_cmd)
28 raise Exception('Do the congress command in controller node failed...'
29 'ret=%s, cmd=%s, output=%s'
30 % (ret, cg_set_cmd, output))
33 def restore_doctor_driver_conf(ssh_client, restart_cmd):
34 cg_restore_cmd = '''#!/bin/bash
35 co_conf=/etc/congress/congress.conf
36 co_conf_bak=/etc/congress/congress.conf.bak
37 if [ -e $co_conf_bak ]; then
38 echo "restore the congress config"
39 sudo cp $co_conf_bak $co_conf
43 echo "Do not need to restore the congress config"
47 ret, output = ssh_client.ssh(cg_restore_cmd)
49 raise Exception('Do the congress command in controller node failed...'
50 'ret=%s, cmd=%s, output=%s'
51 % (ret, cg_restore_cmd, output))