40 lines
1.6 KiB
Bash
Executable File
40 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Oneshot daemon which creates a networking bridge.
|
|
#
|
|
# Creates br-ex, and sets up an ip address for it. We put this in a
|
|
# oneshot so that the ip address persists after reboot, without
|
|
# needing to add networking entries to the host system. (We want this
|
|
# to work well when we turn off classic confinement.)
|
|
|
|
set -ex
|
|
|
|
extcidr=$(snapctl get config.network.ext-cidr)
|
|
controlip=$(snapctl get config.network.control-ip)
|
|
|
|
# NOTE(dmitriis): this needs to be reworked to allow for OVN + direct exit of traffic to
|
|
# the provider network from a compute node.
|
|
|
|
# Create an external bridge in the system datapath.
|
|
ovs-vsctl --retry --may-exist add-br br-ex -- set bridge br-ex datapath_type=system protocols=OpenFlow13,OpenFlow15
|
|
ovs-vsctl set open . external-ids:ovn-bridge-mappings=physnet1:br-ex
|
|
ovs-vsctl set open . external-ids:ovn-cms-options="enable-chassis-as-gw"
|
|
|
|
# Configure the settings used by self-configuration of ovn-controller.
|
|
ovs-vsctl set open . external-ids:ovn-encap-type=geneve -- set open . external-ids:ovn-encap-ip=$controlip
|
|
# Leave SB database connection details for ovn-controller to pick up.
|
|
ovs-vsctl set open . external-ids:ovn-remote='unix:/var/snap/microstack/common/run/ovn/ovnsb_db.sock'
|
|
|
|
# NOTE: system-id is a randomly-generated UUID (see the --system-id=random option for ovs-ctl)
|
|
# As it is generated automatically, we do not set it here.
|
|
# It can be retrieved by looking at `ovs-vsctl get open_vswitch . external-ids`.
|
|
|
|
# Configure br-ex
|
|
ip address add $extcidr dev br-ex || :
|
|
ip link set br-ex up || :
|
|
|
|
iptables-legacy -w -t nat -A POSTROUTING -s $extcidr ! \
|
|
-d $extcidr -j MASQUERADE || :
|
|
|
|
exit 0
|