# get network
networks = pg_rspec.version.get_networks()
- network_hrn = networks[0]
+ network_hrn = networks[0]["name"]
network_element = sfa_rspec.xml.add_element('network', name=network_hrn, id=network_hrn)
# get nodes
- pg_nodes_elements = pg_rspec.version.get_node_elements()
+ pg_nodes_elements = pg_rspec.version.get_nodes()
nodes_with_slivers = pg_rspec.version.get_nodes_with_slivers()
i = 1
- for pg_node_element in pg_nodes_elements:
- attribs = dict(pg_node_element.attrib.items())
+ for pg_node in pg_nodes_elements:
+ attribs = dict(pg_node.items())
attribs['id'] = 'n'+str(i)
node_element = network_element.add_element('node')
for attrib in attribs:
- node_element.set(attrib, attribs[attrib])
- urn = pg_node_element.xpath('@component_id', namespaces=pg_rspec.namespaces)
+ if type(attribs[attrib]) == str:
+ node_element.set(attrib, attribs[attrib])
+ urn = pg_node["component_id"]
if urn:
- urn = urn[0]
+ if type(urn)==list:
+ # legacy code, not sure if urn is ever a list...
+ urn = urn[0]
hostname = Xrn.urn_split(urn)[-1]
hostname_element = node_element.add_element('hostname')
hostname_element.set_text(hostname)
if hostname in nodes_with_slivers:
- node_element.add_element('sliver')
+ node_element.add_element('sliver')
+
+ for hardware_type in pg_node["hardware_types"]:
+ if "name" in hardware_type:
+ node_element.add_element("hardware_type", name=hardware_type["name"])
# just copy over remaining child elements
- for child in pg_node_element.getchildren():
- node_element.append(transform(child).getroot())
+ #for child in pg_node_element.getchildren():
+ # node_element.append(transform(child).getroot())
i = i+1
return sfa_rspec.toxml()