From bbf6d330e9a313c3b9625aa95bcfb25a37d27f96 Mon Sep 17 00:00:00 2001 From: Sandrine Avakian Date: Wed, 31 Jul 2013 11:28:23 +0200 Subject: [PATCH] Changing mobility attribute in iotlab rspec type. --- sfa/iotlab/OARrestapi.py | 26 ++++++++------- sfa/iotlab/iotlabaggregate.py | 33 ++++++++++++-------- sfa/rspecs/elements/versions/iotlabv1Node.py | 12 ++++--- 3 files changed, 42 insertions(+), 29 deletions(-) diff --git a/sfa/iotlab/OARrestapi.py b/sfa/iotlab/OARrestapi.py index c5e714d2..40aad500 100644 --- a/sfa/iotlab/OARrestapi.py +++ b/sfa/iotlab/OARrestapi.py @@ -380,14 +380,25 @@ class ParsingResourcesFull(): # """ # tuplelist.append(('radio', str(value))) + def AddMobilityType(self, tuplelist, value): + """Adds which kind of mobility it is, train or roomba robot. + + :param tuplelist: tuple list on which to add the node's mobility status. + The tuplelist is the value associated with the node's id in the + OARGETParser's dictionary node_dictlist. + :param value: tells if a node is a mobile node or not. The value is + found in the json. + + :type tuplelist: list + :type value: integer + + """ + tuplelist.append(('mobility-type', str(value))) + def AddMobility(self, tuplelist, value): """Add if the node is a mobile node or not to the tuple list. - will also add which kind of mobility it is if the information - is available, supposing the information is formatted as a string - with the 2 information separated by a colon. - :param tuplelist: tuple list on which to add the node's mobility status. The tuplelist is the value associated with the node's id in the OARGETParser's dictionary node_dictlist. @@ -401,13 +412,6 @@ class ParsingResourcesFull(): """ # future support of mobility type - if ":" in value: - value_list = value.split(':') - if value_list[0] is 0: - tuplelist.append(('mobile', 'False')) - else: - tuplelist.append(('mobile', 'True')) - tuplelist.append(('type', value_list[1])) if value is 0: tuplelist.append(('mobile', 'False')) diff --git a/sfa/iotlab/iotlabaggregate.py b/sfa/iotlab/iotlabaggregate.py index cffc1eff..fe678ab8 100644 --- a/sfa/iotlab/iotlabaggregate.py +++ b/sfa/iotlab/iotlabaggregate.py @@ -16,7 +16,7 @@ from sfa.rspecs.elements.granularity import Granularity from sfa.rspecs.version_manager import VersionManager from sfa.rspecs.elements.versions.iotlabv1Node import IotlabPosition, \ - IotlabNode, IotlabLocation + IotlabNode, IotlabLocation, IotlabMobility from sfa.util.sfalogging import logger from sfa.util.xrn import Xrn @@ -199,7 +199,6 @@ class IotlabAggregate: logger.debug("IOTLABAGGREGATE api get_nodes slice_nodes_list %s " % (slices)) - reserved_nodes = self.driver.iotlab_api.GetNodesCurrentlyInUse() logger.debug("IOTLABAGGREGATE api get_nodes slice_nodes_list %s " % (slice_nodes_list)) @@ -212,7 +211,7 @@ class IotlabAggregate: #site_id=node['site_id'] #site=sites_dict[site_id] - rspec_node['mobile'] = node['mobile'] + # rspec_node['mobile'] = node['mobile'] rspec_node['archi'] = node['archi'] rspec_node['radio'] = node['radio'] @@ -233,27 +232,35 @@ class IotlabAggregate: # do not include boot state ( element) #in the manifest rspec - rspec_node['boot_state'] = node['boot_state'] if node['hostname'] in reserved_nodes: rspec_node['boot_state'] = "Reserved" rspec_node['exclusive'] = 'true' - rspec_node['hardware_types'] = [HardwareType({'name': \ - 'iotlab-node'})] + rspec_node['hardware_types'] = [HardwareType({'name': + 'iotlab-node'})] - location = IotlabLocation({'country':'France', 'site': \ + location = IotlabLocation({'country':'France', 'site': node['site']}) rspec_node['location'] = location + # Adding mobility of the node in the rspec + mobility = IotlabMobility() + for field in mobility: + try: + mobility[field] = node[field] + except KeyError, error: + logger.log_exc("IOTLABAGGREGATE\t get_nodes \ + mobility %s " % (error)) + rspec_node['mobility'] = mobility position = IotlabPosition() - for field in position : + for field in position: try: position[field] = node[field] - except KeyError, error : + except KeyError, error: logger.log_exc("IOTLABAGGREGATE\t get_nodes \ - position %s "% (error)) + position %s " % (error)) rspec_node['position'] = position #rspec_node['interfaces'] = [] @@ -270,9 +277,9 @@ class IotlabAggregate: rspec_node['slivers'] = [sliver] # slivers always provide the ssh service - login = Login({'authentication': 'ssh-keys', \ - 'hostname': node['hostname'], 'port':'22', \ - 'username': sliver['name']}) + login = Login({'authentication': 'ssh-keys', + 'hostname': node['hostname'], 'port': '22', + 'username': sliver['name']}) service = Services({'login': login}) rspec_node['services'] = [service] rspec_nodes.append(rspec_node) diff --git a/sfa/rspecs/elements/versions/iotlabv1Node.py b/sfa/rspecs/elements/versions/iotlabv1Node.py index 7efd8f69..af3d0d4c 100644 --- a/sfa/rspecs/elements/versions/iotlabv1Node.py +++ b/sfa/rspecs/elements/versions/iotlabv1Node.py @@ -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'] @@ -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 -- 2.47.0