def GET(self): try: with open('../version') as fin: ver = yaml.load(fin.read().strip()) return error.success({'version': ver['system'], 'feature':config.feature, 'gui version': ver['gui min version']}) except: return error.success({'version': 'UNKOWN', 'feature':config.feature, 'gui version': '1.0.0'})
def handle_reqest(self): o = self.svr.recv_json() try: hdl = getattr(self, 'handle_%s' % o['cmd']) rsp = hdl(o['mod']) self.svr.send_json(error.success(rsp)) except Exception as e: print e self.svr.send_json(error.error(e))
def GET(self): params = web.input() if 'offset' not in params or 'limit' not in params: return error.success([self._as_obj(journal) for journal in db.Journal.select()\ .order_by(db.Journal.created_at.desc())]) try: offset = int(params.offset) if offset < 0: raise error.InvalidParam('offset', params.offset) except: raise error.InvalidParam('offset', params.offset) try: limit = int(params.limit) if limit < 0: raise error.InvalidParam('limit', params.limit) except: raise error.InvalidParam('limit', params.limit) return error.success([self._as_obj(j) for j in db.Journal.select()\ .order_by(db.Journal.created_at.desc()).offset(offset).limit(limit)])
def GET(self): try: disks = [] diskmap = dict((disk.location, disk) for disk in adm.Disk.all() if disk.online and disk.health <> adm.HEALTH_DOWN) for disk in adm.Disk.all(): if disk.raid and not disk.raid.deleted and disk.health == adm.HEALTH_DOWN: diskmap.setdefault(disk.prev_location, disk) disks = sorted(diskmap.values(), cmp=self._cmp_disk) except: tb.print_exc() return error.success([self._as_obj(disk) for disk in disks])
def GET(self): with stat_lock: try: time = input('time') req = {'cmd': 'statistics', 'params':{}} if time: req['params'] = {'time':int(time)} web.header('content-type', 'application/json') return mq.request('speedd', req) except: tb.print_exc() return error.success([])
def GET(self): try: disks = [disk for disk in adm.Disk.all() if disk.health <> 'normal' and disk.raid and not disk.raid.deleted] raids = [raid for raid in adm.Raid.all() if raid.health <> 'normal'] volumes = [volume for volume in adm.Volume.all() if volume.health <> 'normal'] temp_status,temp = self.temp_alert() if not disks and not raids and not volumes and temp_status == 'normal': return error.success({'status': 'normal'}) else: rsp = {'status': 'warning'} if disks: rsp['disks'] = [{disk.prev_location:disk.health} for disk in disks] if raids: rsp['raids'] = [{raid.name:raid.health} for raid in raids] if volumes: rsp['volumes'] = [{volume.name:volume.health} for volume in volumes] if temp_status <> 'normal': rsp['temp'] = temp return error.success(rsp) except Exception as e: log.error(caused(e).detail) return error.internal_error
def _GET(self): ifaces = [] for info in network.ifaces().values(): o = {'id' : info.name, 'iface' : info.name, 'ipaddr' : info.ipaddr, 'netmask': info.netmask, 'slaves' : info.slaves, 'master' : info.master, 'type' : info.type, 'link' : info.link} if info.type == 'bond-master': bond = network.Bond(info.name) o['mode'] = bond.mode ifaces.append(o) return error.success(ifaces)
def POST(self): name, passwd = input('name'), input('password') try: usr = db.User.get(name=name) digest = md5.new(passwd).hexdigest() if str(usr.crypted_passwd) <> digest: raise error.LoginError() usr.perishable_token = md5.new(uuid.uuid4()).hexdigest() usr.save() session.perishable_token = usr.perishable_token login_id = random.randint(1, pow(2, 32)) uevent.UserLogin(login_id=login_id).notify() return error.success({'login_id':login_id}) except Exception as e: print e raise error.LoginError(name)
def GET(self): cmd = "bash /home/zonion/command/spk.sh 0" _,o = execute(cmd, False, logging=False) gw = network.Gateway() return error.success({'gateway': gw.ipaddr})
def GET(self): return error.success([self._as_obj(initr) for initr in db.Initiator.all()])
def GET(self): return error.success([self._as_obj(volume) for volume in db.Volume.all() if volume.deleted == 0])
def GET(self): return error.success([str(info.ipaddr) for info in network.ifaces().values() if info.link])
def GET(self): filesystems = adm.XFS.all() filesystems.extend(adm.MonFS.all()) return error.success([self._as_obj(fs) for fs in filesystems])
def GET(self): fs_list = adm.MonFS.all() if fs_list: return error.success(self._as_obj(fs_list[0])) else: return error.success({})
def GET(self): return error.success([self._as_obj(raid) for raid in adm.Raid.all() if not raid.deleted])
def GET(self): lm = LocationMapping() return error.success([{'location': dsu, 'support_disk_nr': nr} for dsu, nr in lm.dsu_list.items()])