Make networking-bgpvpn as an own module

Enhance basic puppet functionality.
Include config.

Change-Id: Ia4ee9b1d25f4c8e4b6531d8ae09d2cf300e9b5af
This commit is contained in:
Nikolas Hermanns 2015-12-10 12:50:15 +01:00
parent fae23b9890
commit 32e4b36fa2
8 changed files with 111 additions and 13 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
tmp/
repositories/ubuntu/networking-bgpvpn-config_*_amd64.deb
repositories/ubuntu/python-networking-bgpvpn_*_all.deb
.build/

View File

@ -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@<the_Fuel_Master_node_IP address>:/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

View File

@ -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']}

View File

@ -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;}
}

View File

@ -0,0 +1,26 @@
#!/bin/bash
set -e
usage() {
echo "usage: $0 <neutron-conf-file> <service_plugins_to_add>" >&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

View File

@ -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

View File

@ -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

View File

@ -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