attempt to fill in all known Interface fields in get_links()
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Thu, 20 Oct 2011 20:33:20 +0000 (16:33 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Thu, 20 Oct 2011 20:33:20 +0000 (16:33 -0400)
sfa/rspecs/elements/versions/pgv2Link.py

index ee34371..f3c35c9 100644 (file)
@@ -13,8 +13,11 @@ class PGv2Link:
                     link_elem.set(attrib, link[attrib])
             if 'component_manager' in link and link['component_manger']:
                 cm_element = etree.SubElement(xml, 'component_manager', name=link['component_manager'])
-            if_ref1 = etree.SubElement(xml, 'interface_ref', component_id=link['interface1']['component_id'])
-            if_ref2 = etree.SubElement(xml, 'interface_ref', component_id=link['interface2']['component_id'])
+            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]  
             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'])