fix bug in add_links()
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Fri, 21 Oct 2011 20:42:06 +0000 (16:42 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Fri, 21 Oct 2011 20:42:06 +0000 (16:42 -0400)
sfa/rspecs/elements/versions/pgv2Link.py
sfa/rspecs/versions/pgv2.py

index b10e566..5f4e606 100644 (file)
@@ -11,13 +11,13 @@ class PGv2Link:
             for attrib in ['component_name', 'component_id', 'client_id']:
                 if attrib in link and link[attrib]:
                     link_elem.set(attrib, link[attrib])
-            if 'component_manager' in link and link['component_manger']:
+            if 'component_manager' in link and link['component_manager']:
                 cm_element = etree.SubElement(xml, 'component_manager', name=link['component_manager'])
             for if_ref in [link['interface1'], link['interface2']]:
                 if_ref_elem = etree.SubElement(xml, 'interface_ref')
                 for attrib in Interface.fields:
                     if attrib in if_ref and if_ref[attrib]:
-                        if_ref_elem[attrib] = if_ref[attrib]  
+                        if_ref_elem.attrib[attrib] = if_ref[attrib]  
             prop1 = etree.SubElement(xml, 'property', source_id = link['interface1']['component_id'],
                 dest_id = link['interface2']['component_id'], capacity=link['capacity'], 
                 latency=link['latency'], packet_loss=link['packet_loss'])
index 97099d1..79fba2d 100644 (file)
@@ -97,11 +97,11 @@ class PGv2(BaseVersion):
         return slice_attributes
 
     def get_links(self, network=None):
-        links = PGv2Link.get_links(self.xml, self.namespaces)
+        links = PGv2Link.get_links(self.xml.root, self.namespaces)
         return links
 
     def add_links(self, links):
-        PGv2Link.add_links(self.xml, links)
+        PGv2Link.add_links(self.xml.root, links)
 
     def attributes_list(self, elem):
         opts = []
@@ -226,28 +226,6 @@ class PGv2(BaseVersion):
     def add_interfaces(self, interfaces, no_dupes=False):
         pass
 
-    def add_links(self, links, no_dupes=False):
-        for link in links:
-            link_elem = etree.SubElement(self.xml.root, 'link' )
-            link_elem.set('component_name', link.component_name) 
-            link_elem.set('component_id', link.component_id)
-            cm_elem = etree.SubElement(link_elem, 'component_manager')
-            cm_elem.set('name', link.component_manager_name)
-            for endpoint in [link.endpoint1, link.enpoint2]:
-                interface_ref = etree.SubElement(link_elem, 'interface_ref', component_id=endpoint.id)
-                
-            property_attrs = {'capicity': link.capacity, 
-                              'latency': link.latency, 
-                              'packet_loss': link.packet_loss}    
-            property1 = etree.SubElement(link_elem, 'property', source_id=link.endpoint1.id, \
-              dest_id = link.endpoint2.id, capacity = link.capacity, latency=link.latency, \
-              packet_loss = link.packet_loss)
-            
-            property2 = etree.SubElement(link_elem, 'property', source_id=link.endpoint2.id, \
-              dest_id = link.endpoint1.id, capacity = link.capacity, latency=link.latency, \
-              packet_loss = link.packet_loss)
-            link_type = etree.SubElement(link_elem, 'link_type', name=link.type)
-
     def merge(self, in_rspec):
         """
         Merge contents for specified rspec with current rspec