git://git.onelab.eu
/
sfa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
autopep8
[sfa.git]
/
sfa
/
rspecs
/
elements
/
versions
/
ofeliav1Port.py
diff --git
a/sfa/rspecs/elements/versions/ofeliav1Port.py
b/sfa/rspecs/elements/versions/ofeliav1Port.py
index
07520ef
..
3600374
100644
(file)
--- 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.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):
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):
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:
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):
@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)
elem = xml.add_element(name)
elem.set_text(value)
-
+
@staticmethod
def get_port_attributes(xml):
attribs = []
@staticmethod
def get_port_attributes(xml):
attribs = []
@@
-36,18
+38,19
@@
class Ofeliav1Port:
instance['name'] = elem.tag
instance['value'] = elem.text
attribs.append(instance)
instance['name'] = elem.tag
instance['value'] = elem.text
attribs.append(instance)
- return attribs
-
+ return attribs
+
@staticmethod
@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:
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)
# port['component_id'] = xml.attrib['component_id']
#port['tags'] = Ofeliav1Port.get_port_attributes(port_elem)
ports.append(port)
- return ports
-
+ return ports