コード例 #1
0
ファイル: srvc.py プロジェクト: e42s/uss
def srvc_list(type=None):
    try:
        so = SrvcOpt()
        if not type:
            ss = so.select()
        else:
            ss = so.select(where={'type':type})
    except:
        raise

    if ss == {'result':'empty'} or not ss:
        ss = []
    elif ss == {'error': ''}:
        raise Exception("get error response for %s,  srvc_list"%(edog_host))

    service_list = get_service_list()
    service_dict = dict()
    for i in service_list:
        service_dict[i] = []

    #print ss
    for s in ss:
        type   = s['type']
        if type in service_list:
            service_dict[type].append(s)

    return service_dict
コード例 #2
0
def srvc_list(type=None):
    try:
        so = SrvcOpt()
        if not type:
            ss = so.select()
        else:
            ss = so.select(where={'type': type})
    except:
        raise

    if ss == {'result': 'empty'} or not ss:
        ss = []
    elif ss == {'error': ''}:
        raise Exception("get error response for %s,  srvc_list" % (edog_host))

    service_list = get_service_list()
    service_dict = dict()
    for i in service_list:
        service_dict[i] = []

    #print ss
    for s in ss:
        type = s['type']
        if type in service_list:
            service_dict[type].append(s)

    return service_dict
コード例 #3
0
ファイル: srvc.py プロジェクト: e42s/uss
def srvc_list_in_status(status):
    try:
        result = srvc_list()
        service_list = get_service_list()
        d = dict()
        for i in service_list:
            d[i] = []

        for k, v in result.iteritems():
            d[k] = [x for x in v if x['status'] == status]
        return d
    except:
        raise
コード例 #4
0
def srvc_list_in_status(status):
    try:
        result = srvc_list()
        service_list = get_service_list()
        d = dict()
        for i in service_list:
            d[i] = []

        for k, v in result.iteritems():
            d[k] = [x for x in v if x['status'] == status]
        return d
    except:
        raise
コード例 #5
0
ファイル: flog.py プロジェクト: e42s/uss
 def GET(self):
     return render.field_ctrl(racks=rackOpt.select(), services=get_service_list())
コード例 #6
0
ファイル: node.py プロジェクト: spawn3/uss
    def GET(self, type="all"):
        input = web.input()

        limit = int(input.rows)  #每页显示行。
        sord = input.sord  #排序关键字
        sidx = input.sidx  #升序还是降序
        page = input.page  #申请的第几页

        try:
            services = bridge_srvc.srvc_list()
        except:
            print "--------  %s, get message error" % (edog_host)
            raise web.internalerror(message="%s get message error," %
                                    (edog_host))

        ss = []
        if type == 'all':
            for k, v in services.iteritems():
                ss += v
        elif type in get_service_list():
            ss = services[type]
        elif type == 'all_log':
            #因为在日志的操作中也调用的这个方法,
            #和node不同的地方是all,所以添加了这个else判断。
            for k, v in services.iteritems():
                ss += v
        else:
            ss = []

        if ss:
            count = len(ss)  #记录总数
            total_pages = count / limit
            if count % limit != 0:
                total_pages += 1
            start = (int(page) - 1) * limit
            end = int(page) * limit
            if end > count: end = count
            ss = sort_dict_list(ss, sord, sidx)
            rows = []
            if ss:
                for i in range(start, end):
                    s = ss[i]
                    n = s['n']
                    ip = s['ip']
                    type = s['type']
                    status = s['status']
                    pid = s['pid']
                    id = ":".join([str(ip), type, str(n)])
                    argv = "'" + id + "'"
                    opt_start = '<button onclick="srvc_opt(%s, %s);">启动</button>' % (
                        argv, "'" + 'start' + "'")
                    opt_stop = '<button onclick="srvc_opt(%s, %s);">关闭</button>' % (
                        argv, "'" + 'stop' + "'")
                    if status == 'running':
                        opt = opt_stop
                    else:
                        opt = opt_start
                    rows.append({
                        'id': id,
                        'cell': [ip, type, n, status, pid, opt]
                    })

            results = {
                'total': str(total_pages),
                'page': str(page),
                'records': str(count),
                'rows': rows
            }
        else:
            results = {'total': 0, 'page': str(page), 'records': 0, 'rows': []}
        web.header("Content-Type", "application/json")
        return json.dumps(results)
コード例 #7
0
ファイル: node.py プロジェクト: spawn3/uss
 def GET(self):
     d = web.input(type="all")
     return render.tab_srvc(racks=rackOpt.select(),
                            type=d.type,
                            services=get_service_list())
コード例 #8
0
ファイル: flog.py プロジェクト: spawn3/uss
 def GET(self):
     return render.field_ctrl(racks=rackOpt.select(),
                              services=get_service_list())
コード例 #9
0
ファイル: node.py プロジェクト: e42s/uss
    def GET(self, type="all"):
        input = web.input()

        limit = int(input.rows) #每页显示行。
        sord = input.sord #排序关键字
        sidx = input.sidx #升序还是降序
        page = input.page #申请的第几页

        try:
            services = bridge_srvc.srvc_list()
        except:
            print "--------  %s, get message error"%(edog_host)
            raise web.internalerror(message = "%s get message error,"%(edog_host))

        ss = []
        if type == 'all':
            for k, v in services.iteritems():
                ss += v
        elif type in get_service_list():
            ss = services[type]
        elif type == 'all_log':
            #因为在日志的操作中也调用的这个方法,
            #和node不同的地方是all,所以添加了这个else判断。
            for k, v in services.iteritems():
                ss += v
        else:
            ss = []

        if ss:
            count = len(ss)#记录总数
            total_pages = count/limit
            if count%limit != 0:
                total_pages += 1
            start = (int(page) - 1) * limit
            end = int(page) * limit
            if end > count: end = count
            ss = sort_dict_list(ss, sord, sidx)
            rows = []
            if ss:
                for i in range(start, end):
                    s = ss[i]
                    n = s['n']
                    ip = s['ip']
                    type = s['type']
                    status = s['status']
                    pid = s['pid']
                    id = ":".join([str(ip), type, str(n)])
                    argv = "'"+id+"'"
                    opt_start = '<button onclick="srvc_opt(%s, %s);">启动</button>'%(argv, "'"+'start'+"'") 
                    opt_stop = '<button onclick="srvc_opt(%s, %s);">关闭</button>'%(argv, "'"+'stop'+"'")
                    if status == 'running':
                        opt = opt_stop
                    else:
                        opt = opt_start
                    rows.append({'id':id,
                                 'cell':[ip, type, n, status, pid, opt]})

            results = {
                'total'   : str(total_pages),
                'page'    : str(page),
                'records' : str(count),
                'rows'    : rows
                }
        else:
             results = {
                'total'   : 0,
                'page'    : str(page),
                'records' : 0,
                'rows'    : []
                }
        web.header("Content-Type", "application/json")
        return json.dumps(results)
コード例 #10
0
ファイル: node.py プロジェクト: e42s/uss
 def GET(self):
     d = web.input(type="all")
     return render.tab_srvc(racks=rackOpt.select(), type=d.type, services=get_service_list())