Sha256: 7bb00af9f4ae1ef640da01e09cc7462919ede47f1094e297ae2dc2c56a31b298

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 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(payload)
        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
          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 }
        else
          puts " * Execute direct command"
          puts payload[:name]
          res = self.execute command: payload[:name]
          puts res.inspect
          return res
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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