Skip to content

Instantly share code, notes, and snippets.

@markllama
Created September 26, 2013 19:00
Show Gist options
  • Save markllama/6718972 to your computer and use it in GitHub Desktop.
Save markllama/6718972 to your computer and use it in GitHub Desktop.
The portion of openshift.rb which defines the cartridge_repository_action function for managing cartridges on OpenShift nodes.
def cartridge_repository_action
Log.instance.info("action: #{request.action}_action, agent=#{request.agent}, data=#{request.data.pretty_inspect}")
action = request[:action]
path = request[:path]
name = request[:name]
version = request[:version]
cartridge_version = request[:cartridge_version]
reply[:output] = "#{action} succeeded for #{path}"
begin
case action
when 'install'
::OpenShift::Runtime::CartridgeRepository.instance.install(path)
when 'erase'
::OpenShift::Runtime::CartridgeRepository.instance.erase(name, version, cartridge_version)
when 'list'
reply[:output] = ::OpenShift::Runtime::CartridgeRepository.instance.to_s
else
reply.fail(
"#{action} is not implemented. openshift.ddl may be out of date.",
2)
return
end
rescue Exception => e
report_exception e
Log.instance.info("cartridge_repository_action(#{action}): failed #{e.message}\n#{e.backtrace}")
reply.fail!("#{action} failed for #{path} #{e.message}", 4)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment