lib: fix pep8

Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Yoshihiro Kaneko 2014-05-13 19:58:29 +09:00 committed by FUJITA Tomonori
parent 16839dfc68
commit 3f46c5a2ff
7 changed files with 43 additions and 43 deletions

View File

@ -74,9 +74,9 @@ class EventMulticastGroupStateChanged(event.EventBase):
class IgmpLib(app_manager.RyuApp):
"""IGMP snooping library."""
#-------------------------------------------------------------------
# -------------------------------------------------------------------
# PUBLIC METHODS
#-------------------------------------------------------------------
# -------------------------------------------------------------------
def __init__(self):
"""initialization."""
super(IgmpLib, self).__init__()
@ -97,9 +97,9 @@ class IgmpLib(app_manager.RyuApp):
"""
self._querier.set_querier_mode(dpid, server_port)
#-------------------------------------------------------------------
# -------------------------------------------------------------------
# PUBLIC METHODS ( EVENT HANDLERS )
#-------------------------------------------------------------------
# -------------------------------------------------------------------
@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
def packet_in_handler(self, evt):
"""PacketIn event handler. when the received packet was IGMP,
@ -133,9 +133,9 @@ class IgmpLib(app_manager.RyuApp):
class IgmpBase(object):
"""IGMP abstract class library."""
#-------------------------------------------------------------------
# -------------------------------------------------------------------
# PUBLIC METHODS
#-------------------------------------------------------------------
# -------------------------------------------------------------------
def __init__(self):
self._set_flow_func = {
ofproto_v1_0.OFP_VERSION: self._set_flow_entry_v1_0,
@ -148,9 +148,9 @@ class IgmpBase(object):
ofproto_v1_3.OFP_VERSION: self._del_flow_entry_v1_2,
}
#-------------------------------------------------------------------
# -------------------------------------------------------------------
# PROTECTED METHODS ( RELATED TO OPEN FLOW PROTOCOL )
#-------------------------------------------------------------------
# -------------------------------------------------------------------
def _set_flow_entry_v1_0(self, datapath, actions, in_port, dst,
src=None):
ofproto = datapath.ofproto
@ -230,9 +230,9 @@ class IgmpBase(object):
data=data, in_port=in_port, actions=actions)
datapath.send_msg(out)
#-------------------------------------------------------------------
# -------------------------------------------------------------------
# PROTECTED METHODS ( OTHERS )
#-------------------------------------------------------------------
# -------------------------------------------------------------------
def _ipv4_text_to_int(self, ip_text):
"""convert ip v4 string to integer."""
if ip_text is None:
@ -251,9 +251,9 @@ class IgmpQuerier(IgmpBase):
- and so on
"""
#-------------------------------------------------------------------
# -------------------------------------------------------------------
# PUBLIC METHODS
#-------------------------------------------------------------------
# -------------------------------------------------------------------
def __init__(self):
"""initialization."""
super(IgmpQuerier, self).__init__()
@ -319,9 +319,9 @@ class IgmpQuerier(IgmpBase):
self._datapath = None
self.logger.info("stopped a querier.")
#-------------------------------------------------------------------
# -------------------------------------------------------------------
# PRIVATE METHODS ( RELATED TO IGMP )
#-------------------------------------------------------------------
# -------------------------------------------------------------------
def _send_query(self):
""" send a QUERY message periodically."""
timeout = 60
@ -407,7 +407,7 @@ class IgmpQuerier(IgmpBase):
update = False
self._mcast.setdefault(report.address, {})
if not in_port in self._mcast[report.address]:
if in_port not in self._mcast[report.address]:
update = True
self._mcast[report.address][in_port] = True
@ -442,9 +442,9 @@ class IgmpQuerier(IgmpBase):
self._del_flow_entry(
datapath, self.server_port, leave.address)
#-------------------------------------------------------------------
# -------------------------------------------------------------------
# PRIVATE METHODS ( OTHERS )
#-------------------------------------------------------------------
# -------------------------------------------------------------------
def _set_logger(self):
"""change log format."""
self.logger.propagate = False
@ -457,9 +457,9 @@ class IgmpQuerier(IgmpBase):
class IgmpSnooper(IgmpBase):
"""IGMP snooping class library."""
#-------------------------------------------------------------------
# -------------------------------------------------------------------
# PUBLIC METHODS
#-------------------------------------------------------------------
# -------------------------------------------------------------------
def __init__(self, send_event):
"""initialization."""
super(IgmpSnooper, self).__init__()
@ -550,9 +550,9 @@ class IgmpSnooper(IgmpBase):
req_igmp.msgtype)
self._do_flood(in_port, msg)
#-------------------------------------------------------------------
# -------------------------------------------------------------------
# PRIVATE METHODS ( RELATED TO IGMP )
#-------------------------------------------------------------------
# -------------------------------------------------------------------
def _do_query(self, query, iph, eth, in_port, msg):
"""the process when the snooper received a QUERY message."""
datapath = msg.datapath
@ -798,9 +798,9 @@ class IgmpSnooper(IgmpBase):
self._do_packet_out(
datapath, leave.data, in_port, actions)
#-------------------------------------------------------------------
# -------------------------------------------------------------------
# PRIVATE METHODS ( OTHERS )
#-------------------------------------------------------------------
# -------------------------------------------------------------------
def _set_logger(self):
"""change log format."""
self.logger.propagate = False

View File

@ -53,9 +53,9 @@ class EventSlaveStateChanged(event.EventBase):
class LacpLib(app_manager.RyuApp):
"""LACP exchange library. this works only in a PASSIVE mode."""
#-------------------------------------------------------------------
# -------------------------------------------------------------------
# PUBLIC METHODS
#-------------------------------------------------------------------
# -------------------------------------------------------------------
def __init__(self):
"""initialization."""
super(LacpLib, self).__init__()
@ -92,9 +92,9 @@ class LacpLib(app_manager.RyuApp):
bond[dpid] = ifs
self._bonds.append(bond)
#-------------------------------------------------------------------
# -------------------------------------------------------------------
# PUBLIC METHODS ( EVENT HANDLERS )
#-------------------------------------------------------------------
# -------------------------------------------------------------------
@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
def packet_in_handler(self, evt):
"""PacketIn event handler. when the received packet was LACP,
@ -133,9 +133,9 @@ class LacpLib(app_manager.RyuApp):
self.send_event_to_observers(
EventSlaveStateChanged(datapath, port, False))
#-------------------------------------------------------------------
# -------------------------------------------------------------------
# PRIVATE METHODS ( RELATED TO LACP )
#-------------------------------------------------------------------
# -------------------------------------------------------------------
def _do_lacp(self, req_lacp, src, msg):
"""packet-in process when the received packet is LACP."""
datapath = msg.datapath
@ -280,9 +280,9 @@ class LacpLib(app_manager.RyuApp):
break
return result
#-------------------------------------------------------------------
# -------------------------------------------------------------------
# PRIVATE METHODS ( RELATED TO OPEN FLOW PROTOCOL )
#-------------------------------------------------------------------
# -------------------------------------------------------------------
def _add_flow_v1_0(self, src, port, timeout, datapath):
"""enter a flow entry for the packet from the slave i/f
with idle_timeout. for OpenFlow ver1.0."""
@ -320,9 +320,9 @@ class LacpLib(app_manager.RyuApp):
instructions=inst)
datapath.send_msg(mod)
#-------------------------------------------------------------------
# -------------------------------------------------------------------
# PRIVATE METHODS ( OTHERS )
#-------------------------------------------------------------------
# -------------------------------------------------------------------
def _set_logger(self):
"""change log format."""
self.logger.propagate = False

View File

@ -282,10 +282,10 @@ def to_match(dp, attrs):
if attrs.get('dl_type') == ether.ETH_TYPE_ARP or \
attrs.get('eth_type') == ether.ETH_TYPE_ARP:
if 'nw_src' in attrs and not 'arp_spa' in attrs:
if 'nw_src' in attrs and 'arp_spa' not in attrs:
attrs['arp_spa'] = attrs['nw_src']
del attrs['nw_src']
if 'nw_dst' in attrs and not 'arp_tpa' in attrs:
if 'nw_dst' in attrs and 'arp_tpa' not in attrs:
attrs['arp_tpa'] = attrs['nw_dst']
del attrs['nw_dst']

View File

@ -309,10 +309,10 @@ def to_match(dp, attrs):
if attrs.get('dl_type') == ether.ETH_TYPE_ARP or \
attrs.get('eth_type') == ether.ETH_TYPE_ARP:
if 'nw_src' in attrs and not 'arp_spa' in attrs:
if 'nw_src' in attrs and 'arp_spa' not in attrs:
attrs['arp_spa'] = attrs['nw_src']
del attrs['nw_src']
if 'nw_dst' in attrs and not 'arp_tpa' in attrs:
if 'nw_dst' in attrs and 'arp_tpa' not in attrs:
attrs['arp_tpa'] = attrs['nw_dst']
del attrs['nw_dst']

View File

@ -202,7 +202,7 @@ class EndPoint(object):
# bogus msgid
# XXXwarn
return
assert not msgid in self._responses
assert msgid not in self._responses
self._responses[msgid] = (error, result)
self._incoming += 1

View File

@ -459,7 +459,7 @@ class Bridge(object):
if match_field.header == dp.ofproto.OXM_OF_IN_PORT:
in_port_no = match_field.value
break
if not in_port_no in self.ports:
if in_port_no not in self.ports:
return
in_port = self.ports[in_port_no]
@ -506,7 +506,7 @@ class Bridge(object):
elif bpdu.RstBPDUs in pkt:
""" Receive Rst BPDU. """
#TODO: RSTP
# TODO: RSTP
pass
else:
@ -1029,12 +1029,12 @@ class Port(object):
flags=flags,
root_priority=self.port_priority.root_id.priority,
root_mac_address=self.port_priority.root_id.mac_addr,
root_path_cost=self.port_priority.root_path_cost+self.path_cost,
root_path_cost=self.port_priority.root_path_cost + self.path_cost,
bridge_priority=self.bridge_id.priority,
bridge_mac_address=self.bridge_id.mac_addr,
port_priority=self.port_id.priority,
port_number=self.ofport.port_no,
message_age=self.port_times.message_age+1,
message_age=self.port_times.message_age + 1,
max_age=self.port_times.max_age,
hello_time=self.port_times.hello_time,
forward_delay=self.port_times.forward_delay)

View File

@ -294,7 +294,7 @@ class StringifyMixin(object):
try:
return cls(**dict(kwargs, **additional_args))
except TypeError:
#debug
# debug
print "CLS", cls
print "ARG", dict_
print "KWARG", kwargs