Michael Pasternak has uploaded a new change for review.

Change subject: cli: rhevm-shell should contain the hostname of the system 
#866319
......................................................................

cli: rhevm-shell should contain the hostname of the system #866319

Change-Id: Iea827ff9a5180ac8049bbcb3c639707f841b5901
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=866319
Signed-off-by: Michael pasternak <[email protected]>
---
M src/ovirtcli/context.py
M src/ovirtcli/options.py
M src/ovirtcli/settings.py
M src/ovirtcli/shell/engineshell.py
4 files changed, 19 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine-cli refs/changes/85/15285/1

diff --git a/src/ovirtcli/context.py b/src/ovirtcli/context.py
index 0c789d4..649a6d7 100644
--- a/src/ovirtcli/context.py
+++ b/src/ovirtcli/context.py
@@ -144,7 +144,3 @@
         self.settings['ovirt-shell:port'] = -1
         self.settings['ovirt-shell:timeout'] = -1
         self.settings['ovirt-shell:session_timeout'] = -1
-        # do not reset 'debug' on /disconnect as it loaded
-        # from the .rc config file and not set-able via /connect
-        # command
-        # self.settings['cli:debug'] = False
diff --git a/src/ovirtcli/options.py b/src/ovirtcli/options.py
index 446e544..2f58399 100644
--- a/src/ovirtcli/options.py
+++ b/src/ovirtcli/options.py
@@ -53,6 +53,8 @@
                         help='automatically connect')
         self.add_option('-f', '--file', metavar='FILE',
                         help='read commands from FILE instead of stdin')
+        self.add_option('-e', '--extended-prompt', action='store_true',
+                        help='display extra information in the prompt')
         self.disable_interspersed_args()
 
         # list of hidden app. options (long format)
diff --git a/src/ovirtcli/settings.py b/src/ovirtcli/settings.py
index ba7a9ed..3e48fc0 100644
--- a/src/ovirtcli/settings.py
+++ b/src/ovirtcli/settings.py
@@ -67,11 +67,13 @@
         ('ovirt-shell:fields.*', str, None),
         ('ovirt-shell:ps1.connected', str, '[' + PRODUCT + ' shell %(version)s 
(connected)]# '),
         ('ovirt-shell:ps2.connected', str, '[' + PRODUCT + ' shell 
(connected)]# '),
+        ('ovirt-shell:ps3.connected', str, '[' + PRODUCT + ' shell 
(connected@%(host)s)]# '),
         ('ovirt-shell:ps1.disconnected', str, '[%s shell (disconnected)]# ' % 
PRODUCT),
         ('ovirt-shell:commands', str, '%s shell commands:' % PRODUCT),
         ('ovirt-shell:misc_commands', str, '%s shell commands:' % PRODUCT),
         ('ovirt-shell:version', str, ''),
-        ('ovirt-shell:prompt', str, '')
+        ('ovirt-shell:prompt', str, ''),
+        ('ovirt-shell:extended_prompt', boolean, False)
     ]
 
     # config file white list
@@ -87,5 +89,6 @@
         'ovirt-shell:dont_validate_cert_chain',
         'ovirt-shell:filter',
         'ovirt-shell:timeout',
-        'ovirt-shell:session_timeout'
+        'ovirt-shell:session_timeout',
+        'ovirt-shell:extended_prompt'
     ]
diff --git a/src/ovirtcli/shell/engineshell.py 
b/src/ovirtcli/shell/engineshell.py
index 4b16d7e..e2ce60f 100644
--- a/src/ovirtcli/shell/engineshell.py
+++ b/src/ovirtcli/shell/engineshell.py
@@ -44,6 +44,9 @@
 from cli.command.help import HelpCommand
 from cli.messages import Messages
 
+from urlparse import urlparse
+
+
 class EngineShell(cmd.Cmd, ConnectCmdShell, ActionCmdShell, \
                   ShowCmdShell, ListCmdShell, UpdateCmdShell, \
                   RemoveCmdShell, AddCmdShell, DisconnectCmdShell, \
@@ -148,7 +151,15 @@
                 self.__org_prompt = self.prompt
             self.prompt = 
self.context.settings.get('ovirt-shell:ps1.disconnected')
         elif mode == PromptMode.Connected:
-            self.prompt = 
self.context.settings.get('ovirt-shell:ps2.connected')
+            self.prompt = self.__get_connected_prompt()
+
+    def __get_connected_prompt(self):
+        if self.context.settings.get('ovirt-shell:extended_prompt'):
+            url = self.context.settings.get('ovirt-shell:url')
+            url_obj = urlparse(url)
+            return self.context.settings.get('ovirt-shell:ps3.connected') \
+                   % {'host':url_obj.hostname}
+        return self.context.settings.get('ovirt-shell:ps2.connected')
 
     def onecmd_loop(self, s):
         opts, args = self.parser.parse_args()


--
To view, visit http://gerrit.ovirt.org/15285
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iea827ff9a5180ac8049bbcb3c639707f841b5901
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine-cli
Gerrit-Branch: cli_3.2
Gerrit-Owner: Michael Pasternak <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to