mirror of https://github.com/nicolargo/glances
Feature ready. UX to be refactor
parent
e3d84c79b2
commit
bd768aa4da
|
@ -135,3 +135,9 @@ list_2_countmin=1
|
||||||
# Define the static server list
|
# Define the static server list
|
||||||
server_1_name=localhost
|
server_1_name=localhost
|
||||||
server_1_port=61234
|
server_1_port=61234
|
||||||
|
server_2_name=localhost
|
||||||
|
server_2_port=61235
|
||||||
|
server_3_name=localhost
|
||||||
|
server_3_port=61236
|
||||||
|
server_4_name=pasbon
|
||||||
|
server_4_port=61237
|
||||||
|
|
|
@ -67,7 +67,7 @@ class GlancesClientBrowser(object):
|
||||||
if self.args.browser:
|
if self.args.browser:
|
||||||
ret = self.static_server.get_servers_list()
|
ret = self.static_server.get_servers_list()
|
||||||
if self.autodiscover_server is not None:
|
if self.autodiscover_server is not None:
|
||||||
ret = self.autodiscover_server.get_servers_list() + self.static_server.get_servers_list()
|
ret = self.static_server.get_servers_list() + self.autodiscover_server.get_servers_list()
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@ -142,9 +142,15 @@ class GlancesClientBrowser(object):
|
||||||
clear_password = self.screen.display_popup(_("Password needed for %s: " % v['name']), is_input=True)
|
clear_password = self.screen.display_popup(_("Password needed for %s: " % v['name']), is_input=True)
|
||||||
# Hash with SHA256
|
# Hash with SHA256
|
||||||
encoded_password = sha256(clear_password).hexdigest()
|
encoded_password = sha256(clear_password).hexdigest()
|
||||||
self.autodiscover_server.set_server(self.screen.get_active(),
|
# Static list then dynamic one
|
||||||
'password',
|
if self.screen.get_active() >= len(self.static_server.get_servers_list()):
|
||||||
encoded_password)
|
self.autodiscover_server.set_server(self.screen.get_active() - len(self.static_server.get_servers_list()),
|
||||||
|
'password',
|
||||||
|
encoded_password)
|
||||||
|
else:
|
||||||
|
self.static_server.set_server(self.screen.get_active(),
|
||||||
|
'password',
|
||||||
|
encoded_password)
|
||||||
|
|
||||||
# Display the Glance client on the selected server
|
# Display the Glance client on the selected server
|
||||||
logger.info("Connect Glances client to the %s server" %
|
logger.info("Connect Glances client to the %s server" %
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
|
|
||||||
"""Manage the Glances server static list """
|
"""Manage the Glances server static list """
|
||||||
|
|
||||||
|
# System lib
|
||||||
|
from socket import gethostbyname, gaierror
|
||||||
|
|
||||||
# Import Glances libs
|
# Import Glances libs
|
||||||
from glances.core.glances_globals import logger
|
from glances.core.glances_globals import logger
|
||||||
|
|
||||||
|
@ -45,25 +48,24 @@ class GlancesStaticServer(object):
|
||||||
elif not config.has_section(self._section):
|
elif not config.has_section(self._section):
|
||||||
logger.warning("No [%s] section in the configuration file. Can not load server list." % self._section)
|
logger.warning("No [%s] section in the configuration file. Can not load server list." % self._section)
|
||||||
else:
|
else:
|
||||||
|
logger.info("Start reading the [%s] section in the configuration file" % self._section)
|
||||||
for i in range(1, 256):
|
for i in range(1, 256):
|
||||||
new_server = {}
|
new_server = {}
|
||||||
postfix = 'server_%s_' % str(i)
|
postfix = 'server_%s_' % str(i)
|
||||||
# Read the server name (mandatory)
|
# Read the server name (mandatory)
|
||||||
new_server['name'] = config.get_raw_option(self._section, '%sname' % postfix)
|
for s in ['name', 'port']:
|
||||||
|
new_server[s] = config.get_raw_option(self._section, '%s%s' % (postfix, s))
|
||||||
if new_server['name'] is not None:
|
if new_server['name'] is not None:
|
||||||
# Read other optionnal information
|
|
||||||
for s in ['alias', 'port', 'password']:
|
|
||||||
new_server[s] = config.get_raw_option(self._section, '%s%s' % (postfix, s))
|
|
||||||
|
|
||||||
# Manage optionnal information
|
# Manage optionnal information
|
||||||
if new_server['alias'] is None:
|
|
||||||
new_server['alias'] = new_server['name']
|
|
||||||
if new_server['port'] is None:
|
if new_server['port'] is None:
|
||||||
new_server['port'] = 61209
|
new_server['port'] = 61209
|
||||||
if new_server['password'] is None:
|
|
||||||
new_server['password'] = ''
|
|
||||||
new_server['username'] = 'glances'
|
new_server['username'] = 'glances'
|
||||||
new_server['ip'] = new_server['name']
|
new_server['password'] = ''
|
||||||
|
try:
|
||||||
|
new_server['ip'] = gethostbyname(new_server['name'])
|
||||||
|
except gaierror as e:
|
||||||
|
logger.error("Can not get IP address for server %s (%s)" % (new_server['name'], e))
|
||||||
|
continue
|
||||||
new_server['key'] = new_server['name'] + ':' + new_server['port']
|
new_server['key'] = new_server['name'] + ':' + new_server['port']
|
||||||
new_server['status'] = 'UNKNOWN'
|
new_server['status'] = 'UNKNOWN'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue