From 628ebc06c1cc12dabc5025e41e40aa733ea6adde Mon Sep 17 00:00:00 2001 From: Shay Nehmad Date: Wed, 2 Oct 2019 09:59:25 +0300 Subject: [PATCH] Updated docs and TODO (we won't get to it this PR) --- monkey/monkey_island/cc/models/monkey.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/monkey/monkey_island/cc/models/monkey.py b/monkey/monkey_island/cc/models/monkey.py index 5a916e550..436c6b702 100644 --- a/monkey/monkey_island/cc/models/monkey.py +++ b/monkey/monkey_island/cc/models/monkey.py @@ -87,7 +87,8 @@ class Monkey(Document): os = "windows" return os - # TODO This is not a field therefore cache shouldn't be here + # TODO This is not really a field, therefore cache shouldn't be here - we should cache the IP addresses and this + # should be a regular method. @staticmethod @ring.lru() def get_label_by_id(object_id): @@ -97,11 +98,17 @@ class Monkey(Document): @staticmethod @ring.lru() def get_hostname_by_id(object_id): + """ + :param object_id: the object ID of a Monkey in the database. + :return: The hostname of that machine. + :note: Use this and not monkey.hostname for performance - this is lru-cached. + """ return Monkey.get_single_monkey_by_id(object_id).hostname def set_hostname(self, hostname): """ - Need this to clear the cache + Sets a new hostname for a machine and clears the cache for getting it. + :param hostname: The new hostname for the machine. """ self.hostname = hostname self.save()