Support Apex with services in containers
[doctor.git] / doctor_tests / installer / common / restore_aodh.py
1 ##############################################################################
2 # Copyright (c) 2018 Nokia 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 subprocess
11
12
13 def restore_aodh_event_alarm():
14     # Remove modified docker and restore original
15     orig = "orig_docker_id"
16     new = "new_docker_id"
17     if os.path.isfile(orig):
18         with open("orig_docker_id", 'r') as oid:
19             orig_docker_id = oid.read()
20         oid.close()
21         if os.path.isfile(new):
22             with open("new_docker_id", 'r') as nid:
23                 new_docker_id = nid.read()
24             nid.close()
25             subprocess.check_output("docker stop %s" % new_docker_id,
26                                     shell=True)
27             subprocess.check_output("docker rm %s" % new_docker_id, shell=True)
28             os.remove(new)
29         subprocess.check_output("docker start %s" % orig_docker_id, shell=True)
30         os.remove(orig)
31
32 restore_aodh_event_alarm()