From c09cb1cf1e4b83db7c8471d80af249d34ec6a6b7 Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Fri, 21 Oct 2011 16:42:06 -0400 Subject: [PATCH] fix bug in add_links() --- sfa/rspecs/elements/versions/pgv2Link.py | 4 ++-- sfa/rspecs/versions/pgv2.py | 26 ++---------------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/sfa/rspecs/elements/versions/pgv2Link.py b/sfa/rspecs/elements/versions/pgv2Link.py index b10e5667..5f4e6062 100644 --- a/sfa/rspecs/elements/versions/pgv2Link.py +++ b/sfa/rspecs/elements/versions/pgv2Link.py @@ -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']) diff --git a/sfa/rspecs/versions/pgv2.py b/sfa/rspecs/versions/pgv2.py index 97099d19..79fba2d9 100644 --- a/sfa/rspecs/versions/pgv2.py +++ b/sfa/rspecs/versions/pgv2.py @@ -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 -- 2.43.0