changing mobility-type to mobility_type
[sfa.git] / sfa / rspecs / elements / versions / iotlabv1Node.py
index 7efd8f6..d95103a 100644 (file)
@@ -39,7 +39,7 @@ class IotlabLocation(Location):
 class IotlabMobility(Element):
     """ Class to give information of a node's mobility, and what kind of
     mobility it is (train, roomba robot ...) """
-    fields = ['mobile', 'type']
+    fields = ['mobile', 'mobility_type']
 
 
 
@@ -58,15 +58,15 @@ class Iotlabv1Node:
         if len(network_elems) > 0:
             network_elem = network_elems[0]
 
-        iotlab_network_dict = {}
-        iotlab_network_dict['login'] = ldap_username
+            iotlab_network_dict = {}
+            iotlab_network_dict['login'] = ldap_username
 
-        iotlab_network_dict['ssh'] = \
-            ['ssh ' + ldap_username + '@'+site+'.iotlab.info'
-             for site in sites_set]
-        network_elem.set('ssh',
-                         unicode(iotlab_network_dict['ssh']))
-        network_elem.set('login', unicode(iotlab_network_dict['login']))
+            iotlab_network_dict['ssh'] = \
+                ['ssh ' + ldap_username + '@'+site+'.iotlab.info'
+                 for site in sites_set]
+            network_elem.set('ssh',
+                             unicode(iotlab_network_dict['ssh']))
+            network_elem.set('login', unicode(iotlab_network_dict['login']))
 
     @staticmethod
     def add_nodes(xml, nodes):
@@ -94,7 +94,6 @@ class Iotlabv1Node:
         else:
             network_elem = xml
 
-        logger.debug("iotlabv1Node \t add_nodes  nodes %s \r\n " % (nodes[0]))
         node_elems = []
         #Then add nodes items to the network item in the xml
         for node in nodes:
@@ -121,10 +120,9 @@ class Iotlabv1Node:
                         node_elem.add_instance('hardware_types', node, fields)
 
             # set mobility
-                if attribute is 'mobile':
-                    node.elem.add_instance('mobile', node['mobile'],
+                if attribute is 'mobility':
+                    node_elem.add_instance('mobility', node['mobility'],
                                            IotlabMobility.fields)
-
             # set location
                 if attribute is 'location':
                     node_elem.add_instance('location', node['location'],
@@ -132,7 +130,7 @@ class Iotlabv1Node:
 
              # add granularity of the reservation system
              #TODO put the granularity in network instead SA 18/07/12
-                if attribute is 'granularity' :
+                if attribute is 'granularity':
                     granularity = node['granularity']
                     if granularity:
                         node_elem.add_instance('granularity',
@@ -255,6 +253,12 @@ class Iotlabv1Node:
             node['interfaces'] = [iface_elem.get_instance(Interface)
                                   for iface_elem in iface_elems]
 
+            # get position
+            position_elems = node_elem.xpath('./default:position | ./position')
+            if position_elems:
+                position_elem = position_elems[0]
+                node['position'] = position_elem.get_instance(IotlabPosition)
+
             # get services
             #node['services'] = PGv2Services.get_services(node_elem)