Beispiel #1
0
 def get(self, hostname):
     """Search for RPMs installed on given hostname"""
     cache = request.args.get('nocache')
     output = request.args.get('format')
     handler = OutputHandler(cache, output, request.url_rule.rule, request.base_url)
     if handler.cache:
         data = {"last-update": timestamp(), hostname: gather_rpms(hostname, username=SSH_USERNAME)}
         return handler.formatter(data)
     else:
         data = {"last-update": rpm_data.cached_rpms['last-update'], hostname: rpm_data.cached_rpms.get(hostname)}
         return handler.formatter(data)
Beispiel #2
0
 def get(self, hostname):
     """List disk space for hostname"""
     cache = request.args.get('nocache')
     output = request.args.get('format')
     handler = OutputHandler(cache, output, request.url_rule.rule, request.base_url)
     if handler.cache:
         return handler.formatter(
             {"last-update": timestamp(), hostname: diskspace_output(hostname, username=SSH_USERNAME)})
     else:
         return handler.formatter(
             {"last-update": diskspace_data.cached_diskspace['last-update'],
              hostname: diskspace_data.cached_diskspace.get(hostname)})
Beispiel #3
0
 def get(self, hostname):
     """Search netstat info by hostname"""
     cache = request.args.get('nocache')
     output = request.args.get('format')
     handler = OutputHandler(cache, output, request.url_rule.rule, request.base_url)
     if cache and cache.lower() == 'true':
         return handler.formatter(
             {"last-update": timestamp(), hostname: netstat_output(hostname, username=SSH_USERNAME)})
     else:
         return handler.formatter(
             {"last-update": netstat_data.cached_netstat['last-update'],
              hostname: netstat_data.cached_netstat.get(hostname)})
Beispiel #4
0
 def get(self, rpmname):
     """Search for RPM by name or Regular Expression"""
     cache = request.args.get('nocache')
     output = request.args.get('format')
     handler = OutputHandler(cache, output, request.url_rule.rule, request.base_url)
     if handler.cache:
         data = rpm_search(rpmname, rpm_data.rpms(cached=False))
         data["last-update"] = timestamp()
         return handler.formatter(data)
     else:
         data = rpm_search(rpmname, rpm_data.cached_rpms)
         data["last-update"] = rpm_data.cached_rpms['last-update']
         return handler.formatter(data)
Beispiel #5
0
class DiskspaceData(Hosts):
    cached_diskspace = {"last-update": timestamp()}

    @classmethod
    def update_cached_diskspace(cls):
        for host in cls.cached_hosts:
            cls.cached_diskspace[host] = diskspace_output(
                host, username=SSH_USERNAME)
            cls.cached_diskspace['last-update'] = timestamp()
        return cls.cached_diskspace

    @classmethod
    def diskspace(cls, cached=True):
        if cached:
            return cls.cached_diskspace
        else:
            return cls.update_cached_diskspace()
Beispiel #6
0
class NetstatData(Hosts):
    cached_netstat = {"last-update": timestamp()}

    @classmethod
    def update_cached_netstat(cls):
        for host in cls.cached_hosts:
            cls.cached_netstat[host] = netstat_output(host,
                                                      username=SSH_USERNAME)
            cls.cached_netstat['last-update'] = timestamp()
        return cls.cached_netstat

    @classmethod
    def netstat(cls, cached=True):
        if cached:
            return cls.cached_netstat
        else:
            return cls.update_cached_netstat()
Beispiel #7
0
class RPMData(Hosts):
    cached_rpms = {
        "last-update": timestamp(),
    }

    @classmethod
    def update_cached_rpms(cls):
        for host in cls.cached_hosts:
            cls.cached_rpms[host] = gather_rpms(host, username=SSH_USERNAME)
            cls.cached_rpms['last-update'] = timestamp()
        return cls.cached_rpms

    @classmethod
    def rpms(cls, cached=True):
        if cached:
            return cls.cached_rpms
        else:
            return cls.update_cached_rpms()
Beispiel #8
0
 def update_cached_diskspace(cls):
     for host in cls.cached_hosts:
         cls.cached_diskspace[host] = diskspace_output(
             host, username=SSH_USERNAME)
         cls.cached_diskspace['last-update'] = timestamp()
     return cls.cached_diskspace
Beispiel #9
0
 def update_cached_netstat(cls):
     for host in cls.cached_hosts:
         cls.cached_netstat[host] = netstat_output(host,
                                                   username=SSH_USERNAME)
         cls.cached_netstat['last-update'] = timestamp()
     return cls.cached_netstat
Beispiel #10
0
 def update_cached_rpms(cls):
     for host in cls.cached_hosts:
         cls.cached_rpms[host] = gather_rpms(host, username=SSH_USERNAME)
         cls.cached_rpms['last-update'] = timestamp()
     return cls.cached_rpms