X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Frspecs%2Felements%2Fversions%2Fofeliav1Port.py;h=360037436b456fa586b202bee8283c65a1cbff7d;hb=04a3f20dc71bf8b3f96b1e3172623aa346a638a7;hp=07520ef385daa375d8f782cd3fd9bbef34385927;hpb=9db3c20fbf81539809def807beea35a88318de7a;p=sfa.git diff --git a/sfa/rspecs/elements/versions/ofeliav1Port.py b/sfa/rspecs/elements/versions/ofeliav1Port.py index 07520ef3..36003743 100644 --- a/sfa/rspecs/elements/versions/ofeliav1Port.py +++ b/sfa/rspecs/elements/versions/ofeliav1Port.py @@ -1,14 +1,15 @@ from sfa.util.xrn import Xrn from sfa.util.xml import XmlElement -from sfa.rspecs.elements.element import Element -from sfa.rspecs.elements.port import Port +from sfa.rspecs.elements.element import Element +from sfa.rspecs.elements.port import Port + class Ofeliav1Port: @staticmethod def add_portrs(xml, ports): - raise Exception, "not implemented yet" + raise Exception("not implemented yet") if not ports: return if not isinstance(ports, list): @@ -18,14 +19,15 @@ class Ofeliav1Port: tags = port.get('tags', []) if tags: for tag in tags: - Ofeliav1Port.add_port_attribute(port_elem, tag['tagname'], tag['value']) + Ofeliav1Port.add_port_attribute( + port_elem, tag['tagname'], tag['value']) @staticmethod def add_port_attribute(xml, name, value): - raise Exception, "not implemented yet" + raise Exception("not implemented yet") elem = xml.add_element(name) elem.set_text(value) - + @staticmethod def get_port_attributes(xml): attribs = [] @@ -36,18 +38,19 @@ class Ofeliav1Port: instance['name'] = elem.tag instance['value'] = elem.text attribs.append(instance) - return attribs - + return attribs + @staticmethod - def get_ports(xml, filter={}): + def get_ports(xml, filter=None): + if filter is None: + filter = {} xpath = './openflow:port | ./port' port_elems = xml.xpath(xpath) ports = [] for port_elem in port_elems: - port = Port(port_elem.attrib,port_elem) - #if 'component_id' in xml.attrib: + port = Port(port_elem.attrib, port_elem) + # if 'component_id' in xml.attrib: # port['component_id'] = xml.attrib['component_id'] #port['tags'] = Ofeliav1Port.get_port_attributes(port_elem) ports.append(port) - return ports - + return ports