projects
/
openvswitch
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ovs-vsctl: Capitalize names of global constants but not variables.
[openvswitch]
/
utilities
/
ovs-vsctl.in
diff --git
a/utilities/ovs-vsctl.in
b/utilities/ovs-vsctl.in
index cc9f52b33acf184822cf704123b89fb497e82d18..bef868cfc71096e53ae53f3767ab53f19fcc2c46 100755
(executable)
--- a/
utilities/ovs-vsctl.in
+++ b/
utilities/ovs-vsctl.in
@@
-29,14
+29,14
@@
if argv0.find('/') >= 0:
argv0 = argv0[argv0.rfind('/') + 1:]
DEFAULT_VSWITCHD_CONF = "@sysconfdir@/ovs-vswitchd.conf"
argv0 = argv0[argv0.rfind('/') + 1:]
DEFAULT_VSWITCHD_CONF = "@sysconfdir@/ovs-vswitchd.conf"
-
VSWITCHD_CONF
= DEFAULT_VSWITCHD_CONF
+
vswitchd_conf
= DEFAULT_VSWITCHD_CONF
-DEFAULT_VSWITCHD_TARGET = "
@RUNDIR@/ovs-vswitchd.pi
d"
-
VSWITCHD_TARGET
= DEFAULT_VSWITCHD_TARGET
+DEFAULT_VSWITCHD_TARGET = "
ovs-vswitch
d"
+
vswitchd_target
= DEFAULT_VSWITCHD_TARGET
-
RELOAD_VSWITCHD
= True
+
reload_vswitchd
= True
-
SYSLOG
= True
+
enable_syslog
= True
class Error(Exception):
def __init__(self, msg):
class Error(Exception):
def __init__(self, msg):
@@
-44,7
+44,7
@@
class Error(Exception):
self.msg = msg
def log(message):
self.msg = msg
def log(message):
- if
SYSLOG
:
+ if
enable_syslog
:
syslog.syslog(message)
# XXX Most of the functions below should be integrated into a
syslog.syslog(message)
# XXX Most of the functions below should be integrated into a
@@
-159,11
+159,10
@@
def do_cfg_save(cfg, file):
def cfg_reload():
target = VSWITCHD_TARGET
def cfg_reload():
target = VSWITCHD_TARGET
+ if not target.startswith('/'):
+ pid = read_first_line_of_file('%s/%s.pid' % ('@RUNDIR@', target))
+ target = '%s/%s.%s.ctl' % ('@RUNDIR@', target, pid)
s = os.stat(target)
s = os.stat(target)
- if stat.S_ISREG(s.st_mode):
- pid = read_first_line_of_file(target)
- target = "@RUNDIR@/ovs-vswitchd.%s.ctl" % pid
- s = os.stat(target)
if not stat.S_ISSOCK(s.st_mode):
raise Error("%s is not a Unix domain socket, cannot reload" % target)
skt = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
if not stat.S_ISSOCK(s.st_mode):
raise Error("%s is not a Unix domain socket, cannot reload" % target)
skt = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
@@
-183,7
+182,7
@@
def cfg_save(cfg, filename):
do_cfg_save(cfg, f)
f.close()
os.rename(tmp_name, filename)
do_cfg_save(cfg, f)
f.close()
os.rename(tmp_name, filename)
- if
RELOAD_VSWITCHD
:
+ if
reload_vswitchd
:
cfg_reload()
# Returns a set of the immediate subsections of 'section' within 'cfg'. For
cfg_reload()
# Returns a set of the immediate subsections of 'section' within 'cfg'. For
@@
-348,7
+347,7
@@
General options:
--no-syslog do not write mesages to syslog
-c, --config=FILE set configuration file
(default: %(config)s)
--no-syslog do not write mesages to syslog
-c, --config=FILE set configuration file
(default: %(config)s)
- -t, --target=P
IDFILE
|SOCKET set ovs-vswitchd target
+ -t, --target=P
ROGRAM
|SOCKET set ovs-vswitchd target
(default: %(target)s)
--no-reload do not make ovs-vswitchd reload its configuration
-h, --help display this help message and exit
(default: %(target)s)
--no-reload do not make ovs-vswitchd reload its configuration
-h, --help display this help message and exit
@@
-548,29
+547,27
@@
def main():
oneline = False
for opt, optarg in options:
if opt == "-c" or opt == "--config":
oneline = False
for opt, optarg in options:
if opt == "-c" or opt == "--config":
- global
VSWITCHD_CONF
-
VSWITCHD_CONF
= optarg
+ global
vswitchd_conf
+
vswitchd_conf
= optarg
elif opt == "-t" or opt == "--target":
elif opt == "-t" or opt == "--target":
- global VSWITCHD_TARGET
- if optarg[0] != '/':
- optarg = '@RUNDIR@/' + optarg
- VSWITCHD_TARGET = optarg
+ global vswitchd_target
+ vswitchd_target = optarg
elif opt == "--no-reload":
elif opt == "--no-reload":
- global
RELOAD_VSWITCHD
-
RELOAD_VSWITCHD
= False
+ global
reload_vswitchd
+
reload_vswitchd
= False
elif opt == "-h" or opt == "--help":
usage()
elif opt == "-V" or opt == "--version":
version()
elif opt == "--no-syslog":
elif opt == "-h" or opt == "--help":
usage()
elif opt == "-V" or opt == "--version":
version()
elif opt == "--no-syslog":
- global
SYSLOG
-
SYSLOG
= False
+ global
enable_syslog
+
enable_syslog
= False
elif opt == "--oneline":
oneline = True
else:
raise RuntimeError("unhandled option %s" % opt)
elif opt == "--oneline":
oneline = True
else:
raise RuntimeError("unhandled option %s" % opt)
- if
SYSLOG
:
+ if
enable_syslog
:
syslog.openlog("ovs-vsctl")
log("Called as %s" % ' '.join(sys.argv[1:]))
syslog.openlog("ovs-vsctl")
log("Called as %s" % ' '.join(sys.argv[1:]))
@@
-589,7
+586,7
@@
def main():
need_lock = True
# Execute commands.
need_lock = True
# Execute commands.
- cfg = cfg_read(
VSWITCHD_CONF
, need_lock)
+ cfg = cfg_read(
vswitchd_conf
, need_lock)
for command in commands:
output = run_command(cfg, command)
if oneline:
for command in commands:
output = run_command(cfg, command)
if oneline:
@@
-601,7
+598,7
@@
def main():
for line in output:
print line
if need_lock:
for line in output:
print line
if need_lock:
- cfg_save(cfg,
VSWITCHD_CONF
)
+ cfg_save(cfg,
vswitchd_conf
)
sys.exit(0)
if __name__ == "__main__":
sys.exit(0)
if __name__ == "__main__":