Create vhost_socket_dir with proper permissions

For ovs2.8 version, it is required to modify the vhost socket
directory permissions as openvswitch:hugetlbfs instead of
qemu:qemu. Create the dir and assign it proper permissions in
step 3.

Change-Id: I5fc2f852c66c2b825af96aba2657d0f9085dc8c3
This commit is contained in:
Janki Chhatbar 2018-02-26 15:24:14 +05:30 committed by Tim Rozet
parent 3202394f0c
commit c8fe3cbb06
6 changed files with 102 additions and 44 deletions

View File

@ -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.

View File

@ -63,6 +63,19 @@
# 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'),
@ -73,8 +86,22 @@ class tripleo::profile::base::neutron::plugins::ovs::opendaylight (
$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 {
if empty($odl_api_ips) { fail('No IPs assigned to OpenDaylight API Service') }

View File

@ -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
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"}

View File

@ -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',

View File

@ -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'

View File

@ -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'