foreman_omaha 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +0 -0
- data/app/assets/images/{Omaha.png → foreman_omaha/Omaha.png} +0 -0
- data/app/controllers/api/v2/omaha_reports_controller.rb +1 -2
- data/app/controllers/omaha_reports_controller.rb +7 -3
- data/app/models/foreman_omaha/fact_name.rb +1 -1
- data/app/models/foreman_omaha/omaha_report.rb +2 -2
- data/app/views/api/v2/omaha_reports/create.json.rabl +1 -1
- data/app/views/api/v2/omaha_reports/index.json.rabl +1 -1
- data/app/views/api/v2/omaha_reports/main.json.rabl +1 -1
- data/app/views/api/v2/omaha_reports/show.json.rabl +1 -1
- data/app/views/api/v2/omaha_reports/update.json.rabl +1 -1
- data/lib/foreman_omaha/engine.rb +15 -3
- data/lib/foreman_omaha/version.rb +1 -1
- data/test/functional/api/v2/omaha_reports_controller_test.rb +6 -4
- data/test/unit/omaha_report_test.rb +28 -25
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3ec4d257a6b23da8a778b2c6c7646bda239ed8a
|
4
|
+
data.tar.gz: 72996f1f0545e2c51e9bda9d0d1ec3c1765ff483
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49351ba242b536b61204bd5dde6f559a843e979c7de3e3fddb1a3e7c0e104bd5303fdcce6d7fcb4e3bb3a2d9639a6af872e14167289c5d02164b02a2b0acd314
|
7
|
+
data.tar.gz: afcc44fb7da39ece8712fd38d18d9dd1e7cff99e938284b90b5d2a4d0909924753f410a189b25f8b67ce8827ab64532917afa3677d73fb0084353f6bd24b3557
|
data/Rakefile
CHANGED
File without changes
|
File without changes
|
@@ -31,8 +31,7 @@ module Api
|
|
31
31
|
api :GET, '/omaha_reports/:id/', N_('Show a omaha report')
|
32
32
|
param :id, :identifier, :required => true
|
33
33
|
|
34
|
-
def show
|
35
|
-
end
|
34
|
+
def show; end
|
36
35
|
|
37
36
|
api :POST, '/omaha_reports', N_('Create a omaha report')
|
38
37
|
param_group :omaha_report, :as => :create
|
@@ -14,9 +14,13 @@ class OmahaReportsController < ApplicationController
|
|
14
14
|
def show
|
15
15
|
# are we searching for the last report?
|
16
16
|
if params[:id] == 'last'
|
17
|
-
conditions =
|
18
|
-
|
19
|
-
|
17
|
+
conditions = if params[:host_id].present?
|
18
|
+
{
|
19
|
+
:host_id => resource_finder(Host.authorized(:view_hosts), params[:host_id]).try(:id)
|
20
|
+
}
|
21
|
+
else
|
22
|
+
{}
|
23
|
+
end
|
20
24
|
params[:id] = resource_base.where(conditions).maximum(:id)
|
21
25
|
end
|
22
26
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module ForemanOmaha
|
2
2
|
class OmahaReport < ::Report
|
3
3
|
enum :status => [:unknown, :complete, :downloading, :downloaded,
|
4
|
-
|
4
|
+
:installed, :instance_hold, :error]
|
5
5
|
|
6
6
|
scoped_search :on => :omaha_version, :rename => :version, :complete_value => true
|
7
7
|
scoped_search :on => :status, :complete_value => statuses
|
@@ -34,7 +34,7 @@ module ForemanOmaha
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def operatingsystem
|
37
|
-
return
|
37
|
+
return if omaha_version.blank?
|
38
38
|
args = { :type => 'Coreos', :major => osmajor, :minor => osminor }
|
39
39
|
Operatingsystem.find_by(args)
|
40
40
|
end
|
data/lib/foreman_omaha/engine.rb
CHANGED
@@ -27,7 +27,7 @@ module ForemanOmaha
|
|
27
27
|
permission :view_omaha_reports, :omaha_reports => [:index, :show, :auto_complete_search],
|
28
28
|
:'api/v2/omaha_reports' => [:index, :show, :last]
|
29
29
|
permission :destroy_omaha_reports, :omaha_reports => [:destroy],
|
30
|
-
:'api/v2/
|
30
|
+
:'api/v2/omaha_reports' => [:destroy]
|
31
31
|
permission :upload_omaha_reports, :omaha_reports => [:create],
|
32
32
|
:'api/v2/omaha_reports' => [:create]
|
33
33
|
end
|
@@ -45,8 +45,8 @@ module ForemanOmaha
|
|
45
45
|
after: :reports
|
46
46
|
end
|
47
47
|
|
48
|
-
if respond_to?(:
|
49
|
-
|
48
|
+
if respond_to?(:add_controller_action_scope)
|
49
|
+
add_controller_action_scope(HostsController, :index) { |base_scope| base_scope.includes(:last_omaha_report_object) }
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -63,6 +63,18 @@ module ForemanOmaha
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
+
initializer 'foreman_omaha.assets.precompile' do |app|
|
67
|
+
app.config.assets.precompile += %w[foreman_omaha/Omaha.png]
|
68
|
+
end
|
69
|
+
|
70
|
+
initializer 'foreman_omaha.configure_assets', :group => :assets do
|
71
|
+
SETTINGS[:foreman_omaha] = {
|
72
|
+
:assets => {
|
73
|
+
:precompile => ['foreman_omaha/Omaha.png']
|
74
|
+
}
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
66
78
|
rake_tasks do
|
67
79
|
Rake::Task['db:seed'].enhance do
|
68
80
|
ForemanOmaha::Engine.load_seed
|
@@ -34,7 +34,7 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
|
|
34
34
|
delete :destroy, :id => report.to_param
|
35
35
|
end
|
36
36
|
assert_response :success
|
37
|
-
refute Report.
|
37
|
+
refute Report.find_by(id: report.id)
|
38
38
|
end
|
39
39
|
|
40
40
|
test 'should get reports for given host only' do
|
@@ -85,15 +85,15 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
|
|
85
85
|
end
|
86
86
|
|
87
87
|
test 'cannot view the last report without hosts view permission' do
|
88
|
-
setup_user('view', 'omaha_reports')
|
89
88
|
report = FactoryGirl.create(:report)
|
89
|
+
setup_user('view', 'omaha_reports')
|
90
90
|
get :last, { :host_id => report.host.id }, set_session_user.merge(:user => User.current.id)
|
91
91
|
assert_response :not_found
|
92
92
|
end
|
93
93
|
|
94
94
|
describe 'unpriveliged user' do
|
95
95
|
def setup
|
96
|
-
User.current =
|
96
|
+
User.current = FactoryGirl.create(:user, :admin)
|
97
97
|
end
|
98
98
|
|
99
99
|
test 'hosts with a registered smart proxy on should create a report successfully' do
|
@@ -103,7 +103,9 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
|
|
103
103
|
proxy = FactoryGirl.create(:smart_proxy, :omaha)
|
104
104
|
host = URI.parse(proxy.url).host
|
105
105
|
Resolv.any_instance.stubs(:getnames).returns([host])
|
106
|
-
|
106
|
+
as_user :one do
|
107
|
+
post :create, :omaha_report => create_report
|
108
|
+
end
|
107
109
|
assert_equal proxy, @controller.detected_proxy
|
108
110
|
assert_response :created
|
109
111
|
end
|
@@ -2,57 +2,60 @@ require 'test_plugin_helper'
|
|
2
2
|
|
3
3
|
class OmahaReportTest < ActiveSupport::TestCase
|
4
4
|
setup do
|
5
|
-
User.current =
|
6
|
-
@report = FactoryGirl.create(:omaha_report)
|
5
|
+
User.current = FactoryGirl.create(:user, :admin)
|
7
6
|
end
|
8
7
|
|
9
8
|
context 'status' do
|
9
|
+
let(:report) { FactoryGirl.build(:omaha_report) }
|
10
|
+
|
10
11
|
test 'should be complete' do
|
11
|
-
|
12
|
-
assert_equal 'complete',
|
13
|
-
assert_equal 'Complete',
|
12
|
+
report.status = 'complete'
|
13
|
+
assert_equal 'complete', report.status
|
14
|
+
assert_equal 'Complete', report.to_label
|
14
15
|
end
|
15
16
|
|
16
17
|
test 'should be downloading' do
|
17
|
-
|
18
|
-
assert_equal 'downloading',
|
19
|
-
assert_equal 'Downloading',
|
18
|
+
report.status = 'downloading'
|
19
|
+
assert_equal 'downloading', report.status
|
20
|
+
assert_equal 'Downloading', report.to_label
|
20
21
|
end
|
21
22
|
|
22
23
|
test 'should be downloaded' do
|
23
|
-
|
24
|
-
assert_equal 'downloaded',
|
25
|
-
assert_equal 'Downloaded',
|
24
|
+
report.status = 'downloaded'
|
25
|
+
assert_equal 'downloaded', report.status
|
26
|
+
assert_equal 'Downloaded', report.to_label
|
26
27
|
end
|
27
28
|
|
28
29
|
test 'should be installed' do
|
29
|
-
|
30
|
-
assert_equal 'installed',
|
31
|
-
assert_equal 'Installed',
|
30
|
+
report.status = 'installed'
|
31
|
+
assert_equal 'installed', report.status
|
32
|
+
assert_equal 'Installed', report.to_label
|
32
33
|
end
|
33
34
|
|
34
35
|
test 'should be installed' do
|
35
|
-
|
36
|
-
assert_equal 'instance_hold',
|
37
|
-
assert_equal 'Instance Hold',
|
36
|
+
report.status = 'instance_hold'
|
37
|
+
assert_equal 'instance_hold', report.status
|
38
|
+
assert_equal 'Instance Hold', report.to_label
|
38
39
|
end
|
39
40
|
|
40
41
|
test 'should be error' do
|
41
|
-
|
42
|
-
assert_equal 'error',
|
43
|
-
assert_equal 'Error',
|
42
|
+
report.status = 'error'
|
43
|
+
assert_equal 'error', report.status
|
44
|
+
assert_equal 'Error', report.to_label
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
47
48
|
context 'operatingsystem' do
|
49
|
+
let(:os) { FactoryGirl.create(:coreos, :major => '1068', :minor => '9.0') }
|
50
|
+
let(:report) { FactoryGirl.create(:omaha_report) }
|
51
|
+
|
48
52
|
test 'should get operatingsystem' do
|
49
|
-
os
|
50
|
-
assert_equal os, @report.operatingsystem
|
53
|
+
assert_equal os, report.operatingsystem
|
51
54
|
end
|
52
55
|
|
53
56
|
test 'should parse major, minor' do
|
54
|
-
assert_equal '1068',
|
55
|
-
assert_equal '9.0',
|
57
|
+
assert_equal '1068', report.osmajor
|
58
|
+
assert_equal '9.0', report.osminor
|
56
59
|
end
|
57
60
|
end
|
58
61
|
|
@@ -79,7 +82,7 @@ class OmahaReportTest < ActiveSupport::TestCase
|
|
79
82
|
'reported_at' => Time.now.utc.to_s
|
80
83
|
}
|
81
84
|
assert_raise ArgumentError do
|
82
|
-
|
85
|
+
ForemanOmaha::OmahaReport.import(report)
|
83
86
|
end
|
84
87
|
end
|
85
88
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_omaha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timo Goebel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.49.1
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.49.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rdoc
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ files:
|
|
49
49
|
- LICENSE
|
50
50
|
- README.md
|
51
51
|
- Rakefile
|
52
|
-
- app/assets/images/Omaha.png
|
52
|
+
- app/assets/images/foreman_omaha/Omaha.png
|
53
53
|
- app/controllers/api/v2/omaha_reports_controller.rb
|
54
54
|
- app/controllers/omaha_reports_controller.rb
|
55
55
|
- app/helpers/concerns/foreman_omaha/hosts_helper_extensions.rb
|
@@ -90,7 +90,7 @@ files:
|
|
90
90
|
- test/functional/omaha_reports_controller_test.rb
|
91
91
|
- test/test_plugin_helper.rb
|
92
92
|
- test/unit/omaha_report_test.rb
|
93
|
-
homepage: http://github.com/
|
93
|
+
homepage: http://github.com/theforeman/foreman_omaha
|
94
94
|
licenses:
|
95
95
|
- GPL-3
|
96
96
|
metadata: {}
|
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
112
|
rubyforge_project:
|
113
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.6.12
|
114
114
|
signing_key:
|
115
115
|
specification_version: 4
|
116
116
|
summary: This plug-in adds support for the Omaha procotol to The Foreman.
|