Sha256: fa7168c7160c46b9aec191d45c891249502d4960f3b2da8cd07d0a69aa4311d7

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

# coding: utf-8
module Splash
  module Orchestrator
    module Grammar

      include Splash::Config
      include Splash::Loggers


      VERBS=[:ping,:list_commands,:execute_command,:ack_command, :shutdown]


      def shutdown
        terminate
      end

      def ping(payload)
        return "Pong : #{payload[:hostname]} !"
      end


      def list_commands
        return get_config.commands
      end

      def ack_command(payload)
        return execute command: payload[:name], ack: true
      end


      def execute_command(payload)
        unless get_config.commands.include? payload[:name].to_sym
          @log.item "Command not found"
          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}"
          @server.send sched,value do
            @log.trigger "Executing Scheduled command #{payload[:name]} for Scheduling : #{sched.to_s} #{value}"
            execute command: payload[:name]
          end
          return { :case => :quiet_exit }
        else
          @log.info "Execute direct command"
          res = execute command: payload[:name]
          return res
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
prometheus-splash-0.4.5 lib/splash/orchestrator/grammar.rb
prometheus-splash-0.4.4 lib/splash/orchestrator/grammar.rb