role.rb
retry_scale
/usr/lib/one/oneflow/lib/models/role.rb
in
retry_scale
def retry_scale()
nodes_dispose = get_nodes.select { |node|
node['disposed'] == "1"
}
shutdown_nodes(nodes_dispose, true)
set_cardinality( get_nodes.size() - n_dispose.size() )
end
# Deletes VMs in DONE or FAILED, and sends a boot action to VMs in UNKNOWN
def recover()
nodes = @body['nodes']
new_nodes = []
/usr/lib/one/oneflow/lib/models/role.rb
in
recover_scale
def recover_warning()
recover()
deploy()
end
def recover_scale()
recover()
retry_scale()
end
########################################################################
########################################################################
/usr/lib/one/oneflow/lib/models/service.rb
in
recover
end
self.set_state(Service::STATE['DEPLOYING'])
elsif self.state == Service::STATE['FAILED_SCALING']
@roles.each do |name, role|
if role.state == Role::STATE['FAILED_SCALING']
role.recover_scale()
role.set_state(Role::STATE['SCALING'])
end
end
self.set_state(Service::STATE['SCALING'])
elsif self.state == Service::STATE['FAILED_UNDEPLOYING']
/usr/lib/one/oneflow/lib/models/service.rb
in
each
role.recover_deployment()
end
end
self.set_state(Service::STATE['DEPLOYING'])
elsif self.state == Service::STATE['FAILED_SCALING']
@roles.each do |name, role|
if role.state == Role::STATE['FAILED_SCALING']
role.recover_scale()
role.set_state(Role::STATE['SCALING'])
end
end
self.set_state(Service::STATE['SCALING'])
/usr/lib/one/oneflow/lib/models/service.rb
in
recover
role.recover_deployment()
end
end
self.set_state(Service::STATE['DEPLOYING'])
elsif self.state == Service::STATE['FAILED_SCALING']
@roles.each do |name, role|
if role.state == Role::STATE['FAILED_SCALING']
role.recover_scale()
role.set_state(Role::STATE['SCALING'])
end
end
self.set_state(Service::STATE['SCALING'])
/usr/lib/one/oneflow/oneflow-server.rb
in
POST /service/:id/action
rc = nil
service = service_pool.get(params[:id]) { |service|
rc = case action['perform']
when 'shutdown'
service.shutdown
when 'recover', 'deploy'
service.recover
when 'chown'
if opts && opts['owner_id']
args = Array.new
args << opts['owner_id'].to_i
args << (opts['group_id'] || -1).to_i
ret = service.chown(*args)
/usr/lib/one/oneflow/lib/models/service_pool.rb
in
call
@@mutex_hash.delete_if { |s_id, entry|
entry[1] == 0
}
end
}
obj_mutex.synchronize {
block.call(service)
}
@@mutex.synchronize {
entry[1] = entry[1] - 1
}
end
/usr/lib/one/oneflow/lib/models/service_pool.rb
in
get
@@mutex_hash.delete_if { |s_id, entry|
entry[1] == 0
}
end
}
obj_mutex.synchronize {
block.call(service)
}
@@mutex.synchronize {
entry[1] = entry[1] - 1
}
end
/usr/lib/one/oneflow/lib/models/service_pool.rb
in
synchronize
if @@mutex_hash.size > 10000
@@mutex_hash.delete_if { |s_id, entry|
entry[1] == 0
}
end
}
obj_mutex.synchronize {
block.call(service)
}
@@mutex.synchronize {
entry[1] = entry[1] - 1
}
end
/usr/lib/one/oneflow/lib/models/service_pool.rb
in
get
if @@mutex_hash.size > 10000
@@mutex_hash.delete_if { |s_id, entry|
entry[1] == 0
}
end
}
obj_mutex.synchronize {
block.call(service)
}
@@mutex.synchronize {
entry[1] = entry[1] - 1
}
end
/usr/lib/one/oneflow/oneflow-server.rb
in
POST /service/:id/action
post '/service/:id/action' do
service_pool = OpenNebula::ServicePool.new(@client)
action = JSON.parse(request.body.read)['action']
opts = action['params']
rc = nil
service = service_pool.get(params[:id]) { |service|
rc = case action['perform']
when 'shutdown'
service.shutdown
when 'recover', 'deploy'
service.recover
when 'chown'
if opts && opts['owner_id']
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
call
options.each_pair { |option, args| send(option, *args) }
method_name = "#{verb} #{path}"
unbound_method = generate_method(method_name, &block)
pattern, keys = compile path
conditions, @conditions = @conditions, []
wrapper = block.arity != 0 ?
proc { |a,p| unbound_method.bind(a).call(*p) } :
proc { |a,p| unbound_method.bind(a).call }
wrapper.instance_variable_set(:@route_name, method_name)
[ pattern, keys, conditions, wrapper ]
end
def compile(path)
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
compile!
options.each_pair { |option, args| send(option, *args) }
method_name = "#{verb} #{path}"
unbound_method = generate_method(method_name, &block)
pattern, keys = compile path
conditions, @conditions = @conditions, []
wrapper = block.arity != 0 ?
proc { |a,p| unbound_method.bind(a).call(*p) } :
proc { |a,p| unbound_method.bind(a).call }
wrapper.instance_variable_set(:@route_name, method_name)
[ pattern, keys, conditions, wrapper ]
end
def compile(path)
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
[]
# Run routes defined on the class and all superclasses.
def route!(base = settings, pass_block = nil)
if routes = base.routes[@request.request_method]
routes.each do |pattern, keys, conditions, block|
pass_block = process_route(pattern, keys, conditions) do |*args|
env['sinatra.route'] = block.instance_variable_get(:@route_name)
route_eval { block[*args] }
end
end
end
# Run routes defined in superclass.
if base.superclass.respond_to?(:routes)
return route!(base.superclass, pass_block)
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
route!
# Run routes defined on the class and all superclasses.
def route!(base = settings, pass_block = nil)
if routes = base.routes[@request.request_method]
routes.each do |pattern, keys, conditions, block|
pass_block = process_route(pattern, keys, conditions) do |*args|
env['sinatra.route'] = block.instance_variable_get(:@route_name)
route_eval { block[*args] }
end
end
end
# Run routes defined in superclass.
if base.superclass.respond_to?(:routes)
return route!(base.superclass, pass_block)
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
route_eval
route_eval(&pass_block) if pass_block
route_missing
end
# Run a route block and throw :halt with the result.
def route_eval
throw :halt, yield
end
# If the current request matches pattern and conditions, fill params
# with keys and call the given block.
# Revert params afterwards.
#
# Returns pass block.
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
route!
# Run routes defined on the class and all superclasses.
def route!(base = settings, pass_block = nil)
if routes = base.routes[@request.request_method]
routes.each do |pattern, keys, conditions, block|
pass_block = process_route(pattern, keys, conditions) do |*args|
env['sinatra.route'] = block.instance_variable_get(:@route_name)
route_eval { block[*args] }
end
end
end
# Run routes defined in superclass.
if base.superclass.respond_to?(:routes)
return route!(base.superclass, pass_block)
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
process_route
if values.any?
original, @params = params, params.merge('splat' => [], 'captures' => values)
keys.zip(values) { |k,v| Array === @params[k] ? @params[k] << v : @params[k] = v if v }
end
catch(:pass) do
conditions.each { |c| throw :pass if c.bind(self).call == false }
block ? block[self, values] : yield(self, values)
end
ensure
@params = original if original
end
# No matching route was found or all routes passed. The default
# implementation is to forward the request downstream when running
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
catch
values += match.captures.to_a.map { |v| force_encoding URI.unescape(v) if v }
if values.any?
original, @params = params, params.merge('splat' => [], 'captures' => values)
keys.zip(values) { |k,v| Array === @params[k] ? @params[k] << v : @params[k] = v if v }
end
catch(:pass) do
conditions.each { |c| throw :pass if c.bind(self).call == false }
block ? block[self, values] : yield(self, values)
end
ensure
@params = original if original
end
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
process_route
values += match.captures.to_a.map { |v| force_encoding URI.unescape(v) if v }
if values.any?
original, @params = params, params.merge('splat' => [], 'captures' => values)
keys.zip(values) { |k,v| Array === @params[k] ? @params[k] << v : @params[k] = v if v }
end
catch(:pass) do
conditions.each { |c| throw :pass if c.bind(self).call == false }
block ? block[self, values] : yield(self, values)
end
ensure
@params = original if original
end
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
route!
base.filters[type].each { |args| process_route(*args) }
end
# Run routes defined on the class and all superclasses.
def route!(base = settings, pass_block = nil)
if routes = base.routes[@request.request_method]
routes.each do |pattern, keys, conditions, block|
pass_block = process_route(pattern, keys, conditions) do |*args|
env['sinatra.route'] = block.instance_variable_get(:@route_name)
route_eval { block[*args] }
end
end
end
# Run routes defined in superclass.
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
each
filter! type, base.superclass if base.superclass.respond_to?(:filters)
base.filters[type].each { |args| process_route(*args) }
end
# Run routes defined on the class and all superclasses.
def route!(base = settings, pass_block = nil)
if routes = base.routes[@request.request_method]
routes.each do |pattern, keys, conditions, block|
pass_block = process_route(pattern, keys, conditions) do |*args|
env['sinatra.route'] = block.instance_variable_get(:@route_name)
route_eval { block[*args] }
end
end
end
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
route!
filter! type, base.superclass if base.superclass.respond_to?(:filters)
base.filters[type].each { |args| process_route(*args) }
end
# Run routes defined on the class and all superclasses.
def route!(base = settings, pass_block = nil)
if routes = base.routes[@request.request_method]
routes.each do |pattern, keys, conditions, block|
pass_block = process_route(pattern, keys, conditions) do |*args|
env['sinatra.route'] = block.instance_variable_get(:@route_name)
route_eval { block[*args] }
end
end
end
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
dispatch!
end
# Dispatch a request with error handling.
def dispatch!
invoke do
static! if settings.static? && (request.get? || request.head?)
filter! :before
route!
end
rescue ::Exception => boom
invoke { handle_exception!(boom) }
ensure
begin
filter! :after unless env['sinatra.static_file']
rescue ::Exception => boom
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
invoke
# Creates a Hash with indifferent access.
def indifferent_hash
Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
end
# Run the block with 'throw :halt' support and apply result to the response.
def invoke
res = catch(:halt) { yield }
res = [res] if Fixnum === res or String === res
if Array === res and Fixnum === res.first
res = res.dup
status(res.shift)
body(res.pop)
headers(*res)
elsif res.respond_to? :each
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
catch
# Creates a Hash with indifferent access.
def indifferent_hash
Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
end
# Run the block with 'throw :halt' support and apply result to the response.
def invoke
res = catch(:halt) { yield }
res = [res] if Fixnum === res or String === res
if Array === res and Fixnum === res.first
res = res.dup
status(res.shift)
body(res.pop)
headers(*res)
elsif res.respond_to? :each
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
invoke
# Creates a Hash with indifferent access.
def indifferent_hash
Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
end
# Run the block with 'throw :halt' support and apply result to the response.
def invoke
res = catch(:halt) { yield }
res = [res] if Fixnum === res or String === res
if Array === res and Fixnum === res.first
res = res.dup
status(res.shift)
body(res.pop)
headers(*res)
elsif res.respond_to? :each
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
dispatch!
body res
end
nil # avoid double setting the same response tuple twice
end
# Dispatch a request with error handling.
def dispatch!
invoke do
static! if settings.static? && (request.get? || request.head?)
filter! :before
route!
end
rescue ::Exception => boom
invoke { handle_exception!(boom) }
ensure
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
call!
@request = Request.new(env)
@response = Response.new
@params = indifferent_params(@request.params)
template_cache.clear if settings.reload_templates
force_encoding(@params)
@response['Content-Type'] = nil
invoke { dispatch! }
invoke { error_block!(response.status) } unless @env['sinatra.error']
unless @response['Content-Type']
if Array === body and body[0].respond_to? :content_type
content_type body[0].content_type
else
content_type :html
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
invoke
# Creates a Hash with indifferent access.
def indifferent_hash
Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
end
# Run the block with 'throw :halt' support and apply result to the response.
def invoke
res = catch(:halt) { yield }
res = [res] if Fixnum === res or String === res
if Array === res and Fixnum === res.first
res = res.dup
status(res.shift)
body(res.pop)
headers(*res)
elsif res.respond_to? :each
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
catch
# Creates a Hash with indifferent access.
def indifferent_hash
Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
end
# Run the block with 'throw :halt' support and apply result to the response.
def invoke
res = catch(:halt) { yield }
res = [res] if Fixnum === res or String === res
if Array === res and Fixnum === res.first
res = res.dup
status(res.shift)
body(res.pop)
headers(*res)
elsif res.respond_to? :each
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
invoke
# Creates a Hash with indifferent access.
def indifferent_hash
Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
end
# Run the block with 'throw :halt' support and apply result to the response.
def invoke
res = catch(:halt) { yield }
res = [res] if Fixnum === res or String === res
if Array === res and Fixnum === res.first
res = res.dup
status(res.shift)
body(res.pop)
headers(*res)
elsif res.respond_to? :each
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
call!
@request = Request.new(env)
@response = Response.new
@params = indifferent_params(@request.params)
template_cache.clear if settings.reload_templates
force_encoding(@params)
@response['Content-Type'] = nil
invoke { dispatch! }
invoke { error_block!(response.status) } unless @env['sinatra.error']
unless @response['Content-Type']
if Array === body and body[0].respond_to? :content_type
content_type body[0].content_type
else
content_type :html
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
call
@app = app
@template_cache = Tilt::Cache.new
yield self if block_given?
end
# Rack call interface.
def call(env)
dup.call!(env)
end
def call!(env) # :nodoc:
@env = env
@request = Request.new(env)
@response = Response.new
@params = indifferent_params(@request.params)
/usr/lib/ruby/gems/1.8/gems/rack-1.5.2/lib/rack/session/abstract/id.rb
in
context
def call(env)
context(env)
end
def context(env, app=@app)
prepare_session(env)
status, headers, body = app.call(env)
commit_session(env, status, headers, body)
end
private
def initialize_sid
@sidbits = @default_options[:sidbits]
/usr/lib/ruby/gems/1.8/gems/rack-1.5.2/lib/rack/session/abstract/id.rb
in
call
@default_options = self.class::DEFAULT_OPTIONS.merge(options)
@key = @default_options.delete(:key)
@cookie_only = @default_options.delete(:cookie_only)
initialize_sid
end
def call(env)
context(env)
end
def context(env, app=@app)
prepare_session(env)
status, headers, body = app.call(env)
commit_session(env, status, headers, body)
end
/usr/lib/ruby/gems/1.8/gems/rack-1.5.2/lib/rack/commonlogger.rb
in
call_without_check
def initialize(app, logger=nil)
@app = app
@logger = logger
end
def call(env)
began_at = Time.now
status, header, body = @app.call(env)
header = Utils::HeaderHash.new(header)
body = BodyProxy.new(body) { log(env, status, header, began_at) }
[status, header, body]
end
private
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
call
env['sinatra.commonlogger'] ? @app.call(env) : super
end
superclass.class_eval do
alias call_without_check call unless method_defined? :call_without_check
def call(env)
env['sinatra.commonlogger'] = true
call_without_check(env)
end
end
end
class NotFound < NameError #:nodoc:
def http_status; 404 end
end
/usr/lib/ruby/gems/1.8/gems/rack-protection-1.5.0/lib/rack/protection/xss_header.rb
in
call
#
# Options:
# xss_mode:: How the browser should prevent the attack (default: :block)
class XSSHeader < Base
default_options :xss_mode => :block, :nosniff => true
def call(env)
status, headers, body = @app.call(env)
headers['X-XSS-Protection'] ||= "1; mode=#{options[:xss_mode]}" if html? headers
headers['X-Content-Type-Options'] ||= 'nosniff' if options[:nosniff]
[status, headers, body]
end
end
end
end
/usr/lib/ruby/gems/1.8/gems/rack-protection-1.5.0/lib/rack/protection/path_traversal.rb
in
call
#
# Unescapes '/' and '.', expands +path_info+.
# Thus <tt>GET /foo/%2e%2e%2fbar</tt> becomes <tt>GET /bar</tt>.
class PathTraversal < Base
def call(env)
path_was = env["PATH_INFO"]
env["PATH_INFO"] = cleanup path_was if path_was && !path_was.empty?
app.call env
ensure
env["PATH_INFO"] = path_was
end
def cleanup(path)
parts = []
unescaped = path.gsub('%2e', '.').gsub('%2f', '/')
/usr/lib/ruby/gems/1.8/gems/rack-protection-1.5.0/lib/rack/protection/json_csrf.rb
in
call
# Array prototype has been patched to track data. Checks the referrer
# even on GET requests if the content type is JSON.
class JsonCsrf < Base
default_reaction :deny
def call(env)
request = Request.new(env)
status, headers, body = app.call(env)
if has_vector? request, headers
warn env, "attack prevented by #{self.class}"
react(env)
else
[status, headers, body]
end
/usr/lib/ruby/gems/1.8/gems/rack-protection-1.5.0/lib/rack/protection/base.rb
in
call
end
def call(env)
unless accepts? env
warn env, "attack prevented by #{self.class}"
result = react env
end
result or app.call(env)
end
def react(env)
result = send(options[:reaction], env)
result if Array === result and result.size == 3
end
/usr/lib/ruby/gems/1.8/gems/rack-protection-1.5.0/lib/rack/protection/frame_options.rb
in
call
frame_options = options[:frame_options]
frame_options = options[:frame_options].to_s.upcase unless frame_options.respond_to? :to_str
frame_options.to_str
end
end
def call(env)
status, headers, body = @app.call(env)
headers['X-Frame-Options'] ||= frame_options if html? headers
[status, headers, body]
end
end
end
end
/usr/lib/ruby/gems/1.8/gems/rack-1.5.2/lib/rack/nulllogger.rb
in
call
class NullLogger
def initialize(app)
@app = app
end
def call(env)
env['rack.logger'] = self
@app.call(env)
end
def info(progname = nil, &block); end
def debug(progname = nil, &block); end
def warn(progname = nil, &block); end
def error(progname = nil, &block); end
def fatal(progname = nil, &block); end
/usr/lib/ruby/gems/1.8/gems/rack-1.5.2/lib/rack/head.rb
in
call
# Rack::Head returns an empty body for all HEAD requests. It leaves
# all other requests unchanged.
def initialize(app)
@app = app
end
def call(env)
status, headers, body = @app.call(env)
if env["REQUEST_METHOD"] == "HEAD"
body.close if body.respond_to? :close
[status, headers, []]
else
[status, headers, body]
end
/usr/lib/ruby/gems/1.8/gems/rack-1.5.2/lib/rack/methodoverride.rb
in
call
method = method_override(env)
if HTTP_METHODS.include?(method)
env["rack.methodoverride.original_method"] = env["REQUEST_METHOD"]
env["REQUEST_METHOD"] = method
end
end
@app.call(env)
end
def method_override(env)
req = Request.new(env)
method = req.POST[METHOD_OVERRIDE_PARAM_KEY] ||
env[HTTP_METHOD_OVERRIDE_HEADER]
method.to_s.upcase
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/showexceptions.rb
in
call
def initialize(app)
@app = app
@template = ERB.new(TEMPLATE)
end
def call(env)
@app.call(env)
rescue Exception => e
errors, env["rack.errors"] = env["rack.errors"], @@eats_errors
if prefers_plain_text?(env)
content_type = "text/plain"
body = [dump_exception(e)]
else
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
call
# Some Rack handlers (Thin, Rainbows!) implement an extended body object protocol, however,
# some middleware (namely Rack::Lint) will break it by not mirroring the methods in question.
# This middleware will detect an extended body object and will make sure it reaches the
# handler directly. We do this here, so our middleware and middleware set up by the app will
# still be able to run.
class ExtendedRack < Struct.new(:app)
def call(env)
result, callback = app.call(env), env['async.callback']
return result unless callback and async?(*result)
after_response { callback.call result }
setup_close(env, *result)
throw :async
end
private
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
call
end
def helpers
@instance
end
def call(env)
@stack.call(env)
end
def inspect
"#<#{@instance.class} app_file=#{settings.app_file.inspect}>"
end
end
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
call
setup_default_middleware builder
setup_middleware builder
builder.run app
builder
end
def call(env)
synchronize { prototype.call(env) }
end
# Like Kernel#caller but excluding certain magic entries and without
# line / method information; the resulting array contains filenames only.
def caller_files
cleaned_caller(1).flatten
end
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
synchronize
end
@@mutex = Mutex.new
def synchronize(&block)
if lock?
@@mutex.synchronize(&block)
else
yield
end
end
# used for deprecation warnings
def warn(message)
super message + "\n\tfrom #{cleaned_caller.first.join(':')}"
end
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
call
setup_default_middleware builder
setup_middleware builder
builder.run app
builder
end
def call(env)
synchronize { prototype.call(env) }
end
# Like Kernel#caller but excluding certain magic entries and without
# line / method information; the resulting array contains filenames only.
def caller_files
cleaned_caller(1).flatten
end
/usr/lib/ruby/gems/1.8/gems/thin-1.5.1/lib/thin/connection.rb
in
pre_process
# When we're under a non-async framework like rails, we can still spawn
# off async responses using the callback info, so there's little point
# in removing this.
response = AsyncResponse
catch(:async) do
# Process the request calling the Rack adapter
response = @app.call(@request.env)
end
response
rescue Exception
handle_error
# Pass through error response
can_persist? && @request.persistent? ? Response::PERSISTENT_ERROR : Response::ERROR
end
/usr/lib/ruby/gems/1.8/gems/thin-1.5.1/lib/thin/connection.rb
in
catch
end
end
# When we're under a non-async framework like rails, we can still spawn
# off async responses using the callback info, so there's little point
# in removing this.
response = AsyncResponse
catch(:async) do
# Process the request calling the Rack adapter
response = @app.call(@request.env)
end
response
rescue Exception
handle_error
# Pass through error response
/usr/lib/ruby/gems/1.8/gems/thin-1.5.1/lib/thin/connection.rb
in
pre_process
end
end
# When we're under a non-async framework like rails, we can still spawn
# off async responses using the callback info, so there's little point
# in removing this.
response = AsyncResponse
catch(:async) do
# Process the request calling the Rack adapter
response = @app.call(@request.env)
end
response
rescue Exception
handle_error
# Pass through error response
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb
in
call
end
def self.spawn_threadpool # :nodoc:
until @threadpool.size == @threadpool_size.to_i
thread = Thread.new do
while true
op, cback = *@threadqueue.pop
result = op.call
@resultqueue << [result, cback]
EventMachine.signal_loopbreak
end
end
@threadpool << thread
end
end
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb
in
spawn_threadpool
end
def self.spawn_threadpool # :nodoc:
until @threadpool.size == @threadpool_size.to_i
thread = Thread.new do
while true
op, cback = *@threadqueue.pop
result = op.call
@resultqueue << [result, cback]
EventMachine.signal_loopbreak
end
end
@threadpool << thread
end
end
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb
in
initialize
end
@threadqueue << [op||blk,callback]
end
def self.spawn_threadpool # :nodoc:
until @threadpool.size == @threadpool_size.to_i
thread = Thread.new do
while true
op, cback = *@threadqueue.pop
result = op.call
@resultqueue << [result, cback]
EventMachine.signal_loopbreak
end
end
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb
in
new
end
@threadqueue << [op||blk,callback]
end
def self.spawn_threadpool # :nodoc:
until @threadpool.size == @threadpool_size.to_i
thread = Thread.new do
while true
op, cback = *@threadqueue.pop
result = op.call
@resultqueue << [result, cback]
EventMachine.signal_loopbreak
end
end
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb
in
spawn_threadpool
end
@threadqueue << [op||blk,callback]
end
def self.spawn_threadpool # :nodoc:
until @threadpool.size == @threadpool_size.to_i
thread = Thread.new do
while true
op, cback = *@threadqueue.pop
result = op.call
@resultqueue << [result, cback]
EventMachine.signal_loopbreak
end
end
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb
in
defer
#
def self.defer op = nil, callback = nil, &blk
unless @threadpool
require 'thread'
@threadpool = []
@threadqueue = ::Queue.new
@resultqueue = ::Queue.new
spawn_threadpool
end
@threadqueue << [op||blk,callback]
end
def self.spawn_threadpool # :nodoc:
until @threadpool.size == @threadpool_size.to_i
/usr/lib/ruby/gems/1.8/gems/thin-1.5.1/lib/thin/connection.rb
in
process
end
# Called when all data was received and the request
# is ready to be processed.
def process
if threaded?
@request.threaded = true
EventMachine.defer(method(:pre_process), method(:post_process))
else
@request.threaded = false
post_process(pre_process)
end
end
def pre_process
/usr/lib/ruby/gems/1.8/gems/thin-1.5.1/lib/thin/connection.rb
in
receive_data
@response = Response.new
end
# Called when data is received from the client.
def receive_data(data)
@idle = false
trace { data }
process if @request.parse(data)
rescue InvalidRequest => e
log "!! Invalid request"
log_error e
post_process Response::BAD_REQUEST
end
# Called when all data was received and the request
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb
in
run_machine
@reactor_running = true
initialize_event_machine
(b = blk || block) and add_timer(0, b)
if @next_tick_queue && !@next_tick_queue.empty?
add_timer(0) { signal_loopbreak }
end
@reactor_thread = Thread.current
run_machine
ensure
until @tails.empty?
@tails.pop.call
end
begin
release_machine
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb
in
run
@reactor_running = true
initialize_event_machine
(b = blk || block) and add_timer(0, b)
if @next_tick_queue && !@next_tick_queue.empty?
add_timer(0) { signal_loopbreak }
end
@reactor_thread = Thread.current
run_machine
ensure
until @tails.empty?
@tails.pop.call
end
begin
release_machine
/usr/lib/ruby/gems/1.8/gems/thin-1.5.1/lib/thin/backends/base.rb
in
start
@running = true
end
# Allow for early run up of eventmachine.
if EventMachine.reactor_running?
starter.call
else
EventMachine.run(&starter)
end
end
# Stop of the backend from accepting new connections.
def stop
@running = false
@stopping = true
/usr/lib/ruby/gems/1.8/gems/thin-1.5.1/lib/thin/server.rb
in
start
log ">> Thin web server (v#{VERSION::STRING} codename #{VERSION::CODENAME})"
debug ">> Debugging ON"
trace ">> Tracing ON"
log ">> Maximum connections set to #{@backend.maximum_connections}"
log ">> Listening on #{@backend}, CTRL+C to stop"
@backend.start
end
alias :start! :start
# == Gracefull shutdown
# Stops the server after processing all current connections.
# As soon as this method is called, the server stops accepting
# new requests and wait for all current connections to finish.
/usr/lib/ruby/gems/1.8/gems/rack-1.5.2/lib/rack/handler/thin.rb
in
run
host = options.delete(:Host) || '0.0.0.0'
port = options.delete(:Port) || 8080
args = [host, port, app, options]
# Thin versions below 0.8.0 do not support additional options
args.pop if ::Thin::VERSION::MAJOR < 1 && ::Thin::VERSION::MINOR < 8
server = ::Thin::Server.new(*args)
yield server if block_given?
server.start
end
def self.valid_options
{
"Host=HOST" => "Hostname to listen on (default: localhost)",
"Port=PORT" => "Port to listen on (default: 8080)",
}
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/base.rb
in
run!
# Thin, Puma, Mongrel, or WEBrick (in that order). If given a block, will call
# with the constructed handler once we have taken the stage.
def run!(options = {})
set options
handler = detect_rack_handler
handler_name = handler.name.gsub(/.*::/, '')
server_settings = settings.respond_to?(:server_settings) ? settings.server_settings : {}
handler.run self, server_settings.merge(:Port => port, :Host => bind) do |server|
unless handler_name =~ /cgi/i
$stderr.puts "== Sinatra/#{Sinatra::VERSION} has taken the stage " +
"on #{port} for #{environment} with backup from #{handler_name}"
end
[:INT, :TERM].each { |sig| trap(sig) { quit!(server, handler_name) } }
server.threaded = settings.threaded if server.respond_to? :threaded=
set :running, true
/usr/lib/ruby/gems/1.8/gems/sinatra-1.4.3/lib/sinatra/main.rb
in
nil
op.on('-e env', 'set the environment (default is development)') { |val| set :environment, val.to_sym }
op.on('-s server', 'specify rack server/handler (default is thin)') { |val| set :server, val }
op.on('-x', 'turn on the mutex lock (default is off)') { set :lock, true }
}.parse!(ARGV.dup)
end
end
at_exit { Application.run! if $!.nil? && Application.run? }
end
# include would include the module in Object
# extend only extends the `main` object
extend Sinatra::Delegator
class Rack::Builder
/usr/lib/one/oneflow/oneflow-server.rb
in
nil
s_template.info
status 201
#body Parser.render(rc)
body s_template.to_json
end
post '/service_template/:id/action' do
service_template = OpenNebula::ServiceTemplate.new_with_id(params[:id], @client)
action = JSON.parse(request.body.read)['action']
opts = action['params']
rc = case action['perform']
No GET data.
Variable | Value |
---|---|
{ "action": { "perform": "recover" } } | nil |
Variable | Value |
---|---|
CONTENT_LENGTH | 46 |
CONTENT_TYPE | application/x-www-form-urlencoded |
GATEWAY_INTERFACE | CGI/1.2 |
HTTP_ACCEPT | */* |
HTTP_AUTHORIZATION | Basic b25lYWRtaW46dlA0RXVDLWQ= |
HTTP_HOST | localhost:2474 |
HTTP_USER_AGENT | OpenNebula 4.4.1 (CLI) |
HTTP_VERSION | HTTP/1.1 |
PATH_INFO | /service/17/action |
QUERY_STRING | |
REMOTE_ADDR | 127.0.0.1 |
REQUEST_METHOD | POST |
REQUEST_PATH | /service/17/action |
REQUEST_URI | /service/17/action |
SCRIPT_NAME | |
SERVER_NAME | localhost |
SERVER_PORT | 2474 |
SERVER_PROTOCOL | HTTP/1.1 |
SERVER_SOFTWARE | thin 1.5.1 codename Straight Razor |
async.callback | #<Method: Thin::Connection#post_process> |
async.close | #<EventMachine::DefaultDeferrable:0x7f4fad1531b0> |
rack.errors | #<Object:0x7f4faf767ec8> |
rack.input | #<StringIO:0x7f4fad153e30> |
rack.logger | #<Rack::NullLogger:0x7f4fad1c3a78 @app=#<Rack::Protection::FrameOptions:0x7f4fad1c3d20 @frame_options="SAMEORIGIN", @options={:except=>[:session_hijacking, :remote_token], :status=>403, :html_types=>["text/html", "application/xhtml"], :frame_options=>:sameorigin, :message=>"Forbidden", :encryptor=>Digest::SHA1, :session_key=>"rack.session", :logging=>true, :reaction=>:drop_session, :allow_empty_referrer=>true, :report_key=>"protection.failed"}, @app=#<Rack::Protection::HttpOrigin:0x7f4fad1c3eb0 @options={:except=>[:session_hijacking, :remote_token], :status=>403, :html_types=>["text/html", "application/xhtml"], :message=>"Forbidden", :encryptor=>Digest::SHA1, :reaction=>:drop_session, :logging=>true, :session_key=>"rack.session", :allow_empty_referrer=>true, :report_key=>"protection.failed"}, @app=#<Rack::Protection::IPSpoofing:0x7f4fad1c4040 @options={:except=>[:session_hijacking, :remote_token], :status=>403, :html_types=>["text/html", "application/xhtml"], :message=>"Forbidden", :encryptor=>Digest::SHA1, :reaction=>:drop_session, :logging=>true, :session_key=>"rack.session", :allow_empty_referrer=>true, :report_key=>"protection.failed"}, @app=#<Rack::Protection::JsonCsrf:0x7f4fad1c4248 @options={:except=>[:session_hijacking, :remote_token], :status=>403, :html_types=>["text/html", "application/xhtml"], :message=>"Forbidden", :encryptor=>Digest::SHA1, :reaction=>:drop_session, :logging=>true, :session_key=>"rack.session", :allow_empty_referrer=>true, :report_key=>"protection.failed"}, @app=#<Rack::Protection::PathTraversal:0x7f4fad1c43d8 @options={:except=>[:session_hijacking, :remote_token], :status=>403, :html_types=>["text/html", "application/xhtml"], :message=>"Forbidden", :encryptor=>Digest::SHA1, :reaction=>:drop_session, :logging=>true, :session_key=>"rack.session", :allow_empty_referrer=>true, :report_key=>"protection.failed"}, @app=#<Rack::Protection::XSSHeader:0x7f4fad1c4630 @options={:except=>[:session_hijacking, :remote_token], :status=>403, :html_types=>["text/html", "application/xhtml"], :message=>"Forbidden", :encryptor=>Digest::SHA1, :xss_mode=>:block, :session_key=>"rack.session", :logging=>true, :reaction=>:drop_session, :nosniff=>true, :allow_empty_referrer=>true, :report_key=>"protection.failed"}, @app=#<Rack::CommonLogger:0x7f4fad1e9408 @app=#<Rack::Session::Pool:0x7f4fad1e9890 @sid_secure=SecureRandom, @mutex=#<Mutex:0x7f4fad1e9660>, @app=#<Sinatra::Application:0x7f4fad1fd5e8 @template_cache=#<Tilt::Cache:0x7f4fad1fd598 @cache={}>, @app=nil, @default_layout=:layout>, @sidbits=128, @cookie_only=true, @key="oneflow", @pool={}, @default_options={:secure_random=>SecureRandom, :secure=>false, :httponly=>true, :defer=>false, :expire_after=>nil, :renew=>false, :sidbits=>128, :path=>"/", :domain=>nil, :drop=>false}, @sid_length=32>, @logger=#<CloudLogger::CloudLogger:0x7f4fad2363c0 @default_formatter=#<Logger::Formatter:0x7f4fad236348 @datetime_format=nil>, @formatter=#<Proc:0x00007f4faeb85a10@/usr/lib/one/ruby/cloud/CloudServer.rb:137>, @logdev=#<Logger::LogDevice:0x7f4fad2362f8 @shift_age=0, @filename="/var/log/one/oneflow.log", @mutex=#<Logger::LogDevice::LogDeviceMutex:0x7f4fad2362a8 @mon_waiting_queue=[], @mon_entering_queue=[], @mon_count=0, @mon_owner=nil>, @dev=#<File:/var/log/one/oneflow.log>, @shift_size=1048576>, @level=1, @progname=nil>>>>>>>>> |
rack.multiprocess | false |
rack.multithread | true |
rack.request.cookie_hash | {} |
rack.request.form_hash | {"{\n \"action\": {\n \"perform\": \"recover\"\n }\n}"=>nil} |
rack.request.form_input | #<StringIO:0x7f4fad153e30> |
rack.request.form_vars | {
"action": {
"perform": "recover"
}
} |
rack.request.query_hash | {} |
rack.request.query_string | |
rack.run_once | false |
rack.session | #<Rack::Session::Abstract::SessionHash:0x3fa7d68a87a8 not yet loaded> |
rack.session.options | {:secure=>false, :secure_random=>SecureRandom, :httponly=>true, :expire_after=>nil, :defer=>false, :renew=>false, :sidbits=>128, :path=>"/", :drop=>false, :domain=>nil} |
rack.url_scheme | http |
rack.version | [1, 0] |
sinatra.accept | [#<Sinatra::Request::AcceptEntry:0x7f4fad0d3780 @q=1.0, @params={}, @type="*/*", @entry="*/*">] |
sinatra.commonlogger | true |
sinatra.error | #<NameError: undefined local variable or method `n_dispose' for #<OpenNebula::Role:0x7f4fad11d588>> |
sinatra.route | POST /service/:id/action |
You're seeing this error because you have
enabled the show_exceptions
setting.