Method: Orchestrator::Api::SystemsController#exec

Defined in:
app/controllers/orchestrator/api/systems_controller.rb

#execObject



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'app/controllers/orchestrator/api/systems_controller.rb', line 113

def exec
    # Run a function in a system module (async request)
    params.require(:module)
    params.require(:method)
    sys = System.get(id)
    if sys
        para = params.permit(:module, :index, :method, {args: []}).tap do |whitelist|
            whitelist[:args] = params[:args]
        end
        index = para[:index]
        mod = sys.get(para[:module].to_sym, index.nil? ? 0 : (index.to_i - 1))
        if mod
            user = current_user
            mod.thread.schedule do
                perform_exec(mod, para, user)
            end
            throw :async
        else
            render nothing: true, status: :not_found
        end
    else
        render nothing: true, status: :not_found
    end
end