def config_canvas_settings(): ensure_settings() msg = "" auto_config_form = SQLFORM.factory( submit_button="OPE Auto Configure", _name="auto_config").process(formname="auto_config") if auto_config_form.accepted: # Try to auto config access_token, msg1 = Canvas.EnsureAdminAccessToken() if access_token != "": # Pull the canvas URL from the environment canvas_url = "" try: canvas_url = str(os.environ["CANVAS_SERVER"]).strip() + "" except KeyError as ex: # not set!! canvas_url = "" if canvas_url != "": AppSettings.SetValue('canvas_server_url', canvas_url) # Make sure to turn enable the canvas integration if it worked AppSettings.SetValue("canvas_import_enabled", True) response.flash = "Canvas integration auto configured and enabled" else: response.flash = "Unable to auto configure canvas integration!" + msg1 rows = db().select(db.my_app_settings.ALL) form = SQLFORM(db.my_app_settings, rows[0], showid=False, _name="canvas_config", fields=[ "canvas_import_enabled", "canvas_integration_enabled", "canvas_auto_create_courses", "canvas_access_token", "canvas_secret", "canvas_database_server_url", "canvas_database_password", "canvas_server_url", "canvas_student_quota", "canvas_faculty_quota", ]).process(formname="canvas_config") if form.accepted: # Saved response.flash = "Settings Saved!" Canvas.Close() pass elif form.errors: response.flash = "Error! " + str(form.errors) return dict(form=form, auto_config_form=auto_config_form, msg=msg)
def refresh_datasets(): ensure_settings() message = "" succeeded = False zfs_enabled = AppSettings.GetValue('zpool_enabled', False) zfs_ip = AppSettings.GetValue('zpool_server_address', '') zfs_user = AppSettings.GetValue('zpool_login_user', 'root') zfs_pass = AppSettings.GetValue('zpool_login_password', '') if not zfs_enabled: message = "ZFS Server Not Enabled - Check settings..." return dict(succeeded=succeeded, message=message) message = "Connecting (" + zfs_user + "@" + zfs_ip + ")..." try: ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(zfs_ip, username=zfs_user, password=zfs_pass) stdin, stdout, stderr = ssh.exec_command("zfs list -H -o name") lines = stdout.readlines() ssh.close() for line in lines: line = line.strip() if line == "": continue message += "\nFound Dataset: " + line if '.system' in line or 'freenas-boot' in line: message += " -- found system or boot dataset, skipping..." else: # Try to add this to the database if db(db.zpool_datasets.name == line).count() < 1: # Add it db.zpool_datasets.insert(name=line) else: # Skip it... message += " -- Already added..." db.commit() succeeded = True except Exception as e: message += "Error getting datasets: " + str(e) return dict(succeeded=succeeded, message=message)
def GetAD_CN(program): ad_cn = AppSettings.GetValue('ad_faculty_cn', 'OU=Faculty,DC=ad,DC=correctionsed,DC=com') if program == "" or program is None: # If no program, take off the program OU ret = ad_cn.replace('ou=', 'OU=') ret = ret.replace('OU=<program>,', '') else: ret = ad_cn.replace('<program>', program) return ret
def GetADQuota(faculty_id, override_quota=False): # Lookup the quota for this user or use the default db = current.db # Start with a default value quota = AppSettings.GetValue('ad_faculty_home_directory_quota', '1048576') # Query for the faculty value if override_quota is not True: rows = db(db.faculty_info.user_id == faculty_id).select(db.faculty_info.faculty_ad_quota) for row in rows: quota = row.faculty_ad_quota return str(quota)
def GetCanvasQuota(student_id, override_quota=False): # Lookup the quota for this user or use the default db = current.db # Start with a default value quota = AppSettings.GetValue('canvas_student_quota', '1048576') # Query for the student's value if override_quota is not True: rows = db(db.student_info.user_id == student_id).select( db.student_info.student_canvas_quota) for row in rows: quota = row.student_canvas_quota return str(quota)
def GetPassword(faculty_id, import_password="", override_password=False, row=None): db = current.db # Get current password if faculty exists so we don't # reset it if the faculty has already changed it unless override_password == True ret = import_password if override_password is not True: rows = db(db.faculty_info.user_id == faculty_id).select(db.faculty_info.faculty_password) for row2 in rows: ret = row2.faculty_password # If password isn't set, use the pattern and set the default pw # Default - add SID to beginning and ! to end (e.g. SID1888182!) if ret == "": pattern = AppSettings.GetValue('faculty_password_pattern', 'FID<user_id>!') ret = Faculty.process_config_params(faculty_id, pattern, row=row) return str(ret)
def GetUsername(faculty_id, row=None): db = current.db ret = "" # Try to get the real (current) username for this id row = db(db.faculty_info.user_id.like(faculty_id)).select().first() if row: # Got the faculty record, get the matching user id user_name = row.account_id.username if user_name is not None and user_name != "": #print("Found real user name: " + user_name) ret = user_name # Unable to find that, return the default pattern if ret == "": pattern = AppSettings.GetValue('faculty_id_pattern', '<user_id>') ret = Faculty.process_config_params(faculty_id, pattern, is_username=True, row=row) return str(ret)
def QueueCanvasImports(sheet_name): db = current.db # Grab the current db object count = 0 # The number of entries processed canvas_enabled = AppSettings.GetValue('canvas_import_enabled', False) if canvas_enabled is not True: return count # Clear the queue and add an entry in the queue table for # each faculty db.executesql('DELETE FROM faculty_canvas_import_queue;') db.executesql('DELETE FROM faculty_canvas_import_status;') rows = db(db.faculty_import_queue.sheet_name==sheet_name).select(db.faculty_import_queue.id) for row in rows: count += 1 db.faculty_canvas_import_queue.insert(faculty_import_queue=row['id']) return count
def verify_ope_account_in_smc(): response.view = 'generic.json' db = current.db student_full_name = "" msg = "" user_name = None laptop_admin_user = "" laptop_admin_password = "" # Get the student user in question if len(request.args) > 0: user_name = request.args[0] else: msg = "No username specified!" # See if user exists in SMC if user_name is not None: # First - does the user exist? user_exists = False rows = db(db.auth_user.username == user_name).select( db.auth_user.id, db.auth_user.first_name, db.auth_user.last_name) for row in rows: user_exists = True if user_exists is True: student_full_name = str(row["last_name"]) + ", " + str( row["first_name"]) msg = "Found" else: # User doesn't exit! msg = "Invalid User! - User name is CASE SENSITIVE - verify that you typed it exactly as it is in the system." if msg == "Found": # Pull the laptop admin info laptop_admin_user = AppSettings.GetValue("laptop_admin_user", "") # Moved pw to credential area laptop_admin_password = "******" # AppSettings.GetValue("laptop_admin_password", "") smc_version = get_app_version() return dict(msg=msg, student_full_name=student_full_name, laptop_admin_user=laptop_admin_user, laptop_admin_password=laptop_admin_password, smc_version=smc_version)
def QueueActiveDirectoryImports(sheet_name): db = current.db # Grab the current db object count = 0 # The number of entries processed ldap_enabled = AppSettings.GetValue('ad_import_enabled', False) if ldap_enabled is not True: return count # Clear the queue and add an entry in the queue table for # each student db.executesql('DELETE FROM student_ad_import_queue;') db.executesql('DELETE FROM student_ad_import_status;') rows = db(db.student_import_queue.sheet_name == sheet_name).select( db.student_import_queue.id) for row in rows: count += 1 db.student_ad_import_queue.insert(student_import_queue=row['id']) return count
def GetProfilePath(student_id): # Default - nothing (off) pattern = AppSettings.GetValue('ad_student_profile_directory', '') ret = Student.process_config_params(student_id, pattern) return str(ret)
def GetLoginScriptPath(student_id): # Default - nothing (off) pattern = AppSettings.GetValue('ad_student_login_script_path', '') ret = Student.process_config_params(student_id, pattern) return str(ret)
def GetHomeDrive(student_id): # Default - nothing (off) pattern = AppSettings.GetValue('ad_student_home_drive', '') ret = Student.process_config_params(student_id, pattern) return str(ret)
def GetHomeDirectory(student_id): # Default - "" # \\files\students\%username% pattern = AppSettings.GetValue('ad_student_home_directory', '') ret = Student.process_config_params(student_id, pattern) return str(ret)
def GetEmail(student_id, row=None): # Default -Prepend user_name @domain.com (e.g. [email protected]) pattern = AppSettings.GetValue('student_email_pattern', '<user_name>@correctionsed.com') ret = Student.process_config_params(student_id, pattern, row=row) return str(ret)
def ProcessADFaculty(): db = current.db # Grab the current db object scheduler = current.scheduler ret = "" ldap_enabled = AppSettings.GetValue('ad_import_enabled', False) if ldap_enabled is not True: return "Done! - LDAP Import Disabled" if AD.Connect() is not True: ret += "<b>Error connecting to Active Directory server</b><br/><font size=-4>" ret += AD.GetErrorString() ret += "</font><br/>Done!" return ret if AD.VerifyADSettings() is not True: ret += "<b>Error verifying AD settings</b><br/><font size=-4>" ret += AD.GetErrorString() ret += "</font><br/>Done!" return ret else: # If everything is good clear errors AD._errors = [] ad_faculty_group_cn = AppSettings.GetValue('ad_faculty_group_cn', 'OU=FacultyGroups,DC=ad,DC=correctionsed,DC=com') ad_faculty_group_dn = 'CN=Faculty,' + ad_faculty_group_cn # Ensure the faculty group exists if AD.CreateGroup(ad_faculty_group_dn) is not True: ret += "<b>Error creating faculty group:</b> " + str(ad_faculty_group_dn) + "<br />" ret += str(AD._errors) # Grab the first faculty off the queue rows = db(db.faculty_import_queue.id == db.faculty_ad_import_queue.faculty_import_queue)\ .select(orderby=db.faculty_import_queue.account_enabled|db.faculty_import_queue.faculty_name, limitby=(0, 1)) for row in rows: # Pop the faculty off the queue db(db.faculty_ad_import_queue.id == row.faculty_ad_import_queue.id).delete() db.commit() # Get the faculty info faculty_user_name = Faculty.GetUsername(row.faculty_import_queue.user_id) faculty_password = Faculty.GetPassword(row.faculty_import_queue.user_id, row.faculty_import_queue.faculty_password) (faculty_first_name, faculty_last_name) = Util.ParseName(row.faculty_import_queue.faculty_name) faculty_email = Faculty.GetEmail(row.faculty_import_queue.user_id) faculty_display_name = row.faculty_import_queue.faculty_name + " (" + faculty_user_name + ")" faculty_user_id = row.faculty_import_queue.user_id faculty_home_directory = Faculty.GetHomeDirectory(row.faculty_import_queue.user_id) faculty_home_drive = Faculty.GetHomeDrive(row.faculty_import_queue.user_id) faculty_login_script_path = Faculty.GetLoginScriptPath(row.faculty_import_queue.user_id) faculty_profile_path = Faculty.GetProfilePath(row.faculty_import_queue.user_id) faculty_enabled = row.faculty_import_queue.account_enabled faculty_quota = Faculty.GetADQuota(row.faculty_import_queue.user_id) faculty_dn = Faculty.GetAD_DN(faculty_user_name, row.faculty_import_queue.program) faculty_cn = Faculty.GetAD_CN(row.faculty_import_queue.program) first_run = False fr = db(db.faculty_ad_import_status.user_id==row.faculty_import_queue.user_id).select().first() if fr is None: first_run = True db.faculty_ad_import_status.insert(user_id=row.faculty_import_queue.user_id) db.commit() # Create the faculty if AD.CreateUser(faculty_user_name, faculty_cn) is not True: ret += "<b>Error creating faculty account:</b> " + str(faculty_user_name) + " - " + str(faculty_cn) +\ "<br />Done!" # + AD.GetErrorString() return ret db.commit() # Update user with current info if AD.UpdateUserInfo(faculty_dn, email_address=faculty_email, first_name=faculty_first_name, last_name=faculty_last_name, display_name=faculty_display_name, description="Faculty Account", id_number=faculty_user_name, home_drive_letter=faculty_home_drive, home_directory=faculty_home_directory, login_script=faculty_login_script_path, profile_path=faculty_profile_path, ts_allow_login='******') is not True: ret += "<b>Error creating setting faculty information:</b> " + str(faculty_user_name) + "<br />" db.commit() # Set password if AD.SetPassword(faculty_dn, faculty_password) is not True: ret += "<b>Error setting password for user:</b> " + str(faculty_user_name) + "<br />" db.commit() # Add to the faculty group if AD.AddUserToGroup(faculty_dn, ad_faculty_group_dn) is not True: ret += "<b>Error adding user to faculty group:</b> " + str(faculty_user_name) + "<br />" db.commit() if faculty_enabled is True: AD.EnableUser(faculty_dn) else: AD.DisableUser(faculty_dn) db.commit() # NOTE - We do NOT want to remove faculty from anything automatically # Get the list of classes for this faculty if faculty_enabled is True: enroll_classes = row.faculty_import_queue.import_classes.split(',') for enroll_class in enroll_classes: # Trim spaces enroll_class = enroll_class.strip() if enroll_class == '': continue # Skip empty class names # ret += "Enrolling into: " + enroll_class Faculty.AddClass(row.faculty_import_queue.user_id, enroll_class) class_dn = AD.GetDN(enroll_class + "-F", ad_faculty_group_cn) if AD.GetLDAPObject(class_dn) is None: # Class group doesn't exist, add it if AD.CreateGroup(class_dn) is not True: ret += "<b>Error creating class group:</b> " + str(enroll_class) + "<br />" # Add faculty to the class group if AD.AddUserToGroup(faculty_dn, class_dn) is not True: ret += "<b>Error adding faculty to group:</b> " + str(faculty_user_name) +\ "/" + str(enroll_class) + "<br />" db.commit() # Setup physical home directory if faculty_enabled is True: # if (AD.CreateHomeDirectory(faculty_user_name, faculty_home_directory) != True): # ret += "<b>Error creating home folder:</b> " + str(faculty_user_name) + "<br />" if first_run: result = scheduler.queue_task('create_home_directory', pvars=dict(user_name=faculty_user_name, home_directory=faculty_home_directory), timeout=1200, immediate=True, sync_output=5, group_name="create_home_directory") if AD.SetDriveQuota(faculty_user_name, faculty_quota) is not True: ret += "<b>Error setting quota for faculty:</b> " + str(faculty_user_name) + "<br />" db.commit() # Show errors if len(AD._errors) > 0: ret += AD.GetErrorString() ret += faculty_display_name # + " (" + faculty_user_name + ")" if row.faculty_import_queue.account_enabled is True: ret += " - <span style='color: green; font-weight: bolder;'>Imported</span>" else: ret += " - <span style='color: red; font-weight: bolder;'>Disabled</span>" # Finished importing, clean up after AD AD.Close() if ret == "": ret = "Done!" return ret
def GetEmail(faculty_id, row=None): # Default - append username and @domain.com (e.g. [email protected]) pattern = AppSettings.GetValue('faculty_email_pattern', '<user_name>@correctionsed.com') ret = Faculty.process_config_params(faculty_id, pattern, row=row) return str(ret)
def GetProfilePath(faculty_id): # Default - nothing (off) pattern = AppSettings.GetValue('ad_faculty_profile_directory', '') ret = Faculty.process_config_params(faculty_id, pattern) return str(ret)
def GetLoginScriptPath(faculty_id): # Default - nothing (off) pattern = AppSettings.GetValue('ad_faculty_login_script_path', '') ret = Faculty.process_config_params(faculty_id, pattern) return str(ret)
def GetHomeDrive(faculty_id): # Default - nothing (off) pattern = AppSettings.GetValue('ad_faculty_home_drive', '') ret = Faculty.process_config_params(faculty_id, pattern) return str(ret)
def GetHomeDirectory(faculty_id): # Default - is empty # \\files\faculty\%username% pattern = AppSettings.GetValue('ad_faculty_home_directory', '') ret = Faculty.process_config_params(faculty_id, pattern) return str(ret)
def ProcessADStudent(): db = current.db # Grab the current db object scheduler = current.scheduler ret = "" # AD.Close() ldap_enabled = AppSettings.GetValue('ad_import_enabled', False) if ldap_enabled is not True: return "Done! - LDAP Import Disabled" if AD.Connect() is not True: ret += "<b>Error connecting to Active Directory server</b><br/><font size=-4>" ret += AD.GetErrorString() ret += "</font><br/>Done!" return ret if AD.VerifyADSettings() is not True: ret += "<b>Error verifying AD settings</b><br/><font size=-4>" ret += AD.GetErrorString() ret += "</font><br/>Done!" return ret else: # If everything is good clear errors AD._errors = [] # ad_student_cn = AppSettings.GetValue('ad_student_cn', 'OU=Students,DC=ad,DC=correctionsed,DC=com') ad_student_group_cn = AppSettings.GetValue( 'ad_student_group_cn', 'OU=StudentGroups,DC=ad,DC=correctionsed,DC=com') ad_student_group_dn = 'CN=Students,' + ad_student_group_cn # Ensure the student group exists if AD.CreateGroup(ad_student_group_dn) is not True: ret += "<b>Error creating students group:</b> " + str( ad_student_group_dn) + "<br />" ret += str(AD._errors) # Grab the first student off the queue rows = db(db.student_import_queue.id == db.student_ad_import_queue.student_import_queue)\ .select(orderby=db.student_import_queue.account_enabled|db.student_import_queue.student_name, limitby=(0, 1)) for row in rows: # Pop the student off the queue db(db.student_ad_import_queue.id == row.student_ad_import_queue.id).delete() db.commit() # Get the student info # Get info for current student student_user_name = Student.GetUsername( row.student_import_queue.user_id) student_password = Student.GetPassword( row.student_import_queue.user_id, row.student_import_queue.student_password) (student_first_name, student_last_name) = Util.ParseName( row.student_import_queue.student_name) student_email = Student.GetEmail(row.student_import_queue.user_id) student_display_name = row.student_import_queue.student_name + " (" + student_user_name + ")" student_user_id = row.student_import_queue.user_id student_home_directory = Student.GetHomeDirectory( row.student_import_queue.user_id) student_home_drive = Student.GetHomeDrive( row.student_import_queue.user_id) student_login_script_path = Student.GetLoginScriptPath( row.student_import_queue.user_id) student_profile_path = Student.GetProfilePath( row.student_import_queue.user_id) student_enabled = row.student_import_queue.account_enabled student_quota = Student.GetADQuota( row.student_import_queue.user_id) student_dn = Student.GetAD_DN(student_user_name, row.student_import_queue.program) student_cn = Student.GetAD_CN(row.student_import_queue.program) first_run = False fr = db(db.student_ad_import_status.user_id == row.student_import_queue.user_id).select().first() if fr is None: first_run = True db.student_ad_import_status.insert( user_id=row.student_import_queue.user_id) db.commit() # print("Student Info: ") # print(" -> User Name: " + str(student_user_name)) # print(" -> Password: "******" -> First Name: " + str(student_first_name)) # print(" -> Last Name: " + str(student_last_name)) # print(" -> Email: " + str(student_email)) # print(" -> Display Name: " + str(student_display_name)) # print(" -> ID: " + str(student_user_id)) # print(" -> Home Dir: " + str(student_home_directory)) # print(" -> Home Drive: " + str(student_home_drive)) # print(" -> Login Script: " + str(student_login_script_path)) # print(" -> Profile Path: " + str(student_profile_path)) # print(" -> Enabled: " + str(student_enabled)) # print(" -> Quota: " + str(student_quota)) # print(" -> AD DN: " + str(student_dn)) # print(" -> AD CN: " + str(student_cn)) # Create the student if AD.CreateUser(student_user_name, student_cn) is not True: ret += "<b>Error creating students account:</b> " + str(student_user_name) +\ " - " + str(student_cn) + "<br />Done!" return ret db.commit() # Update user with current info if AD.UpdateUserInfo(student_dn, email_address=student_email, first_name=student_first_name, last_name=student_last_name, display_name=student_display_name, description="Student Account", id_number=student_user_name, home_drive_letter=student_home_drive, home_directory=student_home_directory, login_script=student_login_script_path, profile_path=student_profile_path, ts_allow_login='******') is not True: ret += "<b>Error creating setting student information:</b> " + str( student_user_name) + "<br />" db.commit() # Set password if AD.SetPassword(student_dn, student_password) is not True: ret += "<b>Error setting password for user:</b> " + str( student_user_name) + "<br />" db.commit() # Add to the students group if AD.AddUserToGroup(student_dn, ad_student_group_dn) is not True: ret += "<b>Error adding user to students group:</b> " + str( student_user_name) + "<br />" db.commit() if student_enabled is True: AD.EnableUser(student_dn) else: AD.DisableUser(student_dn) db.commit() # Get the list of classes for this student if student_enabled is True: enroll_classes = row.student_import_queue.import_classes.split( ',') for enroll_class in enroll_classes: # Trim spaces enroll_class = enroll_class.strip() if enroll_class == '': continue # Skip empty class names Student.AddClass(row.student_import_queue.user_id, enroll_class) class_dn = AD.GetDN(enroll_class, ad_student_group_cn) if AD.GetLDAPObject(class_dn) is None: # Class group doesn't exist, add it if AD.CreateGroup(class_dn) is not True: ret += "<b>Error creating class group:</b> " + str( enroll_class) + "<br />" # Add student to the class group if AD.AddUserToGroup(student_dn, class_dn) is not True: ret += "<b>Error adding student to group:</b> " + str(student_user_name) + "/" +\ str(enroll_class) + "<br />" db.commit() # Setup physical home directory if student_enabled is True: # if (AD.CreateHomeDirectory(student_user_name, student_home_directory) != True): # ret += "<b>Error creating home folder:</b> " + str(student_user_name) + "<br />" if first_run: result = scheduler.queue_task( 'create_home_directory', pvars=dict(user_name=student_user_name, home_directory=student_home_directory), timeout=1200, immediate=True, sync_output=5, group_name="create_home_directory") if AD.SetDriveQuota(student_user_name, student_quota) is not True: ret += "<b>Error setting quota for student:</b> " + str( student_user_name) + "<br />" db.commit() # Show errors if len(AD._errors) > 0: ret += AD.GetErrorString() ret += student_display_name # + " (" + student_user_name + ")" if row.student_import_queue.account_enabled is True: ret += " - <span style='color: green; font-weight: bolder;'>Imported</span>" else: ret += " - <span style='color: red; font-weight: bolder;'>Disabled</span>" if ret == "": ret = "Done!" return ret
def credential_student(): response.view = 'generic.json' db = current.db key = "" msg = "" hash = "" user_name = None full_name = "" laptop_admin_password = "" admin_hash = "" canvas_url = AppSettings.GetValue('canvas_server_url', 'https://canvas.ed') # Get the user in question if len(request.args) > 0: user_name = request.args[0] if user_name is not None: # First - does the user exist? user_exists = False rows = db(db.auth_user.username == user_name).select(db.auth_user.id) for row in rows: user_exists = True if user_exists is True: key, msg, hash, full_name = Canvas.EnsureStudentAccessToken( user_name) # Turn bytes into string so it sends over json better if isinstance(hash, bytes): try: hash = hash.decode('utf-8') except Exception as ex: hash = "ERROR DECODING HASH!!!" # Encode admin hash laptop_admin_password = AppSettings.GetValue( "laptop_admin_password", "") admin_hash = Util.encrypt(laptop_admin_password, key) laptop_admin_password = "" # Clear when done # Turn bytes into string so it sends over json better if isinstance(admin_hash, bytes): try: admin_hash = admin_hash.decode("utf-8") except Exception as ex: admin_hash = "ERROR DECODING HASH!!!" # All is good, if there is an ex_info param, then pull data out # of it and put it in the ope_laptops data table #print(request.vars) try: info = request.vars["ex_info"] if info is not None: print("Saving posted credential information.") record = db((db.ope_laptops.bios_serial_number == info["bios_serial_number"]) & (db.ope_laptops.current_student == info["current_student"])).select().first() if record is None: # No record, add one db.ope_laptops.insert( bios_serial_number=info["bios_serial_number"], boot_disk_serial_number=info[ "disk_boot_drive_serial_number"], current_student=info["current_student"], admin_user=info["admin_user"], credentialed_by_user=info["logged_in_user"], last_sync_date=request.now, bios_name=info["bios_name"], bios_version=info["bios_version"], bios_manufacturer=info["bios_manufacturer"], admin_password_status=info[ "cs_admin_password_status"], extra_info=json.dumps(info), laptop_version=info["mgmt_version"], ) else: # Update existing record record.update_record( #bios_serial_number=info["bios_serial_number"], boot_disk_serial_number=info[ "disk_boot_drive_serial_number"], #current_student=info["current_student"], admin_user=info["admin_user"], credentialed_by_user=info["logged_in_user"], last_sync_date=request.now, bios_name=info["bios_name"], bios_version=info["bios_version"], bios_manufacturer=info["bios_manufacturer"], admin_password_status=info[ "cs_admin_password_status"], extra_info=json.dumps(info), laptop_version=info["mgmt_version"], ) db.commit() except Exception as ex: print("ERROR - Invalid json post!\n" + str(ex)) else: # User doesn't exit! msg = "Invalid User!" return dict(key=key, msg=msg, hash=hash, full_name=full_name, canvas_url=canvas_url, admin_hash=admin_hash)