da299c5b920333f94535c385329ce972809149db
[sfa.git] / sfa / rspecs / elements / versions / ofeliav1link.py
1 from sfa.util.sfalogging import logger
2 from sfa.util.xml import XpathFilter
3 from sfa.util.xrn import Xrn, get_leaf
4
5 from sfa.rspecs.elements.element import Element
6 from sfa.rspecs.elements.link import Link
7
8
9 class Ofeliav1Link:
10
11     @staticmethod
12     def get_links(xml, filter=None):
13         if filter is None:
14             filter = {}
15         xpath = '//link%s | //openflow:link%s' % (
16             XpathFilter.xpath(filter), XpathFilter.xpath(filter))
17         link_elems = xml.xpath(xpath)
18         return Ofeliav1Link.get_link_objs(link_elems)
19
20     @staticmethod
21     def get_link_objs(link_elems):
22         links = []
23         for link_elem in link_elems:
24             link = Link(link_elem.attrib, link_elem)
25             links.append(link)
26         return links