Use ovn-ctl script to start OVN ovsdb-servers

Using the ovn-ctl script to start the OVN ovsdb-server is the better
way. This script is used to start and stop all OVN systemd services.
This script takes care of creating the database from the schema,
updating the database from the schema when the schema version gets
updated.

The present scripts - start_nb_db_server.sh and start_sb_db_server.sh
doesn't take care of schema updates.

With this, we don't need extend_start.sh in ovn-nb-db-server/ovn-sb-db-server
to create the database from the schema.

This patch also deletes kolla_ovn_extend_start from the ovn-base image as it
is not required.

Closes-bug: 1850025
Change-Id: I31a372d801dace92950cd85b29b308431f78bbdb
This commit is contained in:
Numan Siddique 2019-10-27 12:35:47 +05:30
parent 7b309f8300
commit b8c8fa15ed
8 changed files with 52 additions and 62 deletions

View File

@ -26,7 +26,6 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
COPY extend_start.sh /usr/local/bin/kolla_extend_start
RUN touch /usr/local/bin/kolla_ovn_extend_start \
&& chmod 755 /usr/local/bin/kolla_extend_start /usr/local/bin/kolla_ovn_extend_start
RUN chmod 755 /usr/local/bin/kolla_extend_start
{% block ovn_base_footer %}{% endblock %}

View File

@ -6,5 +6,3 @@ fi
if [[ $(stat -c %a /var/log/kolla/openvswitch) != "755" ]]; then
chmod 755 /var/log/kolla/openvswitch
fi
. /usr/local/bin/kolla_ovn_extend_start

View File

@ -18,10 +18,8 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
{% endif %}
{{ macros.install_packages(ovn_nb_db_server_packages | customizable("packages")) }}
COPY extend_start.sh /usr/local/bin/kolla_ovn_extend_start
COPY start_nb_db_server.sh /usr/local/bin/start-nb-db-server
RUN chmod 755 /usr/local/bin/kolla_ovn_extend_start \
/usr/local/bin/start-nb-db-server
RUN chmod 755 /usr/local/bin/start-nb-db-server
{% block ovn_nb_db_server_footer %}{% endblock %}
{% block footer %}{% endblock %}

View File

@ -1,19 +0,0 @@
#!/bin/bash
mkdir -p "/run/openvswitch"
# Check for the presence of schema file in the old
# location before accessing it.
# Note: If latest OVN is used (post split from openvswitch),
# then the new location for the schema file
# is - /usr/share/ovn/ovn-nb.ovsschema.
# It is advisable to use the ovn-ctl script to start
# ovn NB db server. ovn-ctl takes care of creating the
# db file from the schema file if the db file is not
# present. ovn-ctl also takes care of updating the db file
# if the schema file is updated.
if [[ -e "/usr/share/openvswitch/ovn-nb.ovsschema" ]]; then
if [[ ! -e "/var/lib/openvswitch/ovnnb.db" ]]; then
ovsdb-tool create "/var/lib/openvswitch/ovnnb.db" "/usr/share/openvswitch/ovn-nb.ovsschema"
fi
fi

View File

@ -1,11 +1,28 @@
#!/bin/bash
ovsdb_ip=$1
ovnnb_port=$2
if [ -e $ovnnb_port ]; then
ovnnb_port=6641
# All the option passed to this script will be
# passed to the ovn-ctl script. Please see the options
# supported by ovn-ctl script -
# https://github.com/ovn-org/ovn/blob/master/utilities/ovn-ctl
args=$@
# Use ovn-ctl script to start ovn NB db server as it
# takes care of creating the db file from the schema
# file if the db file is not present. It also takes care
# of updating the db file if the schema file is updated.
# Check for the presence of ovn-ctl script in two locations.
# If latest OVN is used (post split from openvswitch),
# then the new location for the ovn-ctl script is
# is - /usr/share/ovn/scripts/ovn-ctl. Otherwise it is
# /usr/share/openvswitch/scripts/ovn-ctl.
if [[ -f "/usr/share/openvswitch/scripts/ovn-ctl" ]]; then
set /usr/share/openvswitch/scripts/ovn-ctl --no-monitor
elif [[ -f "/usr/share/ovn/scripts/ovn-ctl" ]]; then
set /usr/share/ovn/scripts/ovn-ctl --no-monitor
else
exit 1
fi
/usr/sbin/ovsdb-server /var/lib/openvswitch/ovnnb.db -vconsole:emer -vsyslog:err -vfile:info \
--remote=punix:/run/openvswitch/ovnnb_db.sock --remote=ptcp:$ovnnb_port:$ovsdb_ip \
--unixctl=/run/openvswitch/ovnnb_db.ctl --log-file=/var/log/kolla/openvswitch/ovsdb-server-nb.log
$@ $args run_nb_ovsdb

View File

@ -18,10 +18,8 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
{% endif %}
{{ macros.install_packages(ovn_sb_db_server_packages | customizable("packages")) }}
COPY extend_start.sh /usr/local/bin/kolla_ovn_extend_start
COPY start_sb_db_server.sh /usr/local/bin/start-sb-db-server
RUN chmod 755 /usr/local/bin/kolla_ovn_extend_start \
/usr/local/bin/start-sb-db-server
RUN chmod 755 /usr/local/bin/start-sb-db-server
{% block ovn_sb_db_server_footer %}{% endblock %}
{% block footer %}{% endblock %}

View File

@ -1,19 +0,0 @@
#!/bin/bash
mkdir -p "/run/openvswitch"
# Check for the presence of schema file in the old
# location before accessing it.
# Note: If latest OVN is used (post split from openvswitch),
# then the new location for the schema file
# is - /usr/share/ovn/ovn-sb.ovsschema.
# It is advisable to use the ovn-ctl script to start
# ovn SB db server. ovn-ctl takes care of creating the
# db file from the schema file if the db file is not
# present. ovn-ctl also takes care of updating the db file
# if the schema file is updated.
if [[ -e "/usr/share/openvswitch/ovn-sb.ovsschema" ]]; then
if [[ ! -e "/var/lib/openvswitch/ovnsb.db" ]]; then
ovsdb-tool create "/var/lib/openvswitch/ovnsb.db" "/usr/share/openvswitch/ovn-sb.ovsschema"
fi
fi

View File

@ -1,11 +1,29 @@
#!/bin/bash
ovnsb_db_ip=$1
ovnsb_port=$2
if [ -e $ovnsb_port ]; then
ovnsb_port=6642
# All the option passed to this script will be
# passed to the ovn-ctl script. Please see the options
# supported by ovn-ctl script -
# https://github.com/ovn-org/ovn/blob/master/utilities/ovn-ctl
args=$@
# Use ovn-ctl script to start ovn SB db server as it
# takes care of creating the db file from the schema
# file if the db file is not present. It also takes care
# of updating the db file if the schema file is updated.
# Check for the presence of ovn-ctl script in two locations.
# If latest OVN is used (post split from openvswitch),
# then the new location for the ovn-ctl script is
# is - /usr/share/ovn/scripts/ovn-ctl. Otherwise it is
# /usr/share/openvswitch/scripts/ovn-ctl.
if [[ -f "/usr/share/openvswitch/scripts/ovn-ctl" ]]; then
set /usr/share/openvswitch/scripts/ovn-ctl --no-monitor
elif [[ -f "/usr/share/ovn/scripts/ovn-ctl" ]]; then
set /usr/share/ovn/scripts/ovn-ctl --no-monitor
else
exit 1
fi
/usr/sbin/ovsdb-server /var/lib/openvswitch/ovnsb.db -vconsole:emer -vsyslog:err -vfile:info \
--remote=punix:/run/openvswitch/ovnsb_db.sock --remote=ptcp:$ovnsb_port:$ovnsb_db_ip \
--unixctl=/run/openvswitch/ovnsb_db.ctl --log-file=/var/log/kolla/openvswitch/ovsdb-server-sb.log
$@ $args run_sb_ovsdb