From 94ea43fa555fac20c15cdb4f4214af20913b6270 Mon Sep 17 00:00:00 2001 From: Sam Yaple Date: Sun, 27 Sep 2015 12:37:23 +0000 Subject: [PATCH] Replace config-external - openvswitch Change-Id: Ib05442c6ee146d2deb49fc235ba16fc7e0c3d6c8 Partially-Implements: blueprint replace-config-external --- ansible/roles/neutron/tasks/config.yml | 30 +++++++++++++++++-- ansible/roles/neutron/tasks/start.yml | 2 ++ .../templates/openvswitch-db-server.json.j2 | 4 +++ .../templates/openvswitch-vswitchd.json.j2 | 4 +++ docker/openvswitch/ovs-db-server/start.sh | 22 ++++---------- docker/openvswitch/ovs-vswitchd/start.sh | 15 +++------- 6 files changed, 48 insertions(+), 29 deletions(-) create mode 100644 ansible/roles/neutron/templates/openvswitch-db-server.json.j2 create mode 100644 ansible/roles/neutron/templates/openvswitch-vswitchd.json.j2 diff --git a/ansible/roles/neutron/tasks/config.yml b/ansible/roles/neutron/tasks/config.yml index 8d138b11c8..f7b5df4703 100644 --- a/ansible/roles/neutron/tasks/config.yml +++ b/ansible/roles/neutron/tasks/config.yml @@ -147,10 +147,36 @@ template: src: "roles/neutron/templates/neutron-openvswitch-agent.json.j2" dest: "{{ node_config_directory }}/neutron-openvswitch-agent/config.json" - when: neutron_plugin_agent == "openvswitch" + when: (inventory_hostname in groups['compute'] or inventory_hostname in groups['neutron-agents']) + and neutron_plugin_agent == "openvswitch" + +- name: Ensuring config directories exists + file: + path: "{{ node_config_directory }}/{{ item }}" + state: "directory" + with_items: + - "openvswitch-db-server" + - "openvswitch-vswitchd" + when: (inventory_hostname in groups['compute'] or inventory_hostname in groups['neutron-agents']) + and neutron_plugin_agent == "openvswitch" + +- name: Copying openvswitch-db-server JSON configuration file + template: + src: "openvswitch-db-server.json.j2" + dest: "{{ node_config_directory }}/openvswitch-db-server/config.json" + when: (inventory_hostname in groups['compute'] or inventory_hostname in groups['neutron-agents']) + and neutron_plugin_agent == "openvswitch" + +- name: Copying openvswitch-vswitchd JSON configuration file + template: + src: "openvswitch-vswitchd.json.j2" + dest: "{{ node_config_directory }}/openvswitch-vswitchd/config.json" + when: (inventory_hostname in groups['compute'] or inventory_hostname in groups['neutron-agents']) + and neutron_plugin_agent == "openvswitch" - name: Copying Neutron Linuxbridge JSON configuration file template: src: "roles/neutron/templates/neutron-server.json.j2" dest: "{{ node_config_directory }}/neutron-linuxbridge-agent/config.json" - when: neutron_plugin_agent == "linuxbridge" + when: (inventory_hostname in groups['compute'] or inventory_hostname in groups['neutron-agents']) + and neutron_plugin_agent == "linuxbridge" diff --git a/ansible/roles/neutron/tasks/start.yml b/ansible/roles/neutron/tasks/start.yml index d028fd2c0b..7922aee05b 100644 --- a/ansible/roles/neutron/tasks/start.yml +++ b/ansible/roles/neutron/tasks/start.yml @@ -15,6 +15,7 @@ image: "{{ openvswitch_db_image_full }}" volumes: - "/run:/run" + - "{{ node_config_directory }}/openvswitch-db-server/:/opt/kolla/config_files/:ro" env: KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}" when: (inventory_hostname in groups['compute'] or inventory_hostname in groups['neutron-agents']) @@ -38,6 +39,7 @@ volumes: - "/run:/run" - "/lib/modules:/lib/modules:ro" + - "{{ node_config_directory }}/openvswitch-vswitchd/:/opt/kolla/config_files/:ro" env: KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}" when: (inventory_hostname in groups['compute'] or inventory_hostname in groups['neutron-agents']) diff --git a/ansible/roles/neutron/templates/openvswitch-db-server.json.j2 b/ansible/roles/neutron/templates/openvswitch-db-server.json.j2 new file mode 100644 index 0000000000..ed1773ea28 --- /dev/null +++ b/ansible/roles/neutron/templates/openvswitch-db-server.json.j2 @@ -0,0 +1,4 @@ +{ + "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", + "config_files": [] +} diff --git a/ansible/roles/neutron/templates/openvswitch-vswitchd.json.j2 b/ansible/roles/neutron/templates/openvswitch-vswitchd.json.j2 new file mode 100644 index 0000000000..b0d8d07127 --- /dev/null +++ b/ansible/roles/neutron/templates/openvswitch-vswitchd.json.j2 @@ -0,0 +1,4 @@ +{ + "command": "/usr/sbin/ovs-vswitchd unix:/run/openvswitch/db.sock -vconsole:emer -vsyslog:err -vfile:info --mlockall --log-file=/var/log/openvswitch/ovs-vswitchd.log", + "config_files": [] +} diff --git a/docker/openvswitch/ovs-db-server/start.sh b/docker/openvswitch/ovs-db-server/start.sh index 89b2e3e92b..4d3d772cc1 100755 --- a/docker/openvswitch/ovs-db-server/start.sh +++ b/docker/openvswitch/ovs-db-server/start.sh @@ -1,25 +1,15 @@ #!/bin/bash - set -o errexit -LOG_FILE="/var/log/openvswitch/ovsdb-server.log" -DB_FILE="/etc/openvswitch/conf.db" -UNIXSOCK_DIR="/var/run/openvswitch" -UNIXSOCK="${UNIXSOCK_DIR}/db.sock" - -CMD="/usr/sbin/ovsdb-server" -ARGS="$DB_FILE -vconsole:emer -vsyslog:err -vfile:info --remote=punix:${UNIXSOCK} --log-file=${LOG_FILE}" - # Loading common functions. source /opt/kolla/kolla-common.sh -# Execute config strategy -set_configs +python /opt/kolla/set_configs.py +CMD=$(cat /run_command) -mkdir -p "${UNIXSOCK_DIR}" - -if [[ ! -e "${DB_FILE}" ]]; then - ovsdb-tool create "${DB_FILE}" +mkdir -p "/run/openvswitch" +if [[ ! -e "/etc/openvswitch/conf.db" ]]; then + ovsdb-tool create "/etc/openvswitch/conf.db" fi -exec $CMD $ARGS +exec $CMD diff --git a/docker/openvswitch/ovs-vswitchd/start.sh b/docker/openvswitch/ovs-vswitchd/start.sh index 3ec2c26b22..792954bb48 100755 --- a/docker/openvswitch/ovs-vswitchd/start.sh +++ b/docker/openvswitch/ovs-vswitchd/start.sh @@ -1,19 +1,12 @@ #!/bin/bash -LOG_FILE="/var/log/openvswitch/ovs-vswitchd.log" -DB_FILE="/etc/openvswitch/conf.db" -UNIXSOCK_DIR="/var/run/openvswitch" -UNIXSOCK="${UNIXSOCK_DIR}/db.sock" - -CMD="/usr/sbin/ovs-vswitchd" -ARGS="unix:${UNIXSOCK} -vconsole:emer -vsyslog:err -vfile:info --mlockall --log-file=${LOG_FILE}" +set -o errexit # Loading common functions. source /opt/kolla/kolla-common.sh -# Execute config strategy -set_configs +python /opt/kolla/set_configs.py +CMD=$(cat /run_command) modprobe openvswitch -mkdir -p "${UNIXSOCK_DIR}" -exec $CMD $ARGS +exec $CMD