From 4960835d29eeed60106bb78e0c43de9664c9c0b8 Mon Sep 17 00:00:00 2001 From: Joseph Richard Date: Fri, 10 Nov 2017 16:31:47 -0500 Subject: [PATCH 5/8] Add support for neutron bgp dragent --- .../neutron_bgp_dragent_config/ini_setting.rb | 22 +++++++++++++ lib/puppet/type/neutron_bgp_dragent_config.rb | 18 +++++++++++ manifests/bgp.pp | 36 ++++++++++++++++++++++ manifests/params.pp | 1 + 4 files changed, 77 insertions(+) create mode 100644 lib/puppet/provider/neutron_bgp_dragent_config/ini_setting.rb create mode 100644 lib/puppet/type/neutron_bgp_dragent_config.rb create mode 100644 manifests/bgp.pp diff --git a/lib/puppet/provider/neutron_bgp_dragent_config/ini_setting.rb b/lib/puppet/provider/neutron_bgp_dragent_config/ini_setting.rb new file mode 100644 index 0000000..aa3e6fb --- /dev/null +++ b/lib/puppet/provider/neutron_bgp_dragent_config/ini_setting.rb @@ -0,0 +1,22 @@ +Puppet::Type.type(:neutron_bgp_dragent_config).provide( + :ini_setting, + :parent => Puppet::Type.type(:ini_setting).provider(:ruby) +) do + + def section + resource[:name].split('/', 2).first + end + + def setting + resource[:name].split('/', 2).last + end + + def separator + '=' + end + + def file_path + '/etc/neutron/bgp_dragent.ini' + end + +end diff --git a/lib/puppet/type/neutron_bgp_dragent_config.rb b/lib/puppet/type/neutron_bgp_dragent_config.rb new file mode 100644 index 0000000..2db88d2 --- /dev/null +++ b/lib/puppet/type/neutron_bgp_dragent_config.rb @@ -0,0 +1,18 @@ +Puppet::Type.newtype(:neutron_bgp_dragent_config) do + + ensurable + + newparam(:name, :namevar => true) do + desc 'Section/setting name to manage from bgp_dragent.ini' + newvalues(/\S+\/\S+/) + end + + newproperty(:value) do + desc 'The value of the setting to be defined.' + munge do |value| + value = value.to_s.strip + value.capitalize! if value =~ /^(true|false)$/i + value + end + end +end diff --git a/manifests/bgp.pp b/manifests/bgp.pp new file mode 100644 index 0000000..d61656c --- /dev/null +++ b/manifests/bgp.pp @@ -0,0 +1,36 @@ +# == Class: neutron::bgp +# +# Sets up bgp dynamic-routing agent. +# +# === Parameters +# +# [*bgp_router_id*] +# (required) The BGP router_id +# +# [*bgp_speaker_driver*] +# (required) The BGP speaker driver +# +class neutron::bgp ( + $bgp_router_id, + $bgp_speaker_driver, + $service_ensure = 'running', + $enable = true, +) { + + include neutron::params + + Neutron_config<||> ~> Service['neutron-bgp-dragent'] + Neutron_bgp_dragent_config<||> ~> Service['neutron-bgp-dragent'] + + neutron_bgp_dragent_config { + 'bgp/bgp_router_id': value => $neutron_bgp_router_id; + 'bgp/bgp_speaker_driver': value => $neutron_bgp_speaker_driver; + } + + service { 'neutron-bgp-dragent': + ensure => $service_ensure, + name => $::neutron::params::bgp_dragent_service, + enable => $enable, + require => Class['neutron'], + } +} diff --git a/manifests/params.pp b/manifests/params.pp index aeb5c66..d51a23c 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -41,6 +41,7 @@ class neutron::params { $router_scheduler_driver = 'neutron.scheduler.l3_agent_scheduler.HostBasedScheduler' $network_scheduler_driver = 'neutron.scheduler.dhcp_agent_scheduler.HostBasedScheduler' $router_status_managed = true + $bgp_dragent_service = 'neutron-bgp-dragent' # CentOS is in the Redhat osfamily if($::osfamily == 'Redhat') { -- 1.8.3.1