diff options
Diffstat (limited to 'vicn/core')
-rw-r--r-- | vicn/core/api.py | 2 | ||||
-rw-r--r-- | vicn/core/resource.py | 8 | ||||
-rw-r--r-- | vicn/core/resource_mgr.py | 10 |
3 files changed, 15 insertions, 5 deletions
diff --git a/vicn/core/api.py b/vicn/core/api.py index 761177c9..09167aa0 100644 --- a/vicn/core/api.py +++ b/vicn/core/api.py @@ -63,7 +63,7 @@ class API(metaclass = Singleton): # SETTING settings = DEFAULT_SETTINGS - settings.update(topology.get('settings')) + settings.update(topology.get('settings', dict())) # VICN process-related initializations nofile = settings.get('ulimit-n', None) diff --git a/vicn/core/resource.py b/vicn/core/resource.py index 53ad2181..9355cd07 100644 --- a/vicn/core/resource.py +++ b/vicn/core/resource.py @@ -196,8 +196,14 @@ class BaseResource(BaseType, ABC, metaclass=ResourceMetaclass): if mandatory: raise VICNException('Mandatory attributes not set: %r' % (mandatory,)) - # Check requirements + # Check requirements and default values for attr in self.iter_attributes(): + if attr.name not in kwargs: + default = self.get_default_collection(attr) if attr.is_collection else \ + self.get_default(attr) + if vars(attr)['default'] != NEVER_SET: + #import pdb; pdb.set_trace() + self.set(attr.name, default, blocking=False) if issubclass(attr.type, Resource) and attr.requirements: for req in attr.requirements: instance = self.get(attr.name) diff --git a/vicn/core/resource_mgr.py b/vicn/core/resource_mgr.py index b750f555..c6ce77ab 100644 --- a/vicn/core/resource_mgr.py +++ b/vicn/core/resource_mgr.py @@ -902,8 +902,8 @@ class ResourceManager(metaclass=Singleton): new_state = AttributeState.INITIALIZED elif pending_state == AttributeState.PENDING_UPDATE: + attrs = resource._state.attr_change_value[attribute.name] if resource._state.attr_change_success[attribute.name] == True: - attrs = resource._state.attr_change_value[attribute.name] self.attr_log(resource, attribute, 'UPDATE success. Value = {}. Attribute is CLEAN'.format(attrs)) if attrs != NEVER_SET: @@ -934,6 +934,8 @@ class ResourceManager(metaclass=Singleton): resource.get_uuid(), attribute.name)) e = resource._state.attr_change_value[attribute.name] new_state = AttributeState.ERROR + import traceback; traceback.print_tb(e.__traceback__) + import os; os._exit(1) else: raise RuntimeError @@ -954,7 +956,7 @@ class ResourceManager(metaclass=Singleton): return Query.from_dict(dic) def _monitor_netmon(self, resource): - ip = resource.node.host_interface.ip_address + ip = resource.node.host_interface.ip4_address if not ip: log.error('IP of monitored Node is None') import os; os._exit(1) @@ -1007,7 +1009,7 @@ class ResourceManager(metaclass=Singleton): def _monitor_emulator(self, resource): ns = resource - ip = ns.node.bridge.ip_address # host_interface.ip_address + ip = ns.node.bridge.ip4_address # host_interface.ip_address ws_ns = self._router.add_interface('websocketclient', address = ip, port = ns.control_port, @@ -1356,8 +1358,10 @@ class ResourceManager(metaclass=Singleton): new_state = ResourceState.INITIALIZED else: e = resource._state.change_value + import traceback; traceback.print_tb(e.__traceback__) log.error('Cannot setup resource {} : {}'.format( resource.get_uuid(), e)) + import os; os._exit(1) elif pending_state == ResourceState.PENDING_GET: if resource._state.change_success == True: |