Xenserver - adding type and provider too manage rootwrap.conf
This simple patch is adding following stuff: 1. Adding minimize_polling parameter to ovs ml2 agent class. 2. Adding type and provider to mange rootwrap.conf file mainly to manipulate XenServer connection parameters. Change-Id: I3dad47a34af7bab7eefe46db39b3a5eedc7c3c7f
This commit is contained in:
parent
5e3ba88b9f
commit
f0101c709f
15
lib/puppet/provider/neutron_rootwrap_config/ini_setting.rb
Normal file
15
lib/puppet/provider/neutron_rootwrap_config/ini_setting.rb
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
Puppet::Type.type(:neutron_rootwrap_config).provide(
|
||||||
|
:ini_setting,
|
||||||
|
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
|
||||||
|
) do
|
||||||
|
|
||||||
|
def self.file_path
|
||||||
|
'/etc/neutron/rootwrap.conf'
|
||||||
|
end
|
||||||
|
|
||||||
|
# added for backwards compatibility with older versions of inifile
|
||||||
|
def file_path
|
||||||
|
self.class.file_path
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
28
lib/puppet/type/neutron_rootwrap_config.rb
Normal file
28
lib/puppet/type/neutron_rootwrap_config.rb
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
Puppet::Type.newtype(:neutron_rootwrap_config) do
|
||||||
|
|
||||||
|
ensurable
|
||||||
|
|
||||||
|
newparam(:name, :namevar => true) do
|
||||||
|
desc 'Section/setting name to manage from rootwrap config.'
|
||||||
|
newvalues(/\S+\/\S+/)
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:value) do
|
||||||
|
desc 'The value of the setting to be defined.'
|
||||||
|
munge do |value|
|
||||||
|
value = value.to_s.strip
|
||||||
|
value.capitalize! if value =~ /^(true|false)$/i
|
||||||
|
value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
newparam(:ensure_absent_val) do
|
||||||
|
desc 'A value that is specified as the value property will behave as if ensure => absent was specified'
|
||||||
|
defaultto('<SERVICE DEFAULT>')
|
||||||
|
end
|
||||||
|
|
||||||
|
autorequire(:package) do
|
||||||
|
'neutron-common'
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -140,6 +140,11 @@
|
|||||||
# (optional) Enable or not DPDK with OVS
|
# (optional) Enable or not DPDK with OVS
|
||||||
# Defaults to false.
|
# Defaults to false.
|
||||||
#
|
#
|
||||||
|
# [*minimize_polling*]
|
||||||
|
# (optional) Minimize polling by monitoring ovsdb for interface
|
||||||
|
# changes. (boolean value)
|
||||||
|
# Defaults to $::os_service_default
|
||||||
|
#
|
||||||
# === Deprecated Parameters
|
# === Deprecated Parameters
|
||||||
#
|
#
|
||||||
# [*prevent_arp_spoofing*]
|
# [*prevent_arp_spoofing*]
|
||||||
@ -177,6 +182,7 @@ class neutron::agents::ml2::ovs (
|
|||||||
$ovsdb_interface = $::os_service_default,
|
$ovsdb_interface = $::os_service_default,
|
||||||
$purge_config = false,
|
$purge_config = false,
|
||||||
$enable_dpdk = false,
|
$enable_dpdk = false,
|
||||||
|
$minimize_polling = $::os_service_default,
|
||||||
# DEPRECATED PARAMETERS
|
# DEPRECATED PARAMETERS
|
||||||
$prevent_arp_spoofing = $::os_service_default,
|
$prevent_arp_spoofing = $::os_service_default,
|
||||||
$enable_tunneling = false,
|
$enable_tunneling = false,
|
||||||
@ -279,6 +285,7 @@ class neutron::agents::ml2::ovs (
|
|||||||
'agent/drop_flows_on_start': value => $drop_flows_on_start;
|
'agent/drop_flows_on_start': value => $drop_flows_on_start;
|
||||||
'agent/prevent_arp_spoofing': value => $prevent_arp_spoofing;
|
'agent/prevent_arp_spoofing': value => $prevent_arp_spoofing;
|
||||||
'agent/extensions': value => join(any2array($extensions), ',');
|
'agent/extensions': value => join(any2array($extensions), ',');
|
||||||
|
'agent/minimize_polling': value => $minimize_polling;
|
||||||
'ovs/integration_bridge': value => $integration_bridge;
|
'ovs/integration_bridge': value => $integration_bridge;
|
||||||
'ovs/datapath_type': value => $datapath_type;
|
'ovs/datapath_type': value => $datapath_type;
|
||||||
'ovs/vhostuser_socket_dir': value => $vhostuser_socket_dir;
|
'ovs/vhostuser_socket_dir': value => $vhostuser_socket_dir;
|
||||||
|
36
manifests/rootwrap.pp
Normal file
36
manifests/rootwrap.pp
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# == Class: neutron::rootwrap
|
||||||
|
#
|
||||||
|
# Manages the neutron rootwrap.conf file on systems
|
||||||
|
#
|
||||||
|
# === Parameters:
|
||||||
|
#
|
||||||
|
# [*xenapi_connection_url*]
|
||||||
|
# (optional) XenAPI connection URL. Only needed when target a XenServer/XCP
|
||||||
|
# compute host's dom0
|
||||||
|
# Defaults to $::os_service_default.
|
||||||
|
#
|
||||||
|
# [*xenapi_connection_username*]
|
||||||
|
# (optional) XenAPI username. Only needed when target a XenServer/XCP
|
||||||
|
# compute host's dom0
|
||||||
|
# Defaults to $::os_service_default.
|
||||||
|
#
|
||||||
|
# [*xenapi_connection_password*]
|
||||||
|
# (optional) XenAPI connection password. Only needed when target a XenServer/XCP
|
||||||
|
# compute host's dom0
|
||||||
|
# Defaults to $::os_service_default.
|
||||||
|
#
|
||||||
|
class neutron::rootwrap (
|
||||||
|
$xenapi_connection_url = $::os_service_default,
|
||||||
|
$xenapi_connection_username = $::os_service_default,
|
||||||
|
$xenapi_connection_password = $::os_service_default,
|
||||||
|
) {
|
||||||
|
|
||||||
|
Neutron_rootwrap_config <||> ~> Service['neutron-ovs-agent-service']
|
||||||
|
|
||||||
|
neutron_rootwrap_config {
|
||||||
|
'xenapi/xenapi_connection_url': value => $xenapi_connection_url;
|
||||||
|
'xenapi/xenapi_connection_username': value => $xenapi_connection_username;
|
||||||
|
'xenapi/xenapi_connection_password': value => $xenapi_connection_password;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- Add minimize_polling parameter to ovs ml2 agent class.
|
||||||
|
- Add type and provider to mange rootwrap.conf file mainly
|
||||||
|
to manipulate XenServer connection parameters.
|
@ -46,6 +46,7 @@ describe 'neutron::agents::ml2::ovs' do
|
|||||||
is_expected.to contain_neutron_agent_ovs('agent/prevent_arp_spoofing').with_value('<SERVICE DEFAULT>')
|
is_expected.to contain_neutron_agent_ovs('agent/prevent_arp_spoofing').with_value('<SERVICE DEFAULT>')
|
||||||
is_expected.to contain_neutron_agent_ovs('agent/drop_flows_on_start').with_value(p[:drop_flows_on_start])
|
is_expected.to contain_neutron_agent_ovs('agent/drop_flows_on_start').with_value(p[:drop_flows_on_start])
|
||||||
is_expected.to contain_neutron_agent_ovs('agent/extensions').with_value(['<SERVICE DEFAULT>'])
|
is_expected.to contain_neutron_agent_ovs('agent/extensions').with_value(['<SERVICE DEFAULT>'])
|
||||||
|
is_expected.to contain_neutron_agent_ovs('agent/minimize_polling').with_value(['<SERVICE DEFAULT>'])
|
||||||
is_expected.to contain_neutron_agent_ovs('ovs/datapath_type').with_value(['<SERVICE DEFAULT>'])
|
is_expected.to contain_neutron_agent_ovs('ovs/datapath_type').with_value(['<SERVICE DEFAULT>'])
|
||||||
is_expected.to contain_neutron_agent_ovs('ovs/vhostuser_socket_dir').with_value(['<SERVICE DEFAULT>'])
|
is_expected.to contain_neutron_agent_ovs('ovs/vhostuser_socket_dir').with_value(['<SERVICE DEFAULT>'])
|
||||||
is_expected.to contain_neutron_agent_ovs('ovs/ovsdb_interface').with_value(['<SERVICE DEFAULT>'])
|
is_expected.to contain_neutron_agent_ovs('ovs/ovsdb_interface').with_value(['<SERVICE DEFAULT>'])
|
||||||
|
39
spec/classes/neutron_rootwrap_spec.rb
Normal file
39
spec/classes/neutron_rootwrap_spec.rb
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'neutron::rootwrap' do
|
||||||
|
|
||||||
|
let :pre_condition do
|
||||||
|
"class { 'neutron::agents::ml2::ovs': }"
|
||||||
|
end
|
||||||
|
|
||||||
|
let :params do
|
||||||
|
{ :xenapi_connection_url => 'http://127.0.0.1',
|
||||||
|
:xenapi_connection_username => 'user',
|
||||||
|
:xenapi_connection_password => 'passw0rd',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
shared_examples_for 'neutron rootwrap' do
|
||||||
|
|
||||||
|
it 'configures rootwrap.conf' do
|
||||||
|
is_expected.to contain_neutron_rootwrap_config('xenapi/xenapi_connection_url').with_value(params[:xenapi_connection_url]);
|
||||||
|
is_expected.to contain_neutron_rootwrap_config('xenapi/xenapi_connection_username').with_value(params[:xenapi_connection_username]);
|
||||||
|
is_expected.to contain_neutron_rootwrap_config('xenapi/xenapi_connection_password').with_value(params[:xenapi_connection_password]);
|
||||||
|
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 rootwrap'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,74 @@
|
|||||||
|
$LOAD_PATH.push(
|
||||||
|
File.join(
|
||||||
|
File.dirname(__FILE__),
|
||||||
|
'..',
|
||||||
|
'..',
|
||||||
|
'..',
|
||||||
|
'fixtures',
|
||||||
|
'modules',
|
||||||
|
'inifile',
|
||||||
|
'lib')
|
||||||
|
)
|
||||||
|
$LOAD_PATH.push(
|
||||||
|
File.join(
|
||||||
|
File.dirname(__FILE__),
|
||||||
|
'..',
|
||||||
|
'..',
|
||||||
|
'..',
|
||||||
|
'fixtures',
|
||||||
|
'modules',
|
||||||
|
'openstacklib',
|
||||||
|
'lib')
|
||||||
|
)
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
provider_class = Puppet::Type.type(:neutron_rootwrap_config).provider(:ini_setting)
|
||||||
|
|
||||||
|
describe provider_class do
|
||||||
|
|
||||||
|
it 'should default to the default setting when no other one is specified' do
|
||||||
|
resource = Puppet::Type::Neutron_rootwrap_config.new(
|
||||||
|
{
|
||||||
|
:name => 'DEFAULT/foo',
|
||||||
|
:value => 'bar'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
provider = provider_class.new(resource)
|
||||||
|
expect(provider.section).to eq('DEFAULT')
|
||||||
|
expect(provider.setting).to eq('foo')
|
||||||
|
expect(provider.file_path).to eq('/etc/neutron/rootwrap.conf')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should allow setting to be set explicitly' do
|
||||||
|
resource = Puppet::Type::Neutron_rootwrap_config.new(
|
||||||
|
{
|
||||||
|
:name => 'dude/foo',
|
||||||
|
:value => 'bar'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
provider = provider_class.new(resource)
|
||||||
|
expect(provider.section).to eq('dude')
|
||||||
|
expect(provider.setting).to eq('foo')
|
||||||
|
expect(provider.file_path).to eq('/etc/neutron/rootwrap.conf')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should ensure absent when <SERVICE DEFAULT> is specified as a value' do
|
||||||
|
resource = Puppet::Type::Neutron_rootwrap_config.new(
|
||||||
|
{:name => 'dude/foo', :value => '<SERVICE DEFAULT>'}
|
||||||
|
)
|
||||||
|
provider = provider_class.new(resource)
|
||||||
|
provider.exists?
|
||||||
|
expect(resource[:ensure]).to eq :absent
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should ensure absent when value matches ensure_absent_val' do
|
||||||
|
resource = Puppet::Type::Neutron_rootwrap_config.new(
|
||||||
|
{:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' }
|
||||||
|
)
|
||||||
|
provider = provider_class.new(resource)
|
||||||
|
provider.exists?
|
||||||
|
expect(resource[:ensure]).to eq :absent
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
20
spec/unit/type/neutron_rootwrap_config_spec.rb
Normal file
20
spec/unit/type/neutron_rootwrap_config_spec.rb
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
require 'puppet'
|
||||||
|
require 'puppet/type/neutron_rootwrap_config'
|
||||||
|
|
||||||
|
describe 'Puppet::Type.type(:neutron_rootwrap_config)' do
|
||||||
|
|
||||||
|
before :each do
|
||||||
|
@neutron_rootwrap_config = Puppet::Type.type(:neutron_rootwrap_config).new(:name => 'DEFAULT/foo', :value => 'bar')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should autorequire the package that install the file' do
|
||||||
|
catalog = Puppet::Resource::Catalog.new
|
||||||
|
package = Puppet::Type.type(:package).new(:name => 'neutron-common')
|
||||||
|
catalog.add_resource package, @neutron_rootwrap_config
|
||||||
|
dependency = @neutron_rootwrap_config.autorequire
|
||||||
|
expect(dependency.size).to eq(1)
|
||||||
|
expect(dependency[0].target).to eq(@neutron_rootwrap_config)
|
||||||
|
expect(dependency[0].source).to eq(package)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user