From 6054ed5cc37a41b656ee4197f246538692d87bc5 Mon Sep 17 00:00:00 2001
From: Tony Mack <tmack@paris.CS.Princeton.EDU>
Date: Thu, 20 Oct 2011 16:47:24 -0400
Subject: [PATCH] attempt to fill in all known Interface fields in get_links()

---
 sfa/rspecs/elements/versions/pgv2Link.py | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/sfa/rspecs/elements/versions/pgv2Link.py b/sfa/rspecs/elements/versions/pgv2Link.py
index f3c35c9c..b10e5667 100644
--- a/sfa/rspecs/elements/versions/pgv2Link.py
+++ b/sfa/rspecs/elements/versions/pgv2Link.py
@@ -47,17 +47,23 @@ class PGv2Link:
                 if 'name' in link_type.attrib:
                     link['type'] = link_type.attrib['name']
           
-            # get capacity, latency and packet_loss and interfaces from first property  
+            # get capacity, latency and packet_loss from first property  
             props = link_elem.xpath('./default:property', namespaces=namespaces)
             if len(props) > 0:
                 prop = props[0]
-                if 'source_id' in prop.attrib:
-                    link['interface1'] = Interface({'component_id': prop.attrib['source_id']}) 
-                if 'dest_id' in prop.attrib:
-                    link['interface2'] = Interface({'component_id': prop.attrib['dest_id']})
                 for attrib in ['capacity', 'latency', 'packet_loss']:
                     if attrib in prop.attrib:
                         link[attrib] = prop.attrib[attrib]
+                             
+            # get interfaces 
+            if_elems = link_elem.xpath('./default:interface_ref', namespaces=namespaces)
+            ifs = []
+            for if_elem in if_elems:
+                if_ref = Interface(if_elem.attrib)                 
+                ifs.append(if_ref)
+            if len(ifs) > 1:
+                link['interface1'] = ifs[0]
+                link['interface2'] = ifs[1] 
             links.append(link)
         return links 
             
-- 
2.47.0