From c9f487fef3a74e63f39399c34fb224d00a64bd1d Mon Sep 17 00:00:00 2001 From: Sam Morrison Date: Wed, 10 Feb 2016 15:57:35 +1100 Subject: [PATCH] Support midonet type driver for ML2 Midonet now works under ML2 and provides the midonet and uplink network type Change-Id: Id6948c98ffe5b0ff4a18ec44637480a6b68a00a6 --- manifests/plugins/ml2/midonet.pp | 35 ++++++++++ manifests/plugins/ml2/type_driver.pp | 3 + .../neutron_plugins_ml2_midonet_spec.rb | 69 +++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 manifests/plugins/ml2/midonet.pp create mode 100644 spec/classes/neutron_plugins_ml2_midonet_spec.rb diff --git a/manifests/plugins/ml2/midonet.pp b/manifests/plugins/ml2/midonet.pp new file mode 100644 index 000000000..25a505a00 --- /dev/null +++ b/manifests/plugins/ml2/midonet.pp @@ -0,0 +1,35 @@ +# == Class: neutron::plugins::ml2::midonet +# +# Configure the Mech Driver for midonet neutron plugin +# +# === Parameters: +# +# [*midonet_uri*] +# (required) MidoNet API server URI. +# Usually of the form 'http://:8080/midonet-api' +# +# [*username*] +# (required) MidoNet admin username. +# +# [*password*] +# (required) MidoNet admin password. +# +# [*project_id*] +# (optional) Name of the project that MidoNet admin user belongs to. +# Defaults to 'service' +# +class neutron::plugins::ml2::midonet ( + $midonet_uri, + $username, + $password, + $project_id = 'services', +) { + + neutron_plugin_ml2 { + 'MIDONET/midonet_uri' : value => $midonet_uri; + 'MIDONET/username' : value => $username; + 'MIDONET/password' : value => $password, secret => true; + 'MIDONET/project_id' : value => $project_id; + } + +} diff --git a/manifests/plugins/ml2/type_driver.pp b/manifests/plugins/ml2/type_driver.pp index 913be7bda..3919efdf9 100644 --- a/manifests/plugins/ml2/type_driver.pp +++ b/manifests/plugins/ml2/type_driver.pp @@ -107,6 +107,9 @@ define neutron::plugins::ml2::type_driver ( elsif ($name == 'nexus_vxlan') { # Nexus_vxlan type driver has its own class separate from this one } + elsif ($name == 'midonet') or ($name == 'uplink') { + # midonet type driver has its own class separate from this one + } else { # detect an invalid type_drivers value fail('type_driver unknown.') diff --git a/spec/classes/neutron_plugins_ml2_midonet_spec.rb b/spec/classes/neutron_plugins_ml2_midonet_spec.rb new file mode 100644 index 000000000..161a44655 --- /dev/null +++ b/spec/classes/neutron_plugins_ml2_midonet_spec.rb @@ -0,0 +1,69 @@ +# +# Unit tests for neutron::plugins::ml2::midonet class +# + +require 'spec_helper' + +describe 'neutron::plugins::ml2::midonet' do + + let :pre_condition do + "class { 'neutron::server': auth_password => 'password'} + class { 'neutron': + rabbit_password => 'passw0rd', + core_plugin => 'neutron.plugins.ml2.plugin.Ml2Plugin' }" + end + + let :default_params do + { + :midonet_uri => 'http://localhost:8080/midonet-api', + :username => 'admin', + :password => 'passw0rd', + :project_id => 'admin', + } + end + + let :params do + {} + end + + let :test_facts do + { :operatingsystem => 'default', + :operatingsystemrelease => 'default', + :concat_basedir => '/', + } + end + + shared_examples_for 'neutron ml2 midonet plugin' do + + before do + params.merge!(default_params) + end + + it { is_expected.to contain_class('neutron::params') } + + it do + is_expected.to contain_neutron_plugin_ml2('MIDONET/midonet_uri').with_value(params[:midonet_uri]) + is_expected.to contain_neutron_plugin_ml2('MIDONET/username').with_value(params[:username]) + is_expected.to contain_neutron_plugin_ml2('MIDONET/password').with_value(params[:password]) + is_expected.to contain_neutron_plugin_ml2('MIDONET/project_id').with_value(params[:project_id]) + end + + end + + begin + context 'on RedHat platforms' do + let :facts do + @default_facts.merge(test_facts.merge({ + :osfamily => 'RedHat', + :operatingsystemrelease => '7' + })) + end + + let :platform_params do + { :midonet_ml2_config_file => '/etc/neutron/conf.d/neutron-server/ml2_mech_midonet.conf' } + end + + it_configures 'neutron ml2 midonet plugin' + end + end +end