from sfa.util.sfalogging import logger
from sfa.util.xml import XpathFilter
-from sfa.util.plxrn import PlXrn, xrn_to_hostname
from sfa.util.xrn import Xrn
+
from sfa.rspecs.elements.element import Element
from sfa.rspecs.elements.node import Node
from sfa.rspecs.elements.sliver import Sliver
from sfa.rspecs.elements.versions.sfav1PLTag import SFAv1PLTag
from sfa.rspecs.elements.versions.pgv2Services import PGv2Services
+from sfa.planetlab.plxrn import xrn_to_hostname
+
class SFAv1Node:
@staticmethod
network_elem = network_elems[0]
elif len(nodes) > 0 and nodes[0].get('component_manager_id'):
network_urn = nodes[0]['component_manager_id']
- network_elem = xml.add_element('network', name = Xrn(network_urn).get_hrn())
+ network_elem = xml.add_element('network', name = Xrn(network_urn).get_hrn())
else:
network_elem = xml
if location:
node_elem.add_instance('location', location, Location.fields)
- for interface in node.get('interfaces', []):
- node_elem.add_instance('interface', interface, ['component_id', 'client_id', 'ipv4'])
+ 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)
# get slivers
node['slivers'] = SFAv1Sliver.get_slivers(node_elem)
# get tags
- node['tags'] = SFAv1PLTag.get_pl_tags(node_elem, ignore=Node.fields)
+ node['tags'] = SFAv1PLTag.get_pl_tags(node_elem, ignore=Node.fields+["hardware_type"])
+ # get hardware types
+ hardware_type_elems = node_elem.xpath('./default:hardware_type | ./hardware_type')
+ node['hardware_types'] = [hw_type.get_instance(HardwareType) for hw_type in hardware_type_elems]
# temporary... play nice with old slice manager rspec
if not node['component_name']: