Class: Onering::CLI::Automation
- Inherits:
-
Plugin
- Object
- Plugin
- Onering::CLI::Automation
show all
- Defined in:
- lib/onering/cli/automation.rb
Class Method Summary
collapse
Methods inherited from Plugin
default_format, inherited, registered_plugins
Class Method Details
4
5
6
7
8
|
# File 'lib/onering/cli/automation.rb', line 4
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
|
.run(args) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/onering/cli/automation.rb', line 10
def self.run(args)
sc = args.shift ssc = args.shift
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
|