c1f919c17266de784b67dfb1c32057c13ed5f855
[doctor.git] / doctor_tests / installer / common / restore_config.py
1 ##############################################################################
2 # Copyright (c) 2017 ZTE Corporation and others.
3 #
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 import os
10 import shutil
11
12 ep_file = '/etc/ceilometer/event_pipeline.yaml'
13 ep_file_bak = '/etc/ceilometer/event_pipeline.yaml.bak'
14
15
16 def restore_ep_config():
17
18     if not os.path.isfile(ep_file_bak):
19         print('Bak_file:%s does not exist.' % ep_file_bak)
20     else:
21         print('restore')
22         shutil.copyfile(ep_file_bak, ep_file)
23         os.remove(ep_file_bak)
24     return
25
26
27 def restore_ed_config():
28
29     ed_file = '/etc/ceilometer/event_definitions.yaml'
30     ed_file_bak = '/etc/ceilometer/event_definitions.bak'
31
32     if not os.path.isfile(ed_file_bak):
33         print("Bak_file doesn't exist: %s." % ed_file_bak)
34     else:
35         print('restore: %s' % ed_file)
36         shutil.copyfile(ed_file_bak, ed_file)
37         os.remove(ed_file_bak)
38     return
39
40
41 def restore_cpu_allocation_ratio():
42     nova_file = '/etc/nova/nova.conf'
43     nova_file_bak = '/etc/nova/nova.bak'
44
45     if not os.path.isfile(nova_file_bak):
46         print('Bak_file:%s does not exist.' % nova_file_bak)
47     else:
48         print('restore: %s' % nova_file)
49         shutil.copyfile(nova_file_bak, nova_file)
50         os.remove(nova_file_bak)
51     return
52
53 restore_ep_config()
54 restore_ed_config()
55 restore_cpu_allocation_ratio()