From 32e4b36fa2d37dabb53cc3ee71960e2162f64a43 Mon Sep 17 00:00:00 2001 From: Nikolas Hermanns Date: Thu, 10 Dec 2015 12:50:15 +0100 Subject: [PATCH] Make networking-bgpvpn as an own module Enhance basic puppet functionality. Include config. Change-Id: Ia4ee9b1d25f4c8e4b6531d8ae09d2cf300e9b5af --- .gitignore | 4 ++ README.md | 4 +- .../puppet/manifests/install-bgpvpn.pp | 26 ++++++++++-- .../networking-bgpvpn/manifests/init.pp | 41 +++++++++++++++++++ .../templates/inject_service_plugins.sh | 26 ++++++++++++ environment_config.yaml | 2 +- metadata.yaml | 2 +- pre_build_hook | 19 ++++++--- 8 files changed, 111 insertions(+), 13 deletions(-) create mode 100644 .gitignore create mode 100644 deployment_scripts/puppet/modules/networking-bgpvpn/manifests/init.pp create mode 100644 deployment_scripts/puppet/modules/networking-bgpvpn/templates/inject_service_plugins.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..18cd5f2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +tmp/ +repositories/ubuntu/networking-bgpvpn-config_*_amd64.deb +repositories/ubuntu/python-networking-bgpvpn_*_all.deb +.build/ \ No newline at end of file diff --git a/README.md b/README.md index ebf579a..bcc4513 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Limitations Installation Guide ================== -OpenDaylight plugin installation +BGPVPN plugin installation ---------------------------------------- 1. Clone the fuel-plugin-bgpvpn repo from github: @@ -52,7 +52,7 @@ OpenDaylight plugin installation scp bgpnvpn-[x.x.x].rpm root@:/tmp -7. While logged in Fuel Master install the OpenDaylight plugin: +7. While logged in Fuel Master install the BGPVPN plugin: fuel plugins --install bgpvpn-[x.x.x].rpm diff --git a/deployment_scripts/puppet/manifests/install-bgpvpn.pp b/deployment_scripts/puppet/manifests/install-bgpvpn.pp index 3e3625b..98b280c 100644 --- a/deployment_scripts/puppet/manifests/install-bgpvpn.pp +++ b/deployment_scripts/puppet/manifests/install-bgpvpn.pp @@ -1,6 +1,24 @@ -package {'python-networking-bgpvpn': - ensure => installed, -} -> -neutron_config { 'DEFAULT/service_plugins': value => 'networking_bgpvpn.neutron.services.plugin.BGPVPNPlugin';} +service { 'neutron-server': + ensure => running, +} +$inject_script = '/tmp/inject_service_plugins.sh' +file { $inject_script: + ensure => file, + content => template('networking-bgpvpn/inject_service_plugins.sh'), +} +$neutron_conf_file='/etc/neutron/neutron.conf' +file { $neutron_conf_file: + ensure => file +} +exec { 'inject_service_plugins': + command => "bash $inject_script /etc/neutron/neutron.conf networking_bgpvpn.neutron.services.plugin.BGPVPNPlugin", + require => File[$inject_script], + path => '/usr/local/bin:/usr/bin:/sbin:/bin:/usr/local/sbin:/usr/sbin', + subscribe => File[$neutron_conf_file], +} +class {'networking-bgpvpn': + notify => Service['neutron-server']} +class {'networking-bgpvpn-backend-config': + notify => Service['neutron-server']} diff --git a/deployment_scripts/puppet/modules/networking-bgpvpn/manifests/init.pp b/deployment_scripts/puppet/modules/networking-bgpvpn/manifests/init.pp new file mode 100644 index 0000000..0262ecc --- /dev/null +++ b/deployment_scripts/puppet/modules/networking-bgpvpn/manifests/init.pp @@ -0,0 +1,41 @@ +class networking-bgpvpn { + + package {'python-networking-bgpvpn': + ensure => installed, + notify => Service['neutron-server'], + } + package {'networking-bgpvpn-config': + ensure => installed, + notify => Service['neutron-server'], + } + + # This is only needed for kilo. + # fuel-library/puppet/neutron/manifest/server.pp: exec 'neutron-db-sync' was taken as + # example. In liberty it is not needed + exec { 'bgpvpn-db-sync': + command => 'touch /root/db.sync.done;bgpvpn-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head', + path => '/usr/local/bin:/usr/bin:/sbin:/bin:/usr/local/sbin:/usr/sbin', + notify => Service['neutron-server'], + # TODO + #subscribe => Neutron_config['database/connection'], + tries => 10, + # TODO(bogdando) contribute change to upstream: + # new try_sleep param for sleep driven development (SDD) + try_sleep => 20, + require => Package["python-networking-bgpvpn"] + } + Exec<| title == 'neutron-db-sync' |> ~> Exec['bgpvpn-db-sync'] +} + +class networking-bgpvpn-backend-config { + + require networking-bgpvpn + if hiera('opendaylight', false) { + $NETWORKING_BGPVPN_DRIVER = 'BGPVPN:OpenDaylight:networking_bgpvpn.neutron.services.service_drivers.opendaylight.odl.OpenDaylightBgpvpnDriver:default' + } + else { + fail('Bagpipe driver not yet included. You need to have anotehr bgpvpn dirver: Opendaylight') + } + # In liberty this goes to an own config file + neutron_config { 'service_providers/service_provider': value => $NETWORKING_BGPVPN_DRIVER;} +} diff --git a/deployment_scripts/puppet/modules/networking-bgpvpn/templates/inject_service_plugins.sh b/deployment_scripts/puppet/modules/networking-bgpvpn/templates/inject_service_plugins.sh new file mode 100644 index 0000000..3ae0c05 --- /dev/null +++ b/deployment_scripts/puppet/modules/networking-bgpvpn/templates/inject_service_plugins.sh @@ -0,0 +1,26 @@ +#!/bin/bash +set -e +usage() { + echo "usage: $0 " >&2 +} +if [[ $# -ne 2 ]]; then + usage + exit +fi +conf_file=$1 +service_plugin=$2 +if [ -e conf_file ]; then + echo "File: $conf_file not found." + exit 1 +fi +if ! grep -q "$service_plugin" $conf_file ; then + service_plugins_v1=$(grep "^service_plugins" $conf_file | awk {'print $3'}) + service_plugins_v2=$(grep "^service_plugins" $conf_file | awk {'print $2'}) + service_plugins=${service_plugins_v1:-$service_plugins_v2} + sed -i "s/$service_plugins/$service_plugins,$service_plugin/" $conf_file +fi + +if ! grep -q "$service_plugin" $conf_file; then + echo "Could not add $service_plugin as service plugin in $conf_file." + exit 2 +fi diff --git a/environment_config.yaml b/environment_config.yaml index 26ec881..50870a1 100644 --- a/environment_config.yaml +++ b/environment_config.yaml @@ -1,6 +1,6 @@ attributes: metadata: restrictions: - - "cluster:net_provider != 'neutron'": "Only neutron is supported by OpenDaylight" + - "cluster:net_provider != 'neutron'": "Only neutron is supported by BGPVPN-plugin" label: "BGPVPN plugin" weight: 90 diff --git a/metadata.yaml b/metadata.yaml index 5503d88..0bc0518 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -3,7 +3,7 @@ name: bgpvpn # Human-readable name for your plugin title: BGPVPN plugin # Plugin version -version: '0.1.0' +version: '0.2.1' # Description description: 'This plugin provides BGPVPN extension for neutron.' # Required fuel version diff --git a/pre_build_hook b/pre_build_hook index 10b5bfb..0f795ca 100755 --- a/pre_build_hook +++ b/pre_build_hook @@ -25,6 +25,14 @@ function build_pkg { pushd "${DIR}/repositories/${1}/" fpm --force -s python -t deb -m 'mskalski@mirantis.com' --python-disable-dependency oslo.config ${TMP_DIR}/networking-bgpvpn/setup.py popd + + # fpm -C is buggy https://github.com/jordansissel/fpm/issues/818 + # so we have to change the rootdir manually + pushd ${TMP_DIR}/networking-bgpvpn/ + fpm --force -s dir -t deb -m 'nikolas.hermanns@ericsson.com' --config-files etc -n networking-bgpvpn-config -v 1.0 etc + mv networking-bgpvpn-config_*_amd64.deb ${DIR}/repositories/${1}/ + popd + ;; *) echo "Not supported system"; exit 1;; esac @@ -34,16 +42,17 @@ command -v fpm >/dev/null 2>&1 || { echo >&2 "fpm ruby gem required but it's not cleanup + mkdir -p "${TMP_DIR}" + pushd $TMP_DIR - - git clone $NETWORKING_BGPVPN_REPO networking-bgpvpn pushd networking-bgpvpn git checkout $NETWORKING_BGPVPN_BRANCH -sed -i -- 's/sphinxcontrib-blockdiag/sphinxcontrib.blockdiag/' ./requirements.txt -sed -i -- 's/sphinxcontrib-seqdiag/sphinxcontrib.seqdiag/' ./requirements.txt +sed -i -- 's/sphinxcontrib-blockdiag//' ./requirements.txt +sed -i -- 's/sphinxcontrib-seqdiag//' ./requirements.txt +popd popd for system in $BUILD_FOR @@ -51,4 +60,4 @@ do build_pkg $system done -cleanup +#cleanup