Sha256: 3554de1d5bd87d1d2794724e22bcadad323a96d5838dd5e76ae0fc1f202f20e3

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

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

      include Splash::Config
      VERBS=[:ping,:list_commands,:execute_command,:ack_command]

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


      def list_commands
        return get_config.commands
      end

      def ack_command
        return self.execute command: payload[:name], ack: true
      end


      def execute_command(payload)
        unless get_config.commands.include? payload[:name].to_sym
          puts " * Command not found"
          return { :case => :not_found }
        end
        if payload.include? :schedule then
          sched,value = payload[:schedule].flatten
        else
          sched = :in
          value = '1s'
        end
        puts " * Schedule remote call command #{payload[:name]}, scheduling : #{sched.to_s} #{value}"
        @server.send sched,value do
          self.execute command: payload[:name]
        end
        return { :case => :quiet_exit }
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
prometheus-splash-0.2.0 lib/splash/orchestrator/grammar.rb