Support for Nuage Neutron plugin in puppet-neutron
* manifests/plugins/nuage.pp ** Nuage Neutron plugin is a monolithic Neutron plugin (core_plugin in neutron.conf can be set to nuage). ** The plugin.ini file for the Nuage Neutron plugin needs to be created with correct properties for the Neutron service to come up (configured in manifests/plugins/nuage.pp). ** To add the configuration parameters to the plugin.ini file a custom resource type has been created (neutron_plugins_nuage). * init.pp ** Just comment addition that core_plugin=nuage is now supported by puppet-neutron * params.pp ** Parameterizing names of Nuage Neutron Plugin (pattern based on existing midonet code) * config.pp ** Call to create_resource similar to other plugins * Spec tests ** spec tests for the plugin/nuage.pp The associated spec tests and custom types and providers have also been added. This follows the same pattern as other plugins such as midonet and opencontrail. Change-Id: I0f092bf437739cac0b328822022e932fe5d1c6f2
This commit is contained in:
parent
774470c8bb
commit
d4340331aa
11
lib/puppet/provider/neutron_plugin_nuage/ini_setting.rb
Normal file
11
lib/puppet/provider/neutron_plugin_nuage/ini_setting.rb
Normal file
@ -0,0 +1,11 @@
|
||||
Puppet::Type.type(:neutron_plugin_nuage).provide(
|
||||
:ini_setting,
|
||||
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
|
||||
) do
|
||||
|
||||
def file_path
|
||||
'/etc/neutron/plugins/nuage/plugin.ini'
|
||||
end
|
||||
|
||||
end
|
||||
|
24
lib/puppet/type/neutron_plugin_nuage.rb
Normal file
24
lib/puppet/type/neutron_plugin_nuage.rb
Normal file
@ -0,0 +1,24 @@
|
||||
Puppet::Type.newtype(:neutron_plugin_nuage) do
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
desc 'Section/setting name to manage for nuage/plugin.ini'
|
||||
newvalues(/\S+\/\S+/)
|
||||
end
|
||||
|
||||
newproperty(:value) do
|
||||
desc 'The value of the settings to be defined.'
|
||||
munge do |value|
|
||||
value = value.to_s.strip
|
||||
value.capitalize! if value =~ /^(true|false)$/i
|
||||
value
|
||||
end
|
||||
end
|
||||
|
||||
autorequire(:package) do
|
||||
'neutron-plugin-nuage'
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -66,6 +66,9 @@
|
||||
# [*plugin_opencontrail_config*]
|
||||
# (optional) Manage configuration of plugins/opencontrail/ContrailPlugin.ini
|
||||
#
|
||||
# [*plugin_nuage_config*]
|
||||
# (optional) Manage configuration of plugins/nuage/plugin.ini
|
||||
#
|
||||
# [*plugin_ml2_config*]
|
||||
# (optional) Manage configuration of ml2_conf.ini
|
||||
#
|
||||
@ -91,6 +94,7 @@ class neutron::config (
|
||||
$plugin_midonet_config = {},
|
||||
$plugin_plumgrid_config = {},
|
||||
$plugin_opencontrail_config = {},
|
||||
$plugin_nuage_config = {},
|
||||
$plugin_ml2_config = {},
|
||||
) {
|
||||
|
||||
@ -109,6 +113,7 @@ class neutron::config (
|
||||
validate_hash($plugin_midonet_config)
|
||||
validate_hash($plugin_plumgrid_config)
|
||||
validate_hash($plugin_opencontrail_config)
|
||||
validate_hash($plugin_nuage_config)
|
||||
validate_hash($plugin_ml2_config)
|
||||
|
||||
create_resources('neutron_config', $server_config)
|
||||
@ -125,5 +130,6 @@ class neutron::config (
|
||||
create_resources('neutron_plugin_midonet', $plugin_midonet_config)
|
||||
create_resources('neutron_plugin_plumgrid', $plugin_plumgrid_config)
|
||||
create_resources('neutron_plugin_opencontrail', $plugin_opencontrail_config)
|
||||
create_resources('neutron_plugin_nuage', $plugin_nuage_config)
|
||||
create_resources('neutron_plugin_ml2', $plugin_ml2_config)
|
||||
}
|
||||
|
@ -32,7 +32,7 @@
|
||||
# [*core_plugin*]
|
||||
# (optional) Neutron plugin provider
|
||||
# Defaults to openvswitch
|
||||
# Could be bigswitch, brocade, cisco, embrane, hyperv, linuxbridge, midonet, ml2, mlnx, nec, nicira, plumgrid, ryu, opencontrail (full path)
|
||||
# Could be bigswitch, brocade, cisco, embrane, hyperv, linuxbridge, midonet, ml2, mlnx, nec, nicira, plumgrid, ryu, nuage, opencontrail (full path)
|
||||
#
|
||||
# Example for opencontrail:
|
||||
#
|
||||
|
@ -44,6 +44,8 @@ class neutron::params {
|
||||
|
||||
$nvp_server_package = 'openstack-neutron-nicira'
|
||||
|
||||
$nuage_config_file = '/etc/neutron/plugins/nuage/plugin.ini'
|
||||
|
||||
$dhcp_agent_package = false
|
||||
$dhcp_agent_service = 'neutron-dhcp-agent'
|
||||
|
||||
@ -123,6 +125,8 @@ class neutron::params {
|
||||
|
||||
$nvp_server_package = 'neutron-plugin-nicira'
|
||||
|
||||
$nuage_config_file = '/etc/neutron/plugins/nuage/plugin.ini'
|
||||
|
||||
$dhcp_agent_package = 'neutron-dhcp-agent'
|
||||
$dhcp_agent_service = 'neutron-dhcp-agent'
|
||||
|
||||
|
101
manifests/plugins/nuage.pp
Normal file
101
manifests/plugins/nuage.pp
Normal file
@ -0,0 +1,101 @@
|
||||
#
|
||||
# Configure the Nuage plugin for neutron.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*nuage_net_partition_name*]
|
||||
# (required) The net partition under which the VMs will be
|
||||
# seen in the VSD
|
||||
#
|
||||
# [*nuage_vsd_ip*]
|
||||
# (required) IP address of the Virtual Services Directory
|
||||
#
|
||||
# [*nuage_vsd_username*]
|
||||
# (required) Username to be used to log into VSD
|
||||
#
|
||||
# [*nuage_vsd_password*]
|
||||
# (required) Password to be used to log into VSD
|
||||
#
|
||||
# [*nuage_vsd_organization*]
|
||||
# (required) Parameter required to log into VSD
|
||||
#
|
||||
# [*nuage_base_uri_version*]
|
||||
# (required) URI version to be used based on the VSD release
|
||||
# For example v3_0
|
||||
#
|
||||
# [*nuage_cms_id*]
|
||||
# (required) CMS ID generated by the VSD
|
||||
#
|
||||
# [*nuage_auth_resource*]
|
||||
# (optional) The auth resource value to be use to connect
|
||||
# to VSD. The default is /me
|
||||
#
|
||||
# [*nuage_server_ssl*]
|
||||
# (optional) Flag to determine whether to use ssl connection
|
||||
# to connect to VSD. The default is True
|
||||
#
|
||||
#
|
||||
class neutron::plugins::nuage (
|
||||
$nuage_net_partition_name,
|
||||
$nuage_vsd_ip,
|
||||
$nuage_vsd_username,
|
||||
$nuage_vsd_password,
|
||||
$nuage_vsd_organization,
|
||||
$nuage_base_uri_version,
|
||||
$nuage_cms_id,
|
||||
$nuage_auth_resource = '/me',
|
||||
$nuage_server_ssl = true,
|
||||
) {
|
||||
|
||||
include ::neutron::params
|
||||
|
||||
Neutron_plugin_nuage<||> ~> Service['neutron-server']
|
||||
|
||||
file { '/etc/neutron/plugins/nuage':
|
||||
ensure => 'directory',
|
||||
}
|
||||
|
||||
ensure_resource('file', $::neutron::params::nuage_config_file, {
|
||||
ensure => file,
|
||||
owner => 'root',
|
||||
group => 'neutron',
|
||||
mode => '0640'}
|
||||
)
|
||||
|
||||
if $::osfamily == 'Debian' {
|
||||
file_line { '/etc/default/neutron-server:NEUTRON_PLUGIN_CONFIG':
|
||||
path => '/etc/default/neutron-server',
|
||||
match => '^NEUTRON_PLUGIN_CONFIG=(.*)$',
|
||||
line => "NEUTRON_PLUGIN_CONFIG=${::neutron::params::nuage_config_file}",
|
||||
notify => Service['neutron-server'],
|
||||
}
|
||||
}
|
||||
|
||||
if $::osfamily == 'Redhat' {
|
||||
file { '/etc/neutron/plugin.ini':
|
||||
ensure => link,
|
||||
target => $::neutron::params::nuage_config_file,
|
||||
}
|
||||
}
|
||||
|
||||
$nuage_base_uri_base = '/nuage/api'
|
||||
neutron_plugin_nuage {
|
||||
'RESTPROXY/default_net_partition_name': value => $nuage_net_partition_name;
|
||||
'RESTPROXY/server': value => $nuage_vsd_ip;
|
||||
'RESTPROXY/serverauth': value => "${nuage_vsd_username}:${nuage_vsd_password}";
|
||||
'RESTPROXY/organization': value => $nuage_vsd_organization;
|
||||
'RESTPROXY/auth_resource': value => $nuage_auth_resource;
|
||||
'RESTPROXY/serverssl': value => $nuage_server_ssl;
|
||||
'RESTPROXY/base_uri': value => "${nuage_base_uri_base}/${nuage_base_uri_version}";
|
||||
'RESTPROXY/cms_id': value => $nuage_cms_id;
|
||||
}
|
||||
|
||||
if ($::neutron::core_plugin != 'neutron.plugins.nuage.plugin.NuagePlugin') and
|
||||
($::neutron::core_plugin != 'nuage') {
|
||||
fail('Nuage plugin should be the core_plugin in neutron.conf')
|
||||
}
|
||||
|
||||
Neutron_plugin_nuage<||> ~> Exec<| title == 'neutron-db-sync' |>
|
||||
|
||||
}
|
||||
|
105
spec/classes/neutron_plugins_nuage_spec.rb
Normal file
105
spec/classes/neutron_plugins_nuage_spec.rb
Normal file
@ -0,0 +1,105 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'neutron::plugins::nuage' do
|
||||
|
||||
let :pre_condition do
|
||||
"class { 'neutron':
|
||||
rabbit_password => 'passw0rd',
|
||||
core_plugin => 'neutron.plugins.nuage.plugin.NuagePlugin' }
|
||||
class { 'neutron::server': auth_password => 'password' }"
|
||||
end
|
||||
|
||||
let :default_facts do
|
||||
{ :operatingsystem => 'default',
|
||||
:operatingsystemrelease => 'default'
|
||||
}
|
||||
end
|
||||
|
||||
let :params do
|
||||
{
|
||||
:nuage_vsd_ip => %w(192.168.33.3),
|
||||
:nuage_vsd_username => 'test',
|
||||
:nuage_vsd_password => 'test',
|
||||
:nuage_vsd_organization => 'vsd',
|
||||
:nuage_net_partition_name => 'test',
|
||||
:nuage_base_uri_version => 'v3.0',
|
||||
:nuage_cms_id => '7488fae2-7e51-11e5-8bcf-feff819cdc9f'}
|
||||
end
|
||||
|
||||
shared_examples_for 'neutron plugin nuage' do
|
||||
|
||||
it { is_expected.to contain_class('neutron::params') }
|
||||
|
||||
it 'should configure neutron.conf' do
|
||||
is_expected.to contain_neutron_config('DEFAULT/core_plugin').with_value('neutron.plugins.nuage.plugin.NuagePlugin')
|
||||
end
|
||||
|
||||
it 'should configure plugin.ini' do
|
||||
is_expected.to contain_neutron_plugin_nuage('RESTPROXY/default_net_partition_name').with_value(params[:nuage_net_partition_name])
|
||||
is_expected.to contain_neutron_plugin_nuage('RESTPROXY/server').with_value(params[:nuage_vsd_ip])
|
||||
is_expected.to contain_neutron_plugin_nuage('RESTPROXY/organization').with_value(params[:nuage_vsd_organization])
|
||||
is_expected.to contain_neutron_plugin_nuage('RESTPROXY/cms_id').with_value(params[:nuage_cms_id])
|
||||
end
|
||||
|
||||
context 'configure nuage with wrong core_plugin configure' do
|
||||
let :pre_condition do
|
||||
"class { 'neutron':
|
||||
rabbit_password => 'passw0rd',
|
||||
core_plugin => 'foo' }"
|
||||
end
|
||||
|
||||
it_raises 'a Puppet::Error', /Nuage plugin should be the core_plugin in neutron.conf/
|
||||
end
|
||||
end
|
||||
begin
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
default_facts.merge({ :osfamily => 'Debian'})
|
||||
end
|
||||
|
||||
it_configures 'neutron plugin nuage'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
default_facts.merge({ :osfamily => 'RedHat'})
|
||||
end
|
||||
|
||||
it_configures 'neutron plugin nuage'
|
||||
end
|
||||
end
|
||||
begin
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
default_facts.merge({ :osfamily => 'Debian'})
|
||||
end
|
||||
|
||||
it 'configures /etc/default/neutron-server' do
|
||||
is_expected.to contain_file_line('/etc/default/neutron-server:NEUTRON_PLUGIN_CONFIG').with(
|
||||
:path => '/etc/default/neutron-server',
|
||||
:match => '^NEUTRON_PLUGIN_CONFIG=(.*)$',
|
||||
:line => 'NEUTRON_PLUGIN_CONFIG=/etc/neutron/plugins/nuage/plugin.ini',
|
||||
:notify => 'Service[neutron-server]'
|
||||
)
|
||||
end
|
||||
|
||||
it_configures 'neutron plugin nuage'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
default_facts.merge({ :osfamily => 'RedHat'})
|
||||
end
|
||||
|
||||
it 'should create plugin symbolic link' do
|
||||
is_expected.to contain_file('/etc/neutron/plugin.ini').with(
|
||||
:ensure => 'link',
|
||||
:target => '/etc/neutron/plugins/nuage/plugin.ini')
|
||||
end
|
||||
|
||||
it_configures 'neutron plugin nuage'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
37
spec/unit/provider/neutron_plugin_nuage/ini_setting_spec.rb
Normal file
37
spec/unit/provider/neutron_plugin_nuage/ini_setting_spec.rb
Normal file
@ -0,0 +1,37 @@
|
||||
$LOAD_PATH.push(
|
||||
File.join(
|
||||
File.dirname(__FILE__),
|
||||
'..',
|
||||
'..',
|
||||
'..',
|
||||
'fixtures',
|
||||
'modules',
|
||||
'inifile',
|
||||
'lib')
|
||||
)
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
provider_class = Puppet::Type.type(:neutron_plugin_nuage).provider(:ini_setting)
|
||||
describe provider_class do
|
||||
let(:resource ) do
|
||||
Puppet::Type::Neutron_plugin_nuage.new({
|
||||
:name => 'DEFAULT/foo',
|
||||
:value => 'bar',
|
||||
})
|
||||
end
|
||||
|
||||
let (:provider) { resource.provider }
|
||||
|
||||
[ 'RedHat', 'Debian' ].each do |os|
|
||||
context "on #{os} with default setting" do
|
||||
it 'it should fall back to default and use plugin.ini' do
|
||||
Facter.fact(:operatingsystem).stubs(:value).returns("#{os}")
|
||||
expect(provider.section).to eq('DEFAULT')
|
||||
expect(provider.setting).to eq('foo')
|
||||
expect(provider.file_path).to eq('/etc/neutron/plugins/nuage/plugin.ini')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user