apiVersion: v1
data:
  ovn-bgp-agent-init.sh: |
    #!/bin/bash



    set -ex

    # See: https://bugs.launchpad.net/neutron/+bug/2028442
    mkdir -p /tmp/pod-shared
    tee > /tmp/pod-shared/ovn.ini << EOF
    [ovn]
    ovn_nb_connection=tcp:$OVN_OVSDB_NB_SERVICE_HOST:$OVN_OVSDB_NB_SERVICE_PORT_OVSDB
    ovn_sb_connection=tcp:$OVN_OVSDB_SB_SERVICE_HOST:$OVN_OVSDB_SB_SERVICE_PORT_OVSDB
    EOF
    tee > /tmp/pod-shared/ovn-bgp-agent.ini << EOF
    [DEFAULT]
    bgp_router_id=$NODE_IP
    [frr_k8s]
    node_name=$NODE_NAME
    EOF
  ovn-bgp-agent.sh: |
    #!/bin/bash



    set -x

    exec ovn-bgp-agent \
              --config-file /etc/ovn-bgp-agent/ovn-bgp-agent.conf \
              --config-file /tmp/pod-shared/ovn-bgp-agent.ini \
              --config-file /tmp/pod-shared/ovn.ini
  ovn-controller-init.sh: |
    #!/bin/bash -xe

    # Copyright 2023 VEXXHOST, Inc.
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #    http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.

    ANNOTATION_KEY="atmosphere.cloud/ovn-system-id"

    function get_ip_address_from_interface {
      local interface=$1
      local ip=$(ip -4 -o addr s "${interface}" | awk '{ print $4; exit }' | awk -F '/' 'NR==1 {print $1}')
      if [ -z "${ip}" ] ; then
        exit 1
      fi
      echo ${ip}
    }

    function get_current_system_id {
      ovs-vsctl --if-exists get Open_vSwitch . external_ids:system-id | tr -d '"'
    }

    function get_stored_system_id {
      kubectl get node "$NODE_NAME" -o "jsonpath={.metadata.annotations.atmosphere\.cloud/ovn-system-id}"
    }

    function store_system_id() {
      local system_id=$1
      kubectl annotate node "$NODE_NAME" "$ANNOTATION_KEY=$system_id"
    }

    # Detect tunnel interface
    tunnel_interface=""
    if [ -z "${tunnel_interface}" ] ; then
        # search for interface with tunnel network routing
        tunnel_network_cidr="0/0"
        if [ -z "${tunnel_network_cidr}" ] ; then
            tunnel_network_cidr="0/0"
        fi
        # If there is not tunnel network gateway, exit
        tunnel_interface=$(ip -4 route list ${tunnel_network_cidr} | awk -F 'dev' '{ print $2; exit }' \
            | awk '{ print $1 }') || exit 1
    fi
    ovs-vsctl set open . external_ids:ovn-encap-ip="$(get_ip_address_from_interface ${tunnel_interface})"

    # Get the stored system-id from the Kubernetes node annotation
    stored_system_id=$(get_stored_system_id)

    # Get the current system-id set in OVS
    current_system_id=$(get_current_system_id)

    if [ -n "$stored_system_id" ] && [ "$stored_system_id" != "$current_system_id" ]; then
      # If the annotation exists and does not match the current system-id, set the system-id to the stored one
      ovs-vsctl set Open_vSwitch . external_ids:system-id="$stored_system_id"
    elif [ -z "$current_system_id" ]; then
      # If no current system-id is set, generate a new one
      current_system_id=$(uuidgen)
      ovs-vsctl set Open_vSwitch . external_ids:system-id="$current_system_id"
      # Store the new system-id in the Kubernetes node annotation
      store_system_id "$current_system_id"
    elif [ -z "$stored_system_id" ]; then
      # If there is no stored system-id, store the current one
      store_system_id "$current_system_id"
    fi

    # Configure OVN remote

    ovs-vsctl set open . external-ids:ovn-remote="tcp:ovn-ovsdb-sb-0.ovn-ovsdb-sb.openstack.svc.cluster.local:6642"

    # Configure OVN values
    ovs-vsctl set open . external-ids:rundir="/var/run/openvswitch"
    ovs-vsctl set open . external-ids:ovn-encap-type="geneve"
    ovs-vsctl set open . external-ids:ovn-bridge="br-int"
    ovs-vsctl set open . external-ids:ovn-bridge-mappings="external:br-ex"

    GW_ENABLED=$(cat /tmp/gw-enabled/gw-enabled)
    if [[ ${GW_ENABLED} == enabled ]]; then
      ovs-vsctl set open . external-ids:ovn-cms-options=enable-chassis-as-gw,availability-zones=nova
    else
      ovs-vsctl set open . external-ids:ovn-cms-options=availability-zones=nova
    fi



    # Configure hostname
      ovs-vsctl set open . external-ids:hostname="$(hostname -f)"

    # Create bridges and create ports
    # handle any bridge mappings
    # /tmp/auto_bridge_add is one line json file: {"br-ex1":"eth1","br-ex2":"eth2"}
    for bmap in `sed 's/[{}"]//g' /tmp/auto_bridge_add | tr "," "\n"`
    do
      bridge=${bmap%:*}
      iface=${bmap#*:}
      ovs-vsctl --may-exist add-br $bridge -- set bridge $bridge protocols=OpenFlow13
      if [ -n "$iface" ] && [ "$iface" != "null" ] && ( ip link show $iface 1>/dev/null 2>&1 );
      then
        ovs-vsctl --may-exist add-port $bridge $iface
      fi
    done

    /usr/local/bin/ovsinit /tmp/auto_bridge_add
  ovn-network-logging-parser.sh: |
    #!/bin/bash



    set -ex
    COMMAND="${@:-start}"

    function start () {
      exec uwsgi --ini /etc/neutron/neutron-ovn-network-logging-parser-uwsgi.ini
    }

    function stop () {
      kill -TERM 1
    }

    $COMMAND
kind: ConfigMap
metadata:
  annotations:
    meta.helm.sh/release-name: ovn
    meta.helm.sh/release-namespace: openstack
  creationTimestamp: "2026-02-27T18:58:38Z"
  labels:
    app.kubernetes.io/managed-by: Helm
  name: ovn-bin
  namespace: openstack
  resourceVersion: "13454"
  uid: caf6ffc8-7f0e-4ce5-8e74-d99358f111d0
