mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-29 04:50:21 +00:00
Merge pull request #141 from tkucherera-lenovo/defaultWebUI
opening web ui using default ip
This commit is contained in:
commit
f03525aac5
@ -618,7 +618,6 @@ def resourcehandler(env, start_response):
|
||||
yield '500 - ' + str(e)
|
||||
return
|
||||
|
||||
|
||||
def resourcehandler_backend(env, start_response):
|
||||
"""Function to handle new wsgi requests
|
||||
"""
|
||||
@ -728,7 +727,13 @@ def resourcehandler_backend(env, start_response):
|
||||
elif (env['PATH_INFO'].endswith('/forward/web') and
|
||||
env['PATH_INFO'].startswith('/nodes/')):
|
||||
prefix, _, _ = env['PATH_INFO'].partition('/forward/web')
|
||||
_, _, nodename = prefix.rpartition('/')
|
||||
#_, _, nodename = prefix.rpartition('/')
|
||||
default = False
|
||||
if 'default' in env['PATH_INFO']:
|
||||
default = True
|
||||
_,_,nodename,_ = prefix.split('/')
|
||||
else:
|
||||
_, _, nodename = prefix.rpartition('/')
|
||||
hm = cfgmgr.get_node_attributes(nodename, 'hardwaremanagement.manager')
|
||||
targip = hm.get(nodename, {}).get(
|
||||
'hardwaremanagement.manager', {}).get('value', None)
|
||||
@ -737,6 +742,29 @@ def resourcehandler_backend(env, start_response):
|
||||
yield 'No hardwaremanagement.manager defined for node'
|
||||
return
|
||||
targip = targip.split('/', 1)[0]
|
||||
if default:
|
||||
try:
|
||||
ip_info = socket.getaddrinfo(targip, 0, 0, socket.SOCK_STREAM)
|
||||
except socket.gaierror:
|
||||
start_response('404 Not Found', headers)
|
||||
yield 'hardwaremanagement.manager definition could not be resolved'
|
||||
return
|
||||
# this is just to future proof just in case the indexes of the address family change in future
|
||||
for i in range(len(ip_info)):
|
||||
if ip_info[i][0] == socket.AF_INET:
|
||||
url = 'https://{0}/'.format(ip_info[i][-1][0])
|
||||
start_response('302', [('Location', url)])
|
||||
yield 'Our princess is in another castle!'
|
||||
return
|
||||
elif ip_info[i][0] == socket.AF_INET6:
|
||||
url = 'https://[{0}]/'.format(ip_info[i][-1][0])
|
||||
if url.startswith('https://[fe80'):
|
||||
start_response('405 Method Not Allowed', headers)
|
||||
yield 'link local ipv6 address cannot be used in browser'
|
||||
return
|
||||
start_response('302', [('Location', url)])
|
||||
yield 'Our princess is in another castle!'
|
||||
return
|
||||
funport = forwarder.get_port(targip, env['HTTP_X_FORWARDED_FOR'],
|
||||
authorized['sessionid'])
|
||||
host = env['HTTP_X_FORWARDED_HOST']
|
||||
|
Loading…
Reference in New Issue
Block a user