Ejemplo n.º 1
0
def create_project_from_filebrowser(username, password, project_name):
    if database_update.project_exists(username, password, project_name):
        return False, "Project: %s already exists! try another name and try again" % project_name

    database_update.create_project(username, password, project_name, "create from filebrowser")

    return create_project_from_file(username, password, project_name)
Ejemplo n.º 2
0
def create_project_from_file_browser(username, project_name):
    if database_update.project_exists(username, project_name):
        return False, "Project: %s already exists! try another name and try again" % project_name

    url = "create from file browser"
    database_update.create_project(username, project_name, url)

    return create_project_from_file(username, project_name)
Ejemplo n.º 3
0
def create_project_from_table(username, project_name, table):
    if database_update.project_exists(username, project_name):
        return False, "Project: %s already exists! try another name and try again" % project_name

    if os.path.exists('%s/%s/%s' % (config.base_path, username, project_name)):
        return False, "File: %s already exists! try another name and try again" % project_name

    os.mkdir("%s/%s/%s" % (config.base_path, username, project_name))
    project_path = config.base_path + '/' + username + '/' + project_name

    database_update.create_project(username, project_name, 'create from table')

    return create_project_exceptions(username, project_path, table, project_name, 'table')
Ejemplo n.º 4
0
def create_project_from_table(username, project_name, table):
    if database_update.project_exists(username, project_name):
        return False, "Project: %s already exists! try another name and try again" % project_name

    if os.path.exists('%s/%s/%s' % (config.base_path, username, project_name)):
        return False, "File: %s already exists! try another name and try again" % project_name

    os.mkdir("%s/%s/%s" % (config.base_path, username, project_name))
    project_path = config.base_path + '/' + username + '/' + project_name

    database_update.create_project(username, project_name, 'create from table')

    return create_project_exceptions(username, project_path, table,
                                     project_name, 'table')
Ejemplo n.º 5
0
def create_project_from_url(username, password, project_name, url):
    if database_update.project_exists(username, password, project_name):
        return False, "Project: %s already exists! try another name and try again" % project_name

    if os.path.exists('%s/%s/%s' % (config.base_path, username, project_name)):
        return False, "File: %s already exists! try another name and try again" % project_name

    os.mkdir("%s/%s/%s" % (config.base_path, username, project_name))
    project_path = config.base_path + '/' + username + '/' + project_name

    try:
        Repo.clone_from(url, project_path)
    except GitCommandError as e:
        shutil.rmtree(project_path)
        return False, "gitcommanderror, please check url: %s" % url
    except:
        return False, "git clone error, please connect administrator for information"

    database_update.create_project(username, password, project_name, url)

    return create_project_from_file(username, password, project_name)
Ejemplo n.º 6
0
def create_project_from_url(username, project_name, url):
    if database_update.project_exists(username, project_name):
        return False, "Project: %s already exists! try another name and try again" % project_name

    if os.path.exists('%s/%s/%s' % (config.base_path, username, project_name)):
        return False, "File: %s already exists! try another name and try again" % project_name

    os.mkdir("%s/%s/%s" % (config.base_path, username, project_name))
    project_path = config.base_path + '/' + username + '/' + project_name

    try:
        Repo.clone_from(url, project_path)
    except GitCommandError:
        shutil.rmtree(project_path)
        return False, "git command error, please check url: %s" % url
    # except:
    #     return False, "git clone error, please connect administrator for information"

    database_update.create_project(username, project_name, url)

    return create_project_from_file(username, project_name)
Ejemplo n.º 7
0
from orchestration.database import database_update
# import MySQLdb
# from orchestration import config

config = {'name': 'hello', 'scale': 2}
# if __name__ == '__main__':
# ip_list = ['114.212.189.147:2376', '114.212.189.140:2376']
# database_update.create_machine(ip_list)
# database_update.create_user('test', '*****@*****.**')
# database_update.create_project()
database_update.create_project('test', 'project', '*****@*****.**')
# print database_update.get_machine()
print database_update.project_list('test', 0, 2)
print database_update.project_exists('test', 'project')
print database_update.project_exists('test', 'projects')
database_update.create_service('test', 'project', 'service', config, 2)
print database_update.service_list('test', 'project')
database_update.create_container('test', 'project', 'service', 'service0',
                                 '114.212.189.147:2376')
print database_update.container_list('test', 'project', 'service')
print database_update.container_ip('test', 'project', 'service', 'service0')
# print database_update.delete_container_by_name('test', 'project', 'service', 'service0')
print database_update.container_list('test', 'project', 'service')
# print database_update.service_list('test', 'project')
# print database_update.project_list('test', 0, 2)
# database_update.delete_project('test', 'project')
print database_update.project_list('test', 0, 10)

# db = MySQLdb.connect(config.database_url, config.database_user, config.database_passwd, config.database)
# cursor = db.cursor()
# cursor.execute("select name from user")
Ejemplo n.º 8
0
from orchestration.database import database_update
# import MySQLdb
# from orchestration import config

config = {'name': 'hello', 'scale': 2}
# if __name__ == '__main__':
    # ip_list = ['114.212.189.147:2376', '114.212.189.140:2376']
    # database_update.create_machine(ip_list)
    # database_update.create_user('test', '*****@*****.**')
    # database_update.create_project()
database_update.create_project('test', 'project', '*****@*****.**')
    # print database_update.get_machine()
print database_update.project_list('test', 0, 2)
print database_update.project_exists('test', 'project')
print database_update.project_exists('test', 'projects')
database_update.create_service('test', 'project', 'service', config, 2)
print database_update.service_list('test', 'project')
database_update.create_container('test', 'project', 'service', 'service0', '114.212.189.147:2376')
print database_update.container_list('test', 'project', 'service')
print database_update.container_ip('test', 'project', 'service', 'service0')
# print database_update.delete_container_by_name('test', 'project', 'service', 'service0')
print database_update.container_list('test', 'project', 'service')
    # print database_update.service_list('test', 'project')
    # print database_update.project_list('test', 0, 2)
# database_update.delete_project('test', 'project')
print database_update.project_list('test', 0, 10)

# db = MySQLdb.connect(config.database_url, config.database_user, config.database_passwd, config.database)
# cursor = db.cursor()
# cursor.execute("select name from user")
#