summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolargo <nicolas@nicolargo.com>2018-12-29 19:10:48 +0100
committernicolargo <nicolas@nicolargo.com>2018-12-29 19:10:48 +0100
commit8cf364212ea782f3b54449820e0dcff31b2b7f2f (patch)
tree7dee19d15755cac93ff43dd9ecbb6157c81f99db
parentbd5b12d5213673c3aa6acd3c532fa91bbe538ebf (diff)
Create an option to set the username to use in Web or RPC Server mode #1381
-rw-r--r--NEWS1
-rw-r--r--docs/man/glances.12
-rw-r--r--docs/quickstart.rst15
-rw-r--r--glances/main.py12
4 files changed, 20 insertions, 10 deletions
diff --git a/NEWS b/NEWS
index def7673d..b48d9d46 100644
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,7 @@ Bugs corrected:
* TypeError on opening (Wifi plugin) #1373
* Some field name are incorrect in CSV export #1372
* Standard output misbehaviour (need to flush) #1376
+ * Create an option to set the username to use in Web or RPC Server mode #1381
Others:
diff --git a/docs/man/glances.1 b/docs/man/glances.1
index d9192ada..016315f7 100644
--- a/docs/man/glances.1
+++ b/docs/man/glances.1
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
-.TH "GLANCES" "1" "Dec 27, 2018" "3.1.0_beta" "Glances"
+.TH "GLANCES" "1" "Dec 29, 2018" "3.1.0_beta" "Glances"
.SH NAME
glances \- An eye on your system
.
diff --git a/docs/quickstart.rst b/docs/quickstart.rst
index c7c212f8..00b71ef6 100644
--- a/docs/quickstart.rst
+++ b/docs/quickstart.rst
@@ -77,9 +77,15 @@ available network interfaces) and TCP port is ``61209``.
In client/server mode, limits are set by the server side.
-You can set a password to access to the server ``--password``. By
-default, the username is ``glances`` but you can change it with
-``--username``. It is also possible to set the password in the
+You can set a password to access to the server using the ``--password``.
+By default, the username is ``glances`` but you can change it with
+``--username``.
+
+If you want, the SHA password will be stored in ``username.pwd`` file.
+Next time your run the server/client, password will not be asked. To set a
+specific username you can used the -u <username> option.
+
+It is also possible to set the password in the
Glances configuration file:
.. code-block:: ini
@@ -93,9 +99,6 @@ Glances configuration file:
localhost=mylocalhostpassword
default=mydefaultpassword
-If you ask it, the SHA password will be stored in ``username.pwd`` file.
-Next time your run the server/client, password will not be asked.
-
Central client
^^^^^^^^^^^^^^
diff --git a/glances/main.py b/glances/main.py
index 2432f0c5..3a881b5f 100644
--- a/glances/main.py
+++ b/glances/main.py
@@ -194,6 +194,8 @@ Examples of use:
help='define a client/server username')
parser.add_argument('--password', action='store_true', default=False, dest='password_prompt',
help='define a client/server password')
+ parser.add_argument('-u', dest='username_used',
+ help='use the given client/server username')
parser.add_argument('--snmp-community', default='public', dest='snmp_community',
help='SNMP community')
parser.add_argument('--snmp-port', default=161, type=int,
@@ -315,10 +317,14 @@ Examples of use:
args.username = self.__get_username(
description='Enter the Glances server username: ')
else:
- # Default user name is 'glances'
- args.username = self.username
+ if args.username_used:
+ # A username has been set using the -u option ?
+ args.username = args.username_used
+ else:
+ # Default user name is 'glances'
+ args.username = self.username
- if args.password_prompt:
+ if args.password_prompt or args.username_used:
# Interactive or file password
if args.server:
args.password = self.__get_password(