diff --git a/manifests/profile/base/neutron/ovs.pp b/manifests/profile/base/neutron/ovs.pp index 6b4a76fea..c45a57fb0 100644 --- a/manifests/profile/base/neutron/ovs.pp +++ b/manifests/profile/base/neutron/ovs.pp @@ -44,7 +44,7 @@ class tripleo::profile::base::neutron::ovs( ) { include ::tripleo::profile::base::neutron - if $step >= 5 { + if $step >= 3 { if $vhostuser_socket_dir { file { $vhostuser_socket_dir: ensure => directory, @@ -53,7 +53,9 @@ class tripleo::profile::base::neutron::ovs( mode => '0775', } } + } + if $step >= 5 { include ::neutron::agents::ml2::ovs # Optional since manage_service may be false and neutron server may not be colocated. diff --git a/manifests/profile/base/neutron/plugins/ovs/opendaylight.pp b/manifests/profile/base/neutron/plugins/ovs/opendaylight.pp index 582692567..fb57f0c92 100644 --- a/manifests/profile/base/neutron/plugins/ovs/opendaylight.pp +++ b/manifests/profile/base/neutron/plugins/ovs/opendaylight.pp @@ -63,17 +63,44 @@ # for more details. # Defaults to hiera('step') # +# [*vhostuser_socket_group*] +# (Optional) Group name for vhostuser socket dir. +# Defaults to qemu +# +# [*vhostuser_socket_user*] +# (Optional) User name for vhostuser socket dir. +# Defaults to qemu +# +# [*vhostuser_socket_dir*] +# (Optional) vhostuser socket dir, The directory where $vhostuser_socket_dir +# will be created with correct permissions, inorder to support vhostuser +# client mode. +# class tripleo::profile::base::neutron::plugins::ovs::opendaylight ( - $odl_port = hiera('opendaylight::odl_rest_port'), - $odl_check_url = hiera('opendaylight_check_url'), - $odl_api_ips = hiera('opendaylight_api_node_ips'), - $odl_url_ip = hiera('opendaylight_api_vip'), - $conn_proto = 'http', - $certificate_specs = {}, - $enable_internal_tls = hiera('enable_internal_tls', false), - $tunnel_ip = hiera('neutron::agents::ml2::ovs::local_ip'), - $step = Integer(hiera('step')), -) { + $odl_port = hiera('opendaylight::odl_rest_port'), + $odl_check_url = hiera('opendaylight_check_url'), + $odl_api_ips = hiera('opendaylight_api_node_ips'), + $odl_url_ip = hiera('opendaylight_api_vip'), + $conn_proto = 'http', + $certificate_specs = {}, + $enable_internal_tls = hiera('enable_internal_tls', false), + $tunnel_ip = hiera('neutron::agents::ml2::ovs::local_ip'), + $step = Integer(hiera('step')), + $vhostuser_socket_group = hiera('tripleo::profile::base::neutron::plugins::ovs::opendaylight::vhostuser_socket_group', 'qemu'), + $vhostuser_socket_user = hiera('tripleo::profile::base::neutron::plugins::ovs::opendaylight::vhostuser_socket_user', 'qemu'), + $vhostuser_socket_dir = hiera('neutron::plugins::ovs::opendaylight::vhostuser_socket_dir', undef), + ) { + + if $step >= 3 { + if $vhostuser_socket_dir { + file { $vhostuser_socket_dir: + ensure => directory, + owner => $vhostuser_socket_user, + group => $vhostuser_socket_group, + mode => '0775', + } + } + } if $step >= 4 { diff --git a/spec/classes/tripleo_profile_base_neutron_ovs_opendaylight_spec.rb b/spec/classes/tripleo_profile_base_neutron_ovs_opendaylight_spec.rb index 267e58beb..f43d6d066 100644 --- a/spec/classes/tripleo_profile_base_neutron_ovs_opendaylight_spec.rb +++ b/spec/classes/tripleo_profile_base_neutron_ovs_opendaylight_spec.rb @@ -17,24 +17,67 @@ require 'spec_helper' describe 'tripleo::profile::base::neutron::plugins::ovs::opendaylight' do + + shared_examples_for 'tripleo::profile::base::neutron::plugins::ovs::opendaylight' do + let :params do { :step => 4, :odl_port => 8081, - :odl_check_url => 'restconf/operational/network-topology:network-topology/topology/netvirt:1' + :odl_check_url => 'restconf/operational/network-topology:network-topology/topology/netvirt:1', + :odl_api_ips => ['192.0.2.5'], + :odl_url_ip => '192.0.2.6', + :tunnel_ip => '11.0.0.5', } - end - shared_examples_for 'tripleo::profile::base::neutron::plugins::ovs::opendaylight' do + end + before :each do facts.merge!({ :step => params[:step] }) end + context 'with defaults for all parameters at step 3' do + before do + params.merge!({ :step => 3 }) + facts.merge!({ :step => params[:step] }) + end + it 'should do nothing' do + is_expected.not_to contain_file('/var/lib/vhostuser_sockets') + end + end + + context 'with vhostuser_socketdir configured at step 3' do + before do + params.merge!({ :step => 3, + :vhostuser_socket_dir => '/var/lib/vhostuser_sockets' }) + facts.merge!({ :step => params[:step] }) + end + it { is_expected.to contain_file('/var/lib/vhostuser_sockets').with( + :ensure => 'directory', + :owner => 'qemu', + :group => 'qemu', + :mode => '0775', + ) } + end + + context 'with vhostuser_socketdir and its user/group configured' do + before do + params.merge!({ :step => 3, + :vhostuser_socket_dir => '/var/lib/vhostuser_sockets', + :vhostuser_socket_group => 'hugetlbfs', + :vhostuser_socket_user => 'openvswitch'}) + facts.merge!({ :step => params[:step] }) + end + it { is_expected.to contain_file('/var/lib/vhostuser_sockets').with( + :ensure => 'directory', + :owner => 'openvswitch', + :group => 'hugetlbfs', + :mode => '0775', + ) } + end + context 'with empty OpenDaylight API IPs' do before do params.merge!({ - :odl_api_ips => [], - :tunnel_ip => '11.0.0.5', - :odl_url_ip => '192.0.2.6', - :odl_port => 8081 + :odl_api_ips => [] }) end it 'should fail to configure OVS' do @@ -45,10 +88,7 @@ describe 'tripleo::profile::base::neutron::plugins::ovs::opendaylight' do context 'with empty OpenDaylight VIP' do before do params.merge!({ - :odl_api_ips => ['192.0.2.5'], - :odl_url_ip => [], - :tunnel_ip => '11.0.0.5', - :odl_port => 8081 + :odl_url_ip => [] }) end it 'should fail to configure OVS' do @@ -57,14 +97,7 @@ describe 'tripleo::profile::base::neutron::plugins::ovs::opendaylight' do end context 'with no TLS' do - before do - params.merge!({ - :odl_api_ips => ['192.0.2.5'], - :odl_url_ip => '192.0.2.6', - :tunnel_ip => '11.0.0.5', - :odl_port => 8081 - }) - end + it 'should configure OVS for ODL' do is_expected.to contain_class('neutron::plugins::ovs::opendaylight').with( :tunnel_ip => params[:tunnel_ip], @@ -82,12 +115,8 @@ describe 'tripleo::profile::base::neutron::plugins::ovs::opendaylight' do File.stubs(:file?).returns(true) File.stubs(:readlines).returns(["MIIFGjCCBAKgAwIBAgICA"]) params.merge!({ - :odl_api_ips => ['192.0.2.5'], - :odl_url_ip => '192.0.2.6', - :tunnel_ip => '11.0.0.5', :enable_internal_tls => true, :conn_proto => 'https', - :odl_port => 8081, :certificate_specs => { "service_certificate" => "/etc/pki/tls/certs/ovs.crt", "service_key" => "/etc/pki/tls/private/ovs.key"} diff --git a/spec/classes/tripleo_profile_base_neutron_ovs_spec.rb b/spec/classes/tripleo_profile_base_neutron_ovs_spec.rb index b7883b75d..5b9040b11 100644 --- a/spec/classes/tripleo_profile_base_neutron_ovs_spec.rb +++ b/spec/classes/tripleo_profile_base_neutron_ovs_spec.rb @@ -25,11 +25,11 @@ describe 'tripleo::profile::base::neutron::ovs' do end context 'with defaults for all parameters' do - let(:params) { { :step => 5 } } + let(:params) { { :step => 3 } } - it 'should do nothing' do + it 'should do nothing in step 3' do is_expected.to contain_class('tripleo::profile::base::neutron') - is_expected.to contain_class('neutron::agents::ml2::ovs') + is_expected.to_not contain_class('neutron::agents::ml2::ovs') is_expected.not_to contain_file('/var/lib/vhostuser_sockets') end end @@ -44,13 +44,12 @@ describe 'tripleo::profile::base::neutron::ovs' do context 'with vhostuser_socketdir configured' do let :params do { - :step => 5, + :step => 3, :vhostuser_socket_dir => '/var/lib/vhostuser_sockets' } end it { is_expected.to contain_class('tripleo::profile::base::neutron') } - it { is_expected.to contain_class('neutron::agents::ml2::ovs') } it { is_expected.to contain_file('/var/lib/vhostuser_sockets').with( :ensure => 'directory', :owner => 'qemu', @@ -59,10 +58,10 @@ describe 'tripleo::profile::base::neutron::ovs' do ) } end - context 'with vhostuser_socketdir and its permissions configured' do + context 'with vhostuser_socketdir and group/user specified' do let :params do { - :step => 5, + :step => 3, :vhostuser_socket_dir => '/var/lib/vhostuser_sockets', :vhostuser_socket_group => 'hugetlbfs', :vhostuser_socket_user => 'openvswitch' @@ -70,7 +69,6 @@ describe 'tripleo::profile::base::neutron::ovs' do end it { is_expected.to contain_class('tripleo::profile::base::neutron') } - it { is_expected.to contain_class('neutron::agents::ml2::ovs') } it { is_expected.to contain_file('/var/lib/vhostuser_sockets').with( :ensure => 'directory', :owner => 'openvswitch', diff --git a/spec/fixtures/hieradata/default.yaml b/spec/fixtures/hieradata/default.yaml index 1a6c88b3f..0524f6e55 100644 --- a/spec/fixtures/hieradata/default.yaml +++ b/spec/fixtures/hieradata/default.yaml @@ -111,4 +111,8 @@ tripleo::haproxy_basic_auth::haproxy_userlists: - 'luke insecure-password jedi' - 'anakin insecure-password darthvador' - 'sith password $5$h9LsKUOeCr$UlD62CNEpuZQkGYdBoiFJLsM6TlXluRLBlhEnpjDdaC' +# OpenDaylight +neutron::plugins::ovs::opendaylight::odl_port: '8081' +neutron::plugins::ovs::opendaylight::odl_username: 'admin' +neutron::plugins::ovs::opendaylight::odl_password: 'admin' diff --git a/spec/fixtures/hieradata/step4.yaml b/spec/fixtures/hieradata/step4.yaml index 653285a04..493c98dd5 100644 --- a/spec/fixtures/hieradata/step4.yaml +++ b/spec/fixtures/hieradata/step4.yaml @@ -25,5 +25,3 @@ fluentd::plugin_provider: "yum" fluentd::repo_install: false fluentd::service_name: "fluentd" fluentd::service_provider: "systemd" -neutron::plugins::ovs::opendaylight::odl_username: 'admin' -neutron::plugins::ovs::opendaylight::odl_password: 'admin'