33 @resource[:fmri]) |
33 @resource[:fmri]) |
34 if @resource[:ensure] == :absent |
34 if @resource[:ensure] == :absent |
35 # only test for the existance of the property and not the value |
35 # only test for the existance of the property and not the value |
36 return p[:exit] == 0 |
36 return p[:exit] == 0 |
37 elsif @resource[:ensure] == :present |
37 elsif @resource[:ensure] == :present |
38 # if the property doesn't exist at all, the exit code will be 1 |
38 # if the property group or property doesn't exist at all, the exit |
|
39 # code will be 1 |
39 return false if p[:exit] != 0 |
40 return false if p[:exit] != 0 |
40 |
41 |
41 # strip the leading and trailing parens if resource[:property] |
42 # turn @resource[:value] into a simple string by dropping the first |
42 # contains a slash as this indicates that a value is associated |
43 # and last array elements (the parens) and removing all double |
43 # with it. |
44 # quotes |
|
45 simple = @resource[:value][1..-2].join(" ")[1..-2].gsub(/\"/, "") |
|
46 |
|
47 # For properties, check the value against what's in SMF. For |
|
48 # property groups, svcprop already verified the PG exists by not |
|
49 # failing |
44 if @resource[:property].include? "/" |
50 if @resource[:property].include? "/" |
45 return p[:out].strip == \ |
51 return p[:out].strip == simple |
46 @resource[:value][1..-2].join(" ")[1..-2] |
52 else |
|
53 return p[:exit] == 0 |
47 end |
54 end |
48 # resource[:property] is a property group, not a property. |
|
49 # There is no value to manipulate, but the property needs to be |
|
50 # created, so return true. |
|
51 return p[:exit] == 0 |
|
52 end |
55 end |
53 end |
56 end |
54 |
57 |
55 def create |
58 def create |
56 # Check to see if the service instance exists |
59 # Check to see if the service instance exists |
57 cmd = Array[command(:svccfg), "select", @resource[:fmri]] |
60 cmd = Array[command(:svccfg), "select", @resource[:fmri]] |
58 svc_exist = exec_cmd(cmd) |
61 svc_exist = exec_cmd(cmd) |
59 |
62 |
60 # Create the service instance if it doesn't exist |
63 # Raise an error if the entity does not exist |
61 if svc_exist[:exit] != 0 |
64 if svc_exist[:exit] != 0 |
62 service, instance = \ |
65 raise Puppet::Error, "SMF entity #{@resource[:fmri]} does not exist" |
63 @resource[:fmri].split(":").reject{|n| n == "svc"} |
|
64 svccfg("-s", service, "add", instance) |
|
65 end |
66 end |
|
67 |
|
68 args = ["-s", @resource[:fmri]] |
66 |
69 |
67 # Add the property |
|
68 if @resource[:property].include? "/" |
70 if @resource[:property].include? "/" |
69 svccfg("-s", @resource[:fmri], "setprop", @resource[:property], |
71 args << "setprop" << @resource[:property] << "=" |
70 "=", @resource[:type] + ":", @resource[:value]) |
72 if type = @resource[:type] and type != nil |
|
73 args << @resource[:type] + ":" |
|
74 end |
|
75 args << @resource[:value] |
71 else |
76 else |
72 svccfg("-s", @resource[:fmri], "addpg", @resource[:property], |
77 args << "addpg" << @resource[:property] << @resource[:type] |
73 @resource[:type]) |
|
74 end |
78 end |
|
79 svccfg(args) |
75 svccfg("-s", @resource[:fmri], "refresh") |
80 svccfg("-s", @resource[:fmri], "refresh") |
76 end |
81 end |
77 |
82 |
78 def destroy |
83 def destroy |
79 svccfg("-s", @resource[:fmri], "delprop", @resource[:property]) |
84 if @resource[:property].include? "/" |
|
85 svccfg("-s", @resource[:fmri], "delprop", @resource[:property]) |
|
86 else |
|
87 svccfg("-s", @resource[:fmri], "delpg", @resource[:property]) |
|
88 end |
80 svccfg("-s", @resource[:fmri], "refresh") |
89 svccfg("-s", @resource[:fmri], "refresh") |
81 end |
90 end |
82 |
91 |
83 def delcust |
92 def delcust |
84 list_cmd = Array[command(:svccfg), "-s", @resource[:fmri], "listprop", |
93 list_cmd = Array[command(:svccfg), "-s", @resource[:fmri], "listprop", |