From: Aliasgar Ginwala <[email protected]> Add new env variables OVN_NBCTL_OPTIONS and OVN_SBCTL_OPTIONS for ovn-nbctl and ovn-sbctl respectively where user can set supported ovn-nb/sbctl options using environment variable. e.g. OVN_SBCTL_OPTIONS="--db=unix:sb1.ovsdb --no-leader-only"
Signed-off-by: Aliasgar Ginwala <[email protected]> --- utilities/ovn-nbctl.8.xml | 25 +++++++++++++++++++++++++ utilities/ovn-nbctl.c | 3 +++ utilities/ovn-sbctl.8.in | 8 ++++++++ utilities/ovn-sbctl.c | 3 +++ 4 files changed, 39 insertions(+) diff --git a/utilities/ovn-nbctl.8.xml b/utilities/ovn-nbctl.8.xml index fd75c0e44..b207dac46 100644 --- a/utilities/ovn-nbctl.8.xml +++ b/utilities/ovn-nbctl.8.xml @@ -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> diff --git a/utilities/ovn-nbctl.c b/utilities/ovn-nbctl.c index a89a9cb4d..9bc465209 100644 --- a/utilities/ovn-nbctl.c +++ b/utilities/ovn-nbctl.c @@ -136,6 +136,9 @@ main(int argc, char *argv[]) nbctl_cmd_init(); + /* Check if options are set via env var. */ + argv = ovs_cmdl_env_parse_all(&argc, argv, getenv("OVN_NBCTL_OPTIONS")); + /* ovn-nbctl has three operation modes: * * - Direct: Executes commands by contacting ovsdb-server directly. diff --git a/utilities/ovn-sbctl.8.in b/utilities/ovn-sbctl.8.in index 2aaa457e8..b3c21d625 100644 --- a/utilities/ovn-sbctl.8.in +++ b/utilities/ovn-sbctl.8.in @@ -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 . diff --git a/utilities/ovn-sbctl.c b/utilities/ovn-sbctl.c index 9a9b6f0ec..ffcaee2c4 100644 --- a/utilities/ovn-sbctl.c +++ b/utilities/ovn-sbctl.c @@ -108,6 +108,9 @@ main(int argc, char *argv[]) sbctl_cmd_init(); + /* Check if options are set via env var. */ + argv = ovs_cmdl_env_parse_all(&argc, argv, getenv("OVN_SBCTL_OPTIONS")); + /* Parse command line. */ char *args = process_escape_args(argv); shash_init(&local_options); -- 2.20.1 (Apple Git-117) _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
