foreman_content 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +113 -0
- data/Rakefile +111 -0
- data/app/assets/javascripts/content/content.js +12 -0
- data/app/assets/stylesheets/content/application.css +13 -0
- data/app/controllers/content/api/repositories_controller.rb +27 -0
- data/app/controllers/content/gpg_keys_controller.rb +42 -0
- data/app/controllers/content/products_controller.rb +51 -0
- data/app/controllers/content/repositories_controller.rb +57 -0
- data/app/helpers/content/application_helper.rb +5 -0
- data/app/helpers/content/repositories_helper.rb +56 -0
- data/app/models/content/custom_repository_paths.rb +27 -0
- data/app/models/content/environment_product.rb +19 -0
- data/app/models/content/gpg_key.rb +32 -0
- data/app/models/content/host_product.rb +20 -0
- data/app/models/content/hostgroup_product.rb +19 -0
- data/app/models/content/operatingsystem_repository.rb +19 -0
- data/app/models/content/orchestration/pulp.rb +93 -0
- data/app/models/content/product.rb +28 -0
- data/app/models/content/product_operatingsystem.rb +19 -0
- data/app/models/content/remote/pulp/repository.rb +46 -0
- data/app/models/content/repository.rb +70 -0
- data/app/models/content/validators/content_validator.rb +25 -0
- data/app/models/content/validators/description_format.rb +24 -0
- data/app/models/content/validators/name_format.rb +40 -0
- data/app/models/content/validators/no_trailing_space.rb +27 -0
- data/app/models/setting/content.rb +42 -0
- data/app/overrides/add_host_conent_tab.rb +9 -0
- data/app/overrides/add_hostgroup_conent_tab.rb +9 -0
- data/app/overrides/add_os_conent_tab.rb +9 -0
- data/app/services/content/pulp_event_handler.rb +25 -0
- data/app/views/content/gpg_keys/_form.html.erb +8 -0
- data/app/views/content/gpg_keys/edit.html.erb +3 -0
- data/app/views/content/gpg_keys/index.html.erb +20 -0
- data/app/views/content/gpg_keys/new.html.erb +3 -0
- data/app/views/content/products/_form.html.erb +26 -0
- data/app/views/content/products/_form_tab.html.erb +3 -0
- data/app/views/content/products/_host_tab_pane.html.erb +5 -0
- data/app/views/content/products/_hostgroup_tab_pane.html.erb +5 -0
- data/app/views/content/products/_operatingsystem_tab_pane.html.erb +5 -0
- data/app/views/content/products/edit.html.erb +3 -0
- data/app/views/content/products/index.html.erb +27 -0
- data/app/views/content/products/new.html.erb +3 -0
- data/app/views/content/products/welcome.html.erb +8 -0
- data/app/views/content/repositories/_form.html.erb +30 -0
- data/app/views/content/repositories/edit.html.erb +3 -0
- data/app/views/content/repositories/index.html.erb +32 -0
- data/app/views/content/repositories/new.html.erb +3 -0
- data/app/views/content/repositories/show.html.erb +98 -0
- data/app/views/content/repositories/welcome.html.erb +8 -0
- data/config/routes.rb +36 -0
- data/db/migrate/20130702140034_create_content_repositories.rb +19 -0
- data/db/migrate/20130702162629_create_content_products.rb +10 -0
- data/db/migrate/20130709001120_create_content_gpg_keys.rb +10 -0
- data/db/migrate/20130717032320_create_content_environments_products.rb +9 -0
- data/db/migrate/20130722084911_create_content_operatingsystem_repositories.rb +9 -0
- data/db/migrate/20130723084911_create_content_hostgroup_products.rb +9 -0
- data/db/migrate/20130723124911_create_content_host_products.rb +9 -0
- data/db/migrate/20130729032320_create_content_product_operatingsystems.rb +9 -0
- data/lib/content/engine.rb +59 -0
- data/lib/content/version.rb +3 -0
- data/lib/content_environment.rb +13 -0
- data/lib/content_home_helper_patch.rb +23 -0
- data/lib/content_host.rb +55 -0
- data/lib/content_hostgroup.rb +22 -0
- data/lib/content_operatingsystem.rb +17 -0
- data/lib/content_redhat.rb +36 -0
- data/lib/content_taxonomy.rb +18 -0
- data/lib/foreman_content.rb +4 -0
- data/lib/pulp_configuration.rb +23 -0
- data/lib/tasks/content_tasks.rake +4 -0
- data/test/content_test.rb +7 -0
- data/test/fixtures/content/products.yml +11 -0
- data/test/fixtures/content/repositories.yml +11 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +23 -0
- data/test/unit/content/description_format_validator_test.rb +20 -0
- data/test/unit/content/name_format_validator_test.rb +28 -0
- data/test/unit/content/product_validation_test.rb +18 -0
- data/test/unit/content/repositories_test.rb +7 -0
- metadata +194 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
module ContentRedhat
|
2
|
+
def self.included(base)
|
3
|
+
base.send(:include, InstanceMethods)
|
4
|
+
base.class_eval do
|
5
|
+
alias_method_chain :medium_uri, :content_uri
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
module InstanceMethods
|
10
|
+
def medium_uri_with_content_uri host, url = nil
|
11
|
+
if url.nil? && (full_path = Content::Repository.available_for_host(host).kickstart.first.try(:full_path))
|
12
|
+
URI.parse(full_path)
|
13
|
+
else
|
14
|
+
medium_uri_without_content_uri(host, url)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# return an array of repositories for kickstart script as additional repos
|
19
|
+
# to the kickstart main repo, this list will typically include updates and epel
|
20
|
+
def repos host
|
21
|
+
host.attached_repositories.yum.map{ |repo| format_repo(repo) }
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
# convert a repository to a format that kickstart script can consume
|
26
|
+
def format_repo repo
|
27
|
+
{
|
28
|
+
:baseurl => repo.full_path,
|
29
|
+
:name => repo.to_label,
|
30
|
+
:description => repo.product.description,
|
31
|
+
:enabled => repo.enabled,
|
32
|
+
:gpgcheck => !!repo.gpg_key
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ContentTaxonomy
|
2
|
+
def self.included(base)
|
3
|
+
base.send(:include, InstanceMethods)
|
4
|
+
|
5
|
+
base.class_eval do
|
6
|
+
has_many :products, :through => :taxable_taxonomies, :source => :taxable, :source_type => 'Content::Product'
|
7
|
+
alias_method_chain :dup, :content_dup
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module InstanceMethods
|
12
|
+
def dup_with_content_dup
|
13
|
+
new = dup_without_content_dup
|
14
|
+
new.products = products
|
15
|
+
new
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'runcible'
|
2
|
+
|
3
|
+
class PulpConfiguration
|
4
|
+
def self.initialize_runcible
|
5
|
+
Runcible::Base.config = runcible_config
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.runcible_config
|
9
|
+
pulp_url = URI(Setting.pulp_url)
|
10
|
+
{
|
11
|
+
:url => "#{pulp_url.scheme}://#{pulp_url.host}:#{pulp_url.port}",
|
12
|
+
:api_path => pulp_url.path,
|
13
|
+
:user => "admin",
|
14
|
+
:timeout => 60,
|
15
|
+
:open_timeout => 60,
|
16
|
+
:oauth => { :oauth_secret => Setting['pulp_oauth_secret'],
|
17
|
+
:oauth_key => Setting['pulp_oauth_key'] },
|
18
|
+
:logging => { :logger => Rails.logger,
|
19
|
+
:exception => true,
|
20
|
+
:debug => true }
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
2
|
+
|
3
|
+
# This model initially had no columns defined. If you add columns to the
|
4
|
+
# model remove the '{}' from the fixture names and add the columns immediately
|
5
|
+
# below each fixture, per the syntax in the comments below
|
6
|
+
#
|
7
|
+
one: {}
|
8
|
+
# column: value
|
9
|
+
#
|
10
|
+
two: {}
|
11
|
+
# column: value
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
2
|
+
|
3
|
+
# This model initially had no columns defined. If you add columns to the
|
4
|
+
# model remove the '{}' from the fixture names and add the columns immediately
|
5
|
+
# below each fixture, per the syntax in the comments below
|
6
|
+
#
|
7
|
+
one: {}
|
8
|
+
# column: value
|
9
|
+
#
|
10
|
+
two: {}
|
11
|
+
# column: value
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
ENV["RAILS_ENV"] = "test"
|
5
|
+
require File.join("foreman_app/config/environment.rb")
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
require 'content'
|
9
|
+
require 'rails/test_help'
|
10
|
+
|
11
|
+
Rails.backtrace_cleaner.remove_silencers!
|
12
|
+
|
13
|
+
class ActiveSupport::TestCase
|
14
|
+
foreman_dir = File.expand_path("../foreman_app", File.join(Dir.pwd, __FILE__))
|
15
|
+
fixture_path=File.join(foreman_dir, "test/fixtures")
|
16
|
+
fixtures :all
|
17
|
+
|
18
|
+
set_fixture_class({ :hosts => Host::Base })
|
19
|
+
end
|
20
|
+
|
21
|
+
def set_session_user
|
22
|
+
SETTINGS[:login] ? {:user => User.admin.id, :expires_at => 5.minutes.from_now} : {}
|
23
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Content
|
4
|
+
class DescriptionFormatValidatorModelForTest
|
5
|
+
include ActiveModel::Validations
|
6
|
+
attr_accessor :desc
|
7
|
+
def initialize(adescription); @desc = adescription; end
|
8
|
+
validates_with Content::Validators::DescriptionFormat, :attributes => :desc
|
9
|
+
end
|
10
|
+
|
11
|
+
class DescriptionFormatValidatorTest < ActiveSupport::TestCase
|
12
|
+
test "should enforce max length" do
|
13
|
+
assert !DescriptionFormatValidatorModelForTest.new("t" * (Content::Validators::DescriptionFormat::MAX_LENGTH + 1)).valid?
|
14
|
+
end
|
15
|
+
|
16
|
+
test "should be valid with allowed number of characters" do
|
17
|
+
assert DescriptionFormatValidatorModelForTest.new("a description").valid?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Content
|
4
|
+
class NameFormatValidatorModelForTest
|
5
|
+
include ActiveModel::Validations
|
6
|
+
attr_accessor :name
|
7
|
+
def initialize(aname); @name = aname; end
|
8
|
+
validates_with Content::Validators::NameFormat, :attributes => :name
|
9
|
+
end
|
10
|
+
|
11
|
+
class NameFormatValidatorTest < ActiveSupport::TestCase
|
12
|
+
test "should enforce min length" do
|
13
|
+
assert !NameFormatValidatorModelForTest.new("").valid?
|
14
|
+
end
|
15
|
+
|
16
|
+
test "should enforce max length" do
|
17
|
+
assert !NameFormatValidatorModelForTest.new("t" * (Content::Validators::NameFormat::MAX_LENGTH + 1)).valid?
|
18
|
+
end
|
19
|
+
|
20
|
+
test "should be valid with allowed characters" do
|
21
|
+
assert NameFormatValidatorModelForTest.new("abc123 _-").valid?
|
22
|
+
end
|
23
|
+
|
24
|
+
test "should be invalid with a trailing space" do
|
25
|
+
assert !NameFormatValidatorModelForTest.new("abc ").valid?
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Content
|
4
|
+
class ProductValidationTest < ActiveSupport::TestCase
|
5
|
+
test "valid product should be valid" do
|
6
|
+
assert Product.new(:name => "test", :description => "a description").valid?
|
7
|
+
end
|
8
|
+
|
9
|
+
test "should fail validation when the name is invalid" do
|
10
|
+
assert !Product.new(:name => nil, :description => "a description").valid?
|
11
|
+
assert !Product.new(:name => "t" * (Validators::NameFormat::MAX_LENGTH + 1), :description => "a description").valid?
|
12
|
+
end
|
13
|
+
|
14
|
+
test "should fail validation when the description is invalid" do
|
15
|
+
assert !Product.new(:name => "test", :description => "t" * (Validators::DescriptionFormat::MAX_LENGTH + 1)).valid?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,194 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: foreman_content
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dmitri Dolguikh
|
8
|
+
- Amos Benari
|
9
|
+
- Ohad Levy
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2013-08-01 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rails
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.8
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 3.2.8
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: logging
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 1.8.0
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.8.0
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: runcible
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ~>
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.4.10
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.4.10
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: deface
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
type: :runtime
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
description: Add Foreman support for software repositories and puppet environments
|
72
|
+
management.
|
73
|
+
email:
|
74
|
+
- witlessbird@gmail.com
|
75
|
+
- abenari@redhat.com
|
76
|
+
- ohadlevy@gmail.com
|
77
|
+
executables: []
|
78
|
+
extensions: []
|
79
|
+
extra_rdoc_files:
|
80
|
+
- README.md
|
81
|
+
files:
|
82
|
+
- app/models/setting/content.rb
|
83
|
+
- app/models/content/remote/pulp/repository.rb
|
84
|
+
- app/models/content/host_product.rb
|
85
|
+
- app/models/content/product_operatingsystem.rb
|
86
|
+
- app/models/content/gpg_key.rb
|
87
|
+
- app/models/content/orchestration/pulp.rb
|
88
|
+
- app/models/content/hostgroup_product.rb
|
89
|
+
- app/models/content/custom_repository_paths.rb
|
90
|
+
- app/models/content/operatingsystem_repository.rb
|
91
|
+
- app/models/content/validators/no_trailing_space.rb
|
92
|
+
- app/models/content/validators/name_format.rb
|
93
|
+
- app/models/content/validators/content_validator.rb
|
94
|
+
- app/models/content/validators/description_format.rb
|
95
|
+
- app/models/content/repository.rb
|
96
|
+
- app/models/content/product.rb
|
97
|
+
- app/models/content/environment_product.rb
|
98
|
+
- app/services/content/pulp_event_handler.rb
|
99
|
+
- app/overrides/add_os_conent_tab.rb
|
100
|
+
- app/overrides/add_host_conent_tab.rb
|
101
|
+
- app/overrides/add_hostgroup_conent_tab.rb
|
102
|
+
- app/controllers/content/api/repositories_controller.rb
|
103
|
+
- app/controllers/content/repositories_controller.rb
|
104
|
+
- app/controllers/content/products_controller.rb
|
105
|
+
- app/controllers/content/gpg_keys_controller.rb
|
106
|
+
- app/views/content/gpg_keys/_form.html.erb
|
107
|
+
- app/views/content/gpg_keys/new.html.erb
|
108
|
+
- app/views/content/gpg_keys/index.html.erb
|
109
|
+
- app/views/content/gpg_keys/edit.html.erb
|
110
|
+
- app/views/content/repositories/_form.html.erb
|
111
|
+
- app/views/content/repositories/new.html.erb
|
112
|
+
- app/views/content/repositories/show.html.erb
|
113
|
+
- app/views/content/repositories/index.html.erb
|
114
|
+
- app/views/content/repositories/welcome.html.erb
|
115
|
+
- app/views/content/repositories/edit.html.erb
|
116
|
+
- app/views/content/products/_form.html.erb
|
117
|
+
- app/views/content/products/new.html.erb
|
118
|
+
- app/views/content/products/_operatingsystem_tab_pane.html.erb
|
119
|
+
- app/views/content/products/_form_tab.html.erb
|
120
|
+
- app/views/content/products/_hostgroup_tab_pane.html.erb
|
121
|
+
- app/views/content/products/index.html.erb
|
122
|
+
- app/views/content/products/_host_tab_pane.html.erb
|
123
|
+
- app/views/content/products/welcome.html.erb
|
124
|
+
- app/views/content/products/edit.html.erb
|
125
|
+
- app/helpers/content/repositories_helper.rb
|
126
|
+
- app/helpers/content/application_helper.rb
|
127
|
+
- app/assets/javascripts/content/content.js
|
128
|
+
- app/assets/stylesheets/content/application.css
|
129
|
+
- config/routes.rb
|
130
|
+
- db/migrate/20130702162629_create_content_products.rb
|
131
|
+
- db/migrate/20130709001120_create_content_gpg_keys.rb
|
132
|
+
- db/migrate/20130722084911_create_content_operatingsystem_repositories.rb
|
133
|
+
- db/migrate/20130717032320_create_content_environments_products.rb
|
134
|
+
- db/migrate/20130723124911_create_content_host_products.rb
|
135
|
+
- db/migrate/20130729032320_create_content_product_operatingsystems.rb
|
136
|
+
- db/migrate/20130702140034_create_content_repositories.rb
|
137
|
+
- db/migrate/20130723084911_create_content_hostgroup_products.rb
|
138
|
+
- lib/content_hostgroup.rb
|
139
|
+
- lib/content_environment.rb
|
140
|
+
- lib/content_redhat.rb
|
141
|
+
- lib/content_home_helper_patch.rb
|
142
|
+
- lib/content_taxonomy.rb
|
143
|
+
- lib/content/engine.rb
|
144
|
+
- lib/content/version.rb
|
145
|
+
- lib/content_operatingsystem.rb
|
146
|
+
- lib/foreman_content.rb
|
147
|
+
- lib/tasks/content_tasks.rake
|
148
|
+
- lib/content_host.rb
|
149
|
+
- lib/pulp_configuration.rb
|
150
|
+
- Rakefile
|
151
|
+
- README.md
|
152
|
+
- test/unit/content/description_format_validator_test.rb
|
153
|
+
- test/unit/content/repositories_test.rb
|
154
|
+
- test/unit/content/product_validation_test.rb
|
155
|
+
- test/unit/content/name_format_validator_test.rb
|
156
|
+
- test/test_helper.rb
|
157
|
+
- test/fixtures/content/products.yml
|
158
|
+
- test/fixtures/content/repositories.yml
|
159
|
+
- test/content_test.rb
|
160
|
+
- test/integration/navigation_test.rb
|
161
|
+
homepage: https://github.com/theforeman/foreman_content
|
162
|
+
licenses:
|
163
|
+
- GPL-3
|
164
|
+
metadata: {}
|
165
|
+
post_install_message:
|
166
|
+
rdoc_options: []
|
167
|
+
require_paths:
|
168
|
+
- lib
|
169
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - '>='
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
requirements: []
|
180
|
+
rubyforge_project:
|
181
|
+
rubygems_version: 2.0.5
|
182
|
+
signing_key:
|
183
|
+
specification_version: 4
|
184
|
+
summary: Add Foreman support for content management.
|
185
|
+
test_files:
|
186
|
+
- test/unit/content/description_format_validator_test.rb
|
187
|
+
- test/unit/content/repositories_test.rb
|
188
|
+
- test/unit/content/product_validation_test.rb
|
189
|
+
- test/unit/content/name_format_validator_test.rb
|
190
|
+
- test/test_helper.rb
|
191
|
+
- test/fixtures/content/products.yml
|
192
|
+
- test/fixtures/content/repositories.yml
|
193
|
+
- test/content_test.rb
|
194
|
+
- test/integration/navigation_test.rb
|