From: Tony Mack Date: Thu, 20 Oct 2011 20:47:24 +0000 (-0400) Subject: attempt to fill in all known Interface fields in get_links() X-Git-Tag: sfa-1.1-1~79 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=6054ed5cc37a41b656ee4197f246538692d87bc5;hp=25bd7882e893a3a76ac7d31141fd0b18f73a3906;p=sfa.git attempt to fill in all known Interface fields in get_links() --- 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