Beispiel #1
0
 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'})
Beispiel #2
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))
Beispiel #3
0
    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)])
Beispiel #4
0
    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])
Beispiel #5
0
 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([])
Beispiel #6
0
 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
Beispiel #7
0
 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)
Beispiel #8
0
    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)
Beispiel #9
0
    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})
Beispiel #10
0
 def GET(self):
     return error.success([self._as_obj(initr) for initr in db.Initiator.all()])
Beispiel #11
0
 def GET(self):
     return error.success([self._as_obj(volume) for volume in db.Volume.all() if volume.deleted == 0])
Beispiel #12
0
 def GET(self):
     return error.success([str(info.ipaddr) for info in network.ifaces().values() if info.link])
Beispiel #13
0
    def GET(self):
        filesystems = adm.XFS.all()
        filesystems.extend(adm.MonFS.all())

        return error.success([self._as_obj(fs) for fs in filesystems])
Beispiel #14
0
 def GET(self):
     fs_list = adm.MonFS.all()
     if fs_list:
         return error.success(self._as_obj(fs_list[0]))
     else:
         return error.success({})
Beispiel #15
0
 def GET(self):
     return error.success([self._as_obj(raid) for raid in adm.Raid.all() if not raid.deleted])
Beispiel #16
0
 def GET(self):
     lm = LocationMapping()
     return error.success([{'location': dsu, 'support_disk_nr': nr} for dsu, nr in lm.dsu_list.items()])