Commit 6a2a28bd authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Add name and uuid of session user to shell greet

Refs: 3632
parent f42bcc2d
......@@ -473,7 +473,12 @@ def run_one_cmd(exe_string, parser, auth_base, cloud):
def run_shell(exe_string, parser, auth_base, cloud):
from command_shell import _init_shell
shell = _init_shell(exe_string, parser)
username, userid = (
auth_base.user_term('name'), auth_base.user_term('id'))
except Exception:
username, userid = '', ''
shell = _init_shell(exe_string, parser, username, userid)
_load_all_commands(shell.cmd_tree, parser.arguments), cloud, parser)
......@@ -46,12 +46,12 @@ from kamaki.cli.logger import add_file_logger
log = add_file_logger(__name__)
def _init_shell(exe_string, parser):
def _init_shell(exe_string, parser, username='', userid=''):
parser.arguments.pop('version', None)
shell = Shell()
from kamaki import __version__ as version
shell.greet(version, username, userid)
shell.do_EOF = shell.do_exit
from kamaki.cli.command_tree import CommandTree
shell.cmd_tree = CommandTree(
......@@ -98,7 +98,7 @@ class Shell(Cmd):
return line[1:]
return line
def greet(self, version):
def greet(self, version, username='', userid=''):
print('kamaki v%s - Interactive Shell\n' % version)
print('\t/exit \tterminate kamaki')
print('\texit or ^D\texit context')
......@@ -106,6 +106,8 @@ class Shell(Cmd):
print('\t?command \thelp on command')
print('\t!<command>\texecute OS shell command')
if username or userid:
print('Session user is %s (uuid: %s)' % (username, userid))
def set_prompt(self, new_prompt):
self.prompt = '%s%s%s' % (self._prefix, new_prompt, self._suffix)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment