- From: Uwe Bartels <
>
- To:
- Subject: [chef] lwrp and special behavior
- Date: Thu, 13 Nov 2014 15:33:55 +0100
Hiho,
I have problems integrating a special handling in lwrp.
In an apache karaf osgi installation I want to install additional osgi
bundles. Especially after the initial start I need to wait until the
state of all osgi bundles is "Active" before installing new ones.
Technically no so difficult. But additionally I don't want to see in the
output of chef that chef is actually doing something.
In normal chef mode - the resource should either run into an exception
on error, wait until the state of the osgi server is well or time out.
so if everything is fine I allways want to see the output
* karaf_server[wait until all osgi modules are ready] action wait (up
to date)
In why-run similar, it could give the same output or no output at all,
but never does anything - no checking.
How can I achieve that?
Currently I have a small lwrp that has no converge_by method and set
new_resource.updated_by_last_action(false). That works well in normal
chef mode but of course not in whyrun mode, when the "client" command is
not available.
def whyrun_supported?
true
end
use_inline_resources
action :wait do
wait_for_serverstart_finish(new_resource.client)
new_resource.updated_by_last_action(false)
end
def wait_for_serverstart_finish(client)
Chef::Log.debug "calling: wait_for_serverstart_finish(#{client})"
cmdStr = "#{client} 'osgi:list -s -t 0'|egrep '^\['|egrep -v
'Active'|wc -l|grep '^0$' >/dev/null"
shell = Mixlib::ShellOut.new(cmdStr,{:timeout=>600})
shell.run_command
maxtries=60
tries=1
while (shell.exitstatus == 0 && tries<maxtries) do
sleep(1)
shell.run_command
tries+=1
end
shell.error! # raise an exception on error
end
Any help is appreciated.
Best...
Uwe
- [chef] lwrp and special behavior, Uwe Bartels, 11/13/2014
Archive powered by MHonArc 2.6.16.