diff options
Diffstat (limited to 'src/api/models.py')
-rw-r--r-- | src/api/models.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/api/models.py b/src/api/models.py index 7109bbe..b35adf2 100644 --- a/src/api/models.py +++ b/src/api/models.py @@ -116,6 +116,22 @@ class LabManager(object): inventory['host_types'] = self.serialize_host_profiles(profiles) return inventory + def get_host(self, hostname): + host = get_object_or_404(Host, labid=hostname, lab=self.lab) + return { + "booked": host.booked, + "working": host.working, + "type": host.profile.name + } + + def update_host(self, hostname, data): + host = get_object_or_404(Host, labid=hostname, lab=self.lab) + if "working" in data: + working = data['working'] == "true" + host.working = working + host.save() + return self.get_host(hostname) + def get_status(self): return {"status": self.lab.status} |