# Path: modules/fflock_globals.py
# DATABASE_HOST = "192.168.206.133"
# DATABASE_PORT = 3306
# DATABASE_USER = "fflock"
# DATABASE_PASSWD = "fflock"
# DATABASE_NAME = "fflock"
# ENCODER = "ffmpeg"
# NFS_PATH = ""
# SLAVE_MOUNT_PREFIX_PATH = ""
# S3ID = ""
# S3KEY = ""
# S3BUCKET = ""
# CONFIG_FILE = ""
# FETCH_RETRIES = 3
# 
# Path: modules/fflock_utility.py
# def dbconnect():
# def local_ip_address():
# def public_ip_address():
# def ping(address):
# def clear():
# def get_uuid():
# def getFps(file):
# def getTotalFrames(file, fps):
# def ensure_dir(path, storageuuid):
# def get_storage_nfs_folder_path(storageuuid):
# def check_dependencies(jobuuid):
# def remove_dependency_jobs(jobuuid):
# def job_cleanup(jobuuid, storageuuid, masteruuid, jobinput, joboutput):
# def number_of_registered_slaves():
# def number_of_connected_slaves(storageuuid):
# def find_server_storage_UUIDs(serveruuid):
# def find_master_UUID_for_job(uuid):
# def find_job_options_for_job(uuid):
# def find_storage_UUID_for_job():
# def find_server_for_storage_job():
# def find_server_for_slave_job():
# def download_file_http(url, filename):
# def download_file_ftp(url, filename):
# def upload_file_ftp(source, destination):
# def download_file_s3(url, filename):
# def upload_file_s3(source, destination):
# def parse_config_file(configfile, type):
# def submit_job(jobuuid, jobtype, jobsubtype, command, commandpreoptions, commandoptions, input, output, dependencies,
#                masteruuid, joboptions):


import sys
import os
import datetime
from modules import fflock_globals
from modules import fflock_utility
from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
from gluon.contrib.login_methods.rpx_account import use_janrain
mail.settings.login = 'username:password'

## configure auth policy
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True

## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc.
## register with janrain.com, write your domain:api_key in private/janrain.key
use_janrain(auth, filename='private/janrain.key')

#########################################################################
## Define your tables below (or better in another model file) for example
##
## >>> db.define_table('mytable',Field('myfield','string'))
##
## Fields can be 'string','text','password','integer','double','boolean'
##       'date','time','datetime','blob','upload', 'reference TABLENAME'
## There is an implicit 'id integer autoincrement' field
## Consult manual for more options, validators, etc.
##
## More API examples for controllers:
##
## >>> db.mytable.insert(myfield='value')
## >>> rows=db(db.mytable.myfield=='value').select(db.mytable.ALL)
## >>> for row in rows: print row.id, row.myfield
#########################################################################

db.define_table(
    'Servers',

# Path: modules/fflock_globals.py
# DATABASE_HOST = "192.168.206.133"
# DATABASE_PORT = 3306
# DATABASE_USER = "fflock"
# DATABASE_PASSWD = "fflock"
# DATABASE_NAME = "fflock"
# ENCODER = "ffmpeg"
# NFS_PATH = ""
# SLAVE_MOUNT_PREFIX_PATH = ""
# S3ID = ""
# S3KEY = ""
# S3BUCKET = ""
# CONFIG_FILE = ""
# FETCH_RETRIES = 3
# 
# Path: modules/fflock_utility.py
# def dbconnect():
# def local_ip_address():
# def public_ip_address():
# def ping(address):
# def clear():
# def get_uuid():
# def getFps(file):
# def getTotalFrames(file, fps):
# def ensure_dir(path, storageuuid):
# def get_storage_nfs_folder_path(storageuuid):
# def check_dependencies(jobuuid):
# def remove_dependency_jobs(jobuuid):
# def job_cleanup(jobuuid, storageuuid, masteruuid, jobinput, joboutput):
# def number_of_registered_slaves():
# def number_of_connected_slaves(storageuuid):
# def find_server_storage_UUIDs(serveruuid):
# def find_master_UUID_for_job(uuid):
# def find_job_options_for_job(uuid):
# def find_storage_UUID_for_job():
# def find_server_for_storage_job():
# def find_server_for_slave_job():
# def download_file_http(url, filename):
# def download_file_ftp(url, filename):
# def upload_file_ftp(source, destination):
# def download_file_s3(url, filename):
# def upload_file_s3(source, destination):
# def parse_config_file(configfile, type):
# def submit_job(jobuuid, jobtype, jobsubtype, command, commandpreoptions, commandoptions, input, output, dependencies,
#                masteruuid, joboptions):


# Path: web2py/applications/fflock/models/db.py
import sys
import os
import datetime
from modules import fflock_globals
from modules import fflock_utility
from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
from gluon.contrib.login_methods.rpx_account import use_janrain

mail.settings.login = 'username:password'

## configure auth policy
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True

## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc.
## register with janrain.com, write your domain:api_key in private/janrain.key
use_janrain(auth, filename='private/janrain.key')

#########################################################################
## Define your tables below (or better in another model file) for example
##
## >>> db.define_table('mytable',Field('myfield','string'))
##
## Fields can be 'string','text','password','integer','double','boolean'
##       'date','time','datetime','blob','upload', 'reference TABLENAME'
## There is an implicit 'id integer autoincrement' field
## Consult manual for more options, validators, etc.
##
## More API examples for controllers:
##
## >>> db.mytable.insert(myfield='value')
## >>> rows=db(db.mytable.myfield=='value').select(db.mytable.ALL)
## >>> for row in rows: print row.id, row.myfield
#########################################################################

db.define_table(
    'Servers',

    Field('UUID', 'string'),