From 6fe050404deb9f0b9a16dc42db3a22c21306523d Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Fri, 7 Oct 2011 15:46:36 -0400 Subject: [PATCH] component_manger_id should be a urn, not hrn --- sfa/rspecs/sfa_rspec_converter.py | 65 ++++++++++++++++++------------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/sfa/rspecs/sfa_rspec_converter.py b/sfa/rspecs/sfa_rspec_converter.py index 77bdc3cb..d34127b8 100755 --- a/sfa/rspecs/sfa_rspec_converter.py +++ b/sfa/rspecs/sfa_rspec_converter.py @@ -34,38 +34,47 @@ class SfaRSpecConverter: # create node element node_attrs = {} node_attrs['exclusive'] = 'false' - node_attrs['component_manager_id'] = network + if 'component_manager_id' in sfa_node_element.attrib: + component_manager_id = sfa_node_element.attrib['component_manager_id'] + else: + component_manager_id = hrn_to_urn(network, 'authority+cm') + node_attrs['component_manager_id'] = component_manager_id if sfa_node_element.find('hostname') != None: node_attrs['component_name'] = sfa_node_element.find('hostname').text - if sfa_node_element.find('urn') != None: + if sfa_node_element.find('urn') != None: node_attrs['component_id'] = sfa_node_element.find('urn').text - node_element = pg_rspec.xml.add_element('node', node_attrs) + node_element = pg_rspec.xml.add_element('node', node_attrs) + + if content_type == 'request': + sliver_element = sfa_node_element.find('sliver') + if sliver_element != None: + pg_rspec.xml.add_element('sliver_type', {'name': 'planetlab-vnode'}, parent=node_element) + else: + # create node_type element + for hw_type in ['plab-pc', 'pc']: + hdware_type_element = pg_rspec.xml.add_element('hardware_type', {'name': hw_type}, parent=node_element) + # create available element + pg_rspec.xml.add_element('available', {'now': 'true'}, parent=node_element) + # create locaiton element + # We don't actually associate nodes with a country. + # Set country to "unknown" until we figure out how to make + # sure this value is always accurate. + location = sfa_node_element.find('location') + if location != None: + location_attrs = {} + location_attrs['country'] = location.get('country', 'unknown') + location_attrs['latitude'] = location.get('latitiue', 'None') + location_attrs['longitude'] = location.get('longitude', 'None') + pg_rspec.xml.add_element('location', location_attrs, parent=node_element) - # create node_type element - for hw_type in ['plab-pc', 'pc']: - hdware_type_element = pg_rspec.xml.add_element('hardware_type', {'name': hw_type}, parent=node_element) - # create available element - pg_rspec.xml.add_element('available', {'now': 'true'}, parent=node_element) - # create locaiton element - # We don't actually associate nodes with a country. - # Set country to "unknown" until we figure out how to make - # sure this value is always accurate. - location = sfa_node_element.find('location') - if location != None: - location_attrs = {} - location_attrs['country'] = location.get('country', 'unknown') - location_attrs['latitude'] = location.get('latitiue', 'None') - location_attrs['longitude'] = location.get('longitude', 'None') - pg_rspec.xml.add_element('location', location_attrs, parent=node_element) - - sliver_element = sfa_node_element.find('sliver') - if sliver_element != None: - if content_type == 'request': - # remove all child elements - for child in sfa_node_element.iterchildren(): - sfa_node_element.remove(child) - # add the sliver - pg_rspec.xml.add_element('sliver_type', {'name': 'planetlab-vnode'}, parent=node_element) + sliver_element = sfa_node_element.find('sliver') + if sliver_element != None: + if content_type == 'request': + # remove all child elements + for child in sfa_node_element.iterchildren(): + sfa_node_element.remove(child) + # add the sliver + pg_rspec.xml.add_element('sliver_type', {'name': 'planetlab-vnode'}, parent=node_element) return pg_rspec.toxml() -- 2.47.0