import sys if sys.path[0].endswith("master"): sys.path[0] = sys.path[0][:-6] from flask import Flask, request # must first init loadenv from utils import tools, env # default CONFIG=/opt/docklet/local/docklet-running.conf config = env.getenv("CONFIG") tools.loadenv(config) # second init logging # must import logger after initlogging, ugly from utils.log import initlogging initlogging("docklet-master") from utils.log import logger import os import http.server, cgi, json, sys, shutil, traceback import xmlrpc.client from socketserver import ThreadingMixIn from utils import etcdlib, imagemgr from master import nodemgr, vclustermgr, notificationmgr, lockmgr, cloudmgr, jobmgr, taskmgr from utils.logs import logs from master import userManager, beansapplicationmgr, monitor, sysmgr, network, releasemgr from worker.monitor import History_Manager import threading import requests from utils.nettools import portcontrol
this_folder = os.path.realpath(os.path.abspath(os.path.split(inspect.getfile(inspect.currentframe()))[0])) src_folder = os.path.realpath(os.path.abspath(os.path.join(this_folder,"..", "src"))) if src_folder not in sys.path: sys.path.insert(0, src_folder) from utils import tools, env config = env.getenv("CONFIG") tools.loadenv(config) masterips = env.getenv("MASTER_IPS").split(",") G_masterips = [] for masterip in masterips: G_masterips.append(masterip.split("@")[0] + ":" + str(env.getenv("MASTER_PORT"))) # must first init loadenv from utils.log import initlogging initlogging("docklet-user") from utils.log import logger from flask import Flask, request, session, render_template, redirect, send_from_directory, make_response, url_for, abort from functools import wraps from master import userManager,beansapplicationmgr, notificationmgr, lockmgr import threading,traceback from utils.model import User,db from httplib2 import Http from urllib.parse import urlencode from master.settings import settings from master.bugreporter import send_bug_mail external_login = env.getenv('EXTERNAL_LOGIN') if(external_login == 'TRUE'): from userDependence import external_auth
#!/usr/bin/python3 import sys if sys.path[0].endswith("worker"): sys.path[0] = sys.path[0][:-6] from utils import env, tools config = env.getenv("CONFIG") #config = "/opt/docklet/local/docklet-running.conf" tools.loadenv(config) from utils.log import initlogging initlogging("docklet-taskcontroller") from utils.log import logger from concurrent import futures import grpc #from utils.log import logger #from utils import env import json,lxc,subprocess,threading,os,time,traceback from utils import imagemgr,etcdlib,gputools from utils.lvmtool import sys_run from worker import ossmounter from protos import rpc_pb2, rpc_pb2_grpc _ONE_DAY_IN_SECONDS = 60 * 60 * 24 MAX_RUNNING_TIME = _ONE_DAY_IN_SECONDS def ip_to_int(addr): [a, b, c, d] = addr.split('.') return (int(a)<<24) + (int(b)<<16) + (int(c)<<8) + int(d) def int_to_ip(num): return str((num>>24)&255)+"."+str((num>>16)&255)+"."+str((num>>8)&255)+"."+str(num&255)
import sys if sys.path[0].endswith("master"): sys.path[0] = sys.path[0][:-6] from flask import Flask, request # must first init loadenv from utils import tools, env # default CONFIG=/opt/docklet/local/docklet-running.conf config = env.getenv("CONFIG") tools.loadenv(config) # second init logging # must import logger after initlogging, ugly from utils.log import initlogging initlogging("docklet-master") from utils.log import logger import os import http.server, cgi, json, sys, shutil, traceback import xmlrpc.client from socketserver import ThreadingMixIn from utils import etcdlib, imagemgr from master import nodemgr, vclustermgr, notificationmgr, lockmgr, cloudmgr, jobmgr, taskmgr from utils.logs import logs from master import userManager, beansapplicationmgr, monitor, sysmgr, network from worker.monitor import History_Manager import threading import requests from utils.nettools import portcontrol
#!/usr/bin/python3 import sys if sys.path[0].endswith("worker"): sys.path[0] = sys.path[0][:-6] from utils import env, tools config = env.getenv("CONFIG") #config = "/opt/docklet/local/docklet-running.conf" tools.loadenv(config) from utils.log import initlogging initlogging("docklet-taskcontroller") from utils.log import logger from concurrent import futures import grpc #from utils.log import logger #from utils import env import json, lxc, subprocess, threading, os, time, traceback from utils import imagemgr, etcdlib, gputools from utils.lvmtool import sys_run from worker import ossmounter from protos import rpc_pb2, rpc_pb2_grpc _ONE_DAY_IN_SECONDS = 60 * 60 * 24 MAX_RUNNING_TIME = _ONE_DAY_IN_SECONDS def ip_to_int(addr): [a, b, c, d] = addr.split('.') return (int(a) << 24) + (int(b) << 16) + (int(c) << 8) + int(d)
#!/usr/bin/python3 # first init env import sys if sys.path[0].endswith("worker"): sys.path[0] = sys.path[0][:-6] from utils import env, tools config = env.getenv("CONFIG") #config = "/opt/docklet/local/docklet-running.conf" tools.loadenv(config) # must import logger after initlogging, ugly from utils.log import initlogging initlogging("docklet-worker") from utils.log import logger import xmlrpc.server, sys, time from socketserver import ThreadingMixIn import threading from utils import etcdlib, proxytool from worker import container, monitor from utils.nettools import netcontrol,ovscontrol,portcontrol from utils.lvmtool import new_group, recover_group from master import network ################################################################## # Worker # Description : Worker starts at worker node to listen rpc request and complete the work # Init() : # get master ip # initialize rpc server
#!/usr/bin/python3 # first init env import sys if sys.path[0].endswith("worker"): sys.path[0] = sys.path[0][:-6] from utils import env, tools config = env.getenv("CONFIG") #config = "/opt/docklet/local/docklet-running.conf" tools.loadenv(config) # must import logger after initlogging, ugly from utils.log import initlogging initlogging("docklet-worker") from utils.log import logger import xmlrpc.server, sys, time from socketserver import ThreadingMixIn import threading from utils import etcdlib, proxytool from worker import container, monitor from utils.nettools import netcontrol, ovscontrol, portcontrol from utils.lvmtool import new_group, recover_group from master import network ################################################################## # Worker # Description : Worker starts at worker node to listen rpc request and complete the work # Init() : # get master ip # initialize rpc server
#!/usr/bin/python3 import sys if sys.path[0].endswith("worker"): sys.path[0] = sys.path[0][:-6] from utils import env, tools config = env.getenv("CONFIG") #config = "/opt/docklet/local/docklet-running.conf" tools.loadenv(config) from utils.log import initlogging initlogging("docklet-taskworker") from utils.log import logger from concurrent import futures import grpc #from utils.log import logger #from utils import env import json,lxc,subprocess,threading,os,time,traceback from utils import imagemgr,etcdlib,gputools from utils.lvmtool import sys_run from worker import ossmounter from protos import rpc_pb2, rpc_pb2_grpc from utils.nettools import netcontrol from master.network import getip _ONE_DAY_IN_SECONDS = 60 * 60 * 24 MAX_RUNNING_TIME = _ONE_DAY_IN_SECONDS class TaskWorker(rpc_pb2_grpc.WorkerServicer): def __init__(self): rpc_pb2_grpc.WorkerServicer.__init__(self)