summaryrefslogtreecommitdiffstats
path: root/dashboard/src/api/models.py
diff options
context:
space:
mode:
authorParker Berberian <pberberian@iol.unh.edu>2019-03-12 10:28:48 -0400
committerParker Berberian <pberberian@iol.unh.edu>2019-03-12 10:28:48 -0400
commit3fa0f3c171c0b2eb83f05f29e61596ac0f488831 (patch)
tree4ad8f51e27bf0254a01aa3e694fb04cd471c0133 /dashboard/src/api/models.py
parent2f9786ec78b1fd6181405bb9938ab90767838e37 (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 'dashboard/src/api/models.py')
-rw-r--r--dashboard/src/api/models.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/dashboard/src/api/models.py b/dashboard/src/api/models.py
index 7109bbe..b35adf2 100644
--- a/dashboard/src/api/models.py
+++ b/dashboard/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}