fix protogeni rspec converter
authorsmbaker <smbaker@fc8clean.lan>
Fri, 30 Dec 2011 03:38:34 +0000 (19:38 -0800)
committersmbaker <smbaker@fc8clean.lan>
Fri, 30 Dec 2011 03:38:34 +0000 (19:38 -0800)
sfa/rspecs/pg_rspec_converter.py

index 5cccf97..5db0dc3 100755 (executable)
@@ -51,21 +51,22 @@ class PGRSpecConverter:
 
         # 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]
                 hostname = Xrn.urn_split(urn)[-1]
@@ -75,8 +76,8 @@ class PGRSpecConverter:
                     node_element.add_element('sliver')  
                      
             # 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()