From 7544371cf9150ec41eb50395605b9f1f67390d79 Mon Sep 17 00:00:00 2001 From: Koki Sanagi Date: Wed, 30 Nov 2016 11:54:46 -0500 Subject: [PATCH] Add networking-fujitsu support to puppet-neutron Introduce manifests for networking-fujitsu ML2 plugin. This manifest configures ml2_conf.ini for networking-fujitsu which drives FUJITSU C-Fabric switch. Implements: blueprint integration-networking-fujitsu Change-Id: I37a502b43eb7d91bfe20625248ed117eae3ca535 --- manifests/plugins/ml2/fujitsu.pp | 24 +++++++ manifests/plugins/ml2/fujitsu/cfab.pp | 60 ++++++++++++++++ ...or-networking-fujtsu-a558aefc26289305.yaml | 3 + .../neutron_plugins_ml2_fujitsu_cfab_spec.rb | 71 +++++++++++++++++++ .../neutron_plugins_ml2_fujitsu_spec.rb | 60 ++++++++++++++++ 5 files changed, 218 insertions(+) create mode 100644 manifests/plugins/ml2/fujitsu.pp create mode 100644 manifests/plugins/ml2/fujitsu/cfab.pp create mode 100644 releasenotes/notes/add-manifest-for-networking-fujtsu-a558aefc26289305.yaml create mode 100644 spec/classes/neutron_plugins_ml2_fujitsu_cfab_spec.rb create mode 100644 spec/classes/neutron_plugins_ml2_fujitsu_spec.rb diff --git a/manifests/plugins/ml2/fujitsu.pp b/manifests/plugins/ml2/fujitsu.pp new file mode 100644 index 000000000..a9fd6573f --- /dev/null +++ b/manifests/plugins/ml2/fujitsu.pp @@ -0,0 +1,24 @@ +# +# Install the Fujitsu ML2 plugin. +# +# === Parameters +# +# [*package_ensure*] +# (optional) The intended state of the Fujitsu ML2 plugin package +# i.e. any of the possible values of the 'ensure' property for a +# package resource type. Defaults to 'present' +# + +class neutron::plugins::ml2::fujitsu ( + $package_ensure = 'present' +) { + + include ::neutron::deps + + ensure_resource('package', 'python-networking-fujitsu', + { + ensure => $package_ensure, + tag => 'openstack', + } + ) +} diff --git a/manifests/plugins/ml2/fujitsu/cfab.pp b/manifests/plugins/ml2/fujitsu/cfab.pp new file mode 100644 index 000000000..33625683d --- /dev/null +++ b/manifests/plugins/ml2/fujitsu/cfab.pp @@ -0,0 +1,60 @@ +# +# Configure the Fujitsu neutron ML2 plugin for C-Fabric +# +# === Parameters +# +# [*address*] +# (required) The address of the C-Fabric to telnet to. +# Example: 192.168.0.1 +# +# [*username*] +# (optional) The C-Fabric username to use. +# Example: username +# +# [*password*] +# (optional) The C-Fabric password to use. +# Example: password +# +# [*physical_networks*] +# (optional) physical_network names and corresponding vfab ids. +# Example: physnet1:1,physnet2:2 +# Defaults to '' +# +# [*share_pprofile*] +# (optional) Whether to share a C-Fabric pprofile among Neutron ports using the +# same VLAN ID. +# Example: true +# Defaults to false +# +# [*pprofile_prefix*] +# (optional) The prefix string for pprofile name. +# Example: neutron- +# Defaults to '' +# +# [*save_config*] +# (optional) Whether to save configuration. +# Example: true +# Defaults to true + +class neutron::plugins::ml2::fujitsu::cfab ( + $address, + $username, + $password, + $physical_networks = '', + $share_pprofile = false, + $pprofile_prefix = '', + $save_config = true, +) +{ + require ::neutron::plugins::ml2 + + neutron_plugin_ml2 { + 'fujitsu_cfab/address' : value => $address; + 'fujitsu_cfab/username' : value => $username; + 'fujitsu_cfab/password' : value => $password; + 'fujitsu_cfab/physical_networks' : value => join(any2array($physical_networks), ','); + 'fujitsu_cfab/share_pprofile' : value => $share_pprofile; + 'fujitsu_cfab/pprofile_prefix' : value => $pprofile_prefix; + 'fujitsu_cfab/save_config' : value => $save_config; + } +} diff --git a/releasenotes/notes/add-manifest-for-networking-fujtsu-a558aefc26289305.yaml b/releasenotes/notes/add-manifest-for-networking-fujtsu-a558aefc26289305.yaml new file mode 100644 index 000000000..8cc87da4d --- /dev/null +++ b/releasenotes/notes/add-manifest-for-networking-fujtsu-a558aefc26289305.yaml @@ -0,0 +1,3 @@ +--- +features: + - Add the ability to configure networking-fujitsu ML2 plugin. diff --git a/spec/classes/neutron_plugins_ml2_fujitsu_cfab_spec.rb b/spec/classes/neutron_plugins_ml2_fujitsu_cfab_spec.rb new file mode 100644 index 000000000..c00371767 --- /dev/null +++ b/spec/classes/neutron_plugins_ml2_fujitsu_cfab_spec.rb @@ -0,0 +1,71 @@ +# +# Unit tests for neutron::plugins::ml2::fujitsu::cfab class +# + +require 'spec_helper' + +describe 'neutron::plugins::ml2::fujitsu::cfab' 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 + { + :address => '192.168.0.1', + :username => 'admin', + :password => 'admin', + :physical_networks => 'physnet1:1,physnet2:2', + :share_pprofile => 'false', + :pprofile_prefix => 'neutron-', + :save_config => 'true', + } + end + + let :params do + {} + end + + let :test_facts do + { :operatingsystem => 'default', + :operatingsystemrelease => 'default', + :concat_basedir => '/', + } + end + + shared_examples_for 'neutron fujitsu ml2 cfab plugin' do + + before do + params.merge!(default_params) + end + + it do + is_expected.to contain_neutron_plugin_ml2('fujitsu_cfab/address').with_value(params[:address]) + is_expected.to contain_neutron_plugin_ml2('fujitsu_cfab/username').with_value(params[:username]) + is_expected.to contain_neutron_plugin_ml2('fujitsu_cfab/password').with_value(params[:password]) + is_expected.to contain_neutron_plugin_ml2('fujitsu_cfab/physical_networks').with_value(params[:physical_networks]) + is_expected.to contain_neutron_plugin_ml2('fujitsu_cfab/share_pprofile').with_value(params[:share_pprofile]) + is_expected.to contain_neutron_plugin_ml2('fujitsu_cfab/pprofile_prefix').with_value(params[:pprofile_prefix]) + is_expected.to contain_neutron_plugin_ml2('fujitsu_cfab/save_config').with_value(params[:save_config]) + end + + end + + on_supported_os({ + :supported_os => OSDefaults.get_supported_os + }).each do |os,facts| + context "on #{os}" do + let (:facts) do + facts.merge!(OSDefaults.get_facts()) + end + + it_configures 'neutron fujitsu ml2 cfab plugin' + end + end +end diff --git a/spec/classes/neutron_plugins_ml2_fujitsu_spec.rb b/spec/classes/neutron_plugins_ml2_fujitsu_spec.rb new file mode 100644 index 000000000..e16800a7a --- /dev/null +++ b/spec/classes/neutron_plugins_ml2_fujitsu_spec.rb @@ -0,0 +1,60 @@ +require 'spec_helper' + +describe 'neutron::plugins::ml2::fujitsu' 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 fujitsu 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-fujitsu').with( + :ensure => params[:package_ensure], + :tag => 'openstack' + ) + end + end + + on_supported_os({ + :supported_os => OSDefaults.get_supported_os + }).each do |os,facts| + context "on #{os}" do + let (:facts) do + facts.merge!(OSDefaults.get_facts()) + end + + it_configures 'neutron plugin fujitsu ml2' + end + end +end +