From 1633197fdaf01e567396343ffd28e925454824a9 Mon Sep 17 00:00:00 2001 From: Chris Wedgwood Date: Mon, 5 Jun 2017 09:26:00 +0200 Subject: [PATCH] Merge ovs 'ensure' logic into the caller Rename ml2.ovs.auto_bridge_add to network.auto_bridge_add Change-Id: Idf0e746df8b91cbbf89373d1516108ce2163083c Co-Authored-By: Artur Korzeniewski --- .../bin/_openvswitch-ensure-configured.sh.tpl | 41 ------------------- .../bin/_openvswitch-vswitchd.sh.tpl | 26 +++++++++++- neutron/templates/configmap-bin.yaml | 2 - neutron/templates/daemonset-ovs-vswitchd.yaml | 4 -- neutron/values.yaml | 15 ++++--- 5 files changed, 32 insertions(+), 56 deletions(-) delete mode 100644 neutron/templates/bin/_openvswitch-ensure-configured.sh.tpl diff --git a/neutron/templates/bin/_openvswitch-ensure-configured.sh.tpl b/neutron/templates/bin/_openvswitch-ensure-configured.sh.tpl deleted file mode 100644 index 54f5490370..0000000000 --- a/neutron/templates/bin/_openvswitch-ensure-configured.sh.tpl +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -# Copyright 2017 The Openstack-Helm Authors. -# -# 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. - -{{- if not .Values.ml2 -}}{{- set . "Values.ml2" dict -}}{{- end -}} -{{- if not .Values.ml2.ovs -}}{{- set . "Values.ml2.ovs" dict -}}{{- end -}} -{{- if not .Values.ml2.ovs.auto_bridge_add -}}{{- set . "Values.ml2.ovs.auto_bridge_add" dict -}}{{- end -}} - -set -x - -bridge="{{ .Values.network.external_bridge }}" -port="{{ .Values.network.interface.external }}" - -# create bridge device -ovs-vsctl --no-wait --may-exist add-br "$bridge" -if [ ! -z "$port" ] ; then - ovs-vsctl --no-wait --may-exist add-port "$bridge" "$port" - ip link set dev "$port" up -fi - -# handle any bridge mappings -{{ range $br, $phys := .Values.ml2.ovs.auto_bridge_add }} -# create {{ $br }}{{ if $phys }} and add port {{ $phys }}{{ end }} -ovs-vsctl --no-wait --may-exist add-br {{ $br }} -{{ if $phys }} -ovs-vsctl --no-wait --may-exist add-port {{ $br }} {{ $phys }} -ip link set dev {{ $phys }} up -{{ end }} -{{ end -}} diff --git a/neutron/templates/bin/_openvswitch-vswitchd.sh.tpl b/neutron/templates/bin/_openvswitch-vswitchd.sh.tpl index b93ba1e0f7..b4cff833d5 100644 --- a/neutron/templates/bin/_openvswitch-vswitchd.sh.tpl +++ b/neutron/templates/bin/_openvswitch-vswitchd.sh.tpl @@ -23,5 +23,29 @@ modprobe gre modprobe vxlan ovs-vsctl --no-wait show -bash -x /tmp/openvswitch-ensure-configured.sh + +external_bridge="{{- .Values.network.external_bridge -}}" +external_interface="{{- .Values.network.interface.external -}}" +if [ -n "${external_bridge}" ] ; then + # create bridge device + ovs-vsctl --no-wait --may-exist add-br $external_bridge + if [ -n "$external_interface" ] ; then + # add external interface to the bridge + ovs-vsctl --no-wait --may-exist add-port $external_bridge $external_interface + ip link set dev $external_interface up + fi +fi + +# handle any bridge mappings +{{- range $br, $phys := .Values.network.auto_bridge_add }} +if [ -n "{{- $br -}}" ] ; then + # create {{ $br }}{{ if $phys }} and add port {{ $phys }}{{ end }} + ovs-vsctl --no-wait --may-exist add-br "{{ $br }}" + if [ -n "{{- $phys -}}" ] ; then + ovs-vsctl --no-wait --may-exist add-port "{{ $br }}" "{{ $phys }}" + ip link set dev "{{ $phys }}" up + fi +fi +{{- end }} + exec /usr/sbin/ovs-vswitchd unix:/run/openvswitch/db.sock --mlockall -vconsole:emer -vconsole:err -vconsole:info diff --git a/neutron/templates/configmap-bin.yaml b/neutron/templates/configmap-bin.yaml index dcabed38da..c95dd77f67 100644 --- a/neutron/templates/configmap-bin.yaml +++ b/neutron/templates/configmap-bin.yaml @@ -43,7 +43,5 @@ data: {{ tuple "bin/_neutron-server.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} openvswitch-db-server.sh: |+ {{ tuple "bin/_openvswitch-db-server.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} - openvswitch-ensure-configured.sh: |+ -{{ tuple "bin/_openvswitch-ensure-configured.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} openvswitch-vswitchd.sh: |+ {{ tuple "bin/_openvswitch-vswitchd.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} diff --git a/neutron/templates/daemonset-ovs-vswitchd.yaml b/neutron/templates/daemonset-ovs-vswitchd.yaml index 166a5b885f..48c479bb55 100644 --- a/neutron/templates/daemonset-ovs-vswitchd.yaml +++ b/neutron/templates/daemonset-ovs-vswitchd.yaml @@ -60,10 +60,6 @@ spec: mountPath: /tmp/openvswitch-vswitchd.sh subPath: openvswitch-vswitchd.sh readOnly: true - - name: neutron-bin - mountPath: /tmp/openvswitch-ensure-configured.sh - subPath: openvswitch-ensure-configured.sh - readOnly: true - name: libmodules mountPath: /lib/modules readOnly: true diff --git a/neutron/values.yaml b/neutron/values.yaml index ea7871db85..3e4df466e7 100644 --- a/neutron/values.yaml +++ b/neutron/values.yaml @@ -90,6 +90,13 @@ network: # fallback mechanism to search for interface with default routing. external: null tunnel: null + # To automatically add a physical interface to a specific bridge using, + # for example eth3 to bridge br-physnet1 define the following key/value + # in auto_bridge_add: + # br-physnet1: eth3 + auto_bridge_add: + # br0: if0 + # br1: iface_two server: name: "neutron-server" port: 9696 @@ -120,14 +127,6 @@ keystone: metadata: workers: 4 -ml2: - ovs: - auto_bridge_add: -# To automatically add a physical interface to a specific bridge using, -# for example eth3 to bridge br-physnet1 define the following key/value -# in auto_bridge_add: -# br-physnet1: eth3 - dependencies: db_init: services: