aboutsummaryrefslogtreecommitdiffstats
path: root/src/dashboard
diff options
context:
space:
mode:
authorSawyer Bergeron <sbergeron@iol.unh.edu>2021-06-08 11:15:56 -0400
committerSawyer Bergeron <sbergeron@iol.unh.edu>2021-06-14 11:22:47 -0400
commita908da441bf6efcdb289a46d0c2761840138b1a5 (patch)
treec4dfe2823275249309ead57696b976dffacebd9c /src/dashboard
parent8086a7aa9aa95d5af341b67cba85b1377a168b98 (diff)
Draft for cloud-init file generation
Signed-off-by: Sawyer Bergeron <sbergeron@iol.unh.edu> Signed-off-by: Sawyer Bergeron <sbergeron@iol.unh.edu> Change-Id: I07f3a4a1ab67531cba2cc7e3de22e9bb860706e1 Signed-off-by: Sawyer Bergeron <sbergeron@iol.unh.edu>
Diffstat (limited to 'src/dashboard')
-rw-r--r--src/dashboard/utils.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/dashboard/utils.py b/src/dashboard/utils.py
index d6b697a..e9ecb4e 100644
--- a/src/dashboard/utils.py
+++ b/src/dashboard/utils.py
@@ -7,7 +7,7 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from django.core.exceptions import ObjectDoesNotExist
+from django.core.exceptions import (ObjectDoesNotExist, MultipleObjectsReturned)
class AbstractModelQuery():
@@ -38,7 +38,15 @@ class AbstractModelQuery():
@classmethod
def get(cls, *args, **kwargs):
+ """
+ Gets a single matching resource
+ Throws ObjectDoesNotExist if none found matching, or MultipleObjectsReturned if
+ the query does not narrow to a single object
+ """
try:
+ ls = cls.filter(*args, **kwargs)
+ if len(ls) > 1:
+ raise MultipleObjectsReturned()
return cls.filter(*args, **kwargs)[0]
except IndexError:
raise ObjectDoesNotExist()