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