Skip to content

Commit

Permalink
(PUP-2509) Add -H flag to svcs to strip column headers
Browse files Browse the repository at this point in the history
Without this flag, self.instances returns an entry for a service named
'FMRI':

$ puppet resource service

service { 'FMRI':
  ensure => 'stopped',
    enable => 'false',
}

<...>

This is from the header:

$ svcs | head -5
STATE          STIME    FMRI     <-----
legacy_run     Jun_22   lrc:/etc/rc2_d/S47pppd
legacy_run     Jun_22   lrc:/etc/rc2_d/S89PRESERVE
disabled       Jun_22   svc:/platform/i86pc/acpihpd:default
online         Jun_22   svc:/system/early-manifest-import:default
  • Loading branch information
Drew Fisher committed Jun 30, 2015
1 parent 44e9490 commit 0f58977
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/puppet/provider/service/smf.rb
Expand Up @@ -32,7 +32,7 @@ def setupservice
end

def self.instances
svcs.split("\n").select{|l| l !~ /^legacy_run/ }.collect do |line|
svcs("-H").split("\n").select{|l| l !~ /^legacy_run/ }.collect do |line|
state,stime,fmri = line.split(/\s+/)
status = case state
when /online/; :running
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/provider/service/smf_spec.rb
Expand Up @@ -28,7 +28,7 @@
end

it "should get a list of services (excluding legacy)" do
provider_class.expects(:svcs).with().returns File.read(my_fixture('svcs.out'))
provider_class.expects(:svcs).with('-H').returns File.read(my_fixture('svcs.out'))
instances = provider_class.instances.map { |p| {:name => p.get(:name), :ensure => p.get(:ensure)} }
# we dont manage legacy
expect(instances.size).to eq(2)
Expand Down

0 comments on commit 0f58977

Please sign in to comment.