rspec.version.add_nodes take an extra arg to handle Request RSpec
[sfa.git] / sfa / rspecs / elements / versions / iotlabv1Node.py
index 7efd8f6..bb1a010 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']
 
 
 
@@ -69,7 +69,7 @@ class Iotlabv1Node:
         network_elem.set('login', unicode(iotlab_network_dict['login']))
 
     @staticmethod
-    def add_nodes(xml, nodes):
+    def add_nodes(xml, nodes, rspec_content_type=None):
         """Adds the nodes to the xml.
 
         Adds the nodes as well as dedicated iotlab fields to the node xml
@@ -121,10 +121,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 +131,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',
@@ -148,9 +147,12 @@ class Iotlabv1Node:
                                                                now='false')
 
             #set position
+                logger.debug("Iotlabv1Node position node_elem %s" % (node_elem))
                 if attribute is 'position':
                     node_elem.add_instance('position', node['position'],
                                            IotlabPosition.fields)
+                logger.debug("Iotlabv1Node position node[position] %s "
+                            % (node['position']))
             ## add services
             #PGv2Services.add_services(node_elem, node.get('services', []))
             # add slivers
@@ -167,6 +169,11 @@ class Iotlabv1Node:
                                                     #'value': initscript['name']})
 
                     Iotlabv1Sliver.add_slivers(node_elem, slivers)
+            
+            # add sliver tag in Request Rspec
+            if rspec_content_type == "request":
+                node_elem.add_instance('sliver', '', [])
+
         return node_elems
 
     @staticmethod
@@ -255,6 +262,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)