2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-04-14 09:12:34 +00:00

Add ability to get booturl redirect

In some environments, there's a desire to manually manage DHCP configuration.
In such a case, provide a url
that can be given to the dhcp server
to allow confluent to control the profile
without updating such a DHCP service.

With this change, a node can be told to boot:
http://confluentserver/confluent-api/booturl/by-node/n123/boot.ipxe

To be redirected to the currently applicable os profile.
This commit is contained in:
Jarrod Johnson 2022-10-13 10:54:11 -04:00
parent 23ec46bb8b
commit 8de7402b56

View File

@ -27,6 +27,7 @@ except ImportError:
webauthn = None
import confluent.auth as auth
import confluent.config.attributes as attribs
import confluent.config.configmanager as configmanager
import confluent.consoleserver as consoleserver
import confluent.forwarder as forwarder
import confluent.exceptions as exc
@ -621,6 +622,28 @@ def resourcehandler_backend(env, start_response):
for res in selfservice.handle_request(env, start_response):
yield res
return
if env.get('PATH_INFO', '').startswith('/booturl/by-node/'):
request = env['PATH_INFO'].split('/')
if not request[0]:
request = request[1:]
if len(request) != 4:
start_response('400 Bad Request', headers)
yield ''
return
nodename = request[2]
bootfile = request[3]
cfg = configmanager.ConfigManager(None)
nodec = cfg.get_node_attributes(nodename, 'deployment.pendingprofile')
pprofile = nodec.get(nodename, {}).get('deployment.pendingprofile', {}).get('value', None)
if not pprofile:
start_response('404 Not Found', headers)
yield ''
return
redir = '/confluent-public/os/{0}/{1}'.format(pprofile, bootfile)
headers.append(('Location', redir))
start_response('302 Found', headers)
yield ''
return
if 'CONTENT_LENGTH' in env and int(env['CONTENT_LENGTH']) > 0:
reqbody = env['wsgi.input'].read(int(env['CONTENT_LENGTH']))
reqtype = env['CONTENT_TYPE']