knife-reporting 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2ddd85dccb8b6601ec4f0b13f177dbb0d7d8111
4
- data.tar.gz: 3b430b5e09dfe3df7a17e195b5214ebb3690e24c
3
+ metadata.gz: 5f8647bb414c18c46396f38ad5b1f0d90973173c
4
+ data.tar.gz: 7dee63aada85db02cf9db7602fb17f8b4b18368f
5
5
  SHA512:
6
- metadata.gz: 6b67230bcc2ef93e2f63670694eed20c7bdc62a04662871807d60a6fae8db5061f6085cbdd5fed9e99580fe821369b1b696783ff11c68d97e5b10c17347228a2
7
- data.tar.gz: 4129f3a9aff2e68b222b8c25ab0d15e5bca79e138c26a4ca67c840a1360302c817d24eb7e70b2837a110099e79242abe79de4e51bf395e10810036448a0145b5
6
+ metadata.gz: 9a0e1f8cc29f50462de1942de08d6187296ee03ed37ed278b71fb6f36496062745c87cbb88c35e5c06ffcdb6f61302da07f8181d17aabaabce504fac6ca0e333
7
+ data.tar.gz: ab466ed5f076da7d0f859ac5b6a496921067f0ad314687429847008de5685fc5f4f2ae72b5efa7ddb46bf45b954635804eb5f9fc887e54e6f80489fca63b2fd8
@@ -61,8 +61,13 @@ class Chef
61
61
  :required => false,
62
62
  :description => 'Specifies the rows to be returned from the database. The default is 10.'
63
63
 
64
+ option :status,
65
+ :long => '--status STATUS',
66
+ :required => false,
67
+ :description => 'Filters by run status (success, failure, or aborted).'
68
+
64
69
  def run
65
- @rest = Chef::REST.new(Chef::Config[:chef_server_url])
70
+ @rest = Chef::ServerAPI.new(Chef::Config[:chef_server_url])
66
71
 
67
72
  node_name = name_args[0]
68
73
 
@@ -70,7 +75,8 @@ class Chef
70
75
  start_time, end_time = apply_time_args()
71
76
  check_3month_window(start_time, end_time)
72
77
 
73
- query_string = generate_query(start_time, end_time, node_name, config[:rows])
78
+ query_string = generate_query(start_time, end_time, node_name, config[:rows],
79
+ config[:status])
74
80
  runs = history(query_string)
75
81
 
76
82
  output(runs)
@@ -78,24 +84,25 @@ class Chef
78
84
 
79
85
  private
80
86
 
81
- def generate_query(start_time, end_time, node_name = nil, rows = nil)
87
+ def generate_query(start_time, end_time, node_name = nil, rows = nil, status = nil)
88
+ query = '/reports'
82
89
  if node_name
83
- if rows
84
- "reports/nodes/#{node_name}/runs?from=#{start_time}&until=#{end_time}&rows=#{rows}"
85
- else
86
- "reports/nodes/#{node_name}/runs?from=#{start_time}&until=#{end_time}"
87
- end
90
+ query += "/nodes/#{node_name}"
88
91
  else
89
- if rows
90
- "reports/org/runs?from=#{start_time}&until=#{end_time}&rows=#{rows}"
91
- else
92
- "reports/org/runs?from=#{start_time}&until=#{end_time}"
93
- end
92
+ query += "/org"
93
+ end
94
+ query += "/runs?from=#{start_time}&until=#{end_time}"
95
+ if rows
96
+ query += "&rows=#{rows}"
94
97
  end
98
+ if status
99
+ query += "&status=#{status}"
100
+ end
101
+ query
95
102
  end
96
103
 
97
104
  def history(query_string)
98
- runs = @rest.get_rest(query_string, false, HEADERS)
105
+ runs = @rest.get_rest(query_string, HEADERS)
99
106
 
100
107
  runs["run_history"].map do |run|
101
108
  { :run_id => run["run_id"],
@@ -108,4 +115,3 @@ class Chef
108
115
  end
109
116
  end
110
117
  end
111
-
@@ -37,7 +37,7 @@ class Chef
37
37
  HEADERS = {'X-Ops-Reporting-Protocol-Version' => PROTOCOL_VERSION}
38
38
 
39
39
  def run
40
- rest = Chef::REST.new(Chef::Config[:chef_server_url])
40
+ rest = Chef::ServerAPI.new(Chef::Config[:chef_server_url])
41
41
 
42
42
  run_id = name_args[0]
43
43
 
@@ -51,11 +51,11 @@ class Chef
51
51
 
52
52
  query_string = "reports/org/runs/#{run_id}"
53
53
 
54
- runs = rest.get(query_string, false, HEADERS)
54
+ runs = rest.get(query_string, HEADERS)
55
55
 
56
56
  if runs['run_detail']['updated_res_count'] > runs['run_resources'].length
57
57
  all_query = "#{query_string}?start=0&rows=#{runs['run_detail']['updated_res_count']}"
58
- runs = rest.get(all_query, false, HEADERS)
58
+ runs = rest.get(all_query, HEADERS)
59
59
  end
60
60
  output(runs)
61
61
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-reporting
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Software, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-18 00:00:00.000000000 Z
11
+ date: 2016-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-cli
@@ -39,7 +39,7 @@ files:
39
39
  - lib/chef/knife/runs_list.rb
40
40
  - lib/chef/knife/runs_show.rb
41
41
  - lib/chef/reporting/knife_helpers.rb
42
- homepage: http://www.getchef.com/
42
+ homepage: https://github.com/chef/knife-reporting
43
43
  licenses:
44
44
  - Apache 2
45
45
  metadata: {}
@@ -59,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
59
  version: '0'
60
60
  requirements: []
61
61
  rubyforge_project:
62
- rubygems_version: 2.2.2
62
+ rubygems_version: 2.6.2
63
63
  signing_key:
64
64
  specification_version: 4
65
65
  summary: Knife plugin for Opscode Reporting