CORD-1008 add get_attribute method to vroutertenant wrapper, add exists() method to orm, fix missing run_template in ansible_helper
Change-Id: Id088c2f55fdd8831faa6ff2caa249f91e80ef046
diff --git a/xos/synchronizers/new_base/syncstep.py b/xos/synchronizers/new_base/syncstep.py
index e8b18e8..8b1185c 100644
--- a/xos/synchronizers/new_base/syncstep.py
+++ b/xos/synchronizers/new_base/syncstep.py
@@ -3,6 +3,7 @@
from xos.config import Config
from xos.logger import Logger, logging
from synchronizers.new_base.modelaccessor import *
+from synchronizers.base.ansible_helper import run_template
#from synchronizers.new_base.steps import *
#from synchronizers.new_base.ansible_helper import *
#from generate.dependency_walker import *
diff --git a/xos/xos_client/xosapi/convenience/vroutertenant.py b/xos/xos_client/xosapi/convenience/vroutertenant.py
index b891588..a4cd825 100644
--- a/xos/xos_client/xosapi/convenience/vroutertenant.py
+++ b/xos/xos_client/xosapi/convenience/vroutertenant.py
@@ -29,5 +29,14 @@
return int(parts[1].strip())
return None
+ # Use for tenant_for_instance_id
+
+ def get_attribute(self, name, default=None):
+ if self.service_specific_attribute:
+ attributes = json.loads(self.service_specific_attribute)
+ else:
+ attributes = {}
+ return attributes.get(name, default)
+
register_convenience_wrapper("VRouterTenant", ORMWrapperVRouterTenant)
diff --git a/xos/xos_client/xosapi/orm.py b/xos/xos_client/xosapi/orm.py
index d8fc84b..53d214e 100644
--- a/xos/xos_client/xosapi/orm.py
+++ b/xos/xos_client/xosapi/orm.py
@@ -222,6 +222,9 @@
else:
return None
+ def exists(self):
+ return len(self)>0
+
class ORMLocalObjectManager(object):
""" Manages a local list of objects """
@@ -247,6 +250,16 @@
models = self.resolve_queryset()
return [make_ORMWrapper(x,self._stub) for x in models]
+ def exists(self):
+ return len(self._idList)>0
+
+ def first(self):
+ if self._idList:
+ model = make_ORMWrapper(self._stub.invoke("Get%s" % self._modelName, self._stub.make_ID(id=self._idList[0])), self._stub)
+ return model
+ else:
+ return None
+
class ORMObjectManager(object):
""" Manages a remote list of objects """