diff options
author | Tomi Juvonen <tomi.juvonen@nokia.com> | 2018-10-25 13:36:16 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2018-10-25 13:36:16 +0000 |
commit | baac6579556f8216b36db0d0f87f9c2d4f8b4ef5 (patch) | |
tree | 71d467ffd009f469671d77927f34b15098ecd431 /doctor_tests/installer/common/restart_aodh.py | |
parent | 23bf63c4616040cb0d69cd26238af2a4a7c00a90 (diff) | |
parent | a6575910a137f8932e294f66c9da3194ad937691 (diff) |
Merge "Support Apex with services in containers"
Diffstat (limited to 'doctor_tests/installer/common/restart_aodh.py')
-rw-r--r-- | doctor_tests/installer/common/restart_aodh.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/doctor_tests/installer/common/restart_aodh.py b/doctor_tests/installer/common/restart_aodh.py new file mode 100644 index 00000000..4473bdca --- /dev/null +++ b/doctor_tests/installer/common/restart_aodh.py @@ -0,0 +1,42 @@ +############################################################################## +# Copyright (c) 2018 Nokia Corporation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +import socket +import subprocess + + +def restart_aodh_event_alarm(): + # Restart aodh-evaluator docker with localhost as controller host ip + # This makes our alarm sending look the same as without container + + orig_docker_id = subprocess.check_output("docker ps | grep aodh-evaluator " + "| awk '{print $1}'", shell=True) + get_docker_startup = ( + 'docker inspect --format=\'{{range .Config.Env}} -e "{{.}}" {{end}} ' + '{{range .Mounts}} -v {{.Source}}:{{.Destination}}{{if .Mode}}:' + '{{.Mode}}{{end}}{{end}} -ti {{.Config.Image}}\'' + ) + docker_start = subprocess.check_output("%s %s" % (get_docker_startup, + orig_docker_id), shell=True) + with open("orig_docker_id", 'w') as oid: + oid.write(orig_docker_id) + oid.close() + subprocess.check_output("docker stop %s" % orig_docker_id, shell=True) + ip = socket.gethostbyname(socket.gethostname()) + + ae_start = '-d --add-host="localhost:%s" %s' % (ip, docker_start) + subprocess.check_output("docker run %s" % ae_start, shell=True) + new_docker_id = subprocess.check_output("docker ps | grep aodh-evaluator " + " | awk '{print $1}'", shell=True) + if orig_docker_id == new_docker_id: + raise Exception("Docker ids matching!") + with open("new_docker_id", 'w') as nid: + nid.write(new_docker_id) + nid.close() + +restart_aodh_event_alarm() |