aboutsummaryrefslogtreecommitdiffstats
path: root/src/resource_inventory/models.py
diff options
context:
space:
mode:
authorParker Berberian <pberberian@iol.unh.edu>2020-02-06 10:18:42 -0500
committerParker Berberian <pberberian@iol.unh.edu>2020-02-10 11:32:02 -0500
commit80f9bb0bb514133363bd0a40edb8b10ddb8d3a51 (patch)
tree7ebad9355352871a230f0aeaaa34fc761a7ad06a /src/resource_inventory/models.py
parentac50210dd7e1a250307f5d20a43624621c50b0a0 (diff)
Add getInterface() to Resource API
Change-Id: I714b6054bfc199d55de9619672768f8fc1355747 Signed-off-by: Parker Berberian <pberberian@iol.unh.edu>
Diffstat (limited to 'src/resource_inventory/models.py')
-rw-r--r--src/resource_inventory/models.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/resource_inventory/models.py b/src/resource_inventory/models.py
index f462ac5..a8b75d9 100644
--- a/src/resource_inventory/models.py
+++ b/src/resource_inventory/models.py
@@ -127,6 +127,13 @@ class Resource(models.Model):
"""Make this resource available again for new boookings."""
raise NotImplementedError("Must implement in concrete Resource classes")
+ def get_interfaces(self):
+ """
+ Returns a list of interfaces on this resource.
+ The ordering of interfaces should be consistent.
+ """
+ raise NotImplementedError("Must implement in concrete Resource classes")
+
# Generic resource templates
class GenericResourceBundle(models.Model):
@@ -420,6 +427,9 @@ class Host(Resource):
self.booked = False
self.save()
+ def get_interfaces(self):
+ return list(self.interfaces.all().order_by('bus_address'))
+
class Interface(models.Model):
id = models.AutoField(primary_key=True)