def remove(nfs_id): removeString = """ - hosts: web tasks: - command: sudo umount -l /nfs-share/{0} - lvol: vg: vg1 lv: {0} state: absent force: yes """.format(nfs_id) ansibleProg = open("/Arcus/public/tmp/nfs/remove.yaml", "w") ansibleProg.write(removeString) ansibleProg.close() ansF = commands.getstatusoutput( "sudo ansible-playbook /Arcus/public/tmp/nfs/remove.yaml") if (ansF[0] == 0): mountF = commands.getstatusoutput( "sudo sshpass -p {0} ssh -o stricthostkeychecking=no -l root {1} sudo rm -rf /nfs-share/{2}" .format("redhat", "192.168.43.171", nfs_id)) sql = "DELETE FROM nfs WHERE id={0}".format(nfs_id) try: cursor.execute(sql) db.commit() print("Location:/activity.py\r\n\r\n") except: header.header_content() print("can not delete entry") db.rollback() else: header.header_content() print("<pre> " + ansF[1] + " </pre>")
try: cursor.execute(query) db.commit() last = cursor.lastrowid c = Cookie.SimpleCookie() c['id'] = last print c if('HTTP_REFERER' in os.environ): print("Location:{0}\r\n\r\n". format(os.environ['HTTP_REFERER'])) else: print("Location:/") #print "" except: header.header_content() print("Username already exist.") db.rollback() else: query = "SELECT * FROM users WHERE username = '******'". format(username) try: cursor.execute(query) results = cursor.fetchone() if(results>0 and password == results[2]): c = Cookie.SimpleCookie() c['id'] = results[0] print c print("Location:{0}\r\n\r\n". format(os.environ['HTTP_REFERER'])) else: