def student_Deploy_Standard_AddIPs(requests): try: if requests.method == 'POST': utilities.addAWSKeys(requests) form = ServerForm_Add(requests.POST) else: form = ServerForm_Add() response = utilities.addServerDetailsForm( requests, form, 'dataforms/serverdetails/partial_server_create.html') if requests.method == 'POST': utilities.initiateStartServerTime(requests.POST.get('IP_address')) except Exception as e: traceback.print_exc() course_title = requests.POST.get('course_title') classObj = utilities.getStudentClassObject(requests, course_title) credentialsObj = classObj.awscredential servers = utilities.getAllServers(credentialsObj.account_number) response = dict() response['form_is_valid'] = True response['error_message'] = str(e.args[0]) response['html_server_list'] = render_to_string( 'dataforms/serverdetails/partial_server_list.html', { 'servers': servers, 'course_title': course_title }) return JsonResponse(response) return response
def student_Deploy_Standard_UpdateIPs(requests, pk, course_title): server = get_object_or_404(Server_Details, pk=pk) try: if requests.method == 'POST': form = ServerForm_Update(requests.POST, instance=server) else: form = ServerForm_Update(instance=server) response = utilities.addServerDetailsForm( requests, form, 'dataforms/serverdetails/partial_server_update.html', pk=pk) except Exception as e: traceback.print_exc() course_title = requests.POST.get('course_title') classObj = utilities.getStudentClassObject(requests, course_title) credentialsObj = classObj.awscredential servers = utilities.getAllServers(credentialsObj.account_number) response = dict() response['form_is_valid'] = True response['error_message'] = str(e.args[0]) response['html_server_list'] = render_to_string( 'dataforms/serverdetails/partial_server_list.html', { 'servers': servers, 'course_title': course_title }) return JsonResponse(response) return response
def student_Deploy_Standard_DeleteAllIPs(requests, course_title): classObj = utilities.getStudentClassObject(requests, course_title) credentialsObj = classObj.awscredential data = dict() if requests.method == 'POST': servers = Server_Details.objects.filter(account_number=credentialsObj) for server in servers: server.delete() data['form_is_valid'] = True data['message'] = 'All servers successfully deleted' servers = utilities.getAllServers(credentialsObj.account_number) data['html_server_list'] = render_to_string( 'dataforms/serverdetails/partial_server_list.html', { 'servers': servers, 'course_title': course_title }) else: course_title = requests.GET.get('course_title') context = {'course_title': course_title} data['html_form'] = render_to_string( 'dataforms/serverdetails/partial_server_delete_all.html', context, request=requests, ) return JsonResponse(data)
def student_Deploy_Standard_Base(requests, response=None): if response == None: response = {'student_Deploy_Base': 'active'} try: processLogin.studentVerification(requests) except: logout(requests) return render(requests, 'Module_Account/login.html', response) if requests.method == 'GET': course_title = requests.GET.get('course_title') else: course_title = requests.POST.get('course_title') try: classObj = utilities.getStudentClassObject(requests, course_title) credentialsObj = classObj.awscredential team_number = classObj.team_number if team_number != None: team_members = Class.objects.filter( course_section=classObj.course_section).filter( team_number=team_number) for team_member in team_members: if team_member.awscredential == None: team_member.awscredential = credentialsObj team_member.save() response['account_number'] = '' response['servers'] = [] response['servers_count'] = 0 response['course_title'] = course_title response[ 'course_section_id'] = classObj.course_section.course_section_id if credentialsObj != None: account_number = credentialsObj.account_number response['account_number'] = account_number response['servers'] = utilities.getAllServers(account_number) response['servers_count'] = len(response['servers']) except Exception as e: traceback.print_exc() response[ 'error_message'] = 'Error during retrieval of information (Student Deploy Standard): ' + str( e.args[0]) return render( requests, "Module_TeamManagement/Student/ITOpsLabStudentDeployStd.html", response) return render( requests, "Module_TeamManagement/Student/ITOpsLabStudentDeployStd.html", response)
def student_Monitor_Base(requests): response = {"student_Monitor_Base": "active"} try: processLogin.studentVerification(requests) except: logout(requests) return render(requests, 'Module_Account/login.html', {}) response['server_ip'] = requests.GET.get('server_ip') if requests.method == 'GET': course_title = requests.GET.get('course_title') else: course_title = requests.POST.get('course_title') try: response['server_status'] = [] response['webapp_status'] = [] response['webapp_metric'] = {} response['course_title'] = course_title studentClassObj = utilities.getStudentClassObject( requests, course_title) AWS_Credentials = studentClassObj.awscredential team_number = studentClassObj.team_number if AWS_Credentials != None: account_number = AWS_Credentials.account_number if response['server_ip'] == None: servers = utilities.getAllServers(account_number) if len(servers) > 0: response['server_ip'] = servers[0]['server_ip'] if response['server_ip'] != None: response = utilities.getMonitoringStatus( account_number, team_number, response) response = utilities.getMetric(response['server_ip'], response) tz = pytz.timezone('Asia/Singapore') response['last_updated'] = str(datetime.datetime.now(tz=tz))[:19] except Exception as e: traceback.print_exc() response[ 'error_message'] = 'Error during retrieval of information (Student Monitoring): ' + str( e.args[0]) return render( requests, "Module_TeamManagement/Student/ITOpsLabStudentMonitor.html", response) return render(requests, "Module_TeamManagement/Student/ITOpsLabStudentMonitor.html", response)
def student_Deploy_Standard_GetDeploymentPackages(requests): course_title = requests.GET.get('course_title') classObj = utilities.getStudentClassObject(requests, course_title) course_section = classObj.course_section dps = Deployment_Package.objects.filter(course_section=course_section) return render(requests, 'dataforms/deploymentpackage_student/dp_list_student.html', { 'dps': dps, 'course_title': course_title })
def student_Deploy_Standard_GetIPs(requests): course_title = requests.GET.get('course_title') classObj = utilities.getStudentClassObject(requests, course_title) credentialsObj = classObj.awscredential servers = [] if credentialsObj != None: servers = utilities.getAllServers(credentialsObj.account_number) return render(requests, 'dataforms/serverdetails/server_list.html', { 'servers': servers, 'course_title': course_title })