add_element belongs to the XML class not the RSpec class
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Tue, 4 Oct 2011 18:50:26 +0000 (14:50 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Tue, 4 Oct 2011 18:50:26 +0000 (14:50 -0400)
sfa/rspecs/pg_rspec_converter.py
sfa/rspecs/sfa_rspec_converter.py

index 875af8d..3e3729c 100755 (executable)
@@ -47,7 +47,7 @@ class PGRSpecConverter:
         # get network
         network_urn = pg_rspec.version.get_network()
         network,  _ = urn_to_hrn(network_urn)
-        network_element = sfa_rspec.add_element('network', {'name': network, 'id': network})
+        network_element = sfa_rspec.xml.add_element('network', {'name': network, 'id': network})
         
         # get nodes
         pg_nodes_elements = pg_rspec.version.get_node_elements()
@@ -57,16 +57,16 @@ class PGRSpecConverter:
             attribs = dict(pg_node_element.attrib.items()) 
             attribs['id'] = 'n'+str(i)
             
-            node_element = sfa_rspec.add_element('node', attribs, parent=network_element)
+            node_element = sfa_rspec.xml.add_element('node', attribs, parent=network_element)
             urn = pg_node_element.xpath('@component_id', namespaces=pg_rspec.namespaces)
             if urn:
                 urn = urn[0]
                 hostname = Xrn.urn_split(urn)[-1]
-                hostname_element = sfa_rspec.add_element('hostname', parent=node_element, text=hostname)
+                hostname_element = sfa_rspec.xml.add_element('hostname', parent=node_element, text=hostname)
                 if hostname in nodes_with_slivers:
-                    sfa_rspec.add_element('sliver', parent=node_element)
+                    sfa_rspec.xml.add_element('sliver', parent=node_element)
                      
-            urn_element = sfa_rspec.add_element('urn', parent=node_element, text=urn)
+            urn_element = sfa_rspec.xml.add_element('urn', parent=node_element, text=urn)
 
 
             # just copy over remaining child elements  
index 4d07846..29d14e4 100755 (executable)
@@ -34,13 +34,13 @@ class SfaRSpecConverter:
                     node_attrs['component_name'] = sfa_node_element.find('hostname').text
                 if sfa_node_element.find('urn') != None:    
                     node_attrs['component_id'] = sfa_node_element.find('urn').text
-                node_element = pg_rspec.add_element('node', node_attrs)
+                node_element = pg_rspec.xml.add_element('node', node_attrs)
 
                 # create node_type element
                 for hw_type in ['plab-pc', 'pc']:
-                    hdware_type_element = pg_rspec.add_element('hardware_type', {'name': hw_type}, parent=node_element)
+                    hdware_type_element = pg_rspec.xml.add_element('hardware_type', {'name': hw_type}, parent=node_element)
                 # create available element
-                pg_rspec.add_element('available', {'now': 'true'}, parent=node_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
@@ -51,11 +51,11 @@ class SfaRSpecConverter:
                     location_attrs['country'] =  location.get('country', 'unknown')
                     location_attrs['latitude'] = location.get('latitiue', 'None')
                     location_attrs['longitude'] = location.get('longitude', 'None')
-                    pg_rspec.add_element('location', location_attrs, parent=node_element)
+                    pg_rspec.xml.add_element('location', location_attrs, parent=node_element)
 
                 sliver_element = sfa_node_element.find('sliver')
                 if sliver_element != None:
-                    pg_rspec.add_element('sliver_type', {'name': 'planetlab-vnode'}, parent=node_element)
+                    pg_rspec.xml.add_element('sliver_type', {'name': 'planetlab-vnode'}, parent=node_element)
 
         return pg_rspec.toxml()