Change in the order of configuration of attributes for wireless interfaces in OMF
authorAlina Quereilhac <alina.quereilhac@inria.fr>
Thu, 11 Oct 2012 15:19:30 +0000 (17:19 +0200)
committerAlina Quereilhac <alina.quereilhac@inria.fr>
Thu, 11 Oct 2012 15:19:30 +0000 (17:19 +0200)
src/nepi/testbeds/omf/metadata.py

index 55d48c8..0f15542 100644 (file)
@@ -127,14 +127,19 @@ class OmfWifiInterface(OmfResource):
         self.ip = None
 
     def __setattr__(self, name, value):
-        if name in ["ip", "mode", "type", "essid", "channel"]:
-            if value is not None:
-                node = self.tc.elements.get(self._node_guid)    
-                attribute = "net/%s/%s" % (self.alias, name)
-                self._tc().api.configure(node.hostname, attribute, value)
-        
         super(OmfWifiInterface, self).__setattr__(name, value)
 
+        try:
+            if self.mode and self.type and self.essid and self.channel and self.ip:
+                node = self.tc.elements.get(self._node_guid)    
+                for attrname in ["mode", "type", "essid", "channel", "ip"]:
+                    attrval = getattr(self, attrname)
+                    attrname = "net/%s/%s" % (self.alias, attrname)
+                    self._tc().api.configure(node.hostname, attrname, attrval)
+        except AttributeError:
+            # If the attribute is not yet defined, ignore the error
+            pass
+
 # Factories
 NODE = "Node"
 WIFIIFACE = "WifiInterface"