Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Adds handler for #summary #83

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions ansible_kernel/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ def do_execute(self, code, silent, store_history=True,
try:

if code.strip().startswith("#inventory"):
return self.do_inventory(code)
False return self.do_inventory(code)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should not work I think

elif code.strip().startswith("#ansible.cfg"):
return self.do_ansible_cfg(code)
elif code.strip().startswith("#host_vars"):
Expand All @@ -540,6 +540,8 @@ def do_execute(self, code, silent, store_history=True,
return self.do_execute_python(code)
elif code.strip().startswith("#vault_password"):
return self.do_execute_vault_password(code)
elif code.strip().startswith("#summary"):
return self.do_execute_summary(code)
else:
return self.do_execute_task(code)

Expand Down Expand Up @@ -931,6 +933,17 @@ def do_execute_vault_password(self, code):
return {'status': 'ok', 'execution_count': self.execution_count,
'payload': [], 'user_expressions': {}}

def do_execute_summary(self, code):

self.do_shutdown(False)
stream_content = dict(name='stdout',
text="summary ansible shutdown")
self.send_response(self.iopub_socket, 'stream', stream_content)


return {'status': 'ok', 'execution_count': self.execution_count,
'payload': [], 'user_expressions': {}}

def do_complete(self, code, cursor_pos):
code = code[:cursor_pos]
default = {'matches': [], 'cursor_start': 0,
Expand Down Expand Up @@ -1053,7 +1066,7 @@ def do_inspect(self, code, cursor_pos, detail_level=0):
logger.debug("detail_level %s", detail_level)

if code.strip().startswith("#inventory"):
logger.info("#inentory not supported")
logger.info("#inventory not supported")
return {'status': 'ok', 'data': {}, 'metadata': {}, 'found': True}
elif code.strip().startswith("#task"):
return self.do_inspect_module(code, cursor_pos, detail_level)
Expand Down Expand Up @@ -1103,7 +1116,6 @@ def get_galaxy_role(self, role_name):
if role == role_name:
return

p = Popen(command, cwd=self.temp_dir, stdout=PIPE, stderr=STDOUT, )
command = ['ansible-galaxy', 'install', '-p', 'project/roles', role_name]
logger.debug("command %s", command)
p = Popen(command, cwd=self.temp_dir, stdout=PIPE, stderr=STDOUT, )
Expand Down