default for get_property, add throw_exception arg to get_xos_object
diff --git a/xos/tosca/resources/xosresource.py b/xos/tosca/resources/xosresource.py
index 9cd9a31..8507172 100644
--- a/xos/tosca/resources/xosresource.py
+++ b/xos/tosca/resources/xosresource.py
@@ -52,13 +52,18 @@
else:
return {}
- def get_property(self, name):
- return self.nodetemplate.get_property_value(name)
+ def get_property(self, name, default=None):
+ v = self.nodetemplate.get_property_value(name)
+ if (v==None):
+ return default
+ return v
- def get_xos_object(self, cls, **kwargs):
+ def get_xos_object(self, cls, throw_exception=True, **kwargs):
objs = cls.objects.filter(**kwargs)
if not objs:
- raise Exception("Failed to find %s filtered by %s" % (cls.__name__, str(kwargs)))
+ if throw_exception:
+ raise Exception("Failed to find %s filtered by %s" % (cls.__name__, str(kwargs)))
+ return None
return objs[0]
def get_existing_objs(self):