| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 1 | #!/bin/bash | 
 | 2 | # | 
 | 3 | #    Licensed under the Apache License, Version 2.0 (the "License"); you may | 
 | 4 | #    not use this file except in compliance with the License. You may obtain | 
 | 5 | #    a copy of the License at | 
 | 6 | # | 
 | 7 | #         http://www.apache.org/licenses/LICENSE-2.0 | 
 | 8 | # | 
 | 9 | #    Unless required by applicable law or agreed to in writing, software | 
 | 10 | #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | 
 | 11 | #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | 
 | 12 | #    License for the specific language governing permissions and limitations | 
 | 13 | #    under the License. | 
 | 14 | # | 
 | 15 |  | 
 | 16 | # Global Sources | 
 | 17 | # -------------- | 
 | 18 |  | 
 | 19 | # There are some ovs functions OVN depends on that must be sourced from | 
 | 20 | # the ovs neutron plugins. | 
 | 21 | source ${TOP_DIR}/lib/neutron_plugins/ovs_base | 
 | 22 | source ${TOP_DIR}/lib/neutron_plugins/openvswitch_agent | 
 | 23 |  | 
| Ian Wienand | 7783563 | 2021-05-13 13:14:42 +1000 | [diff] [blame] | 24 | # Load devstack ovs compliation and loading functions | 
 | 25 | source ${TOP_DIR}/lib/neutron_plugins/ovs_source | 
 | 26 |  | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 27 | # Set variables for building OVN from source | 
 | 28 | OVN_REPO=${OVN_REPO:-https://github.com/ovn-org/ovn.git} | 
 | 29 | OVN_REPO_NAME=$(basename ${OVN_REPO} | cut -f1 -d'.') | 
 | 30 | OVN_REPO_NAME=${OVN_REPO_NAME:-ovn} | 
 | 31 | OVN_BRANCH=${OVN_BRANCH:-v20.06.1} | 
 | 32 | # The commit removing OVN bits from the OVS tree, it is the commit that is not | 
 | 33 | # present in OVN tree and is used to distinguish if OVN is part of OVS or not. | 
 | 34 | # https://github.com/openvswitch/ovs/commit/05bf1dbb98b0635a51f75e268ef8aed27601401d | 
 | 35 | OVN_SPLIT_HASH=05bf1dbb98b0635a51f75e268ef8aed27601401d | 
 | 36 |  | 
 | 37 | if is_service_enabled tls-proxy; then | 
 | 38 |     OVN_PROTO=ssl | 
 | 39 | else | 
 | 40 |     OVN_PROTO=tcp | 
 | 41 | fi | 
 | 42 |  | 
 | 43 | # How to connect to ovsdb-server hosting the OVN SB database. | 
 | 44 | OVN_SB_REMOTE=${OVN_SB_REMOTE:-$OVN_PROTO:$SERVICE_HOST:6642} | 
 | 45 |  | 
 | 46 | # How to connect to ovsdb-server hosting the OVN NB database | 
 | 47 | OVN_NB_REMOTE=${OVN_NB_REMOTE:-$OVN_PROTO:$SERVICE_HOST:6641} | 
 | 48 |  | 
 | 49 | # ml2/config for neutron_sync_mode | 
 | 50 | OVN_NEUTRON_SYNC_MODE=${OVN_NEUTRON_SYNC_MODE:-log} | 
 | 51 |  | 
 | 52 | # Configured DNS servers to be used with internal_dns extension, only | 
 | 53 | # if the subnet DNS is not configured. | 
 | 54 | OVN_DNS_SERVERS=${OVN_DNS_SERVERS:-8.8.8.8} | 
 | 55 |  | 
 | 56 | # The type of OVN L3 Scheduler to use. The OVN L3 Scheduler determines the | 
 | 57 | # hypervisor/chassis where a routers gateway should be hosted in OVN. The | 
 | 58 | # default OVN L3 scheduler is leastloaded | 
 | 59 | OVN_L3_SCHEDULER=${OVN_L3_SCHEDULER:-leastloaded} | 
 | 60 |  | 
 | 61 | # A UUID to uniquely identify this system.  If one is not specified, a random | 
 | 62 | # one will be generated.  A randomly generated UUID will be saved in a file | 
| Slawek Kaplonski | 1ed276c | 2021-03-11 13:10:28 +0100 | [diff] [blame] | 63 | # $OVS_SYSCONFDIR/system-id.conf (typically /etc/openvswitch/system-id.conf) | 
 | 64 | # so that the same one will be re-used if you re-run DevStack or restart | 
 | 65 | # Open vSwitch service. | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 66 | OVN_UUID=${OVN_UUID:-} | 
 | 67 |  | 
 | 68 | # Whether or not to build the openvswitch kernel module from ovs.  This is required | 
 | 69 | # unless the distro kernel includes ovs+conntrack support. | 
 | 70 | OVN_BUILD_MODULES=$(trueorfalse False OVN_BUILD_MODULES) | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 71 | OVN_BUILD_FROM_SOURCE=$(trueorfalse False OVN_BUILD_FROM_SOURCE) | 
| Slawek Kaplonski | 4185358 | 2021-07-06 12:05:31 +0200 | [diff] [blame] | 72 | if [[ "$OVN_BUILD_FROM_SOURCE" == "True" ]]; then | 
 | 73 |     Q_BUILD_OVS_FROM_GIT=True | 
 | 74 | fi | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 75 |  | 
 | 76 | # Whether or not to install the ovs python module from ovs source.  This can be | 
 | 77 | # used to test and validate new ovs python features.  This should only be used | 
 | 78 | # for development purposes since the ovs python version is controlled by OpenStack | 
 | 79 | # requirements. | 
 | 80 | OVN_INSTALL_OVS_PYTHON_MODULE=$(trueorfalse False OVN_INSTALL_OVS_PYTHON_MODULE) | 
 | 81 |  | 
 | 82 | # GENEVE overlay protocol overhead. Defaults to 38 bytes plus the IP version | 
 | 83 | # overhead (20 bytes for IPv4 (default) or 40 bytes for IPv6) which is determined | 
 | 84 | # based on the ML2 overlay_ip_version option. The ML2 framework will use this to | 
 | 85 | # configure the MTU DHCP option. | 
 | 86 | OVN_GENEVE_OVERHEAD=${OVN_GENEVE_OVERHEAD:-38} | 
 | 87 |  | 
| Lucas Alvares Gomes | e38a39a | 2021-05-14 09:14:24 +0100 | [diff] [blame] | 88 | # The log level of the OVN databases (north and south). | 
 | 89 | # Supported log levels are: off, emer, err, warn, info or dbg. | 
 | 90 | # More information about log levels can be found at | 
 | 91 | # http://www.openvswitch.org/support/dist-docs/ovs-appctl.8.txt | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 92 | OVN_DBS_LOG_LEVEL=${OVN_DBS_LOG_LEVEL:-info} | 
 | 93 |  | 
 | 94 | OVN_META_CONF=$NEUTRON_CONF_DIR/neutron_ovn_metadata_agent.ini | 
 | 95 | OVN_META_DATA_HOST=${OVN_META_DATA_HOST:-$(ipv6_unquote $SERVICE_HOST)} | 
 | 96 |  | 
| Lucas Alvares Gomes | e38a39a | 2021-05-14 09:14:24 +0100 | [diff] [blame] | 97 | # If True (default) the node will be considered a gateway node. | 
 | 98 | ENABLE_CHASSIS_AS_GW=$(trueorfalse True ENABLE_CHASSIS_AS_GW) | 
| Lucas Alvares Gomes | 22038a9 | 2021-05-27 13:44:20 +0100 | [diff] [blame] | 99 | OVN_L3_CREATE_PUBLIC_NETWORK=$(trueorfalse True OVN_L3_CREATE_PUBLIC_NETWORK) | 
| Lucas Alvares Gomes | e38a39a | 2021-05-14 09:14:24 +0100 | [diff] [blame] | 100 |  | 
| Lucas Alvares Gomes | 6ecfe67 | 2020-09-23 11:54:19 +0100 | [diff] [blame] | 101 | export OVSDB_SERVER_LOCAL_HOST=$SERVICE_LOCAL_HOST | 
| Brian Haley | c869d59 | 2020-02-28 14:55:08 -0500 | [diff] [blame] | 102 | TUNNEL_IP=$TUNNEL_ENDPOINT_IP | 
| Lucas Alvares Gomes | 6ecfe67 | 2020-09-23 11:54:19 +0100 | [diff] [blame] | 103 | if [[ "$SERVICE_IP_VERSION" == 6 ]]; then | 
 | 104 |     OVSDB_SERVER_LOCAL_HOST=[$OVSDB_SERVER_LOCAL_HOST] | 
| Brian Haley | c869d59 | 2020-02-28 14:55:08 -0500 | [diff] [blame] | 105 |     TUNNEL_IP=[$TUNNEL_IP] | 
| Lucas Alvares Gomes | 6ecfe67 | 2020-09-23 11:54:19 +0100 | [diff] [blame] | 106 | fi | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 107 |  | 
 | 108 | OVN_IGMP_SNOOPING_ENABLE=$(trueorfalse False OVN_IGMP_SNOOPING_ENABLE) | 
 | 109 |  | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 110 | OVS_PREFIX= | 
 | 111 | if [[ "$OVN_BUILD_FROM_SOURCE" == "True" ]]; then | 
 | 112 |     OVS_PREFIX=/usr/local | 
 | 113 | fi | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 114 | OVS_SBINDIR=$OVS_PREFIX/sbin | 
 | 115 | OVS_BINDIR=$OVS_PREFIX/bin | 
 | 116 | OVS_RUNDIR=$OVS_PREFIX/var/run/openvswitch | 
 | 117 | OVS_SHAREDIR=$OVS_PREFIX/share/openvswitch | 
 | 118 | OVS_SCRIPTDIR=$OVS_SHAREDIR/scripts | 
 | 119 | OVS_DATADIR=$DATA_DIR/ovs | 
| Rodolfo Alonso Hernandez | 30819e6 | 2021-03-22 07:14:50 +0000 | [diff] [blame] | 120 | OVS_SYSCONFDIR=${OVS_SYSCONFDIR:-$OVS_PREFIX/etc/openvswitch} | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 121 |  | 
| Gregory Thiemonge | 6822ff3 | 2021-09-01 09:36:31 +0200 | [diff] [blame] | 122 | if [[ "$OVN_BUILD_FROM_SOURCE" == "True" ]]; then | 
 | 123 |     OVN_DATADIR=$DATA_DIR/ovn | 
 | 124 | else | 
 | 125 |     # When using OVN from packages, the data dir for OVN DBs is | 
 | 126 |     # /var/lib/ovn | 
 | 127 |     OVN_DATADIR=/var/lib/ovn | 
 | 128 | fi | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 129 | OVN_SHAREDIR=$OVS_PREFIX/share/ovn | 
 | 130 | OVN_SCRIPTDIR=$OVN_SHAREDIR/scripts | 
 | 131 | OVN_RUNDIR=$OVS_PREFIX/var/run/ovn | 
 | 132 |  | 
 | 133 | NEUTRON_OVN_BIN_DIR=$(get_python_exec_prefix) | 
 | 134 | NEUTRON_OVN_METADATA_BINARY="neutron-ovn-metadata-agent" | 
 | 135 |  | 
 | 136 | STACK_GROUP="$( id --group --name "$STACK_USER" )" | 
 | 137 |  | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 138 | OVN_NORTHD_SERVICE=ovn-northd.service | 
 | 139 | if is_ubuntu; then | 
 | 140 |     # The ovn-central.service file on Ubuntu is responsible for starting | 
 | 141 |     # ovn-northd and the OVN DBs (on CentOS this is done by ovn-northd.service) | 
 | 142 |     OVN_NORTHD_SERVICE=ovn-central.service | 
 | 143 | fi | 
 | 144 | OVSDB_SERVER_SERVICE=ovsdb-server.service | 
 | 145 | OVS_VSWITCHD_SERVICE=ovs-vswitchd.service | 
 | 146 | OVN_CONTROLLER_SERVICE=ovn-controller.service | 
 | 147 | OVN_CONTROLLER_VTEP_SERVICE=ovn-controller-vtep.service | 
 | 148 | if [[ "$OVN_BUILD_FROM_SOURCE" == "True" ]]; then | 
 | 149 |     OVSDB_SERVER_SERVICE=devstack@ovsdb-server.service | 
 | 150 |     OVS_VSWITCHD_SERVICE=devstack@ovs-vswitchd.service | 
 | 151 |     OVN_NORTHD_SERVICE=devstack@ovn-northd.service | 
 | 152 |     OVN_CONTROLLER_SERVICE=devstack@ovn-controller.service | 
 | 153 |     OVN_CONTROLLER_VTEP_SERVICE=devstack@ovn-controller-vtep.service | 
 | 154 | fi | 
 | 155 |  | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 156 | # Defaults Overwrite | 
 | 157 | # ------------------ | 
 | 158 |  | 
 | 159 | Q_ML2_PLUGIN_MECHANISM_DRIVERS=${Q_ML2_PLUGIN_MECHANISM_DRIVERS:-ovn,logger} | 
 | 160 | Q_ML2_PLUGIN_TYPE_DRIVERS=${Q_ML2_PLUGIN_TYPE_DRIVERS:-local,flat,vlan,geneve} | 
 | 161 | Q_ML2_TENANT_NETWORK_TYPE=${Q_ML2_TENANT_NETWORK_TYPE:-"geneve"} | 
 | 162 | Q_ML2_PLUGIN_GENEVE_TYPE_OPTIONS=${Q_ML2_PLUGIN_GENEVE_TYPE_OPTIONS:-"vni_ranges=1:65536"} | 
| Lucas Alvares Gomes | e7625fc | 2020-08-26 09:46:35 +0100 | [diff] [blame] | 163 | Q_ML2_PLUGIN_EXT_DRIVERS=${Q_ML2_PLUGIN_EXT_DRIVERS:-port_security,qos} | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 164 | # this one allows empty: | 
 | 165 | ML2_L3_PLUGIN=${ML2_L3_PLUGIN-"ovn-router"} | 
 | 166 |  | 
| Flavio Fernandes | a2273cc | 2021-02-06 16:23:36 -0500 | [diff] [blame] | 167 | Q_LOG_DRIVER_RATE_LIMIT=${Q_LOG_DRIVER_RATE_LIMIT:-100} | 
 | 168 | Q_LOG_DRIVER_BURST_LIMIT=${Q_LOG_DRIVER_BURST_LIMIT:-25} | 
 | 169 | Q_LOG_DRIVER_LOG_BASE=${Q_LOG_DRIVER_LOG_BASE:-acl_log_meter} | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 170 |  | 
 | 171 | # Utility Functions | 
 | 172 | # ----------------- | 
 | 173 |  | 
| yatinkarel | 1baa890 | 2022-05-06 17:53:54 +0530 | [diff] [blame] | 174 | function wait_for_db_file { | 
 | 175 |     local count=0 | 
 | 176 |     while [ ! -f $1 ]; do | 
 | 177 |         sleep 1 | 
 | 178 |         count=$((count+1)) | 
| Dr. Jens Harbott | bd6e520 | 2022-07-03 22:27:15 +0200 | [diff] [blame] | 179 |         if [ "$count" -gt 40 ]; then | 
| yatinkarel | 1baa890 | 2022-05-06 17:53:54 +0530 | [diff] [blame] | 180 |             die $LINENO "DB File $1 not found" | 
 | 181 |         fi | 
 | 182 |     done | 
 | 183 | } | 
 | 184 |  | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 185 | function wait_for_sock_file { | 
 | 186 |     local count=0 | 
 | 187 |     while [ ! -S $1 ]; do | 
 | 188 |         sleep 1 | 
 | 189 |         count=$((count+1)) | 
| Dr. Jens Harbott | bd6e520 | 2022-07-03 22:27:15 +0200 | [diff] [blame] | 190 |         if [ "$count" -gt 40 ]; then | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 191 |             die $LINENO "Socket $1 not found" | 
 | 192 |         fi | 
 | 193 |     done | 
 | 194 | } | 
 | 195 |  | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 196 | function use_new_ovn_repository { | 
| Lucas Alvares Gomes | e38a39a | 2021-05-14 09:14:24 +0100 | [diff] [blame] | 197 |     if [[ "$OVN_BUILD_FROM_SOURCE" == "False" ]]; then | 
 | 198 |         return 0 | 
 | 199 |     fi | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 200 |     if [ -z "$is_new_ovn" ]; then | 
 | 201 |         local ovs_repo_dir=$DEST/$OVS_REPO_NAME | 
 | 202 |         if [ ! -d $ovs_repo_dir ]; then | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 203 |             git_timed clone $OVS_REPO $ovs_repo_dir | 
 | 204 |             pushd $ovs_repo_dir | 
 | 205 |             git checkout $OVS_BRANCH | 
 | 206 |             popd | 
 | 207 |         else | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 208 |             clone_repository $OVS_REPO $ovs_repo_dir $OVS_BRANCH | 
 | 209 |         fi | 
 | 210 |         # Check the split commit exists in the current branch | 
 | 211 |         pushd $ovs_repo_dir | 
 | 212 |         git log $OVS_BRANCH --pretty=format:"%H" | grep -q $OVN_SPLIT_HASH | 
 | 213 |         is_new_ovn=$? | 
 | 214 |         popd | 
 | 215 |     fi | 
 | 216 |     return $is_new_ovn | 
 | 217 | } | 
 | 218 |  | 
 | 219 | # NOTE(rtheis): Function copied from DevStack _neutron_ovs_base_setup_bridge | 
 | 220 | # and _neutron_ovs_base_add_bridge with the call to neutron-ovs-cleanup | 
 | 221 | # removed. The call is not relevant for OVN, as it is specific to the use | 
 | 222 | # of Neutron's OVS agent and hangs when running stack.sh because | 
 | 223 | # neutron-ovs-cleanup uses the OVSDB native interface. | 
 | 224 | function ovn_base_setup_bridge { | 
 | 225 |     local bridge=$1 | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 226 |     local addbr_cmd="sudo ovs-vsctl --no-wait -- --may-exist add-br $bridge -- set bridge $bridge protocols=OpenFlow13,OpenFlow15" | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 227 |  | 
 | 228 |     if [ "$OVS_DATAPATH_TYPE" != "system" ] ; then | 
 | 229 |         addbr_cmd="$addbr_cmd -- set Bridge $bridge datapath_type=${OVS_DATAPATH_TYPE}" | 
 | 230 |     fi | 
 | 231 |  | 
 | 232 |     $addbr_cmd | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 233 |     sudo ovs-vsctl --no-wait br-set-external-id $bridge bridge-id $bridge | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 234 | } | 
 | 235 |  | 
 | 236 | function _start_process { | 
 | 237 |     $SYSTEMCTL daemon-reload | 
 | 238 |     $SYSTEMCTL enable $1 | 
 | 239 |     $SYSTEMCTL restart $1 | 
 | 240 | } | 
 | 241 |  | 
 | 242 | function _run_process { | 
 | 243 |     local service=$1 | 
 | 244 |     local cmd="$2" | 
 | 245 |     local stop_cmd="$3" | 
 | 246 |     local group=$4 | 
| Brian Haley | 71c9965 | 2022-10-19 14:08:43 -0400 | [diff] [blame] | 247 |     local user=$5 | 
 | 248 |     local rundir=${6:-$OVS_RUNDIR} | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 249 |  | 
 | 250 |     local systemd_service="devstack@$service.service" | 
 | 251 |     local unit_file="$SYSTEMD_DIR/$systemd_service" | 
| Brian Haley | 71c9965 | 2022-10-19 14:08:43 -0400 | [diff] [blame] | 252 |     local environment="OVN_RUNDIR=$OVN_RUNDIR OVN_DBDIR=$OVN_DATADIR OVN_LOGDIR=$LOGDIR OVS_RUNDIR=$OVS_RUNDIR OVS_DBDIR=$OVS_DATADIR OVS_LOGDIR=$LOGDIR" | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 253 |  | 
 | 254 |     echo "Starting $service executed command": $cmd | 
 | 255 |  | 
 | 256 |     write_user_unit_file $systemd_service "$cmd" "$group" "$user" | 
 | 257 |     iniset -sudo $unit_file "Service" "Type" "forking" | 
 | 258 |     iniset -sudo $unit_file "Service" "RemainAfterExit" "yes" | 
 | 259 |     iniset -sudo $unit_file "Service" "KillMode" "mixed" | 
 | 260 |     iniset -sudo $unit_file "Service" "LimitNOFILE" "65536" | 
 | 261 |     iniset -sudo $unit_file "Service" "Environment" "$environment" | 
 | 262 |     if [ -n "$stop_cmd" ]; then | 
 | 263 |         iniset -sudo $unit_file "Service" "ExecStop" "$stop_cmd" | 
 | 264 |     fi | 
 | 265 |  | 
 | 266 |     _start_process $systemd_service | 
 | 267 |  | 
| Brian Haley | 71c9965 | 2022-10-19 14:08:43 -0400 | [diff] [blame] | 268 |     local testcmd="test -e $rundir/$service.pid" | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 269 |     test_with_retry "$testcmd" "$service did not start" $SERVICE_TIMEOUT 1 | 
| Rodolfo Alonso Hernandez | 8c67103 | 2022-02-09 18:01:46 +0000 | [diff] [blame] | 270 |     local service_ctl_file | 
| Brian Haley | 71c9965 | 2022-10-19 14:08:43 -0400 | [diff] [blame] | 271 |     service_ctl_file=$(ls $rundir | grep $service | grep ctl) | 
| Rodolfo Alonso Hernandez | 8c67103 | 2022-02-09 18:01:46 +0000 | [diff] [blame] | 272 |     if [ -z "$service_ctl_file" ]; then | 
 | 273 |         die $LINENO "ctl file for service $service is not present." | 
 | 274 |     fi | 
| Brian Haley | 71c9965 | 2022-10-19 14:08:43 -0400 | [diff] [blame] | 275 |     sudo ovs-appctl -t $rundir/$service_ctl_file vlog/set console:off syslog:info file:info | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 276 | } | 
 | 277 |  | 
 | 278 | function clone_repository { | 
 | 279 |     local repo=$1 | 
 | 280 |     local dir=$2 | 
 | 281 |     local branch=$3 | 
 | 282 |     # Set ERROR_ON_CLONE to false to avoid the need of having the | 
 | 283 |     # repositories like OVN and OVS in the required_projects of the job | 
 | 284 |     # definition. | 
 | 285 |     ERROR_ON_CLONE=false git_clone $repo $dir $branch | 
 | 286 | } | 
 | 287 |  | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 288 | function create_public_bridge { | 
 | 289 |     # Create the public bridge that OVN will use | 
| Radosław Piliszek | 9529878 | 2021-06-08 16:19:40 +0000 | [diff] [blame] | 290 |     sudo ovs-vsctl --may-exist add-br $PUBLIC_BRIDGE -- set bridge $PUBLIC_BRIDGE protocols=OpenFlow13,OpenFlow15 | 
 | 291 |     sudo ovs-vsctl set open . external-ids:ovn-bridge-mappings=$PHYSICAL_NETWORK:$PUBLIC_BRIDGE | 
| Slawek Kaplonski | b1a89eb | 2021-08-26 21:42:32 +0200 | [diff] [blame] | 292 |     _configure_public_network_connectivity | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 293 | } | 
 | 294 |  | 
 | 295 | function _disable_libvirt_apparmor { | 
 | 296 |     if ! sudo aa-status --enabled ; then | 
 | 297 |         return 0 | 
 | 298 |     fi | 
 | 299 |     # NOTE(arosen): This is used as a work around to allow newer versions | 
 | 300 |     # of libvirt to work with ovs configured ports. See LP#1466631. | 
 | 301 |     # requires the apparmor-utils | 
 | 302 |     install_package apparmor-utils | 
 | 303 |     # disables apparmor for libvirtd | 
 | 304 |     sudo aa-complain /etc/apparmor.d/usr.sbin.libvirtd | 
 | 305 | } | 
 | 306 |  | 
 | 307 |  | 
 | 308 | # OVN compilation functions | 
 | 309 | # ------------------------- | 
 | 310 |  | 
 | 311 |  | 
 | 312 | # compile_ovn() - Compile OVN from source and load needed modules | 
 | 313 | #                 Accepts three parameters: | 
| Slawek Kaplonski | 5888947 | 2021-12-22 16:00:29 +0100 | [diff] [blame] | 314 | #                   - first optional parameter defines prefix for | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 315 | #                     ovn compilation | 
| Slawek Kaplonski | 5888947 | 2021-12-22 16:00:29 +0100 | [diff] [blame] | 316 | #                   - second optional parameter defines localstatedir for | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 317 | #                     ovn single machine runtime | 
 | 318 | function compile_ovn { | 
| Slawek Kaplonski | 5888947 | 2021-12-22 16:00:29 +0100 | [diff] [blame] | 319 |     local prefix=$1 | 
 | 320 |     local localstatedir=$2 | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 321 |  | 
 | 322 |     if [ -n "$prefix" ]; then | 
 | 323 |         prefix="--prefix=$prefix" | 
 | 324 |     fi | 
 | 325 |  | 
 | 326 |     if [ -n "$localstatedir" ]; then | 
 | 327 |         localstatedir="--localstatedir=$localstatedir" | 
 | 328 |     fi | 
 | 329 |  | 
 | 330 |     clone_repository $OVN_REPO $DEST/$OVN_REPO_NAME $OVN_BRANCH | 
 | 331 |     pushd $DEST/$OVN_REPO_NAME | 
 | 332 |  | 
 | 333 |     if [ ! -f configure ] ; then | 
 | 334 |         ./boot.sh | 
 | 335 |     fi | 
 | 336 |  | 
 | 337 |     if [ ! -f config.status ] || [ configure -nt config.status ] ; then | 
 | 338 |         ./configure --with-ovs-source=$DEST/$OVS_REPO_NAME $prefix $localstatedir | 
 | 339 |     fi | 
 | 340 |     make -j$(($(nproc) + 1)) | 
 | 341 |     sudo make install | 
 | 342 |     popd | 
 | 343 | } | 
 | 344 |  | 
 | 345 |  | 
 | 346 | # OVN Neutron driver functions | 
 | 347 | # ---------------------------- | 
 | 348 |  | 
 | 349 | # OVN service sanity check | 
 | 350 | function ovn_sanity_check { | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 351 |     if is_service_enabled q-agt neutron-agent; then | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 352 |         die $LINENO "The q-agt/neutron-agt service must be disabled with OVN." | 
 | 353 |     elif is_service_enabled q-l3 neutron-l3; then | 
 | 354 |         die $LINENO "The q-l3/neutron-l3 service must be disabled with OVN." | 
 | 355 |     elif is_service_enabled q-svc neutron-api && [[ ! $Q_ML2_PLUGIN_MECHANISM_DRIVERS =~ "ovn" ]]; then | 
 | 356 |         die $LINENO "OVN needs to be enabled in \$Q_ML2_PLUGIN_MECHANISM_DRIVERS" | 
 | 357 |     elif is_service_enabled q-svc neutron-api && [[ ! $Q_ML2_PLUGIN_TYPE_DRIVERS =~ "geneve" ]]; then | 
 | 358 |         die $LINENO "Geneve needs to be enabled in \$Q_ML2_PLUGIN_TYPE_DRIVERS to be used with OVN" | 
 | 359 |     fi | 
 | 360 | } | 
 | 361 |  | 
 | 362 | # install_ovn() - Collect source and prepare | 
 | 363 | function install_ovn { | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 364 |     echo "Installing OVN and dependent packages" | 
 | 365 |  | 
 | 366 |     # Check the OVN configuration | 
 | 367 |     ovn_sanity_check | 
 | 368 |  | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 369 |     # Install tox, used to generate the config (see devstack/override-defaults) | 
 | 370 |     pip_install tox | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 371 |  | 
 | 372 |     sudo mkdir -p $OVS_RUNDIR | 
 | 373 |     sudo chown $(whoami) $OVS_RUNDIR | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 374 |  | 
 | 375 |     if [[ "$OVN_BUILD_FROM_SOURCE" == "True" ]]; then | 
 | 376 |         # If OVS is already installed, remove it, because we're about to | 
 | 377 |         # re-install it from source. | 
 | 378 |         for package in openvswitch openvswitch-switch openvswitch-common; do | 
 | 379 |             if is_package_installed $package ; then | 
 | 380 |                 uninstall_package $package | 
 | 381 |             fi | 
 | 382 |         done | 
 | 383 |  | 
 | 384 |         remove_ovs_packages | 
 | 385 |         sudo rm -f $OVS_RUNDIR/* | 
 | 386 |  | 
 | 387 |         compile_ovs $OVN_BUILD_MODULES | 
 | 388 |         if use_new_ovn_repository; then | 
| Slawek Kaplonski | 5888947 | 2021-12-22 16:00:29 +0100 | [diff] [blame] | 389 |             compile_ovn | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 390 |         fi | 
 | 391 |  | 
 | 392 |         sudo mkdir -p $OVS_PREFIX/var/log/openvswitch | 
 | 393 |         sudo chown $(whoami) $OVS_PREFIX/var/log/openvswitch | 
 | 394 |         sudo mkdir -p $OVS_PREFIX/var/log/ovn | 
 | 395 |         sudo chown $(whoami) $OVS_PREFIX/var/log/ovn | 
 | 396 |     else | 
| yatinkarel | 6dd896f | 2022-04-26 16:37:07 +0530 | [diff] [blame] | 397 |         # Load fixup_ovn_centos | 
 | 398 |         source ${TOP_DIR}/tools/fixup_stuff.sh | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 399 |         fixup_ovn_centos | 
 | 400 |         install_package $(get_packages openvswitch) | 
 | 401 |         install_package $(get_packages ovn) | 
 | 402 |     fi | 
 | 403 |  | 
 | 404 |     # Ensure that the OVS commands are accessible in the PATH | 
 | 405 |     export PATH=$OVS_BINDIR:$PATH | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 406 |  | 
 | 407 |     # Archive log files and create new | 
 | 408 |     local log_archive_dir=$LOGDIR/archive | 
 | 409 |     mkdir -p $log_archive_dir | 
 | 410 |     for logfile in ovs-vswitchd.log ovn-northd.log ovn-controller.log ovn-controller-vtep.log ovs-vtep.log ovsdb-server.log ovsdb-server-nb.log ovsdb-server-sb.log; do | 
 | 411 |         if [ -f "$LOGDIR/$logfile" ] ; then | 
 | 412 |             mv "$LOGDIR/$logfile"  "$log_archive_dir/$logfile.${CURRENT_LOG_TIME}" | 
 | 413 |         fi | 
 | 414 |     done | 
 | 415 |  | 
 | 416 |     # Install ovsdbapp from source if requested | 
 | 417 |     if use_library_from_git "ovsdbapp"; then | 
 | 418 |         git_clone_by_name "ovsdbapp" | 
 | 419 |         setup_dev_lib "ovsdbapp" | 
 | 420 |     fi | 
 | 421 |  | 
 | 422 |     # Install ovs python module from ovs source. | 
 | 423 |     if [[ "$OVN_INSTALL_OVS_PYTHON_MODULE" == "True" ]]; then | 
 | 424 |         sudo pip uninstall -y ovs | 
 | 425 |         # Clone the OVS repository if it's not yet present | 
 | 426 |         clone_repository $OVS_REPO $DEST/$OVS_REPO_NAME $OVS_BRANCH | 
 | 427 |         sudo pip install -e $DEST/$OVS_REPO_NAME/python | 
 | 428 |     fi | 
 | 429 | } | 
 | 430 |  | 
 | 431 | # filter_network_api_extensions() - Remove non-supported API extensions by | 
 | 432 | # the OVN driver from the list of enabled API extensions | 
 | 433 | function filter_network_api_extensions { | 
 | 434 |     SUPPORTED_NETWORK_API_EXTENSIONS=$($PYTHON -c \ | 
 | 435 |         'from neutron.common.ovn import extensions ;\ | 
 | 436 |         print(",".join(extensions.ML2_SUPPORTED_API_EXTENSIONS))') | 
 | 437 |     SUPPORTED_NETWORK_API_EXTENSIONS=$SUPPORTED_NETWORK_API_EXTENSIONS,$($PYTHON -c \ | 
 | 438 |         'from neutron.common.ovn import extensions ;\ | 
 | 439 |         print(",".join(extensions.ML2_SUPPORTED_API_EXTENSIONS_OVN_L3))') | 
 | 440 |     if is_service_enabled q-qos neutron-qos ; then | 
 | 441 |         SUPPORTED_NETWORK_API_EXTENSIONS="$SUPPORTED_NETWORK_API_EXTENSIONS,qos" | 
 | 442 |     fi | 
 | 443 |     NETWORK_API_EXTENSIONS=${NETWORK_API_EXTENSIONS:-$SUPPORTED_NETWORK_API_EXTENSIONS} | 
 | 444 |     extensions=$(echo $NETWORK_API_EXTENSIONS | tr ', ' '\n' | sort -u) | 
 | 445 |     supported_ext=$(echo $SUPPORTED_NETWORK_API_EXTENSIONS | tr ', ' '\n' | sort -u) | 
 | 446 |     enabled_ext=$(comm -12 <(echo -e "$extensions") <(echo -e "$supported_ext")) | 
 | 447 |     disabled_ext=$(comm -3 <(echo -e "$extensions") <(echo -e "$enabled_ext")) | 
 | 448 |  | 
 | 449 |     # Log a message in case some extensions had to be disabled because | 
 | 450 |     # they are not supported by the OVN driver | 
 | 451 |     if [ ! -z "$disabled_ext" ]; then | 
 | 452 |         _disabled=$(echo $disabled_ext | tr ' ' ',') | 
 | 453 |         echo "The folling network API extensions have been disabled because they are not supported by OVN: $_disabled" | 
 | 454 |     fi | 
 | 455 |  | 
 | 456 |     # Export the final list of extensions that have been enabled and are | 
 | 457 |     # supported by OVN | 
 | 458 |     export NETWORK_API_EXTENSIONS=$(echo $enabled_ext | tr ' ' ',') | 
 | 459 | } | 
 | 460 |  | 
 | 461 | function configure_ovn_plugin { | 
 | 462 |     echo "Configuring Neutron for OVN" | 
 | 463 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 464 |     if is_service_enabled q-svc neutron-api; then | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 465 |         filter_network_api_extensions | 
 | 466 |         populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_type_geneve max_header_size=$OVN_GENEVE_OVERHEAD | 
 | 467 |         populate_ml2_config /$Q_PLUGIN_CONF_FILE ovn ovn_nb_connection="$OVN_NB_REMOTE" | 
 | 468 |         populate_ml2_config /$Q_PLUGIN_CONF_FILE ovn ovn_sb_connection="$OVN_SB_REMOTE" | 
 | 469 |         if is_service_enabled tls-proxy; then | 
 | 470 |             populate_ml2_config /$Q_PLUGIN_CONF_FILE ovn ovn_sb_ca_cert="$INT_CA_DIR/ca-chain.pem" | 
 | 471 |             populate_ml2_config /$Q_PLUGIN_CONF_FILE ovn ovn_sb_certificate="$INT_CA_DIR/$DEVSTACK_CERT_NAME.crt" | 
 | 472 |             populate_ml2_config /$Q_PLUGIN_CONF_FILE ovn ovn_sb_private_key="$INT_CA_DIR/private/$DEVSTACK_CERT_NAME.key" | 
 | 473 |             populate_ml2_config /$Q_PLUGIN_CONF_FILE ovn ovn_nb_ca_cert="$INT_CA_DIR/ca-chain.pem" | 
 | 474 |             populate_ml2_config /$Q_PLUGIN_CONF_FILE ovn ovn_nb_certificate="$INT_CA_DIR/$DEVSTACK_CERT_NAME.crt" | 
 | 475 |             populate_ml2_config /$Q_PLUGIN_CONF_FILE ovn ovn_nb_private_key="$INT_CA_DIR/private/$DEVSTACK_CERT_NAME.key" | 
 | 476 |         fi | 
 | 477 |         populate_ml2_config /$Q_PLUGIN_CONF_FILE ovn neutron_sync_mode="$OVN_NEUTRON_SYNC_MODE" | 
 | 478 |         populate_ml2_config /$Q_PLUGIN_CONF_FILE ovn ovn_l3_scheduler="$OVN_L3_SCHEDULER" | 
 | 479 |         populate_ml2_config /$Q_PLUGIN_CONF_FILE securitygroup enable_security_group="$Q_USE_SECGROUP" | 
 | 480 |         inicomment /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver | 
 | 481 |  | 
| Flavio Fernandes | a2273cc | 2021-02-06 16:23:36 -0500 | [diff] [blame] | 482 |         if is_service_enabled q-log neutron-log; then | 
 | 483 |             populate_ml2_config /$Q_PLUGIN_CONF_FILE network_log rate_limit="$Q_LOG_DRIVER_RATE_LIMIT" | 
 | 484 |             populate_ml2_config /$Q_PLUGIN_CONF_FILE network_log burst_limit="$Q_LOG_DRIVER_BURST_LIMIT" | 
 | 485 |             inicomment /$Q_PLUGIN_CONF_FILE network_log local_output_log_base="$Q_LOG_DRIVER_LOG_BASE" | 
 | 486 |         fi | 
 | 487 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 488 |         if is_service_enabled q-ovn-metadata-agent neutron-ovn-metadata-agent; then | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 489 |             populate_ml2_config /$Q_PLUGIN_CONF_FILE ovn ovn_metadata_enabled=True | 
 | 490 |         else | 
 | 491 |             populate_ml2_config /$Q_PLUGIN_CONF_FILE ovn ovn_metadata_enabled=False | 
 | 492 |         fi | 
 | 493 |  | 
 | 494 |         if is_service_enabled q-dns neutron-dns ; then | 
 | 495 |             iniset $NEUTRON_CONF DEFAULT dns_domain openstackgate.local | 
 | 496 |             populate_ml2_config /$Q_PLUGIN_CONF_FILE ovn dns_servers="$OVN_DNS_SERVERS" | 
 | 497 |         fi | 
 | 498 |  | 
 | 499 |         iniset $NEUTRON_CONF ovs igmp_snooping_enable $OVN_IGMP_SNOOPING_ENABLE | 
 | 500 |     fi | 
 | 501 |  | 
 | 502 |     if is_service_enabled q-dhcp neutron-dhcp ; then | 
 | 503 |         iniset $NEUTRON_CONF DEFAULT dhcp_agent_notification True | 
 | 504 |     else | 
 | 505 |         iniset $NEUTRON_CONF DEFAULT dhcp_agent_notification False | 
 | 506 |     fi | 
 | 507 |  | 
 | 508 |     if is_service_enabled n-api-meta ; then | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 509 |         if is_service_enabled q-ovn-metadata-agent neutron-ovn-metadata-agent; then | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 510 |             iniset $NOVA_CONF neutron service_metadata_proxy True | 
 | 511 |         fi | 
 | 512 |     fi | 
 | 513 | } | 
 | 514 |  | 
 | 515 | function configure_ovn { | 
 | 516 |     echo "Configuring OVN" | 
 | 517 |  | 
 | 518 |     if [ -z "$OVN_UUID" ] ; then | 
| Slawek Kaplonski | 1ed276c | 2021-03-11 13:10:28 +0100 | [diff] [blame] | 519 |         if [ -f $OVS_SYSCONFDIR/system-id.conf ]; then | 
 | 520 |             OVN_UUID=$(cat $OVS_SYSCONFDIR/system-id.conf) | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 521 |         else | 
 | 522 |             OVN_UUID=$(uuidgen) | 
| Slawek Kaplonski | 1ed276c | 2021-03-11 13:10:28 +0100 | [diff] [blame] | 523 |             echo $OVN_UUID | sudo tee $OVS_SYSCONFDIR/system-id.conf | 
 | 524 |         fi | 
 | 525 |     else | 
 | 526 |         local ovs_uuid | 
 | 527 |         ovs_uuid=$(cat $OVS_SYSCONFDIR/system-id.conf) | 
 | 528 |         if [ "$ovs_uuid" != $OVN_UUID ]; then | 
 | 529 |             echo $OVN_UUID | sudo tee $OVS_SYSCONFDIR/system-id.conf | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 530 |         fi | 
 | 531 |     fi | 
 | 532 |  | 
| Lucas Alvares Gomes | 8903d8c | 2021-01-15 09:26:44 +0000 | [diff] [blame] | 533 |     # Erase the pre-set configurations from packages. DevStack will | 
 | 534 |     # configure OVS and OVN accordingly for its use. | 
 | 535 |     if [[ "$OVN_BUILD_FROM_SOURCE" == "False" ]] && is_fedora; then | 
 | 536 |         sudo truncate -s 0 /etc/openvswitch/default.conf | 
 | 537 |         sudo truncate -s 0 /etc/sysconfig/openvswitch | 
 | 538 |         sudo truncate -s 0 /etc/sysconfig/ovn | 
 | 539 |     fi | 
 | 540 |  | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 541 |     # Metadata | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 542 |     if is_service_enabled q-ovn-metadata-agent neutron-ovn-metadata-agent && is_service_enabled ovn-controller; then | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 543 |         sudo install -d -o $STACK_USER $NEUTRON_CONF_DIR | 
 | 544 |  | 
 | 545 |         mkdir -p $NEUTRON_DIR/etc/neutron/plugins/ml2 | 
 | 546 |         (cd $NEUTRON_DIR && exec ./tools/generate_config_file_samples.sh) | 
 | 547 |  | 
 | 548 |         cp $NEUTRON_DIR/etc/neutron_ovn_metadata_agent.ini.sample $OVN_META_CONF | 
 | 549 |         configure_root_helper_options $OVN_META_CONF | 
 | 550 |  | 
 | 551 |         iniset $OVN_META_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL | 
 | 552 |         iniset $OVN_META_CONF DEFAULT nova_metadata_host $OVN_META_DATA_HOST | 
 | 553 |         iniset $OVN_META_CONF DEFAULT metadata_workers $API_WORKERS | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 554 |         iniset $OVN_META_CONF DEFAULT state_path $DATA_DIR/neutron | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 555 |         iniset $OVN_META_CONF ovs ovsdb_connection tcp:$OVSDB_SERVER_LOCAL_HOST:6640 | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 556 |         iniset $OVN_META_CONF ovn ovn_sb_connection $OVN_SB_REMOTE | 
 | 557 |         if is_service_enabled tls-proxy; then | 
 | 558 |             iniset $OVN_META_CONF ovn \ | 
 | 559 |                 ovn_sb_ca_cert $INT_CA_DIR/ca-chain.pem | 
 | 560 |             iniset $OVN_META_CONF ovn \ | 
 | 561 |                 ovn_sb_certificate $INT_CA_DIR/$DEVSTACK_CERT_NAME.crt | 
 | 562 |             iniset $OVN_META_CONF ovn \ | 
 | 563 |                 ovn_sb_private_key $INT_CA_DIR/private/$DEVSTACK_CERT_NAME.key | 
 | 564 |         fi | 
 | 565 |     fi | 
 | 566 | } | 
 | 567 |  | 
 | 568 | function init_ovn { | 
 | 569 |     # clean up from previous (possibly aborted) runs | 
 | 570 |     # create required data files | 
 | 571 |  | 
 | 572 |     # Assumption: this is a dedicated test system and there is nothing important | 
 | 573 |     # in the ovn, ovn-nb, or ovs databases.  We're going to trash them and | 
 | 574 |     # create new ones on each devstack run. | 
 | 575 |  | 
 | 576 |     _disable_libvirt_apparmor | 
| Roman Dobosz | bd68251 | 2021-11-26 15:34:50 +0100 | [diff] [blame] | 577 |     local mkdir_cmd="mkdir -p ${OVN_DATADIR}" | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 578 |  | 
| Roman Dobosz | bd68251 | 2021-11-26 15:34:50 +0100 | [diff] [blame] | 579 |     if [[ "$OVN_BUILD_FROM_SOURCE" == "False" ]]; then | 
 | 580 |         mkdir_cmd="sudo ${mkdir_cmd}" | 
| yatinkarel | b575af0 | 2021-11-26 12:44:41 +0530 | [diff] [blame] | 581 |     fi | 
| Roman Dobosz | bd68251 | 2021-11-26 15:34:50 +0100 | [diff] [blame] | 582 |  | 
 | 583 |     $mkdir_cmd | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 584 |     mkdir -p $OVS_DATADIR | 
 | 585 |  | 
 | 586 |     rm -f $OVS_DATADIR/*.db | 
 | 587 |     rm -f $OVS_DATADIR/.*.db.~lock~ | 
| Gregory Thiemonge | 6822ff3 | 2021-09-01 09:36:31 +0200 | [diff] [blame] | 588 |     sudo rm -f $OVN_DATADIR/*.db | 
 | 589 |     sudo rm -f $OVN_DATADIR/.*.db.~lock~ | 
| yatinkarel | 7fecba2 | 2023-01-12 17:31:36 +0530 | [diff] [blame] | 590 |     sudo rm -f $OVN_RUNDIR/*.sock | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 591 | } | 
 | 592 |  | 
 | 593 | function _start_ovs { | 
 | 594 |     echo "Starting OVS" | 
 | 595 |     if is_service_enabled ovn-controller ovn-controller-vtep ovn-northd; then | 
 | 596 |         # ovsdb-server and ovs-vswitchd are used privately in OVN as openvswitch service names. | 
 | 597 |         enable_service ovsdb-server | 
 | 598 |         enable_service ovs-vswitchd | 
 | 599 |  | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 600 |         if [[ "$OVN_BUILD_FROM_SOURCE" == "True" ]]; then | 
 | 601 |             if [ ! -f $OVS_DATADIR/conf.db ]; then | 
 | 602 |                 ovsdb-tool create $OVS_DATADIR/conf.db $OVS_SHAREDIR/vswitch.ovsschema | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 603 |             fi | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 604 |  | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 605 |             if is_service_enabled ovn-controller-vtep; then | 
 | 606 |                 if [ ! -f $OVS_DATADIR/vtep.db ]; then | 
 | 607 |                     ovsdb-tool create $OVS_DATADIR/vtep.db $OVS_SHAREDIR/vtep.ovsschema | 
 | 608 |                 fi | 
 | 609 |             fi | 
 | 610 |  | 
 | 611 |             local dbcmd="$OVS_SBINDIR/ovsdb-server --remote=punix:$OVS_RUNDIR/db.sock --remote=ptcp:6640:$OVSDB_SERVER_LOCAL_HOST --pidfile --detach --log-file" | 
 | 612 |             dbcmd+=" --remote=db:Open_vSwitch,Open_vSwitch,manager_options" | 
 | 613 |             if is_service_enabled ovn-controller-vtep; then | 
 | 614 |                 dbcmd+=" --remote=db:hardware_vtep,Global,managers $OVS_DATADIR/vtep.db" | 
 | 615 |             fi | 
 | 616 |             dbcmd+=" $OVS_DATADIR/conf.db" | 
| Brian Haley | 71c9965 | 2022-10-19 14:08:43 -0400 | [diff] [blame] | 617 |             _run_process ovsdb-server "$dbcmd" "" "$STACK_GROUP" "root" "$OVS_RUNDIR" | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 618 |  | 
 | 619 |             # Note: ovn-controller will create and configure br-int once it is started. | 
 | 620 |             # So, no need to create it now because nothing depends on that bridge here. | 
 | 621 |             local ovscmd="$OVS_SBINDIR/ovs-vswitchd --log-file --pidfile --detach" | 
| Brian Haley | 71c9965 | 2022-10-19 14:08:43 -0400 | [diff] [blame] | 622 |             _run_process ovs-vswitchd "$ovscmd" "" "$STACK_GROUP" "root" "$OVS_RUNDIR" | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 623 |         else | 
 | 624 |             _start_process "$OVSDB_SERVER_SERVICE" | 
 | 625 |             _start_process "$OVS_VSWITCHD_SERVICE" | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 626 |         fi | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 627 |  | 
 | 628 |         echo "Configuring OVSDB" | 
 | 629 |         if is_service_enabled tls-proxy; then | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 630 |             sudo ovs-vsctl --no-wait set-ssl \ | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 631 |                 $INT_CA_DIR/private/$DEVSTACK_CERT_NAME.key \ | 
 | 632 |                 $INT_CA_DIR/$DEVSTACK_CERT_NAME.crt \ | 
 | 633 |                 $INT_CA_DIR/ca-chain.pem | 
 | 634 |         fi | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 635 |  | 
 | 636 |         sudo ovs-vsctl --no-wait set-manager ptcp:6640:$OVSDB_SERVER_LOCAL_HOST | 
 | 637 |         sudo ovs-vsctl --no-wait set open_vswitch . system-type="devstack" | 
 | 638 |         sudo ovs-vsctl --no-wait set open_vswitch . external-ids:system-id="$OVN_UUID" | 
 | 639 |         sudo ovs-vsctl --no-wait set open_vswitch . external-ids:ovn-remote="$OVN_SB_REMOTE" | 
 | 640 |         sudo ovs-vsctl --no-wait set open_vswitch . external-ids:ovn-bridge="br-int" | 
 | 641 |         sudo ovs-vsctl --no-wait set open_vswitch . external-ids:ovn-encap-type="geneve" | 
| Brian Haley | c869d59 | 2020-02-28 14:55:08 -0500 | [diff] [blame] | 642 |         sudo ovs-vsctl --no-wait set open_vswitch . external-ids:ovn-encap-ip="$TUNNEL_IP" | 
| Vladislav Belogrudov | 8a38a73 | 2022-05-25 12:58:52 +0300 | [diff] [blame] | 643 |         sudo ovs-vsctl --no-wait set open_vswitch . external-ids:hostname=$(hostname) | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 644 |         # Select this chassis to host gateway routers | 
 | 645 |         if [[ "$ENABLE_CHASSIS_AS_GW" == "True" ]]; then | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 646 |             sudo ovs-vsctl --no-wait set open_vswitch . external-ids:ovn-cms-options="enable-chassis-as-gw" | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 647 |         fi | 
 | 648 |  | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 649 |         if is_provider_network || [[ $Q_USE_PROVIDERNET_FOR_PUBLIC == "True" ]]; then | 
 | 650 |             ovn_base_setup_bridge $OVS_PHYSICAL_BRIDGE | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 651 |             sudo ovs-vsctl set open . external-ids:ovn-bridge-mappings=${PHYSICAL_NETWORK}:${OVS_PHYSICAL_BRIDGE} | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 652 |         fi | 
 | 653 |  | 
 | 654 |         if is_service_enabled ovn-controller-vtep ; then | 
 | 655 |             ovn_base_setup_bridge br-v | 
 | 656 |             vtep-ctl add-ps br-v | 
| Brian Haley | c869d59 | 2020-02-28 14:55:08 -0500 | [diff] [blame] | 657 |             vtep-ctl set Physical_Switch br-v tunnel_ips=$TUNNEL_IP | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 658 |  | 
 | 659 |             enable_service ovs-vtep | 
 | 660 |             local vtepcmd="$OVS_SCRIPTDIR/ovs-vtep --log-file --pidfile --detach br-v" | 
| Brian Haley | 71c9965 | 2022-10-19 14:08:43 -0400 | [diff] [blame] | 661 |             _run_process ovs-vtep "$vtepcmd" "" "$STACK_GROUP" "root" "$OVS_RUNDIR" | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 662 |  | 
 | 663 |             vtep-ctl set-manager tcp:$HOST_IP:6640 | 
 | 664 |         fi | 
 | 665 |     fi | 
 | 666 | } | 
 | 667 |  | 
 | 668 | function _start_ovn_services { | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 669 |     _start_process "$OVSDB_SERVER_SERVICE" | 
 | 670 |     _start_process "$OVS_VSWITCHD_SERVICE" | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 671 |  | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 672 |     if is_service_enabled ovn-northd ; then | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 673 |         _start_process "$OVN_NORTHD_SERVICE" | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 674 |     fi | 
 | 675 |     if is_service_enabled ovn-controller ; then | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 676 |         _start_process "$OVN_CONTROLLER_SERVICE" | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 677 |     fi | 
 | 678 |     if is_service_enabled ovn-controller-vtep ; then | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 679 |         _start_process "$OVN_CONTROLLER_VTEP_SERVICE" | 
 | 680 |     fi | 
 | 681 |     if is_service_enabled ovs-vtep ; then | 
 | 682 |         _start_process "devstack@ovs-vtep.service" | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 683 |     fi | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 684 |     if is_service_enabled q-ovn-metadata-agent neutron-ovn-metadata-agent ; then | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 685 |         _start_process "devstack@q-ovn-metadata-agent.service" | 
 | 686 |     fi | 
 | 687 | } | 
 | 688 |  | 
 | 689 | # start_ovn() - Start running processes, including screen | 
 | 690 | function start_ovn { | 
 | 691 |     echo "Starting OVN" | 
 | 692 |  | 
 | 693 |     _start_ovs | 
 | 694 |  | 
 | 695 |     local SCRIPTDIR=$OVN_SCRIPTDIR | 
 | 696 |     if ! use_new_ovn_repository; then | 
 | 697 |         SCRIPTDIR=$OVS_SCRIPTDIR | 
 | 698 |     fi | 
 | 699 |  | 
 | 700 |     if is_service_enabled ovn-northd ; then | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 701 |         if [[ "$OVN_BUILD_FROM_SOURCE" == "True" ]]; then | 
 | 702 |             local cmd="/bin/bash $SCRIPTDIR/ovn-ctl --no-monitor start_northd" | 
 | 703 |             local stop_cmd="/bin/bash $SCRIPTDIR/ovn-ctl stop_northd" | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 704 |  | 
| Brian Haley | 71c9965 | 2022-10-19 14:08:43 -0400 | [diff] [blame] | 705 |             _run_process ovn-northd "$cmd" "$stop_cmd" "$STACK_GROUP" "root" "$OVN_RUNDIR" | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 706 |         else | 
 | 707 |             _start_process "$OVN_NORTHD_SERVICE" | 
 | 708 |         fi | 
 | 709 |  | 
 | 710 |         # Wait for the service to be ready | 
| yatinkarel | 1baa890 | 2022-05-06 17:53:54 +0530 | [diff] [blame] | 711 |         # Check for socket and db files for both OVN NB and SB | 
| Brian Haley | 71c9965 | 2022-10-19 14:08:43 -0400 | [diff] [blame] | 712 |         wait_for_sock_file $OVN_RUNDIR/ovnnb_db.sock | 
 | 713 |         wait_for_sock_file $OVN_RUNDIR/ovnsb_db.sock | 
| yatinkarel | 1baa890 | 2022-05-06 17:53:54 +0530 | [diff] [blame] | 714 |         wait_for_db_file $OVN_DATADIR/ovnnb_db.db | 
 | 715 |         wait_for_db_file $OVN_DATADIR/ovnsb_db.db | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 716 |  | 
 | 717 |         if is_service_enabled tls-proxy; then | 
| Brian Haley | 71c9965 | 2022-10-19 14:08:43 -0400 | [diff] [blame] | 718 |             sudo ovn-nbctl --db=unix:$OVN_RUNDIR/ovnnb_db.sock set-ssl $INT_CA_DIR/private/$DEVSTACK_CERT_NAME.key $INT_CA_DIR/$DEVSTACK_CERT_NAME.crt $INT_CA_DIR/ca-chain.pem | 
 | 719 |             sudo ovn-sbctl --db=unix:$OVN_RUNDIR/ovnsb_db.sock set-ssl $INT_CA_DIR/private/$DEVSTACK_CERT_NAME.key $INT_CA_DIR/$DEVSTACK_CERT_NAME.crt $INT_CA_DIR/ca-chain.pem | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 720 |         fi | 
| Brian Haley | 71c9965 | 2022-10-19 14:08:43 -0400 | [diff] [blame] | 721 |         sudo ovn-nbctl --db=unix:$OVN_RUNDIR/ovnnb_db.sock set-connection p${OVN_PROTO}:6641:$SERVICE_LISTEN_ADDRESS -- set connection . inactivity_probe=60000 | 
 | 722 |         sudo ovn-sbctl --db=unix:$OVN_RUNDIR/ovnsb_db.sock set-connection p${OVN_PROTO}:6642:$SERVICE_LISTEN_ADDRESS -- set connection . inactivity_probe=60000 | 
 | 723 |         sudo ovs-appctl -t $OVN_RUNDIR/ovnnb_db.ctl vlog/set console:off syslog:$OVN_DBS_LOG_LEVEL file:$OVN_DBS_LOG_LEVEL | 
 | 724 |         sudo ovs-appctl -t $OVN_RUNDIR/ovnsb_db.ctl vlog/set console:off syslog:$OVN_DBS_LOG_LEVEL file:$OVN_DBS_LOG_LEVEL | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 725 |     fi | 
 | 726 |  | 
 | 727 |     if is_service_enabled ovn-controller ; then | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 728 |         if [[ "$OVN_BUILD_FROM_SOURCE" == "True" ]]; then | 
 | 729 |             local cmd="/bin/bash $SCRIPTDIR/ovn-ctl --no-monitor start_controller" | 
 | 730 |             local stop_cmd="/bin/bash $SCRIPTDIR/ovn-ctl stop_controller" | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 731 |  | 
| Brian Haley | 71c9965 | 2022-10-19 14:08:43 -0400 | [diff] [blame] | 732 |             _run_process ovn-controller "$cmd" "$stop_cmd" "$STACK_GROUP" "root" "$OVN_RUNDIR" | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 733 |         else | 
 | 734 |             _start_process "$OVN_CONTROLLER_SERVICE" | 
 | 735 |         fi | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 736 |     fi | 
 | 737 |  | 
 | 738 |     if is_service_enabled ovn-controller-vtep ; then | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 739 |         if [[ "$OVN_BUILD_FROM_SOURCE" == "True" ]]; then | 
 | 740 |             local cmd="$OVS_BINDIR/ovn-controller-vtep --log-file --pidfile --detach --ovnsb-db=$OVN_SB_REMOTE" | 
| Brian Haley | 71c9965 | 2022-10-19 14:08:43 -0400 | [diff] [blame] | 741 |             _run_process ovn-controller-vtep "$cmd" "" "$STACK_GROUP" "root" "$OVN_RUNDIR" | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 742 |         else | 
 | 743 |             _start_process "$OVN_CONTROLLER_VTEP_SERVICE" | 
 | 744 |         fi | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 745 |     fi | 
 | 746 |  | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 747 |     if is_service_enabled q-ovn-metadata-agent neutron-ovn-metadata-agent; then | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 748 |         run_process q-ovn-metadata-agent "$NEUTRON_OVN_BIN_DIR/$NEUTRON_OVN_METADATA_BINARY --config-file $OVN_META_CONF" | 
 | 749 |         # Format logging | 
 | 750 |         setup_logging $OVN_META_CONF | 
 | 751 |     fi | 
 | 752 |  | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 753 |     _start_ovn_services | 
 | 754 | } | 
 | 755 |  | 
 | 756 | function _stop_ovs_dp { | 
 | 757 |     sudo ovs-dpctl dump-dps | sudo xargs -n1 ovs-dpctl del-dp | 
 | 758 |     modprobe -q -r vport_geneve vport_vxlan openvswitch || true | 
 | 759 | } | 
 | 760 |  | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 761 | function _stop_process { | 
 | 762 |     local service=$1 | 
 | 763 |     echo "Stopping process $service" | 
 | 764 |     if $SYSTEMCTL is-enabled $service; then | 
 | 765 |         $SYSTEMCTL stop $service | 
 | 766 |         $SYSTEMCTL disable $service | 
 | 767 |     fi | 
 | 768 | } | 
 | 769 |  | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 770 | function stop_ovn { | 
| Slawek Kaplonski | a52041c | 2022-11-18 11:39:56 +0100 | [diff] [blame] | 771 |     if is_service_enabled q-ovn-metadata-agent neutron-ovn-metadata-agent; then | 
| Bence Romsics | 71c3c40 | 2022-12-21 13:50:54 +0100 | [diff] [blame^] | 772 |         # pkill takes care not to kill itself, but it may kill its parent | 
 | 773 |         # sudo unless we use the "ps | grep [f]oo" trick | 
 | 774 |         sudo pkill -9 -f "[h]aproxy" || : | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 775 |         _stop_process "devstack@q-ovn-metadata-agent.service" | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 776 |     fi | 
 | 777 |     if is_service_enabled ovn-controller-vtep ; then | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 778 |         _stop_process "$OVN_CONTROLLER_VTEP_SERVICE" | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 779 |     fi | 
 | 780 |     if is_service_enabled ovn-controller ; then | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 781 |         _stop_process "$OVN_CONTROLLER_SERVICE" | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 782 |     fi | 
 | 783 |     if is_service_enabled ovn-northd ; then | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 784 |         _stop_process "$OVN_NORTHD_SERVICE" | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 785 |     fi | 
 | 786 |     if is_service_enabled ovs-vtep ; then | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 787 |         _stop_process "devstack@ovs-vtep.service" | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 788 |     fi | 
 | 789 |  | 
| Lucas Alvares Gomes | e651d9e | 2020-11-19 14:50:01 +0000 | [diff] [blame] | 790 |     _stop_process "$OVS_VSWITCHD_SERVICE" | 
 | 791 |     _stop_process "$OVSDB_SERVER_SERVICE" | 
| Lucas Alvares Gomes | 1d468d4 | 2020-06-09 14:35:52 +0100 | [diff] [blame] | 792 |  | 
 | 793 |     _stop_ovs_dp | 
 | 794 | } | 
 | 795 |  | 
 | 796 | function _cleanup { | 
 | 797 |     local path=${1:-$DEST/$OVN_REPO_NAME} | 
 | 798 |     pushd $path | 
 | 799 |     cd $path | 
 | 800 |     sudo make uninstall | 
 | 801 |     sudo make distclean | 
 | 802 |     popd | 
 | 803 | } | 
 | 804 |  | 
 | 805 | # cleanup_ovn() - Remove residual data files, anything left over from previous | 
 | 806 | # runs that a clean run would need to clean up | 
 | 807 | function cleanup_ovn { | 
 | 808 |     local ovn_path=$DEST/$OVN_REPO_NAME | 
 | 809 |     local ovs_path=$DEST/$OVS_REPO_NAME | 
 | 810 |  | 
 | 811 |     if [ -d $ovn_path ]; then | 
 | 812 |         _cleanup $ovn_path | 
 | 813 |     fi | 
 | 814 |  | 
 | 815 |     if [ -d $ovs_path ]; then | 
 | 816 |         _cleanup $ovs_path | 
 | 817 |     fi | 
 | 818 |  | 
 | 819 |     sudo rm -f $OVN_RUNDIR | 
 | 820 | } |