summaryrefslogtreecommitdiffstats
path: root/deploy/status_callback.py
diff options
context:
space:
mode:
authorHarry Huang <huangxiangyu5@huawei.com>2017-07-20 20:17:36 +0800
committerHarry Huang <huangxiangyu5@huawei.com>2017-07-24 10:33:30 +0800
commit069835924120224ec46fc40877c89ac48608a6f5 (patch)
tree3e5e1e09affa32c648f766872fe441e0ae1d4dd1 /deploy/status_callback.py
parentf12c7c6d19eb21cd99690271f4ef71794a24b683 (diff)
Dynamic Inventory
JIRA: COMPASS-556 1. using dynamic ansible inventory 2. modify Class AnsibleInstaller in compass-tasks 3. modify compass conf to support this behavior 4. specify docker image in /deploy/conf/compass.conf 5. remove clusterhost status update in playbook_done.py Change-Id: I04079547c8b251571ae4e5b165d3bf425b8913b7 Signed-off-by: Harry Huang <huangxiangyu5@huawei.com>
Diffstat (limited to 'deploy/status_callback.py')
-rw-r--r--deploy/status_callback.py28
1 files changed, 21 insertions, 7 deletions
diff --git a/deploy/status_callback.py b/deploy/status_callback.py
index 47df1d30..4bbbc321 100644
--- a/deploy/status_callback.py
+++ b/deploy/status_callback.py
@@ -13,6 +13,8 @@ import sys # noqa:F401
from ansible.plugins.callback import CallbackBase
+COMPASS_HOST = "compass-deck"
+
def task_error(display, host, data):
display.display("task_error: host=%s,data=%s" % (host, data))
@@ -20,7 +22,7 @@ def task_error(display, host, data):
# if isinstance(data, dict):
# invocation = data.pop('invocation', {})
- notify_host(display, "compass-deck", host, "failed")
+ notify_host(display, COMPASS_HOST, host, "failed")
class CallbackModule(CallbackBase):
@@ -42,7 +44,7 @@ class CallbackModule(CallbackBase):
# task_error(self._display, host, res)
pass
- def v2_runner_on_ok(self, host, res):
+ def v2_runner_on_ok(self, res):
pass
def v2_runner_on_skipped(self, host, item=None):
@@ -112,14 +114,26 @@ class CallbackModule(CallbackBase):
if summary['unreachable'] > 0:
unreachable = True
- clusterhosts = set(hosts) - set(['localhost'])
+ headers = {"Content-type": "application/json",
+ "Accept": "*/*"}
+
+ conn = httplib.HTTPConnection(COMPASS_HOST, 80)
+ token = auth(conn)
+ headers["X-Auth-Token"] = token
+ get_url = "/api/hosts"
+ conn.request("GET", get_url, "", headers)
+ resp = conn.getresponse()
+ raise_for_status(resp)
+ host_data = json.loads(resp.read())
+ clusterhosts = [item["name"] for item in host_data]
+
if failures or unreachable:
- for host in clusterhosts:
- notify_host(self._display, "compass-deck", host, "error")
- return
+ host_status = "error"
+ else:
+ host_status = "succ"
for host in clusterhosts:
- notify_host(self._display, "compass-deck", host, "succ")
+ notify_host(self._display, "compass-deck", host, host_status)
def raise_for_status(resp):