def pods(): """ Render all the templates not from base. This is a main method """ # # Basic authentication module requirement # If the auth module is installed and the user is not authenticated, so go to login # session = {} if hasattr(app, 'auth'): try: session = get_session_data(transaction=transaction, session_id=request.cookies.get('session_id')) except Exception as e: return redirect(url_for('auth_blueprint.login')) else: session['kubeconfig'] = None # not current_user.is_authenticated: if hasattr(app, 'auth') and session['email'] == None: return redirect(url_for('auth_blueprint.login')) # # End basic authentication requirement # if not 'kubeconfig' in session or session['kubeconfig'] == None or session['kubeconfig'] == '': kubeconfig = None api_client = None else: kubeconfig = session['kubeconfig'] api_client = remote_cluster(kubeconfig=kubeconfig) if (not 'username' in session or session['username'] == None or session['username'] == '' or not 'email' in session or session['email'] == None or session['email'] == ''): username = None email = None else: username = session['username'] email = session['email'] try: return render_template('pods.html', username=username, email=email, state_pods=state_pods( api_client=api_client), compute_allocated_resources=compute_allocated_resources( api_client=api_client), cluster_name_configured=cluster_name_configured( api_client=api_client), pystol_version=PYSTOL_VERSION,) except TemplateNotFound: return render_template('page-404.html'), 404 except Exception as e: print("Exception found in %s: %s" % (blueprint.name, e)) if current_app.config['DEBUG']: raise e return render_template('page-500.html'), 500
def run(): """ Render all the templates not from base. This is a main method """ # # Basic authentication module requirement # If the auth module is installed and the user is not authenticated, so go to login # session = {} form = RunForm(request.form) if hasattr(app, 'auth'): try: session = get_session_data( transaction=transaction, session_id=request.cookies.get('session_id')) except Exception as e: return redirect(url_for('auth_blueprint.login')) else: session['kubeconfig'] = None if hasattr(app, 'auth') and session['email'] == None: return redirect(url_for('auth_blueprint.login')) # # End basic authentication requirement # if not 'kubeconfig' in session or session['kubeconfig'] == None or session[ 'kubeconfig'] == '': kubeconfig = None api_client = None else: kubeconfig = session['kubeconfig'] api_client = remote_cluster(kubeconfig=kubeconfig) if (not 'username' in session or session['username'] == None or session['username'] == '' or not 'email' in session or session['email'] == None or session['email'] == ''): username = None email = None else: username = session['username'] email = session['email'] form = RunForm() if request.method == "POST": dict = request.form namespace = "" collection = "" role = "" source = "" extra_vars = {} if 'namespace' in dict: namespace = dict['namespace'] else: namespace = "" if 'collection' in dict: collection = dict['collection'] else: collection = "" if 'role' in dict: role = dict['role'] else: role = "" if 'source' in dict: source = dict['source'] else: source = "" if 'extra_vars' in dict: if dict['extra_vars'] == "" or dict['extra_vars'] is None: extra_vars = "{}" else: extra_vars = dict['extra_vars'] else: extra_vars = "{}" errors = 0 try: json.loads(extra_vars) except ValueError as e: errors = errors + 1 if errors == 0: insert_pystol_object(namespace=namespace, collection=collection, role=role, source=source, extra_vars=extra_vars, api_client=api_client) return redirect(url_for('executed_blueprint.executed')) else: form.extra_vars.errors = ["This must be a valid JSON"] try: return render_template( 'run.html', username=username, email=email, form=form, compute_allocated_resources=compute_allocated_resources( api_client=api_client), cluster_name_configured=cluster_name_configured( api_client=api_client), pystol_version=PYSTOL_VERSION, ) except TemplateNotFound: return render_template('page-404.html'), 404 except Exception as e: print("Exception found in %s: %s" % (blueprint.name, e)) if current_app.config['DEBUG']: raise e return render_template('page-500.html'), 500