From: Parker Berberian Date: Thu, 6 Feb 2020 15:18:42 +0000 (-0500) Subject: Add getInterface() to Resource API X-Git-Tag: 2.0.99~42 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F54%2F69654%2F2;p=laas.git Add getInterface() to Resource API Change-Id: I714b6054bfc199d55de9619672768f8fc1355747 Signed-off-by: Parker Berberian --- 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)