@@ -1178,6 +1178,31 @@
wait at all. Use the <code>sync</code> command to override this
behavior.
</p>
+
+ <p>
+ User can set one or more <env>OVN_NBCTL_OPTIONS</env> options in
+ environment variable. Under the Bourne shell this might be
+ done like this:
+ </p>
+
+ <pre fixed="yes">
+ OVN_NBCTL_OPTIONS="--db=unix:nb1.ovsdb --no-leader-only"
+ </pre>
+
+ <p>
+ When <env>OVN_NBCTL_OPTIONS</env> is set, <code>ovn-nbctl</code>
+ automatically and transparently uses the environment variable to
+ execute its commands. However user can still over-ride environment
+ options by passing different in cli.
+ </p>
+
+ <p>
+ When the environment variable is no longer needed, unset it, e.g.:
+ </p>
+
+ <pre fixed="yes">
+ unset OVN_NBCTL_OPTIONS
+ </pre>
</dd>
<dt><code>--db</code> <var>database</var></dt>
@@ -124,18 +124,33 @@ static char * OVS_WARN_UNUSED_RESULT main_loop(const char *args,
static void server_loop(struct ovsdb_idl *idl, int argc, char *argv[]);
int
-main(int argc, char *argv[])
+main(int argc, char *argv_[])
{
struct ovsdb_idl *idl;
struct shash local_options;
- set_program_name(argv[0]);
+ set_program_name(argv_[0]);
fatal_ignore_sigpipe();
vlog_set_levels(NULL, VLF_CONSOLE, VLL_WARN);
vlog_set_levels_from_string_assert("reconnect:warn");
nbctl_cmd_init();
+ /* Check if options are set via env var. */
+ char *ctl_options = getenv("OVN_NBCTL_OPTIONS");
+ char **argv;
+ int *argcp;
+ argcp = xmalloc(sizeof(int));
+ *argcp = argc;
+ argv = ovs_cmdl_env_parse_all(argcp, argv_,
+ ctl_options);
+ if (!argv) {
+ /* This situation should never occur, but... */
+ ctl_fatal("Unable to read argv");
+ }
+ argc = *argcp;
+ free(argcp);
+
/* ovn-nbctl has three operation modes:
*
* - Direct: Executes commands by contacting ovsdb-server directly.
@@ -93,6 +93,14 @@ to approximately \fIsecs\fR seconds. If the timeout expires,
would normally happen only if the database cannot be contacted, or if
the system is overloaded.)
.
+.IP "\fBOVN_SBCTL_OPTIONS\fR"
+.User can set one or more options using \fBOVN_SBCTL_OPTIONS\fR environment
+.variable. Under the Bourne shell this might be done like this:
+.export \fBOVN_SBCTL_OPTIONS\fR"="--db=unix:sb1.ovsdb --no-leader-only".
+.However user can still over-ride environment options by passing different
+.options in cli. When the environment variable is no longer needed, unset it,
+.e.g.: unset \fBOVN_SBCTL_OPTIONS\fR"
+.
.so lib/vlog.man
.so lib/common.man
.
@@ -93,7 +93,7 @@ static bool do_sbctl(const char *args, struct ctl_command *, size_t n,
struct ovsdb_idl *);
int
-main(int argc, char *argv[])
+main(int argc, char *argv_[])
{
struct ovsdb_idl *idl;
struct ctl_command *commands;
@@ -101,13 +101,28 @@ main(int argc, char *argv[])
unsigned int seqno;
size_t n_commands;
- set_program_name(argv[0]);
+ set_program_name(argv_[0]);
fatal_ignore_sigpipe();
vlog_set_levels(NULL, VLF_CONSOLE, VLL_WARN);
vlog_set_levels_from_string_assert("reconnect:warn");
sbctl_cmd_init();
+ /* Check if options are set via env var. */
+ char *ctl_options = getenv("OVN_SBCTL_OPTIONS");
+ char **argv;
+ int *argcp;
+ argcp = xmalloc(sizeof(int));
+ *argcp = argc;
+ argv = ovs_cmdl_env_parse_all(argcp, argv_,
+ ctl_options);
+ if (!argv) {
+ /* This situation should never occur, but... */
+ ctl_fatal("Unable to read argv");
+ }
+ argc = *argcp;
+ free(argcp);
+
/* Parse command line. */
char *args = process_escape_args(argv);
shash_init(&local_options);