From f754ef3bcf05177e50375c6464231214f66f83f8 Mon Sep 17 00:00:00 2001 From: Yanis Guenane Date: Thu, 16 Jul 2015 12:28:15 +0200 Subject: [PATCH] Add a proxy inifile provider Create a proxy inifile provider that will sit between the openstack configuration providers (ie. keystone_config) and the actual ini_setting provider. Adding such a component will give us more flexibility on the ini_setting provider. With that in place we could : * Test new feature with the provider - merge them upstream when validated * Bypass upstream limit if our queries are not valid for upstream. By inheriting the provider we don't fork and hence should remain compatible with the next releases of puppetlabs-inifile Change-Id: I061371d8cf2faf928019161e635e1b4252a6b433 --- .fixtures.yml | 1 + .../provider/openstack_config/ini_setting.rb | 30 +++++++++++++++++++ lib/puppet/type/openstack_config.rb | 3 ++ lib/puppet_x/openstack/util/ini_file.rb | 12 ++++++++ metadata.json | 1 + 5 files changed, 47 insertions(+) create mode 100644 lib/puppet/provider/openstack_config/ini_setting.rb create mode 100644 lib/puppet/type/openstack_config.rb create mode 100644 lib/puppet_x/openstack/util/ini_file.rb diff --git a/.fixtures.yml b/.fixtures.yml index bcf98bc4..04caf7aa 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -4,6 +4,7 @@ fixtures: concat: repo: 'git://github.com/puppetlabs/puppetlabs-concat.git' ref: '1.2.1' + inifile: git://github.com/puppetlabs/puppetlabs-inifile.git mysql: git://github.com/puppetlabs/puppetlabs-mysql.git postgresql: git://github.com/puppetlabs/puppetlabs-postgresql.git stdlib: git://github.com/puppetlabs/puppetlabs-stdlib.git diff --git a/lib/puppet/provider/openstack_config/ini_setting.rb b/lib/puppet/provider/openstack_config/ini_setting.rb new file mode 100644 index 00000000..08532925 --- /dev/null +++ b/lib/puppet/provider/openstack_config/ini_setting.rb @@ -0,0 +1,30 @@ +$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),"..","..","..")) +require 'puppet_x/openstack/util/ini_file' + +Puppet::Type.type(:openstack_config).provide( + :ini_setting, + :parent => Puppet::Type.type(:ini_setting).provider(:ruby) +) do + + def section + resource[:name].split('/', 2).first + end + + def setting + resource[:name].split('/', 2).last + end + + def separator + '=' + end + + def file_path + self.class.file_path + end + + private + def ini_file + @ini_file ||= PuppetX::Openstack::Util::IniFile.new(file_path, separator, section_prefix, section_suffix) + end + +end diff --git a/lib/puppet/type/openstack_config.rb b/lib/puppet/type/openstack_config.rb new file mode 100644 index 00000000..8addb2b3 --- /dev/null +++ b/lib/puppet/type/openstack_config.rb @@ -0,0 +1,3 @@ +Puppet::Type.newtype(:openstack_config) do + +end diff --git a/lib/puppet_x/openstack/util/ini_file.rb b/lib/puppet_x/openstack/util/ini_file.rb new file mode 100644 index 00000000..73913311 --- /dev/null +++ b/lib/puppet_x/openstack/util/ini_file.rb @@ -0,0 +1,12 @@ +require File.expand_path('../../../../../../inifile/lib/puppet/util/ini_file', __FILE__) + +module PuppetX + module Openstack + module Util + class IniFile < Puppet::Util::IniFile + + end + end + end +end + diff --git a/metadata.json b/metadata.json index 6520213a..3c2430a7 100644 --- a/metadata.json +++ b/metadata.json @@ -32,6 +32,7 @@ "description": "Puppet module library to expose common functionality between OpenStack modules.", "dependencies": [ { "name": "puppetlabs/apache", "version_requirement": ">=1.0.0 <2.0.0" }, + { "name": "puppetlabs/inifile", "version_requirement": ">=1.0.0 <2.0.0" }, { "name": "puppetlabs/mysql", "version_requirement": ">=3.0.0 <4.0.0" }, { "name": "puppetlabs/stdlib", "version_requirement": ">=4.0.0 <5.0.0" }, { "name": "puppetlabs/rabbitmq", "version_requirement": ">=2.0.2 <6.0.0" },