# 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()