[ovs-dev] [PATCH] Add unixctl option for ovn-northd
Anil Venkata
anilvenkata at redhat.com
Tue Jan 30 10:51:19 UTC 2018
This is required for spawning ovn-northd for networking-ovn functional
tests i.e https://review.openstack.org/#/c/532440/
https://review.openstack.org/#/c/532440/11/networking_ovn/tests/functional/resources/process.py@60
https://review.openstack.org/#/c/532440/11/networking_ovn/tests/functional/resources/process.py@95
Thanks
Anil
On Tue, Jan 30, 2018 at 3:12 PM, <vkommadi at redhat.com> wrote:
> From: Venkata Anil <vkommadi at redhat.com>
>
> Signed-off-by: Venkata Anil <vkommadi at redhat.com>
> ---
> lib/automake.mk | 3 ++-
> lib/unixctl.xml | 26 ++++++++++++++++++++++++++
> ovn/northd/ovn-northd.8.xml | 7 +++++--
> ovn/northd/ovn-northd.c | 9 ++++++++-
> tests/ovn-northd.at | 39 +++++++++++++++++++++++++++++++++++++++
> 5 files changed, 80 insertions(+), 4 deletions(-)
> create mode 100644 lib/unixctl.xml
>
> diff --git a/lib/automake.mk b/lib/automake.mk
> index 159319f..38d2a99 100644
> --- a/lib/automake.mk
> +++ b/lib/automake.mk
> @@ -455,7 +455,8 @@ EXTRA_DIST += \
> lib/ssl.xml \
> lib/ssl-bootstrap.xml \
> lib/table.xml \
> - lib/vlog.xml
> + lib/vlog.xml \
> + lib/unixctl.xml
>
> MAN_FRAGMENTS += \
> lib/colors.man \
> diff --git a/lib/unixctl.xml b/lib/unixctl.xml
> new file mode 100644
> index 0000000..51bfc5f
> --- /dev/null
> +++ b/lib/unixctl.xml
> @@ -0,0 +1,26 @@
> +<?xml version="1.0" encoding="utf-8"?>
> +<dl>
> + <dt><code>--unixctl=<var>socket</var></code></dt>
> + <dd>
> + Sets the name of the control socket on which
> + <code><var>program</var></code> listens for runtime management
> commands
> + (see <var>RUNTIME MANAGEMENT COMMANDS,</var> below). If
> <var>socket</var>
> + does not begin with <code>/</code>, it is interpreted as relative to
> + <code>@RUNDIR@</code>. If <code>--unixctl</code> is not used at all,
> + the default socket is
> + <code>@RUNDIR@/<var>program</var>.</code><var>pid</var><
> code>.ctl</code>,
> + where <var>pid</var> is <code><var>program</var></code>'s process ID.
> + <p>
> + On Windows a local named pipe is used to listen for runtime management
> + commands. A file is created in the absolute path as pointed by
> + <var>socket</var> or if <code>--unixctl</code> is not used at all,
> + a file is created as <code><var>program</var></code> in the
> configured
> + <var>OVS_RUNDIR</var> directory. The file exists just to mimic the
> + behavior of a Unix domain socket.
> + </p>
> + <p>
> + Specifying <code>none</code> for <var>socket</var> disables the
> control
> + socket feature.
> + </p>
> + </dd>
> +</dl>
> diff --git a/ovn/northd/ovn-northd.8.xml b/ovn/northd/ovn-northd.8.xml
> index ee9cf8c..6bc2dd6 100644
> --- a/ovn/northd/ovn-northd.8.xml
> +++ b/ovn/northd/ovn-northd.8.xml
> @@ -54,8 +54,11 @@
> <xi:include href="lib/ssl.xml" xmlns:xi="http://www.w3.org/
> 2003/XInclude"/>
>
> <h2>Other Options</h2>
> -
> - <xi:include href="lib/common.xml" xmlns:xi="http://www.w3.org/
> 2003/XInclude"/>
> + <xi:include href="lib/unixctl.xml"
> + xmlns:xi="http://www.w3.org/2003/XInclude"/>
> + <h3></h3>
> + <xi:include href="lib/common.xml"
> + xmlns:xi="http://www.w3.org/2003/XInclude"/>
>
> <h1>Runtime Management Commands</h1>
> <p>
> diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
> index f4edd8f..e206e0a 100644
> --- a/ovn/northd/ovn-northd.c
> +++ b/ovn/northd/ovn-northd.c
> @@ -59,6 +59,7 @@ struct northd_context {
>
> static const char *ovnnb_db;
> static const char *ovnsb_db;
> +static const char *unixctl_path;
>
> #define MAC_ADDR_PREFIX 0x0A0000000000ULL
> #define MAC_ADDR_SPACE 0xffffff
> @@ -239,6 +240,7 @@ Options:\n\
> (default: %s)\n\
> --ovnsb-db=DATABASE connect to ovn-sb database at DATABASE\n\
> (default: %s)\n\
> + --unixctl = SOCKET override default control socket name\n\
> -h, --help display this help message\n\
> -o, --options list available options\n\
> -V, --version display version information\n\
> @@ -6663,6 +6665,7 @@ parse_options(int argc OVS_UNUSED, char *argv[]
> OVS_UNUSED)
> static const struct option long_options[] = {
> {"ovnsb-db", required_argument, NULL, 'd'},
> {"ovnnb-db", required_argument, NULL, 'D'},
> + {"unixctl", required_argument, NULL, 'u'},
> {"help", no_argument, NULL, 'h'},
> {"options", no_argument, NULL, 'o'},
> {"version", no_argument, NULL, 'V'},
> @@ -6694,6 +6697,10 @@ parse_options(int argc OVS_UNUSED, char *argv[]
> OVS_UNUSED)
> ovnnb_db = optarg;
> break;
>
> + case 'u':
> + unixctl_path = optarg;
> + break;
> +
> case 'h':
> usage();
> exit(EXIT_SUCCESS);
> @@ -6746,7 +6753,7 @@ main(int argc, char *argv[])
>
> daemonize_start(false);
>
> - retval = unixctl_server_create(NULL, &unixctl);
> + retval = unixctl_server_create(unixctl_path, &unixctl);
> if (retval) {
> exit(EXIT_FAILURE);
> }
> diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
> index baa2add..1878eb2 100644
> --- a/tests/ovn-northd.at
> +++ b/tests/ovn-northd.at
> @@ -262,3 +262,42 @@ AT_CHECK_UNQUOTED([ovn-sbctl get Port_Binding ${uuid}
> options:ipv6_ra_prefixes],
> ])
>
> AT_CLEANUP
> +
> +AT_SETUP([ovn -- test unixctl])
> +ovn_init_db ovn-sb; ovn-sbctl init
> +ovn_init_db ovn-nb; ovn-nbctl init
> +
> +# test unixctl option
> +mkdir "$ovs_base"/northd
> +as northd start_daemon ovn-northd --unixctl="$ovs_base"/northd/ovn-northd.ctl
> --ovnnb-db=unix:"$ovs_base"/ovn-nb/ovn-nb.sock
> --ovnsb-db=unix:"$ovs_base"/ovn-sb/ovn-sb.sock
> +ovn-nbctl ls-add sw
> +ovn-nbctl --wait=sb lsp-add sw p1
> +# northd created with unixctl option successfully created port_binding
> entry
> +AT_CHECK([ovn-sbctl --bare --columns datapath find port_binding
> logical_port="p1" | wc -l], [0], [1
> +])
> +AT_CHECK([ovn-nbctl --wait=sb lsp-del p1])
> +
> +# ovs-appctl exit with unixctl option
> +OVS_APP_EXIT_AND_WAIT_BY_TARGET(["$ovs_base"/northd/ovn-northd.ctl],
> ["$ovs_base"/northd/ovn-northd.pid])
> +
> +# Check no port_binding entry for new port as ovn-northd is not running
> +ovn-nbctl lsp-add sw p2
> +ovn-nbctl --timeout=10 --wait=sb sync
> +AT_CHECK([ovn-sbctl --bare --columns datapath find port_binding
> logical_port="p2" | wc -l], [0], [0
> +])
> +
> +# test default unixctl path
> +as northd start_daemon ovn-northd --ovnnb-db=unix:"$ovs_base"/ovn-nb/ovn-nb.sock
> --ovnsb-db=unix:"$ovs_base"/ovn-sb/ovn-sb.sock
> +ovn-nbctl --wait=sb lsp-add sw p3
> +# northd created with default unixctl path successfully created
> port_binding entry
> +AT_CHECK([ovn-sbctl --bare --columns datapath find port_binding
> logical_port="p3" | wc -l], [0], [1
> +])
> +
> +as ovn-sb
> +OVS_APP_EXIT_AND_WAIT([ovsdb-server])
> +as ovn-nb
> +OVS_APP_EXIT_AND_WAIT([ovsdb-server])
> +as northd
> +OVS_APP_EXIT_AND_WAIT([ovn-northd])
> +
> +AT_CLEANUP
> --
> 1.8.3.1
>
>
More information about the dev
mailing list