module Splash::Daemon::Orchestrator::Grammar

Orchestrator grammar method defiition module

Constants

VERBS

list of known verbs for Splash orchestrator

Public Instance Methods

ack_command(content) click to toggle source

ack_command verb : send ack to Prometheus, for command specified in payload @param [Hash] content message content Hash Structure, include mandatory payload @return [Hash] Exiter case

# File lib/splash/daemon/orchestrator/grammar.rb, line 45
def ack_command(content)
  return execute command: content[:payload][:name], ack: true
end
execute_command(content) click to toggle source

execute_command verb : execute command specified in payload @param [Hash] content message content Hash Structure, include mandatory payload @return [Hash] Exiter case

# File lib/splash/daemon/orchestrator/grammar.rb, line 67
def execute_command(content)
  payload = content[:payload]
  unless get_config.commands.select {|cmd| cmd[:name] == payload[:name].to_sym}.count > 0 then
    @log.item "Command not found", content[:session]
    return { :case => :not_found }
  end
  if payload.include? :schedule then
    sched,value = payload[:schedule].flatten
    @log.schedule "remote call command #{payload[:name]}, scheduling : #{sched.to_s} #{value}", content[:session]
    @server.send sched,value do
      @log.trigger "Executing Scheduled command #{payload[:name]} for Scheduling : #{sched.to_s} #{value}", content[:session]
      execute command: payload[:name], session: content[:session]
    end
    return { :case => :quiet_exit }
  else
    @log.info "Execute direct command",  content[:session]
    res = execute command: payload[:name], session: content[:session]
    return res
  end
end
get_jobs(content) click to toggle source

get_jobs verb : return list of scheduled jobs for internal scheduler @param [Hash] content message content Hash Structure, ignored @return [String] YAML dataset

# File lib/splash/daemon/orchestrator/grammar.rb, line 53
def get_jobs(content)
  return @server.jobs.to_yaml
end
list_commands(content) click to toggle source

list_commands verb : return the list of specified commands in local Splash @param [Hash] content message content Hash Structure, ignored @return [Hash] structure of commands

# File lib/splash/daemon/orchestrator/grammar.rb, line 38
def list_commands(content)
  return get_config.commands
end
ping(content) click to toggle source

ping verb : return pong to hostname precise in payload @param [Hash] content message content Hash Structure, include mandatory payload @return [String] the pong

# File lib/splash/daemon/orchestrator/grammar.rb, line 31
def ping(content)
  return "Pong : #{content[:payload][:hostname]} !"
end
reset(content) click to toggle source

reset verb : reset the internal scheduler @param [Hash] content message content Hash Structure, ignored @return [String] “Scheduler reset” static

# File lib/splash/daemon/orchestrator/grammar.rb, line 60
def reset(content)
  return "Scheduler reset" if reset_orchestrator
end
shutdown(content) click to toggle source

shutdown verb : stop the Splash daemon gracefully @param [Hash] content message content Hash Structure, ignored @return [Hash] Exiter Case :quiet_exit

# File lib/splash/daemon/orchestrator/grammar.rb, line 24
def shutdown(content)
  terminate
end