Sha256: 70ab3369dbf4017ceb75d320169a48a1e99ee1a6e6c7879d995820354d0ead42

Contents?: true

Size: 1.7 KB

Versions: 13

Compression:

Stored size: 1.7 KB

Contents

module Onering
  module CLI
    class Automation < Plugin
      def self.configure(global={})
        @requests = Onering::CLI.connect(global).automation_requests
        @jobs = Onering::CLI.connect(global).automation_jobs
        @tasks = Onering::CLI.connect(global).automation_tasks
      end

      def self.run(args)
        sc = args.shift   # subcommand
        ssc = args.shift  # sub-subcommand

        case (sc.downcase.to_sym rescue nil)
# -----------------------------------------------------------------------------
        when :requests
          @opts = ::Trollop::options do
            banner <<-EOS
Options:
EOS
            stop_on %w{show status requeue flush purge}
          end

          case (ssc.downcase.to_sym rescue nil)
          when :show
            return @requests.show(args[0])

          when :requeue
            return @requests.requeue_all_failed() if args[0].nil?
            return @requests.requeue(args[0])

          when :status
            fields = (args.empty? ? ["status"] : args)
            rv = {}
            out = @requests.summary(fields)

            _rejigger_hash = Proc.new do |h|
              [*h].collect{|i|
                [i['id'], (i['children'].nil? ? i['count'] : Hash[_rejigger_hash.call(i['children'])])]
              }
            end

            return Hash[_rejigger_hash.call(out)]

          when :flush
            return @requests.flush_queue()

          when :purge
            return @requests.purge()
          end

# -----------------------------------------------------------------------------
        when :jobs


# -----------------------------------------------------------------------------
        when :tasks
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
onering-agent-0.4.4 lib/onering/cli/automation.rb
onering-agent-0.4.3 lib/onering/cli/automation.rb
onering-client-0.4.3 lib/onering/cli/automation.rb
onering-client-0.4.2 lib/onering/cli/automation.rb
onering-client-0.4.1 lib/onering/cli/automation.rb
onering-client-0.4.0 lib/onering/cli/automation.rb
onering-client-0.3.4 lib/onering/cli/automation.rb
onering-client-0.3.3 lib/onering/cli/automation.rb
onering-client-0.3.2 lib/onering/cli/automation.rb
onering-client-0.3.1 lib/onering/cli/automation.rb
onering-client-0.3.0 lib/onering/cli/automation.rb
onering-client-0.2.4 lib/onering/cli/automation.rb
onering-client-0.2.3 lib/onering/cli/automation.rb