Exemple #1
0
    def all(self):
        ret = []
        hosts = Host.all()
        for host in hosts:
            ret.append(host)

        return ret
Exemple #2
0
    def add_host(self, ip, domain):
        if (len(ip) == 0 or len(domain) == 0):
            return

        updated = False
        hosts = db.GqlQuery("SELECT * FROM Host WHERE domain = :1 LIMIT 1", domain)
        for host in hosts:
            host.ip = ip
            try:
                db.put(host)
                updated = True
            except CapabilityDisabledError:
                return

        if (not updated):
            host = Host(ip = ip, domain = domain)
            try:
                host.put()
            except CapabilityDisabledError:
                pass

        return
Exemple #3
0
 def del_all(self):
     hosts = Host.all()
     for host in hosts:
         host.delete()
Exemple #4
0
    def count(self):
        count = 0
        hosts = Host.all()
        count = hosts.count()

        return count