From 77f71b9f59d2900d1536a2a72a01779a61d8fd94 Mon Sep 17 00:00:00 2001 From: Sam Yaple Date: Thu, 23 Jul 2015 11:25:42 +0000 Subject: [PATCH] Adds the appropriate tools to addin the ovs bridge Ansible will exec a script in the OVS container to ensure the bridge and ports are properly setup. The script is idempotent. Change-Id: I5adca595a4d2ef4edf26c9635cfa5ceb30ca4a59 Closes-Bug: #1466375 --- ansible/roles/neutron/defaults/main.yml | 2 ++ ansible/roles/neutron/tasks/start.yml | 5 +++++ ansible/roles/neutron/templates/ml2_conf.ini.j2 | 4 ++-- .../binary/openvswitch/ovs-vswitchd/Dockerfile | 2 +- .../ovs-vswitchd/ovs_ensure_configured.sh | 1 + .../ovs-vswitchd/ovs_ensure_configured.sh | 17 +++++++++++++++++ etc/kolla/globals.yml | 4 ++-- 7 files changed, 30 insertions(+), 5 deletions(-) create mode 120000 docker/centos/binary/openvswitch/ovs-vswitchd/ovs_ensure_configured.sh create mode 100755 docker/common/openvswitch/ovs-vswitchd/ovs_ensure_configured.sh diff --git a/ansible/roles/neutron/defaults/main.yml b/ansible/roles/neutron/defaults/main.yml index d68a775fa4..bc4b272655 100644 --- a/ansible/roles/neutron/defaults/main.yml +++ b/ansible/roles/neutron/defaults/main.yml @@ -59,3 +59,5 @@ neutron_logging_verbose: "{{ openstack_logging_verbose }}" neutron_logging_debug: "{{ openstack_logging_debug }}" neutron_keystone_user: "neutron" + +neutron_bridge_name: "br-ex" diff --git a/ansible/roles/neutron/tasks/start.yml b/ansible/roles/neutron/tasks/start.yml index 4cecfc35b6..daa21dd7d5 100644 --- a/ansible/roles/neutron/tasks/start.yml +++ b/ansible/roles/neutron/tasks/start.yml @@ -23,6 +23,11 @@ when: inventory_hostname in groups['compute'] or inventory_hostname in groups['neutron-agents'] +- name: Ensuring OVS bridge is properly setup + command: docker exec openvswitch_vswitchd /opt/kolla/ovs_ensure_configured.sh {{ neutron_bridge_name }} {{ neutron_interface }} + register: status + changed_when: status.stdout.find('changed') != -1 + - include: ../../start.yml vars: container_environment: diff --git a/ansible/roles/neutron/templates/ml2_conf.ini.j2 b/ansible/roles/neutron/templates/ml2_conf.ini.j2 index f994ba1a15..772e8fd9d2 100644 --- a/ansible/roles/neutron/templates/ml2_conf.ini.j2 +++ b/ansible/roles/neutron/templates/ml2_conf.ini.j2 @@ -31,5 +31,5 @@ arp_responder = true #enable_distributed_routing = true [ovs] -local_ip = {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }} -bridge_mappings = external:{{ neutron_interface }} +local_ip = {{ hostvars[inventory_hostname]['ansible_' + tunnel_interface]['ipv4']['address'] }} +bridge_mappings = external:{{ neutron_bridge_name }} diff --git a/docker/centos/binary/openvswitch/ovs-vswitchd/Dockerfile b/docker/centos/binary/openvswitch/ovs-vswitchd/Dockerfile index c34d72302b..60989c846c 100644 --- a/docker/centos/binary/openvswitch/ovs-vswitchd/Dockerfile +++ b/docker/centos/binary/openvswitch/ovs-vswitchd/Dockerfile @@ -3,6 +3,6 @@ MAINTAINER Kolla Project (https://launchpad.net/kolla) COPY ./start.sh /start.sh -COPY config-internal.sh config-external.sh /opt/kolla/ +COPY ovs_ensure_configured.sh config-internal.sh config-external.sh /opt/kolla/ CMD ["/start.sh"] diff --git a/docker/centos/binary/openvswitch/ovs-vswitchd/ovs_ensure_configured.sh b/docker/centos/binary/openvswitch/ovs-vswitchd/ovs_ensure_configured.sh new file mode 120000 index 0000000000..19efaf06a1 --- /dev/null +++ b/docker/centos/binary/openvswitch/ovs-vswitchd/ovs_ensure_configured.sh @@ -0,0 +1 @@ +../../../../common/openvswitch/ovs-vswitchd/ovs_ensure_configured.sh \ No newline at end of file diff --git a/docker/common/openvswitch/ovs-vswitchd/ovs_ensure_configured.sh b/docker/common/openvswitch/ovs-vswitchd/ovs_ensure_configured.sh new file mode 100755 index 0000000000..c39d64ff7a --- /dev/null +++ b/docker/common/openvswitch/ovs-vswitchd/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 add-br $bridge +fi + +if [[ ! $(ovs-vsctl list-ports $bridge) =~ $(echo "\<$port\>") ]]; then + changed=changed + ovs-vsctl add-port $bridge $port +fi + +echo $changed diff --git a/etc/kolla/globals.yml b/etc/kolla/globals.yml index 63bf15f5f4..adfa1c3477 100644 --- a/etc/kolla/globals.yml +++ b/etc/kolla/globals.yml @@ -54,12 +54,12 @@ docker_restart_policy_retry: "10" #################### # The interface to use for various services types network_interface: "eth0" +neutron_interface: "eth1" # These can be adjusted for even more customization api_interface: "{{ network_interface }}" storage_interface: "{{ network_interface }}" -neutron_interface: "{{ network_interface }}" - +tunnel_interface: "{{ network_interface }}" #################### # Openstack options