Skip to content

Commit fa817e8

Browse files
committed
fixes for erl_call
1 parent 0032da3 commit fa817e8

2 files changed

Lines changed: 22 additions & 17 deletions

File tree

chef/lib/chef/provider/erl_call.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ class ErlCall < Chef::Provider
2727

2828
def initialize(node, new_resource)
2929
super(node, new_resource)
30-
action_run
3130
end
3231

33-
def action_run
32+
def load_current_resource
3433
case @new_resource.name_type
3534
when "sname"
3635
node = "-sname #{@new_resource.node_name}"
@@ -50,11 +49,15 @@ def action_run
5049
distributed = ""
5150
end
5251

53-
status = popen4("erl_call -e #{distributed} #{cookie} #{node}") do |pid, stdin, stdout, stderr|
52+
command = "erl_call -e #{distributed} #{node} #{cookie}"
53+
54+
status = popen4(command, :waitlast => true) do |pid, stdin, stdout, stderr|
5455
Chef::Log.info("Running erl_call '#{@new_resource.name}' on '#{@new_resource.node_name}'")
55-
@new_resource.code.each { |line| stdin.puts "#{line}" }
56+
Chef::Log.debug("erl_call '#{@new_resource.name}' command: #{command}")
57+
Chef::Log.debug("erl_call '#{@new_resource.name}' code: #{@new_resource.code}")
58+
@new_resource.code.each { |line| stdin.puts "#{line.chomp!}" }
5659
stdin.close
57-
Chef::Log.debug("Output from erl_call on '#{@new_resource.node_name}': ")
60+
Chef::Log.debug("erl_call '#{@new_resource.name}' output: ")
5861
stdout.each { |line| Chef::Log.debug("#{line}")}
5962
end
6063
end

chef/lib/chef/resource/erl_call.rb

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,47 +25,49 @@ class ErlCall < Chef::Resource
2525
def initialize(name, collection=nil, node=nil)
2626
super(name, collection, node)
2727
@resource_name = :erl_call
28+
29+
@code = "q()."
2830
@cookie = nil
29-
@node_name = "chef@localhost"
30-
@name_type = "sname"
3131
@distributed = false
32+
@name_type = "sname"
33+
@node_name = "chef@localhost"
3234
end
3335

34-
def cookie(arg=nil)
36+
def code(arg=nil)
3537
set_or_return(
36-
:cookie,
38+
:code,
3739
arg,
3840
:kind_of => [ String ]
3941
)
4042
end
4143

42-
def distributed(arg=nil)
44+
def cookie(arg=nil)
4345
set_or_return(
44-
:distributed,
46+
:cookie,
4547
arg,
46-
:kind_of => [ TrueClass, FalseClass ]
48+
:kind_of => [ String ]
4749
)
4850
end
4951

50-
def name(arg=nil)
52+
def distributed(arg=nil)
5153
set_or_return(
52-
:name,
54+
:distributed,
5355
arg,
54-
:kind_of => [ String ]
56+
:kind_of => [ TrueClass, FalseClass ]
5557
)
5658
end
5759

5860
def name_type(arg=nil)
5961
set_or_return(
60-
:sname,
62+
:name_type,
6163
arg,
6264
:kind_of => [ String ]
6365
)
6466
end
6567

6668
def node_name(arg=nil)
6769
set_or_return(
68-
:name,
70+
:node_name,
6971
arg,
7072
:kind_of => [ String ]
7173
)

0 commit comments

Comments
 (0)