Sha256: cf549a449e5bc86fc22609611a1f214e62f8d792cb4533e9aed21066451fa8fe

Contents?: true

Size: 1.69 KB

Versions: 45

Compression:

Stored size: 1.69 KB

Contents

module Onering
  module CLI
    module Automation
      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

45 entries across 45 versions & 1 rubygems

Version Path
onering-client-0.2.1 lib/onering/cli/automation.rb
onering-client-0.2.0 lib/onering/cli/automation.rb
onering-client-0.1.7 lib/onering/cli/automation.rb
onering-client-0.1.6 lib/onering/cli/automation.rb
onering-client-0.1.5 lib/onering/cli/automation.rb
onering-client-0.1.4 lib/onering/cli/automation.rb
onering-client-0.1.3 lib/onering/cli/automation.rb
onering-client-0.1.2 lib/onering/cli/automation.rb
onering-client-0.1.1 lib/onering/cli/automation.rb
onering-client-0.0.99 lib/onering/cli/automation.rb
onering-client-0.0.98 lib/onering/cli/automation.rb
onering-client-0.0.97 lib/onering/cli/automation.rb
onering-client-0.0.96 lib/onering/cli/automation.rb
onering-client-0.0.95 lib/onering/cli/automation.rb
onering-client-0.0.94 lib/onering/cli/automation.rb
onering-client-0.0.93 lib/onering/cli/automation.rb
onering-client-0.0.92 lib/onering/cli/automation.rb
onering-client-0.0.91 lib/onering/cli/automation.rb
onering-client-0.0.90 lib/onering/cli/automation.rb
onering-client-0.0.89 lib/onering/cli/automation.rb