From 3bd0e9ed94814a7a91845ca29981629028aa6191 Mon Sep 17 00:00:00 2001 From: Proskurin Kirill Date: Wed, 6 Jul 2016 15:57:56 +0300 Subject: [PATCH] Add ovs to neutron repo In upstream we don't have a separated ovs repo. Change-Id: If027e953f38408aabcdcce475b9742a6fb26ec04 --- docker/openvswitch-base/Dockerfile.j2 | 7 ++++ docker/openvswitch-db/Dockerfile.j2 | 2 ++ docker/openvswitch-vswitchd/Dockerfile.j2 | 3 ++ service/files/openvswitch-db-bootstrap.sh | 6 ++++ service/files/ovs-ensure-configured.sh | 17 ++++++++++ service/openvswitch-db.yaml | 31 +++++++++++++++++ service/openvswitch-vswitchd.yaml | 41 +++++++++++++++++++++++ 7 files changed, 107 insertions(+) create mode 100644 docker/openvswitch-base/Dockerfile.j2 create mode 100644 docker/openvswitch-db/Dockerfile.j2 create mode 100644 docker/openvswitch-vswitchd/Dockerfile.j2 create mode 100644 service/files/openvswitch-db-bootstrap.sh create mode 100644 service/files/ovs-ensure-configured.sh create mode 100644 service/openvswitch-db.yaml create mode 100644 service/openvswitch-vswitchd.yaml diff --git a/docker/openvswitch-base/Dockerfile.j2 b/docker/openvswitch-base/Dockerfile.j2 new file mode 100644 index 0000000..b750e28 --- /dev/null +++ b/docker/openvswitch-base/Dockerfile.j2 @@ -0,0 +1,7 @@ +FROM {{ namespace }}/base-tools:{{ tag }} +MAINTAINER {{ maintainer }} + +RUN apt-get -y install --no-install-recommends \ + openvswitch-switch \ + && apt-get clean + diff --git a/docker/openvswitch-db/Dockerfile.j2 b/docker/openvswitch-db/Dockerfile.j2 new file mode 100644 index 0000000..76f3605 --- /dev/null +++ b/docker/openvswitch-db/Dockerfile.j2 @@ -0,0 +1,2 @@ +FROM {{ namespace }}/openvswitch-base:{{ tag }} +MAINTAINER {{ maintainer }} diff --git a/docker/openvswitch-vswitchd/Dockerfile.j2 b/docker/openvswitch-vswitchd/Dockerfile.j2 new file mode 100644 index 0000000..49bdf5f --- /dev/null +++ b/docker/openvswitch-vswitchd/Dockerfile.j2 @@ -0,0 +1,3 @@ +FROM {{ namespace }}/openvswitch-base:{{ tag }} +MAINTAINER {{ maintainer }} + diff --git a/service/files/openvswitch-db-bootstrap.sh b/service/files/openvswitch-db-bootstrap.sh new file mode 100644 index 0000000..606cd5f --- /dev/null +++ b/service/files/openvswitch-db-bootstrap.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +mkdir -p "/run/openvswitch" +if [[ ! -e "/etc/openvswitch/conf.db" ]]; then + ovsdb-tool create "/etc/openvswitch/conf.db" +fi diff --git a/service/files/ovs-ensure-configured.sh b/service/files/ovs-ensure-configured.sh new file mode 100644 index 0000000..99bae3e --- /dev/null +++ b/service/files/ovs-ensure-configured.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +bridge=$1 +port=$2 + +ovs-vsctl br-exists $bridge; rc=$? +if [[ $rc == 2 ]]; then + changed=changed + ovs-vsctl --no-wait add-br $bridge +fi + +if [[ ! $(ovs-vsctl list-ports $bridge) =~ $(echo "\<$port\>") ]]; then + changed=changed + ovs-vsctl --no-wait add-port $bridge $port +fi + +echo $changed diff --git a/service/openvswitch-db.yaml b/service/openvswitch-db.yaml new file mode 100644 index 0000000..8025a85 --- /dev/null +++ b/service/openvswitch-db.yaml @@ -0,0 +1,31 @@ +service: + name: openvswitch-db + host-net: true + daemonset: true + node-selector: + openstack-compute-controller: "true" + containers: + - name: openvswitch-db + image: openvswitch-db + probes: + readiness: "true" + liveness: "true" + volumes: + - name: run + type: host + path: /run + pre: + - name: ovs-bootstrap + command: /opt/ccp/bin/openvswitch-db-bootstrap.sh + dependencies: + - rabbitmq + - neutron-db-sync + daemon: + command: /usr/sbin/ovsdb-server /etc/openvswitch/conf.db -vconsole:emer -vsyslog:err -vfile:info --remote=punix:/run/openvswitch/db.sock --log-file=/var/log/openvswitch/ovsdb-server.log + files: + - openvswitch-db-bootstrap.sh +files: + openvswitch-db-bootstrap.sh: + path: /opt/ccp/bin/openvswitch-db-bootstrap.sh + content: openvswitch-db-bootstrap.sh + perm: "0755" diff --git a/service/openvswitch-vswitchd.yaml b/service/openvswitch-vswitchd.yaml new file mode 100644 index 0000000..f1fc0a3 --- /dev/null +++ b/service/openvswitch-vswitchd.yaml @@ -0,0 +1,41 @@ +service: + name: openvswitch-vswitchd + host-net: true + daemonset: true + node-selector: + openstack-compute-controller: "true" + containers: + - name: openvswitch-vswitchd + image: openvswitch-vswitchd + privileged: true + probes: + readiness: "true" + liveness: "true" + volumes: + - name: run + type: host + path: /run + - name: modules + type: host + path: /lib/modules + pre: + - name: vswitchd-bootstrap + command: modprobe openvswitch + - name: vswitchd-check-ovs-db + command: ovs-vsctl --no-wait show + dependencies: + - vswitchd-bootstrap + - openvswitch-db + - name: vswitchd-setup-ovs-bridge + command: /usr/local/bin/ovs-ensure-configured.sh {{ neutron_bridge_name }} {{ neutron_external_interface }} + dependencies: + - vswitchd-check-ovs-db + daemon: + command: /usr/sbin/ovs-vswitchd unix:/run/openvswitch/db.sock --mlockall + files: + - ovs-ensure-configured.sh +files: + ovs-ensure-configured.sh: + path: /usr/local/bin/ovs-ensure-configured.sh + content: ovs-ensure-configured.sh + perm: "0755"