summaryrefslogtreecommitdiffstats
path: root/glances/main.py
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 /glances/main.py
parentbd5b12d5213673c3aa6acd3c532fa91bbe538ebf (diff)
Create an option to set the username to use in Web or RPC Server mode #1381
Diffstat (limited to 'glances/main.py')
-rw-r--r--glances/main.py12
1 files changed, 9 insertions, 3 deletions
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(