forked from p15670423/monkey
Renamed collection from TTL to MonkeyTTL
This commit is contained in:
parent
1018906602
commit
0602a3bc83
|
@ -22,7 +22,7 @@ class Config(EmbeddedDocument):
|
||||||
|
|
||||||
class Creds(EmbeddedDocument):
|
class Creds(EmbeddedDocument):
|
||||||
"""
|
"""
|
||||||
TODO get an example of this data
|
TODO get an example of this data, and make it strict
|
||||||
"""
|
"""
|
||||||
meta = {'strict': False}
|
meta = {'strict': False}
|
||||||
pass
|
pass
|
||||||
|
@ -36,7 +36,7 @@ class PbaResults(EmbeddedDocument):
|
||||||
result = ListField()
|
result = ListField()
|
||||||
|
|
||||||
|
|
||||||
class Ttl(Document):
|
class MonkeyTtl(Document):
|
||||||
meta = {
|
meta = {
|
||||||
'indexes': [
|
'indexes': [
|
||||||
{
|
{
|
||||||
|
@ -72,7 +72,7 @@ class Monkey(Document):
|
||||||
config_error = BooleanField()
|
config_error = BooleanField()
|
||||||
critical_services = ListField(StringField())
|
critical_services = ListField(StringField())
|
||||||
pba_results = ListField()
|
pba_results = ListField()
|
||||||
ttl_ref = ReferenceField(Ttl)
|
ttl_ref = ReferenceField(MonkeyTtl)
|
||||||
|
|
||||||
def is_dead(self):
|
def is_dead(self):
|
||||||
monkey_is_dead = False
|
monkey_is_dead = False
|
||||||
|
@ -80,7 +80,7 @@ class Monkey(Document):
|
||||||
monkey_is_dead = True
|
monkey_is_dead = True
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
if Ttl.objects(id=self.ttl_ref.id).count() == 0:
|
if MonkeyTtl.objects(id=self.ttl_ref.id).count() == 0:
|
||||||
# No TTLs - monkey has timed out. The monkey is MIA
|
# No TTLs - monkey has timed out. The monkey is MIA
|
||||||
monkey_is_dead = True
|
monkey_is_dead = True
|
||||||
except mongoengine.DoesNotExist:
|
except mongoengine.DoesNotExist:
|
||||||
|
|
|
@ -48,7 +48,7 @@ class Monkey(flask_restful.Resource):
|
||||||
tunnel_host_ip = monkey_json['tunnel'].split(":")[-2].replace("//", "")
|
tunnel_host_ip = monkey_json['tunnel'].split(":")[-2].replace("//", "")
|
||||||
NodeService.set_monkey_tunnel(monkey["_id"], tunnel_host_ip)
|
NodeService.set_monkey_tunnel(monkey["_id"], tunnel_host_ip)
|
||||||
|
|
||||||
current_ttl = models.monkey.Ttl(expire_at=datetime.now() + timedelta(seconds=30))
|
current_ttl = models.monkey.MonkeyTtl(expire_at=datetime.now() + timedelta(seconds=30))
|
||||||
current_ttl.save()
|
current_ttl.save()
|
||||||
|
|
||||||
update['$set']['ttl_ref'] = current_ttl.id
|
update['$set']['ttl_ref'] = current_ttl.id
|
||||||
|
|
Loading…
Reference in New Issue