]> review.fuel-infra Code Review - puppet-modules/puppet-ceilometer.git/commitdiff
compute agent: do not try to configure nova.conf
authorEmilien Macchi <emilien@redhat.com>
Tue, 22 Sep 2015 19:23:43 +0000 (15:23 -0400)
committerEmilien Macchi <emilien@redhat.com>
Thu, 24 Sep 2015 18:38:15 +0000 (18:38 +0000)
Back in history, we tried to configure something in nova.conf which is
now managed by puppet-nova. It causes the module conflicting with
puppet-nova and makes Puppet runs not idempotent and nova.conf with
wrong parameters.

nova_notifier plugin was removed in Kilo (ceilometer commit eed463659f2e6f7018b5db1fcae9931ae1d60a00).

Change-Id: I2b8d55613f0a962662d67b9fd82db17b758af80f

lib/puppet/provider/file_line_after/ruby.rb [deleted file]
lib/puppet/type/file_line_after.rb [deleted file]
manifests/agent/compute.pp
manifests/agent/polling.pp
spec/classes/ceilometer_agent_compute_spec.rb
spec/classes/ceilometer_agent_polling_spec.rb

diff --git a/lib/puppet/provider/file_line_after/ruby.rb b/lib/puppet/provider/file_line_after/ruby.rb
deleted file mode 100644 (file)
index 0d7f287..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-Puppet::Type.type(:file_line_after).provide(:ruby) do
-  def exists?
-    lines.find do |line|
-      line.chomp == resource[:line].chomp
-    end
-  end
-
-  def create
-    if resource[:match]
-      handle_create_with_match
-    elsif resource[:after]
-      handle_create_with_after
-    else
-      append_line
-    end
-  end
-
-  def destroy
-    local_lines = lines
-    File.open(resource[:path],'w') do |fh|
-      fh.write(local_lines.reject{|l| l.chomp == resource[:line] }.join(''))
-    end
-  end
-
-  private
-  def lines
-    # If this type is ever used with very large files, we should
-    #  write this in a different way, using a temp
-    #  file; for now assuming that this type is only used on
-    #  small-ish config files that can fit into memory without
-    #  too much trouble.
-    @lines ||= File.readlines(resource[:path])
-  end
-
-  def handle_create_with_match()
-    regex = resource[:match] ? Regexp.new(resource[:match]) : nil
-    match_count = lines.select { |l| regex.match(l) }.size
-    if match_count > 1 && resource[:multiple].to_s != 'true'
-     raise Puppet::Error, "More than one line in file '#{resource[:path]}' matches pattern '#{resource[:match]}'"
-    end
-    File.open(resource[:path], 'w') do |fh|
-      lines.each do |l|
-        fh.puts(regex.match(l) ? resource[:line] : l)
-      end
-
-      if (match_count == 0)
-        fh.puts(resource[:line])
-      end
-    end
-  end
-
-  def handle_create_with_after
-    regex = Regexp.new(resource[:after])
-
-    count = lines.count {|l| l.match(regex)}
-
-    case count
-    when 1 # find the line to put our line after
-      File.open(resource[:path], 'w') do |fh|
-        lines.each do |l|
-          fh.puts(l)
-          if regex.match(l) then
-            fh.puts(resource[:line])
-          end
-        end
-      end
-    when 0 # append the line to the end of the file
-      append_line
-    else
-      raise Puppet::Error, "#{count} lines match pattern '#{resource[:after]}' in file '#{resource[:path]}'.  One or no line must match the pattern."
-    end
-  end
-
-  ##
-  # append the line to the file.
-  #
-  # @api private
-  def append_line
-    File.open(resource[:path], 'a') do |fh|
-      fh.puts resource[:line]
-    end
-  end
-end
diff --git a/lib/puppet/type/file_line_after.rb b/lib/puppet/type/file_line_after.rb
deleted file mode 100644 (file)
index d71d7c2..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-Puppet::Type.newtype(:file_line_after) do
-
-  desc <<-EOT
-    Ensures that a given line is contained within a file.  The implementation
-    matches the full line, including whitespace at the beginning and end.  If
-    the line is not contained in the given file, Puppet will add the line to
-    ensure the desired state.  Multiple resources may be declared to manage
-    multiple lines in the same file.
-
-    Example:
-
-        file_line_after { 'sudo_rule':
-          path => '/etc/sudoers',
-          line => '%sudo ALL=(ALL) ALL',
-        }
-        file_line_after { 'sudo_rule_nopw':
-          path => '/etc/sudoers',
-          line => '%sudonopw ALL=(ALL) NOPASSWD: ALL',
-        }
-
-    In this example, Puppet will ensure both of the specified lines are
-    contained in the file /etc/sudoers.
-
-  EOT
-
-  ensurable do
-    defaultvalues
-    defaultto :present
-  end
-
-  newparam(:name, :namevar => true) do
-    desc 'An arbitrary name used as the identity of the resource.'
-  end
-
-  newparam(:match) do
-    desc 'An optional regular expression to run against existing lines in the file;\n' +
-        'if a match is found, we replace that line rather than adding a new line.'
-  end
-
-  newparam(:multiple) do
-    desc 'An optional value to determine if match can change multiple lines.'
-    newvalues(true, false)
-  end
-
-  newparam(:after) do
-    desc 'An optional value used to specify the line after which we will add any new lines. (Existing lines are added in place)'
-  end
-
-  newparam(:line) do
-    desc 'The line to be appended to the file located by the path parameter.'
-  end
-
-  newparam(:path) do
-    desc 'The file Puppet will ensure contains the line specified by the line parameter.'
-    validate do |value|
-      unless (Puppet.features.posix? and value =~ /^\//) or (Puppet.features.microsoft_windows? and (value =~ /^.:\// or value =~ /^\/\/[^\/]+\/[^\/]+/))
-        raise(Puppet::Error, "File paths must be fully qualified, not '#{value}'")
-      end
-    end
-  end
-
-  # Autorequire the file resource if it's being managed
-  autorequire(:file) do
-    self[:path]
-  end
-
-  validate do
-    unless self[:line] and self[:path]
-      raise(Puppet::Error, "Both line and path are required attributes")
-    end
-
-    if (self[:match])
-      unless Regexp.new(self[:match]).match(self[:line])
-        raise(Puppet::Error, "When providing a 'match' parameter, the value must be a regex that matches against the value of your 'line' parameter")
-      end
-    end
-
-  end
-end
index a40a707da62b14aa4b97eb5137fee76d19d01e7b..7da7a8bdd51d8d9857c854d6f959951c7b0ad470 100644 (file)
@@ -61,28 +61,4 @@ class ceilometer::agent::compute (
     tag        => 'ceilometer-service',
   }
 
-  #NOTE(dprince): This is using a custom (inline) file_line provider
-  # until this lands upstream:
-  # https://github.com/puppetlabs/puppetlabs-stdlib/pull/174
-  Nova_config<| |> {
-    before +> File_line_after[
-      'nova-notification-driver-common',
-      'nova-notification-driver-ceilometer'
-    ],
-  }
-
-  file_line_after {
-    'nova-notification-driver-common':
-      line   =>
-        'notification_driver=nova.openstack.common.notifier.rpc_notifier',
-      path   => '/etc/nova/nova.conf',
-      after  => '^\s*\[DEFAULT\]',
-      notify => Service['nova-compute'];
-    'nova-notification-driver-ceilometer':
-      line   => 'notification_driver=ceilometer.compute.nova_notifier',
-      path   => '/etc/nova/nova.conf',
-      after  => '^\s*\[DEFAULT\]',
-      notify => Service['nova-compute'];
-  }
-
 }
index 4e9acb76a9eb3b42230fa1fbbba078371927604e..624166e15c08246deee3746a24aa36fcf786b79a 100644 (file)
@@ -57,30 +57,6 @@ class ceilometer::agent::polling (
       }
     }
 
-    #NOTE(dprince): This is using a custom (inline) file_line provider
-    # until this lands upstream:
-    # https://github.com/puppetlabs/puppetlabs-stdlib/pull/174
-    Nova_config<| |> {
-      before +> File_line_after[
-        'nova-notification-driver-common',
-        'nova-notification-driver-ceilometer'
-      ],
-    }
-
-    file_line_after {
-      'nova-notification-driver-common':
-        line   =>
-          'notification_driver=nova.openstack.common.notifier.rpc_notifier',
-        path   => '/etc/nova/nova.conf',
-        after  => '^\s*\[DEFAULT\]',
-        notify => Service['nova-compute'];
-      'nova-notification-driver-ceilometer':
-        line   => 'notification_driver=ceilometer.compute.nova_notifier',
-        path   => '/etc/nova/nova.conf',
-        after  => '^\s*\[DEFAULT\]',
-        notify => Service['nova-compute'];
-    }
-
     $compute_namespace_name = 'compute'
 
     Package <| title == 'nova-common' |> -> Package['ceilometer-common']
index e012c982e03a7e5c04b0c89371e8e28424972d4a..dddafb0ef2476b43ecaea9c162a2b768800c3ce7 100644 (file)
@@ -47,19 +47,6 @@ describe 'ceilometer::agent::compute' do
         )
     end
 
-    it 'configures nova notification driver' do
-      is_expected.to contain_file_line_after('nova-notification-driver-common').with(
-        :line   => 'notification_driver=nova.openstack.common.notifier.rpc_notifier',
-        :path   => '/etc/nova/nova.conf',
-        :notify => 'Service[nova-compute]'
-      )
-      is_expected.to contain_file_line_after('nova-notification-driver-ceilometer').with(
-        :line   => 'notification_driver=ceilometer.compute.nova_notifier',
-        :path   => '/etc/nova/nova.conf',
-        :notify => 'Service[nova-compute]'
-      )
-    end
-
     [{:enabled => true}, {:enabled => false}].each do |param_hash|
       context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
         before do
index b35ec0fcac65b5e75eb23a8fb0eeb91944aa4560..43eea81e7b1bf9dd529c85fb4f5bac2a029995dd 100644 (file)
@@ -37,19 +37,6 @@ describe 'ceilometer::agent::polling' do
               :before => /Package\[ceilometer-common\]/
           )
       end
-
-      it 'configures nova notification driver' do
-        is_expected.to contain_file_line_after('nova-notification-driver-common').with(
-          :line   => 'notification_driver=nova.openstack.common.notifier.rpc_notifier',
-          :path   => '/etc/nova/nova.conf',
-          :notify => 'Service[nova-compute]'
-        )
-        is_expected.to contain_file_line_after('nova-notification-driver-ceilometer').with(
-          :line   => 'notification_driver=ceilometer.compute.nova_notifier',
-          :path   => '/etc/nova/nova.conf',
-          :notify => 'Service[nova-compute]'
-        )
-      end
     end
 
     it 'installs ceilometer-polling package' do