[ovs-dev] [PATCH 2/4] ovs-vtep: Store physical switch name globally.
Gurucharan Shetty
shettyg at nicira.com
Fri Aug 1 17:40:36 UTC 2014
ovs-vtep is an emulator and it works only on one
physical switch. This switch name is stored in the variable
'ps_name' and then passed around. An upcoming commit requires
access to this variable at more places and it is easier if this
variable is global.
Signed-off-by: Gurucharan Shetty <gshetty at nicira.com>
---
vtep/ovs-vtep | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/vtep/ovs-vtep b/vtep/ovs-vtep
index d78a842..a44fbde 100755
--- a/vtep/ovs-vtep
+++ b/vtep/ovs-vtep
@@ -38,6 +38,7 @@ __pychecker__ = 'no-reuseattr' # Remove in pychecker >= 0.8.19.
vlog = ovs.vlog.Vlog("ovs-vtep")
exiting = False
+ps_name = ""
Tunnel_Ip = ""
Lswitches = {}
Bindings = {}
@@ -305,7 +306,7 @@ class Logical_Switch(object):
self.update_remote_macs()
self.update_stats()
-def add_binding(ps_name, binding, ls):
+def add_binding(binding, ls):
vlog.info("adding binding %s" % binding)
vlan, pp_name = binding.split("-")
@@ -346,7 +347,7 @@ def add_binding(ps_name, binding, ls):
ls.add_lbinding(lbinding)
Bindings[binding] = ls.name
-def del_binding(ps_name, binding, ls):
+def del_binding(binding, ls):
vlog.info("removing binding %s" % binding)
vlan, pp_name = binding.split("-")
@@ -375,7 +376,7 @@ def del_binding(ps_name, binding, ls):
del Bindings[binding]
-def handle_physical(ps_name):
+def handle_physical():
# Gather physical ports except the patch ports we created
ovs_ports = ovs_vsctl("list-ports %s" % ps_name).split()
ovs_port_set = set([port for port in ovs_ports if port[-2:] != "-p"])
@@ -408,9 +409,9 @@ def handle_physical(ps_name):
if Bindings[binding] == ls_name:
continue
else:
- del_binding(ps_name, binding, Lswitches[Bindings[binding]])
+ del_binding(binding, Lswitches[Bindings[binding]])
- add_binding(ps_name, binding, ls)
+ add_binding(binding, ls)
dead_bindings = set(Bindings.keys()).difference(new_bindings)
@@ -418,14 +419,14 @@ def handle_physical(ps_name):
ls_name = Bindings[binding]
ls = Lswitches[ls_name]
- del_binding(ps_name, binding, ls)
+ del_binding(binding, ls)
if not len(ls.ports):
ovs_vsctl("del-br %s" % Lswitches[ls_name].short_name)
vtep_ctl("clear-local-macs %s" % Lswitches[ls_name].name)
del Lswitches[ls_name]
-def setup(ps_name):
+def setup():
br_list = ovs_vsctl("list-br").split()
if (ps_name not in br_list):
ovs.util.ovs_fatal(0, "couldn't find OVS bridge %s" % ps_name, vlog)
@@ -483,6 +484,7 @@ def main():
if args.root_prefix:
root_prefix = args.root_prefix
+ global ps_name
ps_name = args.ps_name
ovs.daemon.daemonize()
@@ -493,14 +495,14 @@ def main():
if error:
ovs.util.ovs_fatal(error, "could not create unixctl server", vlog)
- setup(ps_name)
+ setup()
while True:
unixctl.run()
if exiting:
break
- handle_physical(ps_name)
+ handle_physical()
for ls_name, ls in Lswitches.items():
ls.run()
--
1.7.9.5
More information about the dev
mailing list