aboutsummaryrefslogtreecommitdiffstats
path: root/vicn/core
diff options
context:
space:
mode:
Diffstat (limited to 'vicn/core')
-rw-r--r--vicn/core/resource.py9
-rw-r--r--vicn/core/resource_mgr.py12
2 files changed, 12 insertions, 9 deletions
diff --git a/vicn/core/resource.py b/vicn/core/resource.py
index 878a8108..a80e09ed 100644
--- a/vicn/core/resource.py
+++ b/vicn/core/resource.py
@@ -467,7 +467,7 @@ class BaseResource(Object): #, ABC, metaclass=ResourceMetaclass):
self._state.manager.attribute_set(self, attribute_name, value)
async def async_set(self, attribute_name, value, current=False,
- set_reverse=True, blocking=None):
+ set_reverse=True):
"""
Example:
- setting the ip address on a node's interface
@@ -478,7 +478,12 @@ class BaseResource(Object): #, ABC, metaclass=ResourceMetaclass):
"""
value = self._set(attribute_name, value, current=current,
set_reverse=set_reverse)
- await self._state.manager.attribute_set_async(self, attribute_name, value)
+ if self.is_local_attribute(attribute_name) or current:
+ if value is None:
+ attribute = self.get_attribute(attribute_name)
+ vars(self)[attribute_name] = value
+ else:
+ await self._state.manager.attribute_async_set(self, attribute_name, value)
def set_many(self, attribute_dict, current=False):
if not attribute_dict:
diff --git a/vicn/core/resource_mgr.py b/vicn/core/resource_mgr.py
index 8db7f04d..b4aa6bb7 100644
--- a/vicn/core/resource_mgr.py
+++ b/vicn/core/resource_mgr.py
@@ -587,7 +587,7 @@ class ResourceManager(metaclass=Singleton):
await self.wait_attr_init(resource, attribute)
return resource.get(attribute)
- async def _attribute_set(self, resource, attribute_name, value):
+ async def _attribute_set(self, resource, attribute_name, value, blocking=False):
with await resource._state.write_lock:
attr_state = resource._state.attr_state[attribute_name]
@@ -632,8 +632,8 @@ class ResourceManager(metaclass=Singleton):
raise RuntimeError("Resource cannot be in state".format(
resource_state))
-# if blocking:
-# await self.wait_attr_clean(resource, attribute_name)
+ if blocking:
+ await self.wait_attr_clean(resource, attribute_name)
def attribute_set(self, resource, attribute_name, value):
# Add the current operation to the pending list
@@ -643,15 +643,13 @@ class ResourceManager(metaclass=Singleton):
value)
asyncio.ensure_future(self._attribute_set(resource, attribute_name, value))
- async def attribute_set_async(self, resource, attribute_name, value):
+ async def attribute_async_set(self, resource, attribute_name, value):
# Add the current operation to the pending list
# NOTE: collections are unordered and can be updated concurrently
#self._attribute_set_pending_value(resource, attribute_name)
resource._state.dirty[attribute_name].trigger(Operations.SET,
value)
- await self._attribute_set(resource, attribute_name, value)
-
-
+ await self._attribute_set(resource, attribute_name, value, blocking=True)
#---------------------------------------------------------------------------
# Resource dependency management