<s> from django . http import HttpResponse , HttpResponseServerError <EOL> from core . models import * <EOL> from services . hpc . models import * <EOL> from services . requestrouter . models import * <EOL> import xos . settings <EOL> import json <EOL> import os <EOL> import time <EOL> def get_service_slices ( service ) : <EOL> try : <EOL> return service . slices . all ( ) <EOL> except : <EOL> return service . service . all ( ) <EOL> def HpcConfig ( request ) : <EOL> hpcSlice = None <EOL> cmiSlice = None <EOL> redirSlice = None <EOL> demuxSlice = None <EOL> node_slicename = request . GET . get ( "<STR_LIT>" , None ) <EOL> if not node_slicename : <EOL> return HttpResponseServerError ( "<STR_LIT>" ) <EOL> hpc = None <EOL> for candidate in HpcService . objects . all ( ) : <EOL> if candidate . cmi_hostname == node_slicename : <EOL> hpc = candidate <EOL> for slice in get_service_slices ( candidate ) : <EOL> if slice . name == node_slicename : <EOL> hpc = candidate <EOL> if ( not hpc ) : <EOL> return HttpResponseServerError ( "<STR_LIT>" ) <EOL> for slice in get_service_slices ( hpc ) : <EOL> if "<STR_LIT>" in slice . name : <EOL> cmiSlice = slice <EOL> elif ( "<STR_LIT>" in slice . name ) or ( "<STR_LIT>" in slice . name ) : <EOL> hpcSlice = slice <EOL> elif "<STR_LIT>" in slice . name : <EOL> redirSlice = slice <EOL> elif "<STR_LIT>" in slice . name : <EOL> demuxSlice = slice <EOL> if ( hpc . cmi_hostname ) : <EOL> cmi_hostname = hpc . cmi_hostname <EOL> else : <EOL> if not cmiSlice : <EOL> return HttpResponseServerError ( "<STR_LIT>" ) <EOL> if len ( cmiSlice . instances . all ( ) ) == <NUM_LIT:0> : <EOL> return HttpResponseServerError ( "<STR_LIT>" ) <EOL> cmi_hostname = cmiSlice . instances . all ( ) [ <NUM_LIT:0> ] . node . name <EOL> if not hpcSlice : <EOL> return HttpResponseServerError ( "<STR_LIT>" ) <EOL> if ( redirSlice == None ) or ( demuxSlice == None ) : <EOL> rr = RequestRouterService . objects . all ( ) <EOL> if not ( rr ) : <EOL> return HttpResponseServerError ( "<STR_LIT>" ) <EOL> rr = rr [ <NUM_LIT:0> ] <EOL> try : <EOL> slices = rr . slices . all ( ) <EOL> except : <EOL> slices = rr . service . all ( ) <EOL> for slice in slices : <EOL> if "<STR_LIT>" in slice . name : <EOL> redirSlice = slice <EOL> elif "<STR_LIT>" in slice . name : <EOL> demuxSlice = slice <EOL> if not redirSlice : <EOL> return HttpResponseServerError ( "<STR_LIT>" ) <EOL> if not demuxSlice : <EOL> return HttpResponseServerError ( "<STR_LIT>" ) <EOL> d = { } <EOL> d [ "<STR_LIT>" ] = hpcSlice . name <EOL> d [ "<STR_LIT>" ] = redirSlice . name <EOL> d [ "<STR_LIT>" ] = demuxSlice . name <EOL> d [ "<STR_LIT>" ] = cmi_hostname <EOL> d [ "<STR_LIT>" ] = xos . settings . RESTAPI_HOSTNAME <EOL> d [ "<STR_LIT>" ] = str ( xos . settings . RESTAPI_PORT ) <EOL> if hpc . hpc_port80 : <EOL> d [ "<STR_LIT>" ] = "<STR_LIT:True>" <EOL> else : <EOL> d [ "<STR_LIT>" ] = "<STR_LIT:False>" <EOL> return HttpResponse ( """<STR_LIT>""" . format ( ** d ) ) </s>
