Revision 6a2a28bd
b/kamaki/cli/__init__.py | ||
---|---|---|
473 | 473 |
|
474 | 474 |
def run_shell(exe_string, parser, auth_base, cloud): |
475 | 475 |
from command_shell import _init_shell |
476 |
shell = _init_shell(exe_string, parser) |
|
476 |
try: |
|
477 |
username, userid = ( |
|
478 |
auth_base.user_term('name'), auth_base.user_term('id')) |
|
479 |
except Exception: |
|
480 |
username, userid = '', '' |
|
481 |
shell = _init_shell(exe_string, parser, username, userid) |
|
477 | 482 |
_load_all_commands(shell.cmd_tree, parser.arguments) |
478 | 483 |
shell.run(auth_base, cloud, parser) |
479 | 484 |
|
b/kamaki/cli/command_shell.py | ||
---|---|---|
46 | 46 |
log = add_file_logger(__name__) |
47 | 47 |
|
48 | 48 |
|
49 |
def _init_shell(exe_string, parser): |
|
49 |
def _init_shell(exe_string, parser, username='', userid=''):
|
|
50 | 50 |
parser.arguments.pop('version', None) |
51 | 51 |
shell = Shell() |
52 | 52 |
shell.set_prompt(exe_string) |
53 | 53 |
from kamaki import __version__ as version |
54 |
shell.greet(version) |
|
54 |
shell.greet(version, username, userid)
|
|
55 | 55 |
shell.do_EOF = shell.do_exit |
56 | 56 |
from kamaki.cli.command_tree import CommandTree |
57 | 57 |
shell.cmd_tree = CommandTree( |
... | ... | |
98 | 98 |
return line[1:] |
99 | 99 |
return line |
100 | 100 |
|
101 |
def greet(self, version): |
|
101 |
def greet(self, version, username='', userid=''):
|
|
102 | 102 |
print('kamaki v%s - Interactive Shell\n' % version) |
103 | 103 |
print('\t/exit \tterminate kamaki') |
104 | 104 |
print('\texit or ^D\texit context') |
... | ... | |
106 | 106 |
print('\t?command \thelp on command') |
107 | 107 |
print('\t!<command>\texecute OS shell command') |
108 | 108 |
print('') |
109 |
if username or userid: |
|
110 |
print('Session user is %s (uuid: %s)' % (username, userid)) |
|
109 | 111 |
|
110 | 112 |
def set_prompt(self, new_prompt): |
111 | 113 |
self.prompt = '%s%s%s' % (self._prefix, new_prompt, self._suffix) |
Also available in: Unified diff