python: Resolve pep8 comparison errors.
[cascardo/ovs.git] / vtep / ovs-vtep
index 9b6799e..47ef65c 100755 (executable)
@@ -49,21 +49,25 @@ tun_id = 0
 bfd_bridge = "vtep_bfd"
 bfd_ref = {}
 
+
 def call_prog(prog, args_list):
     cmd = [prog, "-vconsole:off"] + args_list
     output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()
-    if len(output) == 0 or output[0] == None:
+    if len(output) == 0 or output[0] is None:
         output = ""
     else:
         output = output[0].strip()
     return output
 
+
 def ovs_vsctl(args):
     return call_prog("ovs-vsctl", shlex.split(args))
 
+
 def ovs_ofctl(args):
     return call_prog("ovs-ofctl", shlex.split(args))
 
+
 def vtep_ctl(args):
     return call_prog("vtep-ctl", shlex.split(args))
 
@@ -96,7 +100,7 @@ class Logical_Switch(object):
         column = vtep_ctl("--columns=tunnel_key find logical_switch "
                               "name=%s" % self.name)
         tunnel_key = column.partition(":")[2].strip()
-        if (tunnel_key and type(eval(tunnel_key)) == types.IntType):
+        if tunnel_key and isinstance(eval(tunnel_key), types.IntType):
             self.tunnel_key = tunnel_key
             vlog.info("using tunnel key %s in %s"
                       % (self.tunnel_key, self.name))
@@ -325,6 +329,7 @@ class Logical_Switch(object):
         self.update_remote_macs()
         self.update_stats()
 
+
 def get_vtep_tunnel(remote_ip):
     # Get the physical_locator record for the local tunnel end point.
     column = vtep_ctl("--columns=_uuid find physical_locator "
@@ -346,6 +351,7 @@ def get_vtep_tunnel(remote_ip):
 
     return (local, remote, tunnel)
 
+
 def create_vtep_tunnel(remote_ip):
     local, remote, tunnel = get_vtep_tunnel(remote_ip)
     if not local or not remote:
@@ -359,6 +365,7 @@ def create_vtep_tunnel(remote_ip):
                           %(ps_name, local, remote))
     return tunnel
 
+
 def destroy_vtep_tunnel(remote_ip):
     local, remote, tunnel = get_vtep_tunnel(remote_ip)
     if tunnel:
@@ -368,6 +375,7 @@ def destroy_vtep_tunnel(remote_ip):
                  "-- --if-exists destroy tunnel %s"
                  % (ps_name, tunnel, tunnel))
 
+
 def add_bfd(remote_ip):
     # The VTEP emulator creates one OVS bridge for every logical switch.
     # Multiple logical switches can have multiple OVS tunnels to the
@@ -397,6 +405,7 @@ def add_bfd(remote_ip):
     # conditions, pass the responsibility of creating a 'tunnel' record
     # to run_bfd() which runs more often.
 
+
 def del_bfd(remote_ip):
     if remote_ip in bfd_ref:
         if bfd_ref[remote_ip] == 1:
@@ -408,6 +417,7 @@ def del_bfd(remote_ip):
         else:
             bfd_ref[remote_ip] -= 1
 
+
 def run_bfd():
     bfd_ports = ovs_vsctl("list-ports %s" % bfd_bridge).split()
     for port in bfd_ports:
@@ -475,6 +485,7 @@ def run_bfd():
                   bfd_lconf_default['bfd_config_local:bfd_dst_mac'],
                   bfd_dst_mac))
 
+
 def add_binding(binding, ls):
     vlog.info("adding binding %s" % binding)
 
@@ -516,6 +527,7 @@ def add_binding(binding, ls):
     ls.add_lbinding(lbinding)
     Bindings[binding] = ls.name
 
+
 def del_binding(binding, ls):
     vlog.info("removing binding %s" % binding)
 
@@ -545,6 +557,7 @@ def del_binding(binding, ls):
 
     del Bindings[binding]
 
+
 def handle_physical():
     # Gather physical ports except the patch ports we created
     ovs_ports = ovs_vsctl("list-ports %s" % ps_name).split()
@@ -582,7 +595,6 @@ def handle_physical():
 
             add_binding(binding, ls)
 
-
     dead_bindings = set(Bindings.keys()).difference(new_bindings)
     for binding in dead_bindings:
         ls_name = Bindings[binding]
@@ -596,6 +608,7 @@ def handle_physical():
             vtep_ctl("clear-local-macs %s" % Lswitches[ls_name].name)
             del Lswitches[ls_name]
 
+
 def setup():
     br_list = ovs_vsctl("list-br").split()
     if (ps_name not in br_list):