def node(request): mgr = manager() # username = request.POST.get('username', None) node = mgr.getNode() ns = mgr.getNS() service = mgr.getService_2() service_list = service['service_list'] pod = mgr.getPod() deployment = mgr.getDeployment() # print(node) node_num = node['num'] ns_num = ns['num'] service_num = service['num'] pod_num = pod['num'] # print(node_num) node_list = node['node_list'] cpu_ratio = node['cpu_ratio'] mem_ratio = node['mem_ratio'] deployment_num = deployment['num'] pod_ratio = int((1 - pod_num / (node_num * 110)) * 100) print(cpu_ratio) print(mem_ratio) return render( request, 'node.html', { 'node_num': node_num, 'ns_num': ns_num, 'service_num': service_num, 'pod_num': pod_num, 'deployment_num': deployment_num, 'node_list': node_list, 'cpu_ratio': cpu_ratio, 'mem_ratio': mem_ratio, 'pod_ratio': pod_ratio, 'service_list': service_list })
def upload(request): if request.method == "POST": # 请求方法为POST时,进行处理 my_file = request.FILES.get("file", None) # 获取上传的文件,如果没有文件,则默认为None print(my_file) if not my_file: return render(request, "form.html", {}) destination = open(os.path.join(my_file.name), 'wb+') # 打开特定的文件进行二进制的写操作 for chunk in my_file.chunks(): # 分块写入文件 destination.write(chunk) destination.close() mgr = manager() mgr.parse_creat() return redirect('/index.html')
def index(request): t = threading.Thread(target=create_thread, args=(request, )) t.start() mgr = manager() # get_user_list() user_num = mgr.get_all_logged_in_users() username = request.POST.get('username', None) node = mgr.getNode() ns = mgr.getNS() service = mgr.getService_2() service_list = service['service_list'] pod = mgr.getPod() pod_list = pod['pod_list'] # print(node) node_num = node['num'] ns_num = ns['num'] service_num = service['num'] pod_num = pod['num'] # print(node_num) node_list = node['node_list'] cpu_ratio = node['cpu_ratio'] mem_ratio = node['mem_ratio'] pod_ratio = int((1 - pod_num / (node_num * 110)) * 100) # print(cpu_ratio) # print(mem_ratio) # print(service_list) return render( request, 'index.html', { 'node_num': node_num, 'ns_num': ns_num, 'service_num': service_num, 'pod_num': pod_num, 'node_list': node_list, 'cpu_ratio': cpu_ratio, 'mem_ratio': mem_ratio, 'pod_ratio': pod_ratio, 'username': username, 'service_list': service_list, 'pod_list': pod_list, 'user_num': user_num })
def pod(request): mgr = manager() username = request.POST.get('username', None) node = mgr.getNode() node_num = node['num'] pod = mgr.getPod() pod_list = pod['pod_list'] pod_num = pod['num'] cpu_ratio = node['cpu_ratio'] mem_ratio = node['mem_ratio'] pod_ratio = int((1 - pod_num / (node_num * 110)) * 100) return render( request, 'pod.html', { 'cpu_ratio': cpu_ratio, 'mem_ratio': mem_ratio, 'pod_ratio': pod_ratio, 'pod_list': pod_list, 'pod_num': pod_num, 'username': username, })