diff options
author | Parker Berberian <pberberian@iol.unh.edu> | 2019-03-12 10:28:48 -0400 |
---|---|---|
committer | Parker Berberian <pberberian@iol.unh.edu> | 2019-03-12 10:28:48 -0400 |
commit | e00d336aeb6da542d8a54f157ab2e285cd4a3e57 (patch) | |
tree | 32556fa89bd500183b30a2ef1601c600db422ecb /src/api/models.py | |
parent | 36c012ef86233a323434be5e4c6de524188591e9 (diff) |
Allow labs to retirieve and update some host information in the api
Change-Id: Ib0682141351f7789c50d98a992ab166c2f033f4b
Signed-off-by: Parker Berberian <pberberian@iol.unh.edu>
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} |