Author: tmckay
Date: 2011-09-01 14:17:26 +0000 (Thu, 01 Sep 2011)
New Revision: 4944
Modified:
trunk/sage/python/sage/wallaby/wallabyoperations.py
Log:
Add is_store_valid(), activate_configuration(), validate_configuration().
Better handling of invalid store object in a few places.
Invalidate store object on stop().
Modified: trunk/sage/python/sage/wallaby/wallabyoperations.py
===================================================================
--- trunk/sage/python/sage/wallaby/wallabyoperations.py 2011-08-31 20:30:52 UTC (rev
4943)
+++ trunk/sage/python/sage/wallaby/wallabyoperations.py 2011-09-01 14:17:26 UTC (rev
4944)
@@ -208,6 +208,7 @@
# Clear cache if we have been stopped....
for attr in self._cache:
self._set_cache(attr, [])
+ self._store = None
#end maintain_cache
def get_values(attr, call, *args):
@@ -258,7 +259,7 @@
Note, for the moment start() and stop() are not thread safe. They
should only be called from a single thread.
'''
- if self.maintain_cache is not None:
+ if self._maintain_cache is not None:
self._condition.acquire()
self._stop = True
self._condition.notify()
@@ -412,6 +413,10 @@
Refresh the cached lists of groups and tags.
'''
+ if self._store is None:
+ log.debug("WallabyOperations: create_tag, store object not yet
created")
+ return False
+
try:
self._store.addTag(name)
self.refresh(WBTypes.GROUPS,WBTypes.TAGS)
@@ -428,6 +433,10 @@
tag name first. Refresh cached lists of
groups, tags, and nodes.
'''
+ if self._store is None:
+ log.debug("WallabyOperations: remove_tag, store object not yet
created")
+ return False
+
if self.get_tag_by_name(name) is not None:
try:
self._store.removeGroup(name)
@@ -528,8 +537,39 @@
self._cache[which].interval = refresh
self._lock.release()
- # Super secret private implementation stuff. Don't look!
+ def activate_configuration(self):
+ '''
+ Call activateConfiguration on the store object.
+ Returns None if the store is not valid, otherwise
+ returns result of store.activateConfiguration.
+ '''
+ if self._store is not None:
+ return self._store.activateConfiguration()
+ else:
+ log.debug("WallabyOperations: activate_configuration," \
+ " store object not yet created")
+ def validate_configuration(self):
+ '''
+ Call validateConfiguration on the store object.
+ Returns None if the store is not valid, otherwise
+ returns result of store.validateConfiguration.
+ '''
+ if self._store is not None:
+ return self._store.validateConfiguration()
+ else:
+ log.debug("WallabyOperations: validate_configuration," \
+ " store object not yet created")
+
+ def is_store_valid(self):
+ '''
+ Return True if contact has been made with the Wallaby agent
+ and a store object has been created.
+ '''
+ return self._store is not None
+
+# Super secret private implementation stuff. Don't look!
+
def _find_min_remaining(self, min):
# None indicates forever, the biggest value
# Note though that None < int is True in Python!
@@ -658,6 +698,9 @@
def get_tag_by_name(self, *args, **kwargs):
return None
+ def get_feature_by_name(self, *args, **kwargs):
+ return None
+
def get_node_names(self, *args, **kwargs):
return []
@@ -673,5 +716,19 @@
def edit_tags(self, *args, **kwargs):
return False
+ def edit_features(self, *args, **kwargs):
+ return False
+
def set_interval(self, *args, **kwargs):
pass
+
+ def activate_configuration(self, *args, **kwargs):
+ return None
+
+ def validate_configuration(self, *args, **kwargs):
+ return None
+
+ def is_store_valid(self):
+ return False
+
+