- if 'boot_state' in node and node['boot_state']:
- node_elem.set('boot_state', node['boot_state'])
- if 'location' in node and node['location']:
- location_elem = etree.SubElement(node_elem, 'location')
- for field in Location.fields:
- if field in node['location'] and node['location'][field]:
- location_elem.set(field, node['location'][field])
- if 'interfaces' in node and node['interfaces']:
- i = 0
- for interface in node['interfaces']:
- if 'bwlimit' in interface and interface['bwlimit']:
- bwlimit = etree.SubElement(node_elem, 'bw_limit', units='kbps').text = str(interface['bwlimit']/1000)
- comp_id = PlXrn(auth=network, interface='node%s:eth%s' % (interface['node_id'], i)).get_urn()
- ipaddr = interface['ipv4']
- interface_elem = etree.SubElement(node_elem, 'interface', component_id=comp_id, ipv4=ipaddr)
- i+=1
- if 'bw_unallocated' in node and node['bw_unallocated']:
- bw_unallocated = etree.SubElement(node_elem, 'bw_unallocated', units='kbps').text = str(int(node['bw_unallocated'])/1000)
-
- if 'tags' in node:
- for tag in node['tags']:
- # expose this hard wired list of tags, plus the ones that are marked 'sfa' in their category
- if tag['name'] in ['fcdistro', 'arch']:
- tag_element = etree.SubElement(node_elem, tag['name']).text=tag['value']
-
- if 'slivers' in node:
- for sliver in node['slivers']:
- sliver_elem = etree.SubElement(node_elem, 'sliver')
- if 'name' in sliver and sliver['name']:
- sliver_elem.set('name', sliver['name'])
+
+ # add locaiton
+ location = node.get('location')
+ if location:
+ node_elem.add_instance('location', location, Location.fields)
+
+ # add granularity of the reservation system
+ granularity = node.get('granularity')
+ if granularity:
+ node_elem.add_instance('granularity', granularity, granularity.fields)
+
+
+ if isinstance(node.get('interfaces'), list):
+ for interface in node.get('interfaces', []):
+ node_elem.add_instance('interface', interface, ['component_id', 'client_id', 'ipv4'])
+
+ #if 'bw_unallocated' in node and node['bw_unallocated']:
+ # bw_unallocated = etree.SubElement(node_elem, 'bw_unallocated', units='kbps').text = str(int(node['bw_unallocated'])/1000)
+
+ PGv2Services.add_services(node_elem, node.get('services', []))
+ tags = node.get('tags', [])
+ if tags:
+ for tag in tags:
+ tag_elem = node_elem.add_element(tag['tagname'])
+ tag_elem.set_text(tag['value'])
+ SFAv1Sliver.add_slivers(node_elem, node.get('slivers', []))