コード例 #1
0
ファイル: api.py プロジェクト: dongdong-2009/PaxosSolutions
def api_cnode_state_by_name(name, no):
    query = Cell.select().where(Cell.name == name)
    try:
        id = query[0].id
    except:
        abort(404)
    return api_cnode_state(id, no)
コード例 #2
0
ファイル: api.py プロジェクト: dongdong-2009/PaxosSolutions
def api_cell_detail_by_name(name):
    query = Cell.select().where(Cell.name == name)
    try:
        id = query[0].id
    except:
        abort(404)
    return api_cell_detail(id)
コード例 #3
0
ファイル: api.py プロジェクト: tritechpaxos/PaxosSolutions
def api_cnode_state_by_name(name, no):
    query = Cell.select().where(Cell.name == name)
    try:
        id = query[0].id
    except:
        abort(404)
    return api_cnode_state(id, no)
コード例 #4
0
ファイル: api.py プロジェクト: tritechpaxos/PaxosSolutions
def api_cell_detail_by_name(name):
    query = Cell.select().where(Cell.name == name)
    try:
        id = query[0].id
    except:
        abort(404)
    return api_cell_detail(id)
コード例 #5
0
 def _update_selectfield(self):
     registerd = RasTarget.select(
         RasTarget.name).where(RasTarget.type == 'cell')
     self.cell.choices = [
         (c.id, c.name)
         for c in Cell.select().where(Cell.name.not_in(registerd))
     ]
コード例 #6
0
ファイル: api.py プロジェクト: dongdong-2009/PaxosSolutions
def query_cell_all_list():
    query = Cell.select().dicts()
    cell_list = []
    for cell in query:
        cell_list.append(cell)
        cell['url'] = url_for('api_cell_detail', id=cell['id'], _external=True)
    return jsonify(cell=cell_list)
コード例 #7
0
 def _cell_status(self):
     cell_name = self.target.name
     from cellconfig.model import Cell
     cell = Cell.select().where(Cell.name == cell_name).first()
     try:
         st = self._get_status(
             self.target.group.cell.name,
             '/RAS/{}/{}'.format(cell.get_appname(), cell.name), cell.nodes)
         if st['running'] == st['total']:
             status = 'running'
         elif st['running'] == 0:
             status = 'stopped'
         elif st['running'] >= (st['total'] + 1) // 2:
             status = 'warning'
         else:
             status = 'error'
         st.update({'cid': cell.id, 'name': cell.name, 'status': status})
         return st
     except Exception as e:
         logger.exception(e)
         return {
             'cid': cell.id,
             'name': cell.name,
             'status': 'unknown',
             'total': len(cell.nodes)
         }
コード例 #8
0
ファイル: forms.py プロジェクト: tritechpaxos/PaxosSolutions
 def obj2dict(cls, obj):
     cell = Cell.select().where(Cell.name == obj.name).first()
     logger.debug("CELL ID: {}".format(cell.id))
     return {
         'type': 'cell',
         'cell': cell.id,
         'comment': obj.comment,
     }
コード例 #9
0
 def obj2dict(cls, obj):
     cell = Cell.select().where(Cell.name == obj.name).first()
     logger.debug("CELL ID: {}".format(cell.id))
     return {
         'type': 'cell',
         'cell': cell.id,
         'comment': obj.comment,
     }
コード例 #10
0
ファイル: api.py プロジェクト: tritechpaxos/PaxosSolutions
def query_cell_all_list():
    query = Cell.select().dicts()
    cell_list = []
    for cell in query:
        cell_list.append(cell)
        cell['url'] = url_for('api_cell_detail', id=cell['id'],
                              _external=True)
    return jsonify(cell=cell_list)
コード例 #11
0
def cell_list():
    if request.method == 'GET':
        cells = Cell.select().where(Cell.type != 'RAS')
        return render_template('cell_list.html', cells=cells)
    elif request.method == 'POST':
        form = CellForm(request.form)
        if not (form.validate() and form.create()):
            return render_template('cell_create.html', form=form)
        return redirect(url_for('cell_list'))
コード例 #12
0
ファイル: views.py プロジェクト: tritechpaxos/PaxosSolutions
def cell_list():
    if request.method == 'GET':
        cells = Cell.select().where(Cell.type != 'RAS')
        return render_template('cell_list.html', cells=cells)
    elif request.method == 'POST':
        form = CellForm(request.form)
        if not (form.validate() and form.create()):
            return render_template('cell_create.html', form=form)
        return redirect(url_for('cell_list'))
コード例 #13
0
ファイル: views.py プロジェクト: dongdong-2009/PaxosSolutions
def rascell_list():
    if request.method == 'GET':
        cells = Cell.select().where(Cell.type == 'RAS')
        return render_template('ras/cell_list.html', cells=cells)
    elif request.method == 'POST':
        form = RasCellForm(request.form)
        if not form.validate():
            return render_template('ras/cell_create.html', form=form)
        form.create()
        return redirect(url_for('rasgrp_list'))
コード例 #14
0
ファイル: views.py プロジェクト: tritechpaxos/PaxosSolutions
def rascell_list():
    if request.method == 'GET':
        cells = Cell.select().where(Cell.type == 'RAS')
        return render_template('ras/cell_list.html', cells=cells)
    elif request.method == 'POST':
        form = RasCellForm(request.form)
        if not form.validate():
            return render_template('ras/cell_create.html', form=form)
        form.create()
        return redirect(url_for('rasgrp_list'))
コード例 #15
0
ファイル: views.py プロジェクト: dongdong-2009/PaxosSolutions
def rasgrp_list():
    if request.method == 'GET':
        if Cell.select().where(Cell.type == 'RAS').count() == 0:
            return redirect(url_for('rascell_list'))
        grps = RasGroup.select()
        return render_template('ras/ras_index.html', groups=grps)
    elif request.method == 'POST':
        form = RasGroupForm(request.form)
        if not form.validate():
            return render_template('ras/group_create.html', form=form)
        logger.debug('URL: {}'.format(request.url_root))
        grp = form.create(request.url_root)
        logger.debug('GROUP: {}'.format(str(grp)))
        return redirect(url_for('rasgrp_list'))
コード例 #16
0
ファイル: views.py プロジェクト: tritechpaxos/PaxosSolutions
def rasgrp_list():
    if request.method == 'GET':
        if Cell.select().where(Cell.type == 'RAS').count() == 0:
            return redirect(url_for('rascell_list'))
        grps = RasGroup.select()
        return render_template('ras/ras_index.html', groups=grps)
    elif request.method == 'POST':
        form = RasGroupForm(request.form)
        if not form.validate():
            return render_template('ras/group_create.html', form=form)
        logger.debug('URL: {}'.format(request.url_root))
        grp = form.create(request.url_root)
        logger.debug('GROUP: {}'.format(str(grp)))
        return redirect(url_for('rasgrp_list'))
コード例 #17
0
ファイル: event.py プロジェクト: tritechpaxos/PaxosSolutions
def cell_list_event():
    listener = EventListener('cell:status')
    cells = Cell.select()
    events = [{'name': 'status;{}'.format(cell.name), 'target': cell}
              for cell in cells]

    def setup(_callback):
        listener.regist(_callback)
        for ev in events:
            listener.enable(ev)

    def teardown(_callback):
        listener.unregist(_callback)
        for ev in events:
            listener.disable(ev)

    return _make_sse_response(_generator(setup, teardown))
コード例 #18
0
def cell_list_event():
    listener = EventListener('cell:status')
    cells = Cell.select()
    events = [{
        'name': 'status;{}'.format(cell.name),
        'target': cell
    } for cell in cells]

    def setup(_callback):
        listener.regist(_callback)
        for ev in events:
            listener.enable(ev)

    def teardown(_callback):
        listener.unregist(_callback)
        for ev in events:
            listener.disable(ev)

    return _make_sse_response(_generator(setup, teardown))
コード例 #19
0
 def _cell_status(self):
     cell_name = self.target.name
     from cellconfig.model import Cell
     cell = Cell.select().where(Cell.name == cell_name).first()
     try:
         st = self._get_status(
             self.target.group.cell.name,
             '/RAS/{}/{}'.format(cell.get_appname(), cell.name),
             cell.nodes)
         if st['running'] == st['total']:
             status = 'running'
         elif st['running'] == 0:
             status = 'stopped'
         elif st['running'] >= (st['total'] + 1) // 2:
             status = 'warning'
         else:
             status = 'error'
         st.update({'cid': cell.id, 'name': cell.name, 'status': status})
         return st
     except Exception as e:
         logger.exception(e)
         return {'cid': cell.id, 'name': cell.name, 'status': 'unknown',
                 'total': len(cell.nodes)}
コード例 #20
0
ファイル: forms.py プロジェクト: tritechpaxos/PaxosSolutions
 def _update_selectfield(self):
     registerd = RasTarget.select(RasTarget.name).where(
         RasTarget.type == 'cell')
     self.cell.choices = [
         (c.id, c.name) for c in
         Cell.select().where(Cell.name.not_in(registerd))]
コード例 #21
0
 def _update_select(self):
     cells = Cell.select().where(Cell.type == 'RAS')
     self.cell.choices = [(c.id, c.name) for c in cells]
コード例 #22
0
ファイル: forms.py プロジェクト: tritechpaxos/PaxosSolutions
 def _update_select(self):
     cells = Cell.select().where(Cell.type == 'RAS')
     self.cell.choices = [(c.id, c.name) for c in cells]