1 from sfa.util.xrn import Xrn
2 from sfa.util.xml import XmlElement
4 from sfa.rspecs.elements.element import Element
5 from sfa.rspecs.elements.port import Port
11 def add_portrs(xml, ports):
12 raise Exception("not implemented yet")
15 if not isinstance(ports, list):
18 port_elem = xml.add_instance('port', port, ['name'])
19 tags = port.get('tags', [])
22 Ofeliav1Port.add_port_attribute(
23 port_elem, tag['tagname'], tag['value'])
26 def add_port_attribute(xml, name, value):
27 raise Exception("not implemented yet")
28 elem = xml.add_element(name)
32 def get_port_attributes(xml):
34 for elem in xml.iterchildren():
35 if elem.tag not in Port.fields:
36 xml_element = XmlElement(elem, xml.namespaces)
37 instance = Element(fields=xml_element, element=elem)
38 instance['name'] = elem.tag
39 instance['value'] = elem.text
40 attribs.append(instance)
44 def get_ports(xml, filter=None):
47 xpath = './openflow:port | ./port'
48 port_elems = xml.xpath(xpath)
50 for port_elem in port_elems:
51 port = Port(port_elem.attrib, port_elem)
52 # if 'component_id' in xml.attrib:
53 # port['component_id'] = xml.attrib['component_id']
54 #port['tags'] = Ofeliav1Port.get_port_attributes(port_elem)