def server_schedule_stop(instance_id): if request.method == 'POST': if 'stoptime' not in request.form and 'gpustoptime' not in request.form: app.logger.info('stoptime and gpustoptime not in request') abort(400) tags = {} if 'stoptime' in request.form: if int(request.form['stoptime']) < 0: app.logger.info('stoptime is less than zero') abort(400) tags['Shutdown'] = request.form['stoptime'] if 'gpustoptime' in request.form: if int(request.form['gpustoptime']) < 0: app.logger.info('gpustoptime is less than zero') abort(400) tags['GPU_Shutdown'] = request.form['gpustoptime'] aws.multi_tag_instance.delay(instance_id, tags) if request_wants_json(): return jsonify(True) else: return redirect(url_for('server_list')) return render_template("confirm.html", message="")
def server_terminate_group(group_id): """Terminate all instances in the specified instance group.""" instances = aws.get_instances_in_group(group_id) instances_metadata = [] is_admin = ldapuser.is_admin(session['username']) for instance in instances: if not is_admin: if not aws.is_owner(instance_id, session['username']): abort(404) instances_metadata.append({ 'id': instance.id, 'private_ip_address': instance.private_ip_address }) if request.method == 'POST': for instance in instances: if aws.can_terminate(instance): aws.terminate_instance.delay(instance.id) if request_wants_json(): return jsonify(True) else: return redirect(url_for('server_list')) return render_template('confirm.html', termination_group_metadata=instances_metadata)
def profiles_remove(profile_id): if request.method == 'POST': profiles.remove_profile(profile_id) if request_wants_json(): return jsonify(True) else: return redirect(url_for('profiles_list')) return render_template("confirm.html")
def server_stop(instance_id): if request.method == 'POST': aws.stop_instance.delay(instance_id) if request_wants_json(): return jsonify(True) else: return redirect(url_for('server_list')) return render_template("confirm.html", message="")
def server_label(instance_id): if request.method == 'POST': if 'label' not in request.form or len(request.form['label']) <= 0: abort(400) label = request.form['label'] aws.tag_instance.delay(instance_id, 'Label', label) if request_wants_json(): return jsonify(True) else: return redirect(url_for('server_list')) return render_template("confirm.html", message="")
def server_schedule_stop(instance_id): if request.method == 'POST': if 'stoptime' not in request.form: app.logger.info('stoptime not in request') abort(400) stoptime = int(request.form['stoptime']) if stoptime <= 0: app.logger.info('stoptime is less than zero') abort(400) aws.tag_instance.delay(instance_id, 'Shutdown', request.form['stoptime']) if request_wants_json(): return jsonify(True) else: return redirect(url_for('server_list')) return render_template("confirm.html", message="")
def token_delete(token_id): if request.method == 'POST': tokens.remove_token(token_id) if request_wants_json(): return jsonify(True) return redirect(url_for('token_list'))