From 6b00f0eb1961a13d9670c511f73b1001da466e0a Mon Sep 17 00:00:00 2001 From: Sanjay Upadhyay Date: Fri, 24 Jun 2016 12:17:32 +0000 Subject: [PATCH] Add ml2_conf_sriov.ini to neutron server daemon Referring http://goo.gl/GAJ1d4 the ml2_conf_sriov.ini resides in /etc/neutron/plugins/ml2. For Neutron-server to pick it up, we need to pass it as --config value. However, there is a easier way of creating a symlink at /etc/neutron/conf.d/neutron-server/ Change-Id: I4857736bcf9af448ee15bdcefa0d57ee6f2c8ed6 implements: blueprint tripleo-sriov --- manifests/plugins/ml2/mech_driver.pp | 17 +++++++ .../neutron_plugins_ml2_mechdriver_spec.rb | 50 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 spec/defines/neutron_plugins_ml2_mechdriver_spec.rb diff --git a/manifests/plugins/ml2/mech_driver.pp b/manifests/plugins/ml2/mech_driver.pp index 7f2817c07..9bb8f4ac2 100644 --- a/manifests/plugins/ml2/mech_driver.pp +++ b/manifests/plugins/ml2/mech_driver.pp @@ -38,5 +38,22 @@ define neutron::plugins::ml2::mech_driver ( 'ml2_sriov/supported_pci_vendor_devs': value => join(any2array($supported_pci_vendor_devs), ','); 'ml2_sriov/agent_required': value => $sriov_agent_required; } + case $::osfamily { + 'RedHat': { + file { '/etc/neutron/conf.d/neutron-server/ml2_conf_sriov.conf': + ensure => link, + target => '/etc/neutron/plugins/ml2/ml2_conf_sriov.ini', + } + } + /^(Debian|Ubuntu)$/: { + file_line { 'DAEMON_ARGS': + path => '/etc/default/neutron-server', + line => 'DAEMON_ARGS="$DAEMON_ARGS --config-file /etc/neutron/plugins/ml2/ml2_conf_sriov.ini"', + } + } + default: { + fail("Unsupported osfamily ${::osfamily}") + } + } } } diff --git a/spec/defines/neutron_plugins_ml2_mechdriver_spec.rb b/spec/defines/neutron_plugins_ml2_mechdriver_spec.rb new file mode 100644 index 000000000..a11256ebb --- /dev/null +++ b/spec/defines/neutron_plugins_ml2_mechdriver_spec.rb @@ -0,0 +1,50 @@ +require 'spec_helper' + +describe 'neutron::plugins::ml2::mech_driver' do + + let :title do + 'mech_driver' + end + + let :params do { + :name => 'sriovnicswitch', + :supported_pci_vendor_devs => '8086:10ed', + } + end + + describe 'provide sriov configuration for Debian' do + let :facts do + @default_facts.merge({ :osfamily => 'Debian' }) + end + + it 'configures supported_pci_vendor_devs' do + is_expected.to contain_neutron_plugin_sriov('ml2_sriov/supported_pci_vendor_devs').with_value('8086:10ed') + end + + it 'adds ml2_conf_sriov.ini to neutron_server' do + is_expected.to contain_file_line('DAEMON_ARGS').with( + :path => '/etc/default/neutron-server', + :line => 'DAEMON_ARGS="$DAEMON_ARGS --config-file /etc/neutron/plugins/ml2/ml2_conf_sriov.ini"', + ) + end + end + + describe 'provide sriov configuration for Redhat' do + let :facts do + @default_facts.merge({ :osfamily => 'RedHat' }) + end + + it 'configures supported_pci_vendor_devs' do + is_expected.to contain_neutron_plugin_sriov('ml2_sriov/supported_pci_vendor_devs').with_value('8086:10ed') + end + + it 'creates symbolic link for ml2_conf_sriov.ini config.d directory' do + is_expected.to contain_file('/etc/neutron/conf.d/neutron-server/ml2_conf_sriov.conf').with( + :ensure => 'link', + :target => '/etc/neutron/plugins/ml2/ml2_conf_sriov.ini' + ) + end + end + +end +