From beb372b1fe58571b2ebdd18bf176346c72943c91 Mon Sep 17 00:00:00 2001 From: Moshe Levi Date: Tue, 27 Feb 2018 11:46:22 +0200 Subject: [PATCH] Add support to networking-mlnx ml2 drivers Change-Id: Ife22d7c113c33d6e42a94b9d6c32ed8cb61d6488 Co-authored-by: Hamdy Khader --- manifests/plugins/ml2/mellanox.pp | 33 +++++++++ .../plugins/ml2/mellanox/mlnx_sdn_assist.pp | 43 ++++++++++++ ...working-mlnx-support-9e9dfb06f7267e68.yaml | 4 ++ .../neutron_plugins_ml2_mellanox_spec.rb | 62 ++++++++++++++++ ...eutron_plugins_ml2_mlnx_sdn_assist_spec.rb | 70 +++++++++++++++++++ 5 files changed, 212 insertions(+) create mode 100644 manifests/plugins/ml2/mellanox.pp create mode 100644 manifests/plugins/ml2/mellanox/mlnx_sdn_assist.pp create mode 100644 releasenotes/notes/add-networking-mlnx-support-9e9dfb06f7267e68.yaml create mode 100644 spec/classes/neutron_plugins_ml2_mellanox_spec.rb create mode 100644 spec/classes/neutron_plugins_ml2_mlnx_sdn_assist_spec.rb diff --git a/manifests/plugins/ml2/mellanox.pp b/manifests/plugins/ml2/mellanox.pp new file mode 100644 index 000000000..bf2bd217d --- /dev/null +++ b/manifests/plugins/ml2/mellanox.pp @@ -0,0 +1,33 @@ +# +# Install the Mellanox plugins and generate the config file +# from parameters in the other classes. +# +# === Parameters +# +# [*package_ensure*] +# (optional) The intended state of the networking-mlnx +# package, i.e. any of the possible values of the 'ensure' +# property for a package resource type. +# Defaults to 'present' +# + +class neutron::plugins::ml2::mellanox ( + $package_ensure = 'present' +) { + + include ::neutron::deps + include ::neutron::params + require ::neutron::plugins::ml2 + + if($::osfamily != 'RedHat') { + # Drivers are only packaged for RedHat at this time + fail("Unsupported osfamily ${::osfamily}") + } + + ensure_resource('package', 'python-networking-mlnx', + { + ensure => $package_ensure, + tag => ['openstack', 'neutron-package'] + } + ) +} diff --git a/manifests/plugins/ml2/mellanox/mlnx_sdn_assist.pp b/manifests/plugins/ml2/mellanox/mlnx_sdn_assist.pp new file mode 100644 index 000000000..1d8b15d81 --- /dev/null +++ b/manifests/plugins/ml2/mellanox/mlnx_sdn_assist.pp @@ -0,0 +1,43 @@ +# +# Install the OpenDaylight and generate config file +# from parameters in the other classes. +# +# === Parameters +# +# [*sdn_username*] +# (optional) The Mellanox controller username +# Defaults to $::os_service_default +# Example: 'admin' +# +# [*sdn_password*] +# (optional) The Mellanox controller password +# Defaults to $::os_service_default +# Example: 'admin' +# +# [*sdn_url*] +# (optional) The Mellanox controller neutron URL +# Defaults to $::os_service_default +# Example: 'http://127.0.0.1/neo' +# +# [*sdn_domain*] +# (optional) The Mellanox controller domain +# Defaults to $::os_service_default +# Example: 'cloudx' +# +class neutron::plugins::ml2::mellanox::mlnx_sdn_assist ( + $sdn_username = $::os_service_default, + $sdn_password = $::os_service_default, + $sdn_url = $::os_service_default, + $sdn_domain = $::os_service_default, +) { + + include ::neutron::deps + require ::neutron::plugins::ml2 + + neutron_plugin_ml2 { + 'sdn/username': value => $sdn_username; + 'sdn/password': value => $sdn_password, secret => true; + 'sdn/url': value => $sdn_url; + 'sdn/domain': value => $sdn_domain; + } +} diff --git a/releasenotes/notes/add-networking-mlnx-support-9e9dfb06f7267e68.yaml b/releasenotes/notes/add-networking-mlnx-support-9e9dfb06f7267e68.yaml new file mode 100644 index 000000000..7a68f5ca4 --- /dev/null +++ b/releasenotes/notes/add-networking-mlnx-support-9e9dfb06f7267e68.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Adding the ability to configure Mellanox mlnx_sdn_assist mechanism driver for Neutron ml2. diff --git a/spec/classes/neutron_plugins_ml2_mellanox_spec.rb b/spec/classes/neutron_plugins_ml2_mellanox_spec.rb new file mode 100644 index 000000000..5c72ed538 --- /dev/null +++ b/spec/classes/neutron_plugins_ml2_mellanox_spec.rb @@ -0,0 +1,62 @@ +require 'spec_helper' + +describe 'neutron::plugins::ml2::mellanox' do + + let :pre_condition do + "class { '::neutron::keystone::authtoken': + password => 'passw0rd', + } + class { 'neutron::server': } + class { 'neutron': + rabbit_password => 'passw0rd', + core_plugin => 'neutron.plugins.ml2.plugin.Ml2Plugin' }" + end + + let :default_params do + { + :package_ensure => 'present' + } + end + + let :params do + {} + end + + let :test_facts do + { + :operatingsystem => 'default', + :operatingsystemrelease => 'default', + :concat_basedir => '/', + } + end + + shared_examples_for 'neutron plugin mellanox ml2' do + before do + params.merge!(default_params) + end + + it { is_expected.to contain_class('neutron::params') } + + it 'should have' do + is_expected.to contain_package('python-networking-mlnx').with( + :ensure => params[:package_ensure], + :tag => ['openstack', 'neutron-package'] + ) + end + end + + begin + context 'on RedHat platforms' do + let :facts do + OSDefaults.get_facts.merge(test_facts.merge({ + :osfamily => 'RedHat', + :operatingsystemrelease => '7' + })) + end + + it_configures 'neutron plugin mellanox ml2' + end + end + +end + diff --git a/spec/classes/neutron_plugins_ml2_mlnx_sdn_assist_spec.rb b/spec/classes/neutron_plugins_ml2_mlnx_sdn_assist_spec.rb new file mode 100644 index 000000000..c740901d0 --- /dev/null +++ b/spec/classes/neutron_plugins_ml2_mlnx_sdn_assist_spec.rb @@ -0,0 +1,70 @@ +require 'spec_helper' + +describe 'neutron::plugins::ml2::mellanox::mlnx_sdn_assist' do + + let :pre_condition do + "class { '::neutron::keystone::authtoken': + password => 'passw0rd', + } + class { 'neutron::server': } + class { 'neutron': + rabbit_password => 'passw0rd', + core_plugin => 'ml2' }" + end + + let :default_params do + { + :sdn_url => '', + } + end + + let :params do + { + :sdn_username => 'user', + :sdn_password => 'password', + } + end + + let :test_facts do + { + :operatingsystem => 'default', + :operatingsystemrelease => 'default', + } + end + + + shared_examples_for 'neutron plugin mellanox ml2 mlnx_sdn_assist' do + before do + params.merge!(default_params) + end + + it 'configures sdn settings' do + is_expected.to contain_neutron_plugin_ml2('sdn/password').with_value(params[:sdn_password]).with_secret(true) + is_expected.to contain_neutron_plugin_ml2('sdn/username').with_value(params[:sdn_username]) + is_expected.to contain_neutron_plugin_ml2('sdn/url').with_value(params[:sdn_url]) + end + + end + + + context 'on RedHat platforms' do + let :facts do + OSDefaults.get_facts.merge(test_facts.merge({ + :osfamily => 'RedHat', + :operatingsystemrelease => '7' + })) + end + + it_configures 'neutron plugin mellanox ml2 mlnx_sdn_assist' + end + + context 'on Debian platforms' do + let :facts do + OSDefaults.get_facts.merge(test_facts.merge({ + :osfamily => 'Debian', + })) + end + + it_configures 'neutron plugin mellanox ml2 mlnx_sdn_assist' + end +end