puppet 2.6.6 → 2.6.7
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/CHANGELOG +107 -1
- data/README.queueing +1 -1
- data/Rakefile +1 -1
- data/conf/solaris/smf/svc-puppetd +0 -2
- data/conf/solaris/smf/svc-puppetmasterd +0 -2
- data/examples/etc/init.d/sleeper +0 -2
- data/examples/modules/sample-module/README.txt +2 -2
- data/ext/puppetstoredconfigclean.rb +1 -1
- data/install.rb +20 -25
- data/lib/puppet.rb +1 -1
- data/lib/puppet/application/agent.rb +2 -2
- data/lib/puppet/application/apply.rb +2 -2
- data/lib/puppet/application/cert.rb +27 -11
- data/lib/puppet/application/filebucket.rb +1 -1
- data/lib/puppet/application/inspect.rb +1 -1
- data/lib/puppet/application/kick.rb +2 -2
- data/lib/puppet/application/master.rb +1 -1
- data/lib/puppet/application/queue.rb +2 -2
- data/lib/puppet/configurer/downloader.rb +1 -0
- data/lib/puppet/configurer/plugin_handler.rb +8 -1
- data/lib/puppet/daemon.rb +1 -1
- data/lib/puppet/defaults.rb +18 -2
- data/lib/puppet/external/nagios.rb +0 -2
- data/lib/puppet/external/nagios/base.rb +0 -2
- data/lib/puppet/indirector/facts/inventory_active_record.rb +97 -0
- data/lib/puppet/indirector/facts/rest.rb +2 -0
- data/lib/puppet/indirector/facts/yaml.rb +75 -0
- data/lib/puppet/indirector/indirection.rb +1 -0
- data/lib/puppet/module.rb +1 -1
- data/lib/puppet/network/http/api/v1.rb +3 -4
- data/lib/puppet/network/http/compression.rb +4 -1
- data/lib/puppet/network/http/handler.rb +1 -1
- data/lib/puppet/network/rest_authconfig.rb +1 -1
- data/lib/puppet/node/facts.rb +29 -0
- data/lib/puppet/parser/ast/collection.rb +5 -4
- data/lib/puppet/parser/ast/leaf.rb +1 -1
- data/lib/puppet/parser/functions/regsubst.rb +7 -14
- data/lib/puppet/parser/functions/split.rb +7 -7
- data/lib/puppet/parser/grammar.ra +2 -4
- data/lib/puppet/parser/lexer.rb +4 -1
- data/lib/puppet/parser/parser.rb +2062 -1976
- data/lib/puppet/parser/parser_support.rb +3 -3
- data/lib/puppet/provider/computer/computer.rb +1 -3
- data/lib/puppet/provider/mount.rb +12 -16
- data/lib/puppet/provider/mount/parsed.rb +67 -8
- data/lib/puppet/provider/parsedfile.rb +3 -1
- data/lib/puppet/provider/service/daemontools.rb +6 -6
- data/lib/puppet/provider/service/gentoo.rb +0 -2
- data/lib/puppet/provider/service/launchd.rb +11 -8
- data/lib/puppet/provider/service/runit.rb +4 -4
- data/lib/puppet/provider/user/useradd.rb +6 -1
- data/lib/puppet/rails/database/004_add_inventory_service_tables.rb +36 -0
- data/lib/puppet/rails/database/schema.rb +17 -0
- data/lib/puppet/rails/fact_name.rb +0 -2
- data/lib/puppet/rails/fact_value.rb +0 -2
- data/lib/puppet/rails/inventory_fact.rb +5 -0
- data/lib/puppet/rails/inventory_node.rb +25 -0
- data/lib/puppet/reference/configuration.rb +1 -1
- data/lib/puppet/reference/metaparameter.rb +1 -1
- data/lib/puppet/reports/store.rb +4 -1
- data/lib/puppet/resource.rb +39 -25
- data/lib/puppet/type.rb +5 -5
- data/lib/puppet/type/augeas.rb +4 -4
- data/lib/puppet/type/computer.rb +5 -1
- data/lib/puppet/type/exec.rb +3 -1
- data/lib/puppet/type/file.rb +3 -1
- data/lib/puppet/type/file/content.rb +13 -15
- data/lib/puppet/type/file/ensure.rb +11 -17
- data/lib/puppet/type/file/selcontext.rb +16 -0
- data/lib/puppet/type/file/target.rb +14 -1
- data/lib/puppet/type/k5login.rb +0 -2
- data/lib/puppet/type/macauthorization.rb +4 -1
- data/lib/puppet/type/mcx.rb +4 -1
- data/lib/puppet/type/mount.rb +37 -21
- data/lib/puppet/type/package.rb +5 -1
- data/lib/puppet/type/schedule.rb +20 -20
- data/lib/puppet/type/selmodule.rb +3 -1
- data/lib/puppet/type/ssh_authorized_key.rb +5 -1
- data/lib/puppet/type/user.rb +14 -1
- data/lib/puppet/type/zfs.rb +3 -1
- data/lib/puppet/type/zone.rb +3 -1
- data/lib/puppet/type/zpool.rb +7 -5
- data/lib/puppet/util.rb +5 -0
- data/lib/puppet/util/command_line.rb +1 -1
- data/lib/puppet/util/execution.rb +4 -5
- data/lib/puppet/util/execution_stub.rb +26 -0
- data/lib/puppet/util/monkey_patches.rb +21 -0
- data/lib/puppet/util/rdoc/code_objects.rb +39 -0
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +18 -0
- data/lib/puppet/util/rdoc/parser.rb +5 -3
- data/lib/puppet/util/settings.rb +1 -1
- data/spec/integration/parser/parser_spec.rb +7 -0
- data/spec/integration/provider/mount_spec.rb +151 -0
- data/spec/integration/type/file_spec.rb +32 -29
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/application/agent_spec.rb +3 -7
- data/spec/unit/application/apply_spec.rb +17 -2
- data/spec/unit/application/cert_spec.rb +54 -14
- data/spec/unit/application/filebucket_spec.rb +1 -1
- data/spec/unit/application/queue_spec.rb +1 -5
- data/spec/unit/configurer/downloader_spec.rb +22 -10
- data/spec/unit/daemon_spec.rb +1 -5
- data/spec/unit/indirector/facts/inventory_active_record_spec.rb +163 -0
- data/spec/unit/indirector/facts/yaml_spec.rb +216 -2
- data/spec/unit/indirector/queue_spec.rb +3 -0
- data/spec/unit/module_spec.rb +2 -2
- data/spec/unit/network/handler/fileserver_spec.rb +1 -1
- data/spec/unit/network/http/api/v1_spec.rb +28 -0
- data/spec/unit/network/http/compression_spec.rb +1 -1
- data/spec/unit/network/http/handler_spec.rb +7 -4
- data/spec/unit/node/facts_spec.rb +24 -0
- data/spec/unit/parser/ast/collection_spec.rb +16 -12
- data/spec/unit/parser/lexer_spec.rb +16 -0
- data/spec/unit/parser/parser_spec.rb +35 -2
- data/spec/unit/provider/mount/parsed_spec.rb +199 -114
- data/spec/unit/provider/mount_spec.rb +54 -53
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +1 -0
- data/spec/unit/provider/user/user_role_add_spec.rb +1 -0
- data/spec/unit/provider/user/useradd_spec.rb +43 -3
- data/spec/unit/reports/store_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +39 -13
- data/spec/unit/type/file/content_spec.rb +38 -137
- data/spec/unit/type/file/selinux_spec.rb +5 -0
- data/spec/unit/type/mount_spec.rb +167 -122
- data/spec/unit/type/user_spec.rb +4 -0
- data/spec/unit/type_spec.rb +12 -1
- data/spec/unit/util/execution_spec.rb +49 -0
- data/spec/unit/util/execution_stub_spec.rb +35 -0
- data/spec/unit/util/rdoc/parser_spec.rb +15 -3
- data/spec/unit/util/settings_spec.rb +11 -2
- data/tasks/rake/git_workflow.rake +1 -1
- data/test/Rakefile +0 -2
- data/test/data/providers/mount/parsed/aix.mount +7 -0
- data/test/data/providers/mount/parsed/darwin.mount +6 -0
- data/test/data/providers/mount/parsed/hpux.mount +17 -0
- data/test/data/providers/mount/parsed/linux.mount +5 -0
- data/test/data/providers/mount/parsed/solaris.mount +6 -0
- data/test/data/types/mount/linux.fstab +1 -0
- data/test/data/types/mount/solaris.fstab +1 -0
- metadata +18 -4
@@ -76,6 +76,12 @@ describe Puppet::Parser do
|
|
76
76
|
|
77
77
|
end
|
78
78
|
|
79
|
+
describe "when parsing selector" do
|
80
|
+
it "should support hash access on the left hand side" do
|
81
|
+
lambda { @parser.parse("$h = { 'a' => 'b' } $a = $h['a'] ? { 'b' => 'd', default => undef }") }.should_not raise_error
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
79
85
|
describe "when parsing 'if'" do
|
80
86
|
it "not, it should create the correct ast objects" do
|
81
87
|
ast::Not.expects(:new).with { |h| h[:value].is_a?(ast::Boolean) }
|
@@ -253,7 +259,7 @@ describe Puppet::Parser do
|
|
253
259
|
before do
|
254
260
|
@lexer = stub 'lexer', :line => 50, :file => "/foo/bar", :getcomment => "whev"
|
255
261
|
@parser.stubs(:lexer).returns @lexer
|
256
|
-
@class =
|
262
|
+
@class = Puppet::Resource::Type.new(:hostclass, "myclass", :use_docs => false)
|
257
263
|
end
|
258
264
|
|
259
265
|
it "should return a new instance of the provided class created with the provided options" do
|
@@ -276,7 +282,7 @@ describe Puppet::Parser do
|
|
276
282
|
it "should include docs when the AST class uses them" do
|
277
283
|
@class.expects(:use_docs).returns true
|
278
284
|
@class.stubs(:new)
|
279
|
-
@parser.expects(:ast_context).with{ |
|
285
|
+
@parser.expects(:ast_context).with{ |docs, line| docs == true }.returns({})
|
280
286
|
@parser.ast(@class, :file => "/bar")
|
281
287
|
end
|
282
288
|
|
@@ -304,6 +310,33 @@ describe Puppet::Parser do
|
|
304
310
|
it "should return an array of nodes" do
|
305
311
|
@parser.newnode(@nodename).should be_instance_of(Array)
|
306
312
|
end
|
313
|
+
|
314
|
+
it "should initialize the ast context with the correct line number" do
|
315
|
+
@parser.expects(:ast_context).with { |a,b| b == 123 }.returns({})
|
316
|
+
@parser.newnode(@nodename, { :line => 123 })
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
%w{class define}.each do |entity|
|
321
|
+
describe "when creating a #{entity}" do
|
322
|
+
before :each do
|
323
|
+
@parser.stubs(:ast_context).returns({})
|
324
|
+
|
325
|
+
@name = stub "#{entity}name", :is_a? => false, :value => "foo"
|
326
|
+
end
|
327
|
+
|
328
|
+
it "should create and add the correct resource type" do
|
329
|
+
instance = stub 'instance'
|
330
|
+
Puppet::Resource::Type.expects(:new).returns(instance)
|
331
|
+
@parser.known_resource_types.expects(:add).with(instance)
|
332
|
+
@parser.send("new#{entity}", @name)
|
333
|
+
end
|
334
|
+
|
335
|
+
it "should initialize the ast context with the correct line number" do
|
336
|
+
@parser.expects(:ast_context).with { |a,b| b == 123 }.returns({})
|
337
|
+
@parser.send("new#{entity}", @name, { :line => 123 })
|
338
|
+
end
|
339
|
+
end
|
307
340
|
end
|
308
341
|
|
309
342
|
describe "when retrieving a specific node" do
|
@@ -5,15 +5,17 @@
|
|
5
5
|
|
6
6
|
require File.dirname(__FILE__) + '/../../../spec_helper'
|
7
7
|
|
8
|
+
require 'puppet_spec/files'
|
8
9
|
require 'puppettest/support/utils'
|
9
10
|
require 'puppettest/fileparsing'
|
10
11
|
|
11
12
|
module ParsedMountTesting
|
12
13
|
include PuppetTest::Support::Utils
|
13
14
|
include PuppetTest::FileParsing
|
15
|
+
include PuppetSpec::Files
|
14
16
|
|
15
17
|
def fake_fstab
|
16
|
-
os = Facter
|
18
|
+
os = Facter.value(:operatingsystem)
|
17
19
|
if os == "Solaris"
|
18
20
|
name = "solaris.fstab"
|
19
21
|
elsif os == "FreeBSD"
|
@@ -22,171 +24,254 @@ module ParsedMountTesting
|
|
22
24
|
# Catchall for other fstabs
|
23
25
|
name = "linux.fstab"
|
24
26
|
end
|
25
|
-
oldpath = @provider_class.default_target
|
26
27
|
fakefile(File::join("data/types/mount", name))
|
27
28
|
end
|
28
29
|
|
29
|
-
def
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
def fake_mountoutput
|
31
|
+
os = Facter.value(:operatingsystem)
|
32
|
+
if os == "Darwin"
|
33
|
+
name = "darwin.mount"
|
34
|
+
elsif os == "HP-UX"
|
35
|
+
name = "hpux.mount"
|
36
|
+
elsif os == "Solaris"
|
37
|
+
name = "solaris.mount"
|
38
|
+
elsif os == "AIX"
|
39
|
+
name = "aix.mount"
|
34
40
|
else
|
35
|
-
|
36
|
-
|
37
|
-
args = {
|
38
|
-
:name => "/fspuppet#{@pcount}",
|
39
|
-
:device => "/dev/dsk#{@pcount}",
|
40
|
-
}
|
41
|
-
|
42
|
-
@provider_class.fields(:parsed).each do |field|
|
43
|
-
args[field] = "fake#{field}#{@pcount}" unless args.include? field
|
41
|
+
# Catchall for other fstabs
|
42
|
+
name = "linux.mount"
|
44
43
|
end
|
45
|
-
|
46
|
-
args
|
44
|
+
fakefile(File::join("data/providers/mount/parsed", name))
|
47
45
|
end
|
48
46
|
|
49
|
-
def mkmount
|
50
|
-
hash = mkmountargs
|
51
|
-
#hash[:provider] = @provider_class.name
|
52
|
-
|
53
|
-
fakeresource = stub :type => :mount, :name => hash[:name]
|
54
|
-
fakeresource.stubs(:[]).with(:name).returns(hash[:name])
|
55
|
-
fakeresource.stubs(:should).with(:target).returns(nil)
|
56
|
-
|
57
|
-
mount = @provider_class.new(fakeresource)
|
58
|
-
hash[:record_type] = :parsed
|
59
|
-
hash[:ensure] = :present
|
60
|
-
mount.property_hash = hash
|
61
|
-
|
62
|
-
mount
|
63
|
-
end
|
64
|
-
|
65
|
-
# Here we just create a fake host type that answers to all of the methods
|
66
|
-
# but does not modify our actual system.
|
67
|
-
def mkfaketype
|
68
|
-
@provider.stubs(:filetype).returns(Puppet::Util::FileType.filetype(:ram))
|
69
|
-
end
|
70
47
|
end
|
71
48
|
|
72
49
|
provider_class = Puppet::Type.type(:mount).provider(:parsed)
|
73
50
|
|
74
51
|
describe provider_class do
|
52
|
+
|
75
53
|
before :each do
|
76
54
|
@mount_class = Puppet::Type.type(:mount)
|
77
|
-
@
|
55
|
+
@provider = @mount_class.provider(:parsed)
|
56
|
+
end
|
57
|
+
|
58
|
+
# LAK:FIXME I can't mock Facter because this test happens at parse-time.
|
59
|
+
it "should default to /etc/vfstab on Solaris" do
|
60
|
+
pending "This test only works on Solaris" unless Facter.value(:operatingsystem) == 'Solaris'
|
61
|
+
Puppet::Type.type(:mount).provider(:parsed).default_target.should == '/etc/vfstab'
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should default to /etc/fstab on anything else" do
|
65
|
+
pending "This test does not work on Solaris" if Facter.value(:operatingsystem) == 'Solaris'
|
66
|
+
Puppet::Type.type(:mount).provider(:parsed).default_target.should == '/etc/fstab'
|
78
67
|
end
|
79
68
|
|
69
|
+
describe "when parsing a line" do
|
80
70
|
|
81
|
-
|
82
|
-
|
71
|
+
it "should not crash on incomplete lines in fstab" do
|
72
|
+
parse = @provider.parse <<-FSTAB
|
73
|
+
/dev/incomplete
|
74
|
+
/dev/device name
|
75
|
+
FSTAB
|
76
|
+
lambda{ @provider.to_line(parse[0]) }.should_not raise_error
|
77
|
+
end
|
83
78
|
|
84
|
-
it "should be able to parse all of the example mount tabs" do
|
85
|
-
tab = fake_fstab
|
86
|
-
@provider = @provider_class
|
87
79
|
|
88
|
-
|
89
|
-
# I suppose this is more of an integration test? I dunno.
|
90
|
-
fakedataparse(tab) do
|
91
|
-
# Now just make we've got some mounts we know will be there
|
92
|
-
hashes = @provider_class.target_records(tab).find_all { |i| i.is_a? Hash }
|
93
|
-
(hashes.length > 0).should be_true
|
94
|
-
root = hashes.find { |i| i[:name] == "/" }
|
80
|
+
describe "on Solaris", :if => Facter.value(:operatingsystem) == 'Solaris' do
|
95
81
|
|
96
|
-
|
82
|
+
before :each do
|
83
|
+
@example_line = "/dev/dsk/c0d0s0 /dev/rdsk/c0d0s0 \t\t / \t ufs 1 no\t-"
|
97
84
|
end
|
98
|
-
end
|
99
85
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
when "Solaris"; "/etc/vfstab"
|
104
|
-
else
|
105
|
-
"/etc/fstab"
|
106
|
-
end
|
107
|
-
Puppet::Type.type(:mount).provider(:parsed).default_target.should == should
|
108
|
-
end
|
86
|
+
it "should extract device from the first field" do
|
87
|
+
@provider.parse_line(@example_line)[:device].should == '/dev/dsk/c0d0s0'
|
88
|
+
end
|
109
89
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
/dev/device name
|
114
|
-
FSTAB
|
90
|
+
it "should extract blockdevice from second field" do
|
91
|
+
@provider.parse_line(@example_line)[:blockdevice].should == "/dev/rdsk/c0d0s0"
|
92
|
+
end
|
115
93
|
|
116
|
-
|
117
|
-
|
118
|
-
|
94
|
+
it "should extract name from third field" do
|
95
|
+
@provider.parse_line(@example_line)[:name].should == "/"
|
96
|
+
end
|
119
97
|
|
120
|
-
|
121
|
-
|
98
|
+
it "should extract fstype from fourth field" do
|
99
|
+
@provider.parse_line(@example_line)[:fstype].should == "ufs"
|
100
|
+
end
|
122
101
|
|
123
|
-
|
124
|
-
|
125
|
-
|
102
|
+
it "should extract pass from fifth field" do
|
103
|
+
@provider.parse_line(@example_line)[:pass].should == "1"
|
104
|
+
end
|
126
105
|
|
127
|
-
|
128
|
-
|
106
|
+
it "should extract atboot from sixth field" do
|
107
|
+
@provider.parse_line(@example_line)[:atboot].should == "no"
|
108
|
+
end
|
129
109
|
|
130
|
-
|
110
|
+
it "should extract options from seventh field" do
|
111
|
+
@provider.parse_line(@example_line)[:options].should == "-"
|
112
|
+
end
|
131
113
|
|
132
|
-
mount.expects(:flush)
|
133
|
-
mount.mount
|
134
114
|
end
|
135
|
-
end
|
136
115
|
|
137
|
-
|
138
|
-
include ParsedMountTesting
|
139
|
-
before do
|
140
|
-
Puppet.settings.stubs(:use)
|
141
|
-
# Never write to disk, only to RAM.
|
142
|
-
#@provider_class.stubs(:filetype).returns(Puppet::Util::FileType.filetype(:ram))
|
143
|
-
@provider_class.stubs(:target_object).returns(Puppet::Util::FileType.filetype(:ram).new("eh"))
|
144
|
-
@provider_class.clear
|
116
|
+
describe "on other platforms than Solaris", :if => Facter.value(:operatingsystem) != 'Solaris' do
|
145
117
|
|
146
|
-
|
147
|
-
|
148
|
-
|
118
|
+
before :each do
|
119
|
+
@example_line = "/dev/vg00/lv01\t/spare \t \t ext3 defaults\t1 2"
|
120
|
+
end
|
149
121
|
|
150
|
-
|
151
|
-
|
122
|
+
it "should extract device from the first field" do
|
123
|
+
@provider.parse_line(@example_line)[:device].should == '/dev/vg00/lv01'
|
124
|
+
end
|
152
125
|
|
153
|
-
|
126
|
+
it "should extract name from second field" do
|
127
|
+
@provider.parse_line(@example_line)[:name].should == "/spare"
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should extract fstype from third field" do
|
131
|
+
@provider.parse_line(@example_line)[:fstype].should == "ext3"
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should extract options from fourth field" do
|
135
|
+
@provider.parse_line(@example_line)[:options].should == "defaults"
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should extract dump from fifth field" do
|
139
|
+
@provider.parse_line(@example_line)[:dump].should == "1"
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should extract options from sixth field" do
|
143
|
+
@provider.parse_line(@example_line)[:pass].should == "2"
|
144
|
+
end
|
154
145
|
|
155
|
-
text = @provider_class.target_object(@provider_class.default_target).read
|
156
|
-
text.should == old_text + @mount.class.to_line(@mount.property_hash) + "\n"
|
157
146
|
end
|
147
|
+
|
158
148
|
end
|
159
149
|
|
160
|
-
describe
|
150
|
+
describe "mountinstances" do
|
161
151
|
include ParsedMountTesting
|
162
152
|
|
163
|
-
|
164
|
-
|
165
|
-
@provider
|
153
|
+
it "should get name from mountoutput found on Solaris" do
|
154
|
+
Facter.stubs(:value).with(:operatingsystem).returns 'Solaris'
|
155
|
+
@provider.stubs(:mountcmd).returns(File.read(fake_mountoutput))
|
156
|
+
mounts = @provider.mountinstances
|
157
|
+
mounts.size.should == 6
|
158
|
+
mounts[0].should == { :name => '/', :mounted => :yes }
|
159
|
+
mounts[1].should == { :name => '/proc', :mounted => :yes }
|
160
|
+
mounts[2].should == { :name => '/etc/mnttab', :mounted => :yes }
|
161
|
+
mounts[3].should == { :name => '/tmp', :mounted => :yes }
|
162
|
+
mounts[4].should == { :name => '/export/home', :mounted => :yes }
|
163
|
+
mounts[5].should == { :name => '/ghost', :mounted => :yes }
|
166
164
|
end
|
167
165
|
|
168
|
-
it "should
|
169
|
-
|
166
|
+
it "should get name from mountoutput found on HP-UX" do
|
167
|
+
Facter.stubs(:value).with(:operatingsystem).returns 'HP-UX'
|
168
|
+
@provider.stubs(:mountcmd).returns(File.read(fake_mountoutput))
|
169
|
+
mounts = @provider.mountinstances
|
170
|
+
mounts.size.should == 17
|
171
|
+
mounts[0].should == { :name => '/', :mounted => :yes }
|
172
|
+
mounts[1].should == { :name => '/devices', :mounted => :yes }
|
173
|
+
mounts[2].should == { :name => '/dev', :mounted => :yes }
|
174
|
+
mounts[3].should == { :name => '/system/contract', :mounted => :yes }
|
175
|
+
mounts[4].should == { :name => '/proc', :mounted => :yes }
|
176
|
+
mounts[5].should == { :name => '/etc/mnttab', :mounted => :yes }
|
177
|
+
mounts[6].should == { :name => '/etc/svc/volatile', :mounted => :yes }
|
178
|
+
mounts[7].should == { :name => '/system/object', :mounted => :yes }
|
179
|
+
mounts[8].should == { :name => '/etc/dfs/sharetab', :mounted => :yes }
|
180
|
+
mounts[9].should == { :name => '/lib/libc.so.1', :mounted => :yes }
|
181
|
+
mounts[10].should == { :name => '/dev/fd', :mounted => :yes }
|
182
|
+
mounts[11].should == { :name => '/tmp', :mounted => :yes }
|
183
|
+
mounts[12].should == { :name => '/var/run', :mounted => :yes }
|
184
|
+
mounts[13].should == { :name => '/export', :mounted => :yes }
|
185
|
+
mounts[14].should == { :name => '/export/home', :mounted => :yes }
|
186
|
+
mounts[15].should == { :name => '/rpool', :mounted => :yes }
|
187
|
+
mounts[16].should == { :name => '/ghost', :mounted => :yes }
|
170
188
|
end
|
171
189
|
|
172
|
-
it "should
|
173
|
-
|
174
|
-
@
|
190
|
+
it "should get name from mountoutput found on Darwin" do
|
191
|
+
Facter.stubs(:value).with(:operatingsystem).returns 'Darwin'
|
192
|
+
@provider.stubs(:mountcmd).returns(File.read(fake_mountoutput))
|
193
|
+
mounts = @provider.mountinstances
|
194
|
+
mounts.size.should == 6
|
195
|
+
mounts[0].should == { :name => '/', :mounted => :yes }
|
196
|
+
mounts[1].should == { :name => '/dev', :mounted => :yes }
|
197
|
+
mounts[2].should == { :name => '/net', :mounted => :yes }
|
198
|
+
mounts[3].should == { :name => '/home', :mounted => :yes }
|
199
|
+
mounts[4].should == { :name => '/usr', :mounted => :yes }
|
200
|
+
mounts[5].should == { :name => '/ghost', :mounted => :yes }
|
175
201
|
end
|
176
202
|
|
177
|
-
it "should
|
178
|
-
|
179
|
-
@
|
203
|
+
it "should get name from mountoutput found on Linux" do
|
204
|
+
Facter.stubs(:value).with(:operatingsystem).returns 'Gentoo'
|
205
|
+
@provider.stubs(:mountcmd).returns(File.read(fake_mountoutput))
|
206
|
+
mounts = @provider.mountinstances
|
207
|
+
mounts[0].should == { :name => '/', :mounted => :yes }
|
208
|
+
mounts[1].should == { :name => '/lib64/rc/init.d', :mounted => :yes }
|
209
|
+
mounts[2].should == { :name => '/sys', :mounted => :yes }
|
210
|
+
mounts[3].should == { :name => '/usr/portage', :mounted => :yes }
|
211
|
+
mounts[4].should == { :name => '/ghost', :mounted => :yes }
|
180
212
|
end
|
213
|
+
|
214
|
+
it "should get name from mountoutput found on AIX" do
|
215
|
+
Facter.stubs(:value).with(:operatingsystem).returns 'AIX'
|
216
|
+
@provider.stubs(:mountcmd).returns(File.read(fake_mountoutput))
|
217
|
+
mounts = @provider.mountinstances
|
218
|
+
mounts[0].should == { :name => '/', :mounted => :yes }
|
219
|
+
mounts[1].should == { :name => '/tmp', :mounted => :yes }
|
220
|
+
mounts[2].should == { :name => '/home', :mounted => :yes }
|
221
|
+
mounts[3].should == { :name => '/usr', :mounted => :yes }
|
222
|
+
mounts[4].should == { :name => '/usr/code', :mounted => :yes }
|
223
|
+
end
|
224
|
+
|
225
|
+
it "should raise an error if a line is not understandable" do
|
226
|
+
@provider.stubs(:mountcmd).returns("bazinga!")
|
227
|
+
lambda { @provider.mountinstances }.should raise_error Puppet::Error
|
228
|
+
end
|
229
|
+
|
181
230
|
end
|
182
231
|
|
183
|
-
describe
|
232
|
+
describe "when prefetching" do
|
184
233
|
include ParsedMountTesting
|
185
234
|
|
186
|
-
|
235
|
+
before :each do
|
236
|
+
# Note: we have to stub default_target before creating resources
|
237
|
+
# because it is used by Puppet::Type::Mount.new to populate the
|
238
|
+
# :target property.
|
239
|
+
@provider.stubs(:default_target).returns fake_fstab
|
240
|
+
|
241
|
+
@res_ghost = Puppet::Type::Mount.new(:name => '/ghost') # in no fake fstab
|
242
|
+
@res_mounted = Puppet::Type::Mount.new(:name => '/') # in every fake fstab
|
243
|
+
@res_unmounted = Puppet::Type::Mount.new(:name => '/boot') # in every fake fstab
|
244
|
+
@res_absent = Puppet::Type::Mount.new(:name => '/absent') # in no fake fstab
|
245
|
+
|
246
|
+
# Simulate transaction.rb:prefetch
|
247
|
+
@resource_hash = {}
|
248
|
+
[@res_ghost, @res_mounted, @res_unmounted, @res_absent].each do |resource|
|
249
|
+
@resource_hash[resource.name] = resource
|
250
|
+
end
|
251
|
+
|
252
|
+
@provider.stubs(:mountcmd).returns File.read(fake_mountoutput)
|
253
|
+
end
|
254
|
+
|
255
|
+
it "should set :ensure to :unmounted if found in fstab but not mounted" do
|
256
|
+
@provider.prefetch(@resource_hash)
|
257
|
+
@res_unmounted.provider.get(:ensure).should == :unmounted
|
258
|
+
end
|
259
|
+
|
260
|
+
it "should set :ensure to :mounted if found in fstab and mounted" do
|
261
|
+
@provider.prefetch(@resource_hash)
|
262
|
+
@res_ghost.provider.get(:ensure).should == :ghost
|
263
|
+
end
|
264
|
+
|
265
|
+
it "should set :ensure to :ghost if not found in fstab but mounted" do
|
266
|
+
@provider.prefetch(@resource_hash)
|
267
|
+
@res_mounted.provider.get(:ensure).should == :mounted
|
268
|
+
end
|
187
269
|
|
188
|
-
it "should
|
270
|
+
it "should set :ensure to :absent if not found in fstab and not mounted" do
|
271
|
+
@provider.prefetch(@resource_hash)
|
272
|
+
@res_absent.provider.get(:ensure).should == :absent
|
273
|
+
end
|
189
274
|
|
190
|
-
it "should specify the filesystem when remounting a filesystem"
|
191
275
|
end
|
276
|
+
|
192
277
|
end
|
@@ -19,18 +19,13 @@ describe Puppet::Provider::Mount do
|
|
19
19
|
|
20
20
|
describe Puppet::Provider::Mount, " when mounting" do
|
21
21
|
|
22
|
-
|
23
|
-
@mounter.stubs(:
|
24
|
-
@mounter.expects(:mountcmd)
|
25
|
-
|
26
|
-
@mounter.mount
|
22
|
+
before :each do
|
23
|
+
@mounter.stubs(:get).with(:ensure).returns(:mounted)
|
27
24
|
end
|
28
25
|
|
29
|
-
it "should
|
30
|
-
@mounter.meta_def(:flush) { }
|
31
|
-
@mounter.expects(:flush)
|
32
|
-
@mounter.stubs(:mountcmd)
|
26
|
+
it "should use the 'mountcmd' method to mount" do
|
33
27
|
@mounter.stubs(:options).returns(nil)
|
28
|
+
@mounter.expects(:mountcmd)
|
34
29
|
|
35
30
|
@mounter.mount
|
36
31
|
end
|
@@ -48,6 +43,23 @@ describe Puppet::Provider::Mount do
|
|
48
43
|
|
49
44
|
@mounter.mount
|
50
45
|
end
|
46
|
+
|
47
|
+
it "should update the :ensure state to :mounted if it was :unmounted before" do
|
48
|
+
@mounter.expects(:mountcmd)
|
49
|
+
@mounter.stubs(:options).returns(nil)
|
50
|
+
@mounter.expects(:get).with(:ensure).returns(:unmounted)
|
51
|
+
@mounter.expects(:set).with(:ensure => :mounted)
|
52
|
+
@mounter.mount
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should update the :ensure state to :ghost if it was :absent before" do
|
56
|
+
@mounter.expects(:mountcmd)
|
57
|
+
@mounter.stubs(:options).returns(nil)
|
58
|
+
@mounter.expects(:get).with(:ensure).returns(:absent)
|
59
|
+
@mounter.expects(:set).with(:ensure => :ghost)
|
60
|
+
@mounter.mount
|
61
|
+
end
|
62
|
+
|
51
63
|
end
|
52
64
|
|
53
65
|
describe Puppet::Provider::Mount, " when remounting" do
|
@@ -77,69 +89,58 @@ describe Puppet::Provider::Mount do
|
|
77
89
|
|
78
90
|
describe Puppet::Provider::Mount, " when unmounting" do
|
79
91
|
|
92
|
+
before :each do
|
93
|
+
@mounter.stubs(:get).with(:ensure).returns(:unmounted)
|
94
|
+
end
|
95
|
+
|
80
96
|
it "should call the :umount command with the resource name" do
|
81
97
|
@mounter.expects(:umount).with(@name)
|
82
98
|
@mounter.unmount
|
83
99
|
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe Puppet::Provider::Mount, " when determining if it is mounted" do
|
87
|
-
|
88
|
-
it "should parse the results of running the mount command with no arguments" do
|
89
|
-
Facter.stubs(:value).returns("whatever")
|
90
|
-
@mounter.expects(:mountcmd).returns("")
|
91
100
|
|
92
|
-
|
101
|
+
it "should update the :ensure state to :absent if it was :ghost before" do
|
102
|
+
@mounter.expects(:umount).with(@name).returns true
|
103
|
+
@mounter.expects(:get).with(:ensure).returns(:ghost)
|
104
|
+
@mounter.expects(:set).with(:ensure => :absent)
|
105
|
+
@mounter.unmount
|
93
106
|
end
|
94
107
|
|
95
|
-
it "should
|
96
|
-
|
97
|
-
@mounter.expects(:
|
98
|
-
|
99
|
-
@mounter.
|
108
|
+
it "should update the :ensure state to :unmounted if it was :mounted before" do
|
109
|
+
@mounter.expects(:umount).with(@name).returns true
|
110
|
+
@mounter.expects(:get).with(:ensure).returns(:mounted)
|
111
|
+
@mounter.expects(:set).with(:ensure => :unmounted)
|
112
|
+
@mounter.unmount
|
100
113
|
end
|
101
114
|
|
102
|
-
|
103
|
-
Facter.stubs(:value).with("operatingsystem").returns("Darwin")
|
104
|
-
@mounter.expects(:mountcmd).returns("/dev/disk03 on / (local, journaled)\ndevfs on /dev")
|
105
|
-
|
106
|
-
@mounter.should be_mounted
|
107
|
-
end
|
115
|
+
end
|
108
116
|
|
109
|
-
|
110
|
-
Facter.stubs(:value).with("operatingsystem").returns("Solaris")
|
111
|
-
@mounter.expects(:mountcmd).returns("/ on /dev/dsk/whatever\n/var on /dev/dsk/other")
|
117
|
+
describe Puppet::Provider::Mount, " when determining if it is mounted" do
|
112
118
|
|
113
|
-
|
119
|
+
it "should query the property_hash" do
|
120
|
+
@mounter.expects(:get).with(:ensure).returns(:mounted)
|
121
|
+
@mounter.mounted?
|
114
122
|
end
|
115
123
|
|
116
|
-
it "should
|
117
|
-
|
118
|
-
@mounter.
|
119
|
-
|
120
|
-
@mounter.should be_mounted
|
124
|
+
it "should return true if prefetched value is :mounted" do
|
125
|
+
@mounter.stubs(:get).with(:ensure).returns(:mounted)
|
126
|
+
@mounter.mounted? == true
|
121
127
|
end
|
122
128
|
|
123
|
-
it "should
|
124
|
-
|
125
|
-
|
126
|
-
@mounter.expects(:mountcmd).returns(mount_data)
|
127
|
-
|
128
|
-
@mounter.should be_mounted
|
129
|
+
it "should return true if prefetched value is :ghost" do
|
130
|
+
@mounter.stubs(:get).with(:ensure).returns(:ghost)
|
131
|
+
@mounter.mounted? == true
|
129
132
|
end
|
130
133
|
|
131
|
-
it "should
|
132
|
-
|
133
|
-
@mounter.
|
134
|
-
|
135
|
-
@mounter.should be_mounted
|
134
|
+
it "should return false if prefetched value is :absent" do
|
135
|
+
@mounter.stubs(:get).with(:ensure).returns(:absent)
|
136
|
+
@mounter.mounted? == false
|
136
137
|
end
|
137
138
|
|
138
|
-
it "should
|
139
|
-
|
140
|
-
@mounter.
|
141
|
-
|
142
|
-
@mounter.should_not be_mounted
|
139
|
+
it "should return false if prefetched value is :unmounted" do
|
140
|
+
@mounter.stubs(:get).with(:ensure).returns(:unmounted)
|
141
|
+
@mounter.mounted? == false
|
143
142
|
end
|
143
|
+
|
144
144
|
end
|
145
|
+
|
145
146
|
end
|