diff mbox series

[ovs-dev,v3,ovn] ovn-nb/sbctl.c: Use env variables for passing options.

Message ID 20191025201057.2309-1-amginwal@gmail.com
State Accepted
Headers show
Series [ovs-dev,v3,ovn] ovn-nb/sbctl.c: Use env variables for passing options. | expand

Commit Message

aginwala aginwala Oct. 25, 2019, 8:10 p.m. UTC
From: Aliasgar Ginwala <aginwala@ebay.com>

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 <aginwala@ebay.com>
---
 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(+)

Comments

Ben Pfaff Oct. 25, 2019, 8:32 p.m. UTC | #1
On Fri, Oct 25, 2019 at 01:10:57PM -0700, amginwal@gmail.com wrote:
> From: Aliasgar Ginwala <aginwala@ebay.com>
> 
> 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 <aginwala@ebay.com>

I didn't test this.

Acked-by: Ben Pfaff <blp@ovn.org>
Li,Rongqing via dev Oct. 25, 2019, 8:38 p.m. UTC | #2
Thanks Ben. I tested it with the command-line changes that you pushed to ovs.
Numan Siddique Oct. 31, 2019, 6:15 p.m. UTC | #3
On Sat, Oct 26, 2019 at 2:02 AM Ben Pfaff <blp@ovn.org> wrote:
>
> On Fri, Oct 25, 2019 at 01:10:57PM -0700, amginwal@gmail.com wrote:
> > From: Aliasgar Ginwala <aginwala@ebay.com>
> >
> > 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 <aginwala@ebay.com>
>
> I didn't test this.
>
> Acked-by: Ben Pfaff <blp@ovn.org>

Hi Aliasgar,

Compilation was failing with the below errors
****

utilities/ovn-sbctl.8:286: warning: macro `User' not defined
utilities/ovn-sbctl.8:287: warning: macro `variable.' not defined
utilities/ovn-sbctl.8:288: warning: macro `export' not defined
(possibly missing space after `ex')
utilities/ovn-sbctl.8:289: warning: macro `However' not defined
utilities/ovn-sbctl.8:290: warning: macro `options' not defined
utilities/ovn-sbctl.8:291: warning: macro `e.g.:' not defined

****

I applied this patch to master with the below changes to fix the
compilation errors.

Thanks
Numan


********************
diff --git a/utilities/ovn-sbctl.8.in b/utilities/ovn-sbctl.8.in
index b3c21d625..644f94432 100644
--- a/utilities/ovn-sbctl.8.in
+++ b/utilities/ovn-sbctl.8.in
@@ -94,12 +94,12 @@ 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"
+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
**********
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
Li,Rongqing via dev Oct. 31, 2019, 6:22 p.m. UTC | #4
Thanks Numan for taking care.

I tested that on branch 2.11 ovs and hence didn't notice this warning. Sorry for the miss.
Ben Pfaff Oct. 31, 2019, 9:07 p.m. UTC | #5
On Thu, Oct 31, 2019 at 11:45:07PM +0530, Numan Siddique wrote:
> On Sat, Oct 26, 2019 at 2:02 AM Ben Pfaff <blp@ovn.org> wrote:
> >
> > On Fri, Oct 25, 2019 at 01:10:57PM -0700, amginwal@gmail.com wrote:
> > > From: Aliasgar Ginwala <aginwala@ebay.com>
> > >
> > > 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 <aginwala@ebay.com>
> >
> > I didn't test this.
> >
> > Acked-by: Ben Pfaff <blp@ovn.org>
> 
> Hi Aliasgar,
> 
> Compilation was failing with the below errors

Well, gosh, I guess I didn't even build it.  I apologize!  Sorry about
that!
Numan Siddique Nov. 1, 2019, 9:53 a.m. UTC | #6
On Fri, Nov 1, 2019, 2:37 AM Ben Pfaff <blp@ovn.org> wrote:

> On Thu, Oct 31, 2019 at 11:45:07PM +0530, Numan Siddique wrote:
> > On Sat, Oct 26, 2019 at 2:02 AM Ben Pfaff <blp@ovn.org> wrote:
> > >
> > > On Fri, Oct 25, 2019 at 01:10:57PM -0700, amginwal@gmail.com wrote:
> > > > From: Aliasgar Ginwala <aginwala@ebay.com>
> > > >
> > > > 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 <aginwala@ebay.com>
> > >
> > > I didn't test this.
> > >
> > > Acked-by: Ben Pfaff <blp@ovn.org>
> >
> > Hi Aliasgar,
> >
> > Compilation was failing with the below errors
>
> Well, gosh, I guess I didn't even build it.  I apologize!  Sorry about
> that!
>

No worries :)

Numan
diff mbox series

Patch

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);