def _update_selectfield(self): registerd = RasTarget.select( RasTarget.name).where(RasTarget.type == 'ras') self.group.choices = [ (g.id, g.name) for g in RasGroup.select().where(RasGroup.name.not_in(registerd)) ]
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)) ]
def regist_ras_eye(self, group): logger.debug("REGIST RAS: {}".format(group)) tgt = RasTargetRasForm(data={'type': 'ras', 'group': group.id}) tgt.create(group.id) tobj = RasTarget.select().where((RasTarget.name == group.name) & ( RasTarget.type == 'ras') & (RasTarget.group == group.id)).first() act = RasActionRestartForm(data={'type': 'restart', 'name': 'restart'}) act.create(tobj.id)
def match(cls, event): from cellconfig.ras.model import RasTarget if _event_name2task(event['name']) not in cls.EVENTS: return False cell = event['target'] count = RasTarget.select().where( (RasTarget.type == 'cell') & (RasTarget.name == cell.name)).count() return count > 0
def match(cls, event): from cellconfig.ras.model import RasTarget if _event_name2task(event['name']) not in cls.EVENTS: return False cell = event['target'] count = RasTarget.select().where((RasTarget.type == 'cell') & ( RasTarget.name == cell.name)).count() return count > 0
def exist_restart_action(self, cell): tgts = RasTarget.select().where((RasTarget.name == cell.name) & (RasTarget.type == 'cell')) for tgt in tgts: acts = RasAction.select().where((RasAction.target == tgt.id) & ( RasAction.type == 'restart')).first() if acts is not None: return True return False
def regist_ras_eye(self, group): logger.debug("REGIST RAS: {}".format(group)) tgt = RasTargetRasForm(data={'type': 'ras', 'group': group.id}) tgt.create(group.id) tobj = RasTarget.select().where( (RasTarget.name == group.name) & (RasTarget.type == 'ras') & (RasTarget.group == group.id)).first() act = RasActionRestartForm(data={'type': 'restart', 'name': 'restart'}) act.create(tobj.id)
def exist_restart_action(self, cell): tgts = RasTarget.select().where( (RasTarget.name == cell.name) & (RasTarget.type == 'cell')) for tgt in tgts: acts = RasAction.select().where( (RasAction.target == tgt.id) & (RasAction.type == 'restart')).first() if acts is not None: return True return False
def _start(self, cell, nodes): from cellconfig.ras.model import RasTarget tgts = RasTarget.select().where( (RasTarget.type == 'cell') & (RasTarget.name == cell.name) & RasTarget.enabled) for tgt in tgts: logger.debug("RasCluster {}".format(tgt.name)) self._execute_fab( task=fabfile.setup_cell, nodes=nodes, cell=cell, ras_cell=tgt.group.cell.name, path=tgt.path, warn_only=False)
def regist_ras_cell(self, group): cell = group.cell if self.exist_restart_action(cell): return logger.debug("REGIST CELL: {}".format(cell)) tgt = RasTargetCellForm(data={'type': 'cell', 'cell': cell.id}) tgt.create(group.id) tobj = RasTarget.select().where((RasTarget.name == cell.name) & ( RasTarget.type == 'cell') & (RasTarget.group == group.id)).first() act = RasActionRestartForm(data={'type': 'restart', 'name': 'restart'}) act.create(tobj.id)
def enable(self, event): from cellconfig.ras.model import RasTarget ras = event['target'] task = _event_name2task(event['name']) if task == 'status': for tgt in ras.targets: self._send_signal(self.signal, tgt) elif task == 'server_status': tgt = RasTarget.select().where((RasTarget.type == 'ras') & ( RasTarget.name == ras.name)).first() if tgt is not None: self._send_server_signal(self.signal, tgt, ras)
def ras_action_info(clst, app, name): ras = RasGroup.select().where(RasGroup.name == clst).first() if ras is None: abort(404) actions = [] tgts = RasTarget.select().where((RasTarget.path == '/'.join([app, name])) & (RasTarget.group == ras.id)) for tgt in tgts: for act in tgt.actions: aparams = {'name': act.name, 'mode': act.mode, 'action': act.type} aparams.update(json.loads(act.data)) actions.append(aparams) return jsonify(actions)
def regist_ras_cell(self, group): cell = group.cell if self.exist_restart_action(cell): return logger.debug("REGIST CELL: {}".format(cell)) tgt = RasTargetCellForm(data={'type': 'cell', 'cell': cell.id}) tgt.create(group.id) tobj = RasTarget.select().where( (RasTarget.name == cell.name) & (RasTarget.type == 'cell') & (RasTarget.group == group.id)).first() act = RasActionRestartForm(data={'type': 'restart', 'name': 'restart'}) act.create(tobj.id)
def enable(self, event): from cellconfig.ras.model import RasTarget ras = event['target'] task = _event_name2task(event['name']) if task == 'status': for tgt in ras.targets: self._send_signal(self.signal, tgt) elif task == 'server_status': tgt = RasTarget.select().where( (RasTarget.type == 'ras') & (RasTarget.name == ras.name)).first() if tgt is not None: self._send_server_signal(self.signal, tgt, ras)
def ras_report(app, name, no): from cellconfig.agents.ras.rasagent import RasEvent, CellEvent rsig = blinker.signal('ras:status') ssig = blinker.signal('ras:server_status') csig = blinker.signal('cell:status') tgts = RasTarget.select().where(RasTarget.path == '/'.join([app, name])) for tgt in tgts: RasEvent._send_signal(rsig, tgt) if tgt.type == 'cell': CellEvent._send_signal(csig, tgt.name, tgt) elif tgt.type == 'ras': ras = RasGroup.select().where(RasGroup.name == tgt.name).first() RasEvent._send_server_signal(ssig, tgt, ras) return make_response('ok')
def ras_action_info(clst, app, name): ras = RasGroup.select().where(RasGroup.name == clst).first() if ras is None: abort(404) actions = [] tgts = RasTarget.select().where( (RasTarget.path == '/'.join([app, name])) & (RasTarget.group == ras.id)) for tgt in tgts: for act in tgt.actions: aparams = {'name': act.name, 'mode': act.mode, 'action': act.type} aparams.update(json.loads(act.data)) actions.append(aparams) return jsonify(actions)
def ras_report(app, name, no): from cellconfig.agents.ras.rasagent import RasEvent, CellEvent rsig = blinker.signal('ras:status') ssig = blinker.signal('ras:server_status') csig = blinker.signal('cell:status') tgts = RasTarget.select().where(RasTarget.path == '/'.join([app, name])) for tgt in tgts: RasEvent._send_signal(rsig, tgt) if tgt.type == 'cell': CellEvent._send_signal(csig, tgt.name, tgt) elif tgt.type == 'ras': ras = RasGroup.select().where(RasGroup.name == tgt.name).first() RasEvent._send_server_signal(ssig, tgt, ras) return make_response('ok')
def start(self): self._execute_fab(fabfile.start_server, nodes=[self.target], group=self.target.group.name, warn_only=False) for tgt in self.target.group.targets: self._set_event(tgt) from cellconfig.ras.model import RasTarget tgts = RasTarget.select().where((RasTarget.type == 'ras') & ( RasTarget.name == self.target.group.name) & RasTarget.enabled) for tgt in tgts: logger.debug("Ras RegistME {}".format(tgt.name)) self._execute_fab( task=fabfile.setup_ras, nodes=[self.target], group=self.target.group.name, ras_cell=self.target.group.cell.name, ) logger.debug("START SERVER: success")
def start(self): self._execute_fab( fabfile.start_server, nodes=[self.target], group=self.target.group.name, warn_only=False) for tgt in self.target.group.targets: self._set_event(tgt) from cellconfig.ras.model import RasTarget tgts = RasTarget.select().where( (RasTarget.type == 'ras') & (RasTarget.name == self.target.group.name) & RasTarget.enabled) for tgt in tgts: logger.debug("Ras RegistME {}".format(tgt.name)) self._execute_fab( task=fabfile.setup_ras, nodes=[self.target], group=self.target.group.name, ras_cell=self.target.group.cell.name, ) logger.debug("START SERVER: success")
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))]
def enable(self, event): from cellconfig.ras.model import RasTarget cell = event['target'] tgt = RasTarget.select().where( (RasTarget.type == 'cell') & (RasTarget.name == cell.name)).first() self._send_signal(self.signal, cell.name, tgt)
def delete_nonexists_target(cls, _type, name): tgts = RasTarget.select().where((RasTarget.type == _type) & (RasTarget.name == name)) for tgt in tgts: RasTargetForm.delete(tgt.id)
def delete_nonexists_target(cls, _type, name): tgts = RasTarget.select().where( (RasTarget.type == _type) & (RasTarget.name == name)) for tgt in tgts: RasTargetForm.delete(tgt.id)
def enable(self, event): from cellconfig.ras.model import RasTarget cell = event['target'] tgt = RasTarget.select().where((RasTarget.type == 'cell') & (RasTarget.name == cell.name)).first() self._send_signal(self.signal, cell.name, tgt)
def _update_selectfield(self): registerd = RasTarget.select(RasTarget.name).where( RasTarget.type == 'ras') self.group.choices = [ (g.id, g.name) for g in RasGroup.select().where(RasGroup.name.not_in(registerd))]