From 80f9bb0bb514133363bd0a40edb8b10ddb8d3a51 Mon Sep 17 00:00:00 2001 From: Parker Berberian Date: Thu, 6 Feb 2020 10:18:42 -0500 Subject: Add getInterface() to Resource API Change-Id: I714b6054bfc199d55de9619672768f8fc1355747 Signed-off-by: Parker Berberian --- src/resource_inventory/models.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/resource_inventory') 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) -- cgit 1.2.3-korg