From: Ben Pfaff Date: Fri, 15 May 2009 18:16:52 +0000 (-0700) Subject: Rename cfg-mod to ovs-cfg-mod, for consistency. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=431ed51b5dc84ddf24b2099052e9fad6293134d1;p=openvswitch Rename cfg-mod to ovs-cfg-mod, for consistency. --- diff --git a/utilities/.gitignore b/utilities/.gitignore index b54ac1c2..5f54285a 100644 --- a/utilities/.gitignore +++ b/utilities/.gitignore @@ -1,10 +1,10 @@ /Makefile /Makefile.in -/cfg-mod -/cfg-mod.8 /dpctl /dpctl.8 /nlmon +/ovs-cfg-mod +/ovs-cfg-mod.8 /ovs-controller /ovs-controller.8 /ovs-discover diff --git a/utilities/automake.mk b/utilities/automake.mk index 8f3fb605..c23a4f8a 100644 --- a/utilities/automake.mk +++ b/utilities/automake.mk @@ -1,7 +1,7 @@ bin_PROGRAMS += \ utilities/vlogconf \ - utilities/cfg-mod \ utilities/dpctl \ + utilities/ovs-cfg-mod \ utilities/ovs-controller \ utilities/ovs-discover \ utilities/ovs-kill \ @@ -12,8 +12,8 @@ noinst_SCRIPTS += utilities/ovs-pki-cgi utilities/ovs-parse-leaks dist_sbin_SCRIPTS += utilities/ovs-monitor EXTRA_DIST += \ - utilities/cfg-mod.8.in \ utilities/dpctl.8.in \ + utilities/ovs-cfg-mod.8.in \ utilities/ovs-controller.8.in \ utilities/ovs-discover.8.in \ utilities/ovs-kill.8.in \ @@ -23,8 +23,8 @@ EXTRA_DIST += \ utilities/ovs-pki.in \ utilities/vlogconf.8.in DISTCLEANFILES += \ - utilities/cfg-mod.8 \ utilities/dpctl.8 \ + utilities/ovs-cfg-mod.8 \ utilities/ovs-controller.8 \ utilities/ovs-discover.8 \ utilities/ovs-kill.8 \ @@ -35,23 +35,23 @@ DISTCLEANFILES += \ utilities/vlogconf.8 man_MANS += \ - utilities/cfg-mod.8 \ utilities/dpctl.8 \ + utilities/ovs-cfg-mod.8 \ utilities/ovs-controller.8 \ utilities/ovs-discover.8 \ utilities/ovs-kill.8 \ utilities/ovs-pki.8 \ utilities/vlogconf.8 -utilities_cfg_mod_SOURCES = utilities/cfg-mod.c -utilities_cfg_mod_LDADD = lib/libopenvswitch.a - utilities_dpctl_SOURCES = utilities/dpctl.c utilities_dpctl_LDADD = lib/libopenvswitch.a $(FAULT_LIBS) $(SSL_LIBS) utilities_vlogconf_SOURCES = utilities/vlogconf.c utilities_vlogconf_LDADD = lib/libopenvswitch.a +utilities_ovs_cfg_mod_SOURCES = utilities/ovs-cfg-mod.c +utilities_ovs_cfg_mod_LDADD = lib/libopenvswitch.a + utilities_ovs_controller_SOURCES = utilities/ovs-controller.c utilities_ovs_controller_LDADD = lib/libopenvswitch.a $(FAULT_LIBS) $(SSL_LIBS) diff --git a/utilities/cfg-mod.8.in b/utilities/cfg-mod.8.in deleted file mode 100644 index b2f212fd..00000000 --- a/utilities/cfg-mod.8.in +++ /dev/null @@ -1,85 +0,0 @@ -.TH cfg-mod 8 "April 2009" "OpenVSwitch" "OpenVSwitch Manual" -.ds PN cfg-mod -. -.SH NAME -cfg-mod \- Safely manage a vswitchd.conf-style configuration file -. -.SH SYNOPSIS -.B cfg-mod ---config-file=\fIfile\fR [ \fIaction\fR ][ \fIaction\fR \fI...\fR ] -. -.SH DESCRIPTION -A program for managing a \fBvswitchd.conf\fR(5)-style configuration file. -\fBcfg-mod\fR uses the same locking mechanisms as \fBvswitchd\fR and its -related utilities. This allows it to be run safely on "live" -configurations. - -The \fB--config-file\fR argument must be the first argument provided: -.TP -\fB-F\fR \fIfile\fR, \fB--config-file=\fIfile\fR -. -Use \fIfile\fR as the configuration file to modify. - -.SS "Specifying Actions" -After a configuration file is specified, a series of one or more -actions follows. These are executed in the order provided and under a -single lock instance, so they appear atomic to external viewers of -\fIfile\fR. - -As discussed in \fBvswitchd.conf\fR(5), each line in the configuration -file consists of a key-value pair. Actions generally take either a -\fIkey\fR or \fIentry\fR argument. A \fIkey\fR is a dot-separated -description of a configuration option. A \fIentry\fR is a key-value -pair, separated by the '=' sign. - -The following actions are supported: - -.TP -\fB-a\fR \fIentry\fR, \fB--add=\fIentry\fR -. -Add \fIentry\fR to \fIfile\fR. Please note that duplicates are -allowed, so if a unique key is required, a delete must be done first. - -.TP -\fB-d\fR \fIentry\fR, \fB--del-entry=\fIentry\fR -. -Delete \fIentry\fR from \fIfile\fR. Deletes only the first entry -that matches \fIentry\fR. - -.TP -\fB-D\fR \fIkey\fR, \fB--del-section=\fIkey\fR -. -Delete section \fIkey\fR from \fIfile\fR. - -.IP "\fB--del-match=\fIpattern\fR" -Deletes every entry that matches the given shell glob \fIpattern\fR. -For example, \fB--del-match=bridge.*.port=*\fR deletes all the ports -from every bridge, and \fB--del-match=bonding.bond0.*\fR is equivalent -to \fB--del-section=bonding.bond0\fR. - -.TP -\fB-q\fR \fIkey\fR, \fB--query=\fIkey\fR -. -Queries \fIfile\fR for entries that match \fIkey\fR. Each matching -value is printed on a separate line. Duplicates will be printed -multiple times. -. -.IP "\fB-c\fR, \fB--changes\fR" -. -Logs all of the changes made to the configuration file in a ``unified -diff''-like format. Only actual changes are logged, so that if, for -example, a \fB--del-match\fR action did not match any key-value pairs, -then nothing will be logged due to that action. Furthermore, only the -net effects of changes are logged: if a key-value pair was deleted and -then an identical key-value pair was added back, then nothing would be -logged due to those changes. -. -This action logs changes that have taken effect at the point where it -is inserted. Thus, if it is given before any other action, it will -not log any changes. If \fB--changes\fR is given more than once, -instances after the first log only the changes since the previous -instance. -. -.SH "SEE ALSO" -.BR vswitchd (8), -.BR vswitchd.conf (5) diff --git a/utilities/cfg-mod.c b/utilities/cfg-mod.c deleted file mode 100644 index b09a7ced..00000000 --- a/utilities/cfg-mod.c +++ /dev/null @@ -1,225 +0,0 @@ -/* Copyright (c) 2008, 2009 Nicira Networks - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * In addition, as a special exception, Nicira Networks gives permission - * to link the code of its release of vswitchd with the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the same - * license as the "OpenSSL" library), and distribute the linked - * executables. You must obey the GNU General Public License in all - * respects for all of the code used other than "OpenSSL". If you modify - * this file, you may extend this exception to your version of the file, - * but you are not obligated to do so. If you do not wish to do so, - * delete this exception statement from your version. - */ -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "cfg.h" -#include "command-line.h" -#include "svec.h" -#include "timeval.h" -#include "util.h" - -#define THIS_MODULE VLM_cfg_mod -#include "vlog.h" - -/* Configuration when we first read the configuration file. */ -static struct svec orig_cfg = SVEC_EMPTY_INITIALIZER; - -static void -usage(char *prog_name, int exit_code) -{ - printf("Usage: %s --config-file=FILE ACTIONS\n" - "\nConfig:\n" - " -F, --config-file=FILE use configuration FILE\n" - "\nActions:\n" - " -a, --add=ENTRY add ENTRY\n" - " -d, --del-entry=ENTRY delete ENTRY\n" - " -D, --del-section=KEY delete section matching KEY\n" - " --del-match=PATTERN delete entries matching shell PATTERN\n" - " -q, --query=KEY return all entries matching KEY\n" - " -c, --log-changes log changes up to this point\n", - prog_name); - exit(exit_code); -} - -static void -open_config(char *config_file) -{ - int error; - - error = cfg_set_file(config_file); - if (error) { - ovs_fatal(error, "failed to add configuration file \"%s\"", - config_file); - } - - error = cfg_lock(NULL, 0); - if (error) { - ovs_fatal(error, "could not lock configuration file\n"); - } - - cfg_get_all(&orig_cfg); -} - -static void -print_vals(char *key) -{ - struct svec vals; - int i; - - svec_init(&vals); - cfg_get_all_strings(&vals, "%s", key); - - for (i=0; i UCHAR_MAX || !strchr("Fh?", option)) - && config_set == false) { - ovs_fatal(0, "no config file specified (use --help for help)"); - } - - switch (option) { - case 'F': - open_config(optarg); - config_set = true; - break; - - case 'a': - cfg_add_entry("%s", optarg); - modified = true; - break; - - case 'd': - cfg_del_entry("%s", optarg); - modified = true; - break; - - case 'D': - cfg_del_section("%s", optarg); - modified = true; - break; - - case OPT_DEL_MATCH: - cfg_del_match("%s", optarg); - modified = true; - break; - - case 'q': - print_vals(optarg); - break; - - case 'c': - log_diffs(); - break; - - case 'h': - usage(argv[0], EXIT_SUCCESS); - break; - - case 'v': - vlog_set_verbosity(optarg); - break; - - case '?': - exit(EXIT_FAILURE); - - default: - NOT_REACHED(); - } - } - free(short_options); - - if (optind != argc) { - ovs_fatal(0, "non-option arguments not accepted " - "(use --help for help)"); - } - - if (modified) { - cfg_write(); - } - cfg_unlock(); - - exit(0); -} diff --git a/utilities/ovs-cfg-mod.8.in b/utilities/ovs-cfg-mod.8.in new file mode 100644 index 00000000..41d12d86 --- /dev/null +++ b/utilities/ovs-cfg-mod.8.in @@ -0,0 +1,85 @@ +.TH ovs-cfg-mod 8 "April 2009" "OpenVSwitch" "OpenVSwitch Manual" +.ds PN ovs-cfg-mod +. +.SH NAME +ovs-cfg-mod \- Safely manage a vswitchd.conf-style configuration file +. +.SH SYNOPSIS +.B ovs-cfg-mod +--config-file=\fIfile\fR [ \fIaction\fR ][ \fIaction\fR \fI...\fR ] +. +.SH DESCRIPTION +A program for managing a \fBvswitchd.conf\fR(5)-style configuration file. +\fBovs-cfg-mod\fR uses the same locking mechanisms as \fBvswitchd\fR and its +related utilities. This allows it to be run safely on "live" +configurations. + +The \fB--config-file\fR argument must be the first argument provided: +.TP +\fB-F\fR \fIfile\fR, \fB--config-file=\fIfile\fR +. +Use \fIfile\fR as the configuration file to modify. + +.SS "Specifying Actions" +After a configuration file is specified, a series of one or more +actions follows. These are executed in the order provided and under a +single lock instance, so they appear atomic to external viewers of +\fIfile\fR. + +As discussed in \fBvswitchd.conf\fR(5), each line in the configuration +file consists of a key-value pair. Actions generally take either a +\fIkey\fR or \fIentry\fR argument. A \fIkey\fR is a dot-separated +description of a configuration option. A \fIentry\fR is a key-value +pair, separated by the '=' sign. + +The following actions are supported: + +.TP +\fB-a\fR \fIentry\fR, \fB--add=\fIentry\fR +. +Add \fIentry\fR to \fIfile\fR. Please note that duplicates are +allowed, so if a unique key is required, a delete must be done first. + +.TP +\fB-d\fR \fIentry\fR, \fB--del-entry=\fIentry\fR +. +Delete \fIentry\fR from \fIfile\fR. Deletes only the first entry +that matches \fIentry\fR. + +.TP +\fB-D\fR \fIkey\fR, \fB--del-section=\fIkey\fR +. +Delete section \fIkey\fR from \fIfile\fR. + +.IP "\fB--del-match=\fIpattern\fR" +Deletes every entry that matches the given shell glob \fIpattern\fR. +For example, \fB--del-match=bridge.*.port=*\fR deletes all the ports +from every bridge, and \fB--del-match=bonding.bond0.*\fR is equivalent +to \fB--del-section=bonding.bond0\fR. + +.TP +\fB-q\fR \fIkey\fR, \fB--query=\fIkey\fR +. +Queries \fIfile\fR for entries that match \fIkey\fR. Each matching +value is printed on a separate line. Duplicates will be printed +multiple times. +. +.IP "\fB-c\fR, \fB--changes\fR" +. +Logs all of the changes made to the configuration file in a ``unified +diff''-like format. Only actual changes are logged, so that if, for +example, a \fB--del-match\fR action did not match any key-value pairs, +then nothing will be logged due to that action. Furthermore, only the +net effects of changes are logged: if a key-value pair was deleted and +then an identical key-value pair was added back, then nothing would be +logged due to those changes. +. +This action logs changes that have taken effect at the point where it +is inserted. Thus, if it is given before any other action, it will +not log any changes. If \fB--changes\fR is given more than once, +instances after the first log only the changes since the previous +instance. +. +.SH "SEE ALSO" +.BR vswitchd (8), +.BR vswitchd.conf (5) diff --git a/utilities/ovs-cfg-mod.c b/utilities/ovs-cfg-mod.c new file mode 100644 index 00000000..b09a7ced --- /dev/null +++ b/utilities/ovs-cfg-mod.c @@ -0,0 +1,225 @@ +/* Copyright (c) 2008, 2009 Nicira Networks + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * In addition, as a special exception, Nicira Networks gives permission + * to link the code of its release of vswitchd with the OpenSSL project's + * "OpenSSL" library (or with modified versions of it that use the same + * license as the "OpenSSL" library), and distribute the linked + * executables. You must obey the GNU General Public License in all + * respects for all of the code used other than "OpenSSL". If you modify + * this file, you may extend this exception to your version of the file, + * but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. + */ +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "cfg.h" +#include "command-line.h" +#include "svec.h" +#include "timeval.h" +#include "util.h" + +#define THIS_MODULE VLM_cfg_mod +#include "vlog.h" + +/* Configuration when we first read the configuration file. */ +static struct svec orig_cfg = SVEC_EMPTY_INITIALIZER; + +static void +usage(char *prog_name, int exit_code) +{ + printf("Usage: %s --config-file=FILE ACTIONS\n" + "\nConfig:\n" + " -F, --config-file=FILE use configuration FILE\n" + "\nActions:\n" + " -a, --add=ENTRY add ENTRY\n" + " -d, --del-entry=ENTRY delete ENTRY\n" + " -D, --del-section=KEY delete section matching KEY\n" + " --del-match=PATTERN delete entries matching shell PATTERN\n" + " -q, --query=KEY return all entries matching KEY\n" + " -c, --log-changes log changes up to this point\n", + prog_name); + exit(exit_code); +} + +static void +open_config(char *config_file) +{ + int error; + + error = cfg_set_file(config_file); + if (error) { + ovs_fatal(error, "failed to add configuration file \"%s\"", + config_file); + } + + error = cfg_lock(NULL, 0); + if (error) { + ovs_fatal(error, "could not lock configuration file\n"); + } + + cfg_get_all(&orig_cfg); +} + +static void +print_vals(char *key) +{ + struct svec vals; + int i; + + svec_init(&vals); + cfg_get_all_strings(&vals, "%s", key); + + for (i=0; i UCHAR_MAX || !strchr("Fh?", option)) + && config_set == false) { + ovs_fatal(0, "no config file specified (use --help for help)"); + } + + switch (option) { + case 'F': + open_config(optarg); + config_set = true; + break; + + case 'a': + cfg_add_entry("%s", optarg); + modified = true; + break; + + case 'd': + cfg_del_entry("%s", optarg); + modified = true; + break; + + case 'D': + cfg_del_section("%s", optarg); + modified = true; + break; + + case OPT_DEL_MATCH: + cfg_del_match("%s", optarg); + modified = true; + break; + + case 'q': + print_vals(optarg); + break; + + case 'c': + log_diffs(); + break; + + case 'h': + usage(argv[0], EXIT_SUCCESS); + break; + + case 'v': + vlog_set_verbosity(optarg); + break; + + case '?': + exit(EXIT_FAILURE); + + default: + NOT_REACHED(); + } + } + free(short_options); + + if (optind != argc) { + ovs_fatal(0, "non-option arguments not accepted " + "(use --help for help)"); + } + + if (modified) { + cfg_write(); + } + cfg_unlock(); + + exit(0); +} diff --git a/vswitchd/vswitchd.conf.5.in b/vswitchd/vswitchd.conf.5.in index 68dc2034..53bdcecc 100644 --- a/vswitchd/vswitchd.conf.5.in +++ b/vswitchd/vswitchd.conf.5.in @@ -41,7 +41,7 @@ within a configuration file is not significant. Blank lines, lines that consist only of white space, and lines that begin with \fB#\fR (optionally preceded by white space) are ignored. Keep in mind that programs that modify the configuration file, such as -\fBbrcompatd\fR and \fBcfg-mod\fR, may alter the order of elements and +\fBbrcompatd\fR and \fBovs-cfg-mod\fR, may alter the order of elements and strip comments and blank lines. .PP The following subsections describe how key-value pairs are used to @@ -638,4 +638,4 @@ To entirely disable controller connection snooping, set .SH "SEE ALSO" .BR vswitchd (8), .BR brcompatd (8), -.BR cfg-mod (8). +.BR ovs-cfg-mod (8). diff --git a/xenserver/etc_xapi.d_plugins_vswitch-cfg-update b/xenserver/etc_xapi.d_plugins_vswitch-cfg-update index 8d254587..a15dba01 100755 --- a/xenserver/etc_xapi.d_plugins_vswitch-cfg-update +++ b/xenserver/etc_xapi.d_plugins_vswitch-cfg-update @@ -30,7 +30,7 @@ import XenAPIPlugin import XenAPI import subprocess -cfg_mod="/root/vswitch/bin/cfg-mod" +cfg_mod="/root/vswitch/bin/ovs-cfg-mod" vswitchd_cfg_filename="/etc/vswitchd.conf" def update(session, args): @@ -106,7 +106,7 @@ def vswitchCfgMod(action_args): "--config-file=" + vswitchd_cfg_filename] + action_args exitcode = subprocess.call(cmd) if exitcode != 0: - log.error("cfg-mod failed with exit code " + log.error("ovs-cfg-mod failed with exit code " + str(exitcode) + " for " + repr(action_args)) raise XenAPIPlugin.Failure("VSWITCH_CONFIG_MOD_FAILURE", [ str(exitcode) , str(action_args) ]) diff --git a/xenserver/etc_xensource_scripts_vif b/xenserver/etc_xensource_scripts_vif index 43eafa7b..6051d9a2 100755 --- a/xenserver/etc_xensource_scripts_vif +++ b/xenserver/etc_xensource_scripts_vif @@ -13,7 +13,7 @@ # Keep other-config/ keys in sync with device.ml:vif_udev_keys -cfg_mod="/root/vswitch/bin/cfg-mod" +cfg_mod="/root/vswitch/bin/ovs-cfg-mod" service="/sbin/service" TYPE=`echo ${XENBUS_PATH} | cut -f 2 -d '/'` diff --git a/xenserver/opt_xensource_libexec_interface-reconfigure b/xenserver/opt_xensource_libexec_interface-reconfigure index 0f9acef4..427491ab 100755 --- a/xenserver/opt_xensource_libexec_interface-reconfigure +++ b/xenserver/opt_xensource_libexec_interface-reconfigure @@ -743,7 +743,7 @@ def configure_netdev(pif): print 'failed.' def modify_config(commands): - run_command(['/root/vswitch/bin/cfg-mod', '-vANY:console:emer', + run_command(['/root/vswitch/bin/ovs-cfg-mod', '-vANY:console:emer', '-F', '/etc/vswitchd.conf'] + commands + ['-c']) run_command(['/sbin/service', 'vswitch', 'reload']) diff --git a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureNiciraVSwitch.py b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureNiciraVSwitch.py index 26641066..24ff6e4c 100644 --- a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureNiciraVSwitch.py +++ b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureNiciraVSwitch.py @@ -14,7 +14,7 @@ logging.basicConfig(filename="/var/log/vswitch-xsplugin.log", level=logging.DEBU import os import subprocess -cfg_mod="/root/vswitch/bin/cfg-mod" +cfg_mod="/root/vswitch/bin/ovs-cfg-mod" vswitchd_cfg_filename="/etc/vswitchd.conf" if __name__ == "__main__": diff --git a/xenserver/vswitch-xen.spec b/xenserver/vswitch-xen.spec index 035e4617..1b1db623 100644 --- a/xenserver/vswitch-xen.spec +++ b/xenserver/vswitch-xen.spec @@ -252,12 +252,12 @@ fi /root/vswitch/scripts/XSFeatureNiciraVSwitch.pyo /root/vswitch/sbin/brcompatd /root/vswitch/sbin/vswitchd -/root/vswitch/bin/cfg-mod +/root/vswitch/bin/ovs-cfg-mod /root/vswitch/bin/dpctl /root/vswitch/bin/vlogconf /root/vswitch/share/man/man5/vswitchd.conf.5 /root/vswitch/share/man/man8/brcompatd.8 -/root/vswitch/share/man/man8/cfg-mod.8 +/root/vswitch/share/man/man8/ovs-cfg-mod.8 /root/vswitch/share/man/man8/dpctl.8 /root/vswitch/share/man/man8/vlogconf.8 /root/vswitch/share/man/man8/vswitchd.8