katello-foreman-engine 0.0.3 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/katello-foreman-engine.gemspec +5 -2
- data/lib/katello_foreman_engine/actions/content_view_demote.rb +12 -0
- data/lib/katello_foreman_engine/actions/content_view_promote.rb +13 -1
- data/lib/katello_foreman_engine/actions/content_view_publish.rb +42 -0
- data/lib/katello_foreman_engine/actions/distribution_publish.rb +26 -7
- data/lib/katello_foreman_engine/actions/distribution_unpublish.rb +12 -0
- data/lib/katello_foreman_engine/actions/environment_create.rb +13 -3
- data/lib/katello_foreman_engine/actions/environment_destroy.rb +13 -1
- data/lib/katello_foreman_engine/actions/org_create.rb +12 -0
- data/lib/katello_foreman_engine/actions/org_destroy.rb +13 -1
- data/lib/katello_foreman_engine/actions/repository_change.rb +4 -0
- data/lib/katello_foreman_engine/actions/user_create.rb +12 -0
- data/lib/katello_foreman_engine/actions/user_destroy.rb +12 -0
- data/lib/katello_foreman_engine/bindings.rb +21 -10
- data/lib/katello_foreman_engine/settings.rb +1 -0
- data/test/lib/actions/content_view_publish_test.rb +45 -0
- data/test/lib/actions/distribution_publish_test.rb +23 -4
- data/test/lib/actions/env_create_test.rb +6 -2
- data/test/lib/actions/env_destroy_test.rb +5 -2
- data/test/lib/actions/org_destroy_test.rb +1 -1
- metadata +19 -23
- data/.gitignore +0 -3
- data/rel-eng/packages/.readme +0 -3
- data/rel-eng/packages/rubygem-katello-foreman-engine +0 -1
- data/rel-eng/tito.props +0 -8
- data/rubygem-katello-foreman-engine.spec +0 -92
- data/script/rails +0 -8
@@ -1,12 +1,15 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "katello-foreman-engine"
|
3
|
-
s.version = "0.0.
|
3
|
+
s.version = "0.0.6"
|
4
4
|
|
5
5
|
s.authors = ["Katello"]
|
6
6
|
s.date = "2013-04-19"
|
7
7
|
s.description = "Foreman specific parts in Katello"
|
8
8
|
s.email = "katello-devel@redhat.com"
|
9
|
-
s.files =
|
9
|
+
s.files = %w(Gemfile katello-foreman-engine.gemspec LICENSE Rakefile)
|
10
|
+
s.files += Dir["lib/**/*.rb"]
|
11
|
+
s.files += Dir["test/test_helper.rb"]
|
12
|
+
s.files += Dir["test/lib/**/*.rb"]
|
10
13
|
s.homepage = "http://github.com/katello/katello-foreman-engine"
|
11
14
|
s.licenses = ["GPL-2"]
|
12
15
|
s.require_paths = ["lib"]
|
@@ -1,3 +1,15 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2013 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# This software is licensed to you under the GNU General Public
|
5
|
+
# License as published by the Free Software Foundation; either version
|
6
|
+
# 2 of the License (GPLv2) or (at your option) any later version.
|
7
|
+
# There is NO WARRANTY for this software, express or implied,
|
8
|
+
# including the implied warranties of MERCHANTABILITY,
|
9
|
+
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
10
|
+
# have received a copy of GPLv2 along with this software; if not, see
|
11
|
+
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
12
|
+
|
1
13
|
module KatelloForemanEngine
|
2
14
|
module Actions
|
3
15
|
class ContentViewDemote < Dynflow::Action
|
@@ -1,3 +1,15 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2013 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# This software is licensed to you under the GNU General Public
|
5
|
+
# License as published by the Free Software Foundation; either version
|
6
|
+
# 2 of the License (GPLv2) or (at your option) any later version.
|
7
|
+
# There is NO WARRANTY for this software, express or implied,
|
8
|
+
# including the implied warranties of MERCHANTABILITY,
|
9
|
+
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
10
|
+
# have received a copy of GPLv2 along with this software; if not, see
|
11
|
+
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
12
|
+
|
1
13
|
module KatelloForemanEngine
|
2
14
|
module Actions
|
3
15
|
class ContentViewPromote < Dynflow::Action
|
@@ -10,7 +22,7 @@ module KatelloForemanEngine
|
|
10
22
|
unless Bindings.environment_find(input['organization_label'], input['to_env_label'], input['label'])
|
11
23
|
plan_self input
|
12
24
|
end
|
13
|
-
content_view.repos(to_env) do |repo|
|
25
|
+
content_view.repos(to_env).each do |repo|
|
14
26
|
plan_action(RepositoryChange, repo)
|
15
27
|
end
|
16
28
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2013 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# This software is licensed to you under the GNU General Public
|
5
|
+
# License as published by the Free Software Foundation; either version
|
6
|
+
# 2 of the License (GPLv2) or (at your option) any later version.
|
7
|
+
# There is NO WARRANTY for this software, express or implied,
|
8
|
+
# including the implied warranties of MERCHANTABILITY,
|
9
|
+
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
10
|
+
# have received a copy of GPLv2 along with this software; if not, see
|
11
|
+
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
12
|
+
|
13
|
+
module KatelloForemanEngine
|
14
|
+
module Actions
|
15
|
+
class ContentViewPublish < Dynflow::Action
|
16
|
+
|
17
|
+
def self.subscribe
|
18
|
+
[Katello::Actions::ContentViewPublish,
|
19
|
+
Katello::Actions::ContentViewRefresh]
|
20
|
+
end
|
21
|
+
|
22
|
+
def plan(content_view)
|
23
|
+
unless Bindings.environment_find(input['organization_label'], 'Library', input['label'])
|
24
|
+
plan_self input
|
25
|
+
end
|
26
|
+
content_view.repos(content_view.organization.library).each do |repo|
|
27
|
+
plan_action(RepositoryChange, repo)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
input_format do
|
32
|
+
param :id, Integer
|
33
|
+
param :label, String
|
34
|
+
param :organization_label, String
|
35
|
+
end
|
36
|
+
|
37
|
+
def run
|
38
|
+
Bindings.environment_create(input['id'], input['organization_label'], 'Library', input['label'])
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -1,3 +1,15 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2013 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# This software is licensed to you under the GNU General Public
|
5
|
+
# License as published by the Free Software Foundation; either version
|
6
|
+
# 2 of the License (GPLv2) or (at your option) any later version.
|
7
|
+
# There is NO WARRANTY for this software, express or implied,
|
8
|
+
# including the implied warranties of MERCHANTABILITY,
|
9
|
+
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
10
|
+
# have received a copy of GPLv2 along with this software; if not, see
|
11
|
+
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
12
|
+
|
1
13
|
module KatelloForemanEngine
|
2
14
|
module Actions
|
3
15
|
class DistributionPublish < Dynflow::Action
|
@@ -21,12 +33,13 @@ module KatelloForemanEngine
|
|
21
33
|
def run
|
22
34
|
medium_name = construct_medium_name
|
23
35
|
medium_path = Helpers.installation_media_path(input['repo']['uri'])
|
36
|
+
org_label = input['repo']['organization_label']
|
24
37
|
return if Bindings.medium_find(medium_path)
|
25
38
|
|
26
39
|
arch = find_or_create_arch
|
27
40
|
os = find_or_create_operating_system
|
28
41
|
assign_arch_to_os(os, arch)
|
29
|
-
medium = Bindings.medium_create(medium_name, medium_path)
|
42
|
+
medium = Bindings.medium_create(medium_name, medium_path, org_label)
|
30
43
|
assign_medium_to_os(os, medium)
|
31
44
|
end
|
32
45
|
|
@@ -88,15 +101,21 @@ module KatelloForemanEngine
|
|
88
101
|
parts << input['variant']
|
89
102
|
parts << input['version']
|
90
103
|
parts << input['arch']
|
91
|
-
name = parts.join(' ')
|
92
|
-
|
93
|
-
# charatcers for medium name
|
94
|
-
name.sub!('Red Hat Enterprise Linux','RHEL')
|
95
|
-
return name
|
104
|
+
name = parts.reject(&:blank?).join(' ')
|
105
|
+
return normalize_name(name)
|
96
106
|
end
|
97
107
|
|
98
108
|
def construct_operating_system_name
|
99
|
-
|
109
|
+
if input['family'].include? 'Red Hat'
|
110
|
+
return 'RedHat'
|
111
|
+
else
|
112
|
+
return input['family'].gsub(' ', '_')
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# Foreman and Puppet uses RedHat name for Red Hat Enterprise Linux
|
117
|
+
def normalize_name(name)
|
118
|
+
name.sub('Red Hat Enterprise Linux','RedHat')
|
100
119
|
end
|
101
120
|
|
102
121
|
end
|
@@ -1,3 +1,15 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2013 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# This software is licensed to you under the GNU General Public
|
5
|
+
# License as published by the Free Software Foundation; either version
|
6
|
+
# 2 of the License (GPLv2) or (at your option) any later version.
|
7
|
+
# There is NO WARRANTY for this software, express or implied,
|
8
|
+
# including the implied warranties of MERCHANTABILITY,
|
9
|
+
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
10
|
+
# have received a copy of GPLv2 along with this software; if not, see
|
11
|
+
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
12
|
+
|
1
13
|
module KatelloForemanEngine
|
2
14
|
module Actions
|
3
15
|
class DistributionUnpublish < Dynflow::Action
|
@@ -1,3 +1,15 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2013 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# This software is licensed to you under the GNU General Public
|
5
|
+
# License as published by the Free Software Foundation; either version
|
6
|
+
# 2 of the License (GPLv2) or (at your option) any later version.
|
7
|
+
# There is NO WARRANTY for this software, express or implied,
|
8
|
+
# including the implied warranties of MERCHANTABILITY,
|
9
|
+
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
10
|
+
# have received a copy of GPLv2 along with this software; if not, see
|
11
|
+
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
12
|
+
|
1
13
|
module KatelloForemanEngine
|
2
14
|
module Actions
|
3
15
|
class EnvironmentCreate < Dynflow::Action
|
@@ -7,9 +19,7 @@ module KatelloForemanEngine
|
|
7
19
|
end
|
8
20
|
|
9
21
|
def plan(env)
|
10
|
-
|
11
|
-
plan_self 'org_label' => env.organization.label, 'label' => env.label, 'content_view_id' => 'env'
|
12
|
-
end
|
22
|
+
plan_self 'org_label' => env.organization.label, 'label' => env.label, 'content_view_id' => 'env'
|
13
23
|
end
|
14
24
|
|
15
25
|
input_format do
|
@@ -1,3 +1,15 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2013 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# This software is licensed to you under the GNU General Public
|
5
|
+
# License as published by the Free Software Foundation; either version
|
6
|
+
# 2 of the License (GPLv2) or (at your option) any later version.
|
7
|
+
# There is NO WARRANTY for this software, express or implied,
|
8
|
+
# including the implied warranties of MERCHANTABILITY,
|
9
|
+
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
10
|
+
# have received a copy of GPLv2 along with this software; if not, see
|
11
|
+
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
12
|
+
|
1
13
|
module KatelloForemanEngine
|
2
14
|
module Actions
|
3
15
|
class EnvironmentDestroy < Dynflow::Action
|
@@ -11,7 +23,7 @@ module KatelloForemanEngine
|
|
11
23
|
end
|
12
24
|
|
13
25
|
def plan(env)
|
14
|
-
if
|
26
|
+
if foreman_env = Bindings.environment_find(env.organization.label, env.label)
|
15
27
|
env.content_views.each do |content_view|
|
16
28
|
plan_action(ContentViewDemote, content_view, env)
|
17
29
|
end
|
@@ -1,3 +1,15 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2013 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# This software is licensed to you under the GNU General Public
|
5
|
+
# License as published by the Free Software Foundation; either version
|
6
|
+
# 2 of the License (GPLv2) or (at your option) any later version.
|
7
|
+
# There is NO WARRANTY for this software, express or implied,
|
8
|
+
# including the implied warranties of MERCHANTABILITY,
|
9
|
+
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
10
|
+
# have received a copy of GPLv2 along with this software; if not, see
|
11
|
+
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
12
|
+
|
1
13
|
module KatelloForemanEngine
|
2
14
|
module Actions
|
3
15
|
class OrgCreate < Dynflow::Action
|
@@ -1,3 +1,15 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2013 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# This software is licensed to you under the GNU General Public
|
5
|
+
# License as published by the Free Software Foundation; either version
|
6
|
+
# 2 of the License (GPLv2) or (at your option) any later version.
|
7
|
+
# There is NO WARRANTY for this software, express or implied,
|
8
|
+
# including the implied warranties of MERCHANTABILITY,
|
9
|
+
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
10
|
+
# have received a copy of GPLv2 along with this software; if not, see
|
11
|
+
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
12
|
+
|
1
13
|
module KatelloForemanEngine
|
2
14
|
module Actions
|
3
15
|
class OrgDestroy < Dynflow::Action
|
@@ -11,7 +23,7 @@ module KatelloForemanEngine
|
|
11
23
|
end
|
12
24
|
|
13
25
|
def plan(org)
|
14
|
-
if foreman_org = Bindings.organization_find(
|
26
|
+
if foreman_org = Bindings.organization_find(input['label'])
|
15
27
|
plan_self('foreman_id' => foreman_org['organization']['id'])
|
16
28
|
end
|
17
29
|
end
|
@@ -1,3 +1,15 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2013 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# This software is licensed to you under the GNU General Public
|
5
|
+
# License as published by the Free Software Foundation; either version
|
6
|
+
# 2 of the License (GPLv2) or (at your option) any later version.
|
7
|
+
# There is NO WARRANTY for this software, express or implied,
|
8
|
+
# including the implied warranties of MERCHANTABILITY,
|
9
|
+
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
10
|
+
# have received a copy of GPLv2 along with this software; if not, see
|
11
|
+
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
12
|
+
|
1
13
|
module KatelloForemanEngine
|
2
14
|
module Actions
|
3
15
|
class UserCreate < Dynflow::Action
|
@@ -1,3 +1,15 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2013 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# This software is licensed to you under the GNU General Public
|
5
|
+
# License as published by the Free Software Foundation; either version
|
6
|
+
# 2 of the License (GPLv2) or (at your option) any later version.
|
7
|
+
# There is NO WARRANTY for this software, express or implied,
|
8
|
+
# including the implied warranties of MERCHANTABILITY,
|
9
|
+
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
10
|
+
# have received a copy of GPLv2 along with this software; if not, see
|
11
|
+
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
12
|
+
|
1
13
|
module KatelloForemanEngine
|
2
14
|
module Actions
|
3
15
|
class UserDestroy < Dynflow::Action
|
@@ -54,7 +54,8 @@ module KatelloForemanEngine
|
|
54
54
|
return user_resource
|
55
55
|
end
|
56
56
|
|
57
|
-
def organization_find(
|
57
|
+
def organization_find(kt_label)
|
58
|
+
name = "KT-[#{kt_label}]"
|
58
59
|
orgs, _ = base.http_call('get', '/api/organizations', 'search' => "name = #{name}")
|
59
60
|
return orgs.first
|
60
61
|
end
|
@@ -62,7 +63,7 @@ module KatelloForemanEngine
|
|
62
63
|
def organization_create(name)
|
63
64
|
base.http_call('post', '/api/organizations',
|
64
65
|
:organization => {:name => name,
|
65
|
-
:ignore_types => %w[User SmartProxy Subnet ComputeResource
|
66
|
+
:ignore_types => %w[User SmartProxy Subnet ComputeResource ConfigTemplate Domain] })
|
66
67
|
end
|
67
68
|
|
68
69
|
def organization_destroy(id)
|
@@ -80,7 +81,7 @@ module KatelloForemanEngine
|
|
80
81
|
|
81
82
|
def environment_create(content_view_id, org_label, env_label, content_view_label = nil)
|
82
83
|
params = {:org => org_label, :env => env_label, :content_view => content_view_label, :content_view_id => content_view_id}
|
83
|
-
if foreman_org = organization_find(
|
84
|
+
if foreman_org = organization_find(org_label)
|
84
85
|
params[:org_id] = foreman_org['organization']['id']
|
85
86
|
end
|
86
87
|
base.http_call('post', '/foreman_katello_engine/api/environments', params)
|
@@ -116,7 +117,7 @@ module KatelloForemanEngine
|
|
116
117
|
end
|
117
118
|
|
118
119
|
def operating_system_find(name, major, minor)
|
119
|
-
find_resource(operating_system,
|
120
|
+
find_resource(operating_system, %{name = "#{name}" AND major = "#{major}" AND minor = "#{minor}"})
|
120
121
|
end
|
121
122
|
|
122
123
|
def operating_system_create(name, major, minor)
|
@@ -126,7 +127,12 @@ module KatelloForemanEngine
|
|
126
127
|
'minor' => minor.to_s,
|
127
128
|
'family' => Settings['foreman_os_family']
|
128
129
|
}
|
129
|
-
|
130
|
+
provisioning_template_name = if name == 'RedHat'
|
131
|
+
Settings['foreman_os_rhel_provisioning_template']
|
132
|
+
else
|
133
|
+
Settings['foreman_os_provisioning_template']
|
134
|
+
end
|
135
|
+
templates_to_add = [template_find(provisioning_template_name),
|
130
136
|
template_find(Settings['foreman_os_pxe_template'])].compact
|
131
137
|
data['os_default_templates_attributes'] = templates_to_add.map do |template|
|
132
138
|
{
|
@@ -169,12 +175,17 @@ module KatelloForemanEngine
|
|
169
175
|
find_resource(medium, %{path = "#{path}"})
|
170
176
|
end
|
171
177
|
|
172
|
-
def medium_create(name, path)
|
178
|
+
def medium_create(name, path, org_label)
|
179
|
+
params = {
|
180
|
+
'name' => name,
|
181
|
+
'path' => path,
|
182
|
+
'os_family' => Settings['foreman_os_family']
|
183
|
+
}
|
184
|
+
if foreman_org = organization_find(org_label)
|
185
|
+
params['organization_ids'] = [foreman_org['organization']['id']]
|
186
|
+
end
|
173
187
|
without_root_key do
|
174
|
-
self.medium.create('medium' =>
|
175
|
-
'name' => name,
|
176
|
-
'path' => path,
|
177
|
-
'os_family' => Settings['foreman_os_family']})
|
188
|
+
self.medium.create('medium' => params)
|
178
189
|
end
|
179
190
|
end
|
180
191
|
|
@@ -8,6 +8,7 @@ module KatelloForemanEngine
|
|
8
8
|
'oauth_consumer_secret' => Katello.config.foreman.oauth_secret,
|
9
9
|
# TODO: make the following options configurable:
|
10
10
|
'foreman_os_family' => 'Redhat',
|
11
|
+
'foreman_os_rhel_provisioning_template' => 'Katello Kickstart Default for RHEL',
|
11
12
|
'foreman_os_provisioning_template' => 'Katello Kickstart Default',
|
12
13
|
'foreman_os_pxe_template' => 'Kickstart default PXElinux',
|
13
14
|
'foreman_os_ptable' => 'RedHat default',
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module KatelloForemanEngine
|
4
|
+
module Actions
|
5
|
+
class ContentViewPublishTest < ActiveSupport::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@org = Organization.new(:label => 'org')
|
9
|
+
@content_view = ContentView.new { |cv| cv.organization = @org }
|
10
|
+
@content_view.stubs(:repos).returns([])
|
11
|
+
|
12
|
+
@input = { 'organization_label' => 'ACME',
|
13
|
+
'id' => '123',
|
14
|
+
'label' => 'cv' }
|
15
|
+
end
|
16
|
+
|
17
|
+
test "runs unless the environment in foreman is already created " do
|
18
|
+
Bindings.stubs(:environment_find).with('ACME', 'Library', 'cv').returns(nil)
|
19
|
+
|
20
|
+
step = run_steps(ContentViewPublish, @input, @content_view).first
|
21
|
+
assert_equal ContentViewPublish, step.action_class
|
22
|
+
assert_equal step.input, @input
|
23
|
+
|
24
|
+
Bindings.stubs(:environment_find).with('ACME', 'Library', 'cv').returns({'id' => '123'})
|
25
|
+
assert_equal [], run_steps(ContentViewPublish, @input, @content_view)
|
26
|
+
end
|
27
|
+
|
28
|
+
test "plans repository change action for every repo involved" do
|
29
|
+
Bindings.stubs(:environment_find).with('ACME', 'Library', 'cv').returns({'id' => '123'})
|
30
|
+
repo = Repository.new
|
31
|
+
@content_view.stubs(:repos).returns([repo])
|
32
|
+
|
33
|
+
action_class, arg = planned_actions(ContentViewPublish, @input, @content_view).first
|
34
|
+
assert_equal RepositoryChange, action_class
|
35
|
+
assert_equal arg, repo
|
36
|
+
end
|
37
|
+
|
38
|
+
test 'calls bindings to create environment' do
|
39
|
+
Bindings.expects(:environment_create).with('123', 'org', 'Library', 'cv')
|
40
|
+
ContentViewPublish.new('organization_label' => 'org', 'label' => 'cv', 'id' => '123').run
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -21,15 +21,18 @@ module KatelloForemanEngine
|
|
21
21
|
}
|
22
22
|
|
23
23
|
@arch = 'x86_64'
|
24
|
-
@os_name = '
|
24
|
+
@os_name = 'RedHat'
|
25
25
|
@os_major = '6'
|
26
26
|
@os_minor = '3'
|
27
27
|
|
28
|
-
@medium_name = 'Org/Env
|
28
|
+
@medium_name = 'Org/Env RedHat Server 6.3 x86_64'
|
29
29
|
@medium_path = 'http://example.com/pulp/repos/os/'
|
30
30
|
|
31
31
|
@arch_output = {'architecture' => { 'id' => 1, 'name' => @arch }}
|
32
32
|
@ptable_output = {'ptable' => { 'id' => 1, 'name' => 'RedHat default' }}
|
33
|
+
@organization_output = {
|
34
|
+
'organization' => { 'id' => 1 }
|
35
|
+
}
|
33
36
|
@os_output = {
|
34
37
|
'operatingsystem' => {
|
35
38
|
'id' => 1,
|
@@ -50,6 +53,7 @@ module KatelloForemanEngine
|
|
50
53
|
}
|
51
54
|
}
|
52
55
|
|
56
|
+
Bindings.stubs(:organization_find).with('Org').returns(@organization_output)
|
53
57
|
stub_foreman_search(:architecture, "name = #{@arch}", @arch_output)
|
54
58
|
stub_foreman_search(:ptable, %{name = "RedHat default"}, @ptable_output)
|
55
59
|
stub_foreman_call(:medium, :index, nil, [])
|
@@ -57,7 +61,7 @@ module KatelloForemanEngine
|
|
57
61
|
stub_foreman_call(:operating_system, :index, nil, [])
|
58
62
|
stub_foreman_call(:operating_system, :create, nil, @os_output)
|
59
63
|
stub_foreman_call(:operating_system, :update)
|
60
|
-
stub_foreman_search(:config_template, %{name = "Katello Kickstart Default"}, nil)
|
64
|
+
stub_foreman_search(:config_template, %{name = "Katello Kickstart Default for RHEL"}, nil)
|
61
65
|
stub_foreman_search(:config_template, %{name = "Kickstart default PXElinux"}, nil)
|
62
66
|
stub_foreman_search(:ptable, %{name = "RedHat default"}, nil)
|
63
67
|
stub_foreman_call(:operating_system, :index, nil, [])
|
@@ -113,12 +117,27 @@ module KatelloForemanEngine
|
|
113
117
|
end
|
114
118
|
|
115
119
|
test "creates medium and assigns it to the os in not created yet" do
|
116
|
-
|
120
|
+
medium_params = {
|
121
|
+
'name' => @medium_name,
|
122
|
+
'path' => @medium_path,
|
123
|
+
'os_family' => 'Redhat',
|
124
|
+
'organization_ids' => [1],
|
125
|
+
}
|
126
|
+
expect_foreman_call(:medium, :create, medium_params, @medium_output)
|
117
127
|
expected_data = {'id' => 1, 'medium_ids' => [@medium_output['medium']['id']]}
|
118
128
|
expect_foreman_call(:operating_system, :update, expected_data)
|
119
129
|
run_action
|
120
130
|
end
|
121
131
|
|
132
|
+
test "it constructs medium name that foreman accepts" do
|
133
|
+
action = DistributionPublish.new(@input)
|
134
|
+
assert_equal 'Org/Env RedHat Server 6.3 x86_64', action.send(:construct_medium_name)
|
135
|
+
|
136
|
+
@input['variant'] = ''
|
137
|
+
@input['arch'] = nil
|
138
|
+
assert_equal 'Org/Env RedHat 6.3', action.send(:construct_medium_name)
|
139
|
+
end
|
140
|
+
|
122
141
|
end
|
123
142
|
end
|
124
143
|
end
|
@@ -4,7 +4,7 @@ module KatelloForemanEngine
|
|
4
4
|
module Actions
|
5
5
|
class EnvCreateTest < ActiveSupport::TestCase
|
6
6
|
|
7
|
-
test "
|
7
|
+
test "runs both for library and non-library envs " do
|
8
8
|
org = Organization.new(:label => 'org')
|
9
9
|
env = KTEnvironment.new(:label => 'dev')
|
10
10
|
env.organization = org
|
@@ -17,7 +17,11 @@ module KatelloForemanEngine
|
|
17
17
|
assert_equal 'env', step.input['content_view_id']
|
18
18
|
|
19
19
|
env.library = true
|
20
|
-
|
20
|
+
step = run_steps(EnvironmentCreate, {}, env).first
|
21
|
+
assert_equal EnvironmentCreate, step.action_class
|
22
|
+
assert_equal 'org', step.input['org_label']
|
23
|
+
assert_equal 'dev', step.input['label']
|
24
|
+
assert_equal 'env', step.input['content_view_id']
|
21
25
|
end
|
22
26
|
|
23
27
|
test 'calls bindings to create environment' do
|
@@ -10,7 +10,8 @@ module KatelloForemanEngine
|
|
10
10
|
env.organization = org
|
11
11
|
|
12
12
|
foreman_env = { 'environment' => { 'id' => '123' } }
|
13
|
-
Bindings.expects(:environment_find).with('org', 'dev').
|
13
|
+
Bindings.expects(:environment_find).with('org', 'dev').
|
14
|
+
times(2).returns(foreman_env)
|
14
15
|
|
15
16
|
env.library = false
|
16
17
|
step = run_steps(EnvironmentDestroy,{}, env).first
|
@@ -18,7 +19,9 @@ module KatelloForemanEngine
|
|
18
19
|
assert_equal step.input['foreman_id'], '123'
|
19
20
|
|
20
21
|
env.library = true
|
21
|
-
|
22
|
+
step = run_steps(EnvironmentDestroy,{}, env).first
|
23
|
+
assert_equal EnvironmentDestroy, step.action_class
|
24
|
+
assert_equal step.input['foreman_id'], '123'
|
22
25
|
|
23
26
|
env.library = false
|
24
27
|
Bindings.expects(:environment_find).returns(nil)
|
@@ -6,7 +6,7 @@ module KatelloForemanEngine
|
|
6
6
|
|
7
7
|
test "runs only when the org is present in Foreman" do
|
8
8
|
foreman_org = { 'organization' => { 'id' => '123' } }
|
9
|
-
Bindings.expects(:organization_find).with('
|
9
|
+
Bindings.expects(:organization_find).with('test').returns(foreman_org)
|
10
10
|
step = run_steps(OrgDestroy, {'label' => 'test'}, nil).first
|
11
11
|
assert_equal OrgDestroy, step.action_class
|
12
12
|
assert_equal step.input['foreman_id'], '123'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: katello-foreman-engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -49,44 +49,40 @@ executables: []
|
|
49
49
|
extensions: []
|
50
50
|
extra_rdoc_files: []
|
51
51
|
files:
|
52
|
-
- .gitignore
|
53
52
|
- Gemfile
|
53
|
+
- katello-foreman-engine.gemspec
|
54
54
|
- LICENSE
|
55
55
|
- Rakefile
|
56
|
-
- katello-foreman-engine.gemspec
|
57
|
-
- lib/katello-foreman-engine.rb
|
58
56
|
- lib/katello_foreman_engine.rb
|
59
57
|
- lib/katello_foreman_engine/actions/changeset_promote.rb
|
60
|
-
- lib/katello_foreman_engine/actions/content_view_demote.rb
|
61
58
|
- lib/katello_foreman_engine/actions/content_view_promote.rb
|
62
|
-
- lib/katello_foreman_engine/actions/
|
59
|
+
- lib/katello_foreman_engine/actions/content_view_publish.rb
|
60
|
+
- lib/katello_foreman_engine/actions/repository_change.rb
|
61
|
+
- lib/katello_foreman_engine/actions/content_view_demote.rb
|
62
|
+
- lib/katello_foreman_engine/actions/user_destroy.rb
|
63
63
|
- lib/katello_foreman_engine/actions/distribution_unpublish.rb
|
64
|
-
- lib/katello_foreman_engine/actions/
|
65
|
-
- lib/katello_foreman_engine/actions/environment_destroy.rb
|
66
|
-
- lib/katello_foreman_engine/actions/org_create.rb
|
64
|
+
- lib/katello_foreman_engine/actions/distribution_publish.rb
|
67
65
|
- lib/katello_foreman_engine/actions/org_destroy.rb
|
68
|
-
- lib/katello_foreman_engine/actions/repository_change.rb
|
69
66
|
- lib/katello_foreman_engine/actions/user_create.rb
|
70
|
-
- lib/katello_foreman_engine/actions/
|
71
|
-
- lib/katello_foreman_engine/
|
67
|
+
- lib/katello_foreman_engine/actions/org_create.rb
|
68
|
+
- lib/katello_foreman_engine/actions/environment_create.rb
|
69
|
+
- lib/katello_foreman_engine/actions/environment_destroy.rb
|
70
|
+
- lib/katello_foreman_engine/settings.rb
|
72
71
|
- lib/katello_foreman_engine/engine.rb
|
73
72
|
- lib/katello_foreman_engine/helpers.rb
|
74
|
-
- lib/katello_foreman_engine/
|
75
|
-
-
|
76
|
-
-
|
77
|
-
-
|
78
|
-
-
|
79
|
-
- script/rails
|
80
|
-
- test/lib/actions/distribution_publish_test.rb
|
73
|
+
- lib/katello_foreman_engine/bindings.rb
|
74
|
+
- lib/katello-foreman-engine.rb
|
75
|
+
- test/test_helper.rb
|
76
|
+
- test/lib/settings_test.rb
|
77
|
+
- test/lib/actions/env_destroy_test.rb
|
81
78
|
- test/lib/actions/distribution_unpublish_test.rb
|
79
|
+
- test/lib/actions/org_destroy_test.rb
|
82
80
|
- test/lib/actions/env_create_test.rb
|
83
|
-
- test/lib/actions/env_destroy_test.rb
|
84
81
|
- test/lib/actions/org_create_test.rb
|
85
|
-
- test/lib/actions/org_destroy_test.rb
|
86
82
|
- test/lib/actions/repository_change_test.rb
|
83
|
+
- test/lib/actions/distribution_publish_test.rb
|
84
|
+
- test/lib/actions/content_view_publish_test.rb
|
87
85
|
- test/lib/bindings_test.rb
|
88
|
-
- test/lib/settings_test.rb
|
89
|
-
- test/test_helper.rb
|
90
86
|
homepage: http://github.com/katello/katello-foreman-engine
|
91
87
|
licenses:
|
92
88
|
- GPL-2
|
data/.gitignore
DELETED
data/rel-eng/packages/.readme
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.0.3-1 /
|
data/rel-eng/tito.props
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
%{?scl:%scl_package rubygem-%{gem_name}}
|
2
|
-
%{!?scl:%global pkg_name %{name}}
|
3
|
-
|
4
|
-
%global gem_name katello-foreman-engine
|
5
|
-
|
6
|
-
%define rubyabi 1.9.1
|
7
|
-
%global katello_bundlerd_dir /usr/share/katello/bundler.d
|
8
|
-
|
9
|
-
Summary: Foreman specific parts of Katello
|
10
|
-
Name: %{?scl_prefix}rubygem-%{gem_name}
|
11
|
-
Version: 0.0.3
|
12
|
-
Release: 1%{?dist}
|
13
|
-
Group: Development/Libraries
|
14
|
-
License: GPLv2
|
15
|
-
URL: http://github.com/Katello/katello-foreman-engine
|
16
|
-
Source0: http://rubygems.org/downloads/%{gem_name}-%{version}.gem
|
17
|
-
Requires: katello
|
18
|
-
Requires: %{?scl_prefix}ruby(abi) >= %{rubyabi}
|
19
|
-
Requires: %{?scl_prefix}rubygem(foreman_api)
|
20
|
-
Requires: %{?scl_prefix}rubygems
|
21
|
-
BuildRequires: %{?scl_prefix}rubygems-devel
|
22
|
-
BuildRequires: %{?scl_prefix}ruby(abi) >= %{rubyabi}
|
23
|
-
BuildRequires: %{?scl_prefix}rubygems
|
24
|
-
BuildArch: noarch
|
25
|
-
Provides: %{?scl_prefix}rubygem(%{gem_name}) = %{version}
|
26
|
-
|
27
|
-
%description
|
28
|
-
Foreman specific parts of Katello.
|
29
|
-
|
30
|
-
%package doc
|
31
|
-
BuildArch: noarch
|
32
|
-
Requires: %{?scl_prefix}%{pkg_name} = %{version}-%{release}
|
33
|
-
Summary: Documentation for rubygem-%{gem_name}
|
34
|
-
|
35
|
-
%description doc
|
36
|
-
This package contains documentation for rubygem-%{gem_name}.
|
37
|
-
|
38
|
-
%prep
|
39
|
-
%setup -n %{pkg_name}-%{version} -q -c -T
|
40
|
-
mkdir -p .%{gem_dir}
|
41
|
-
%{?scl:scl enable %{scl} "}
|
42
|
-
gem install --local --install-dir .%{gem_dir} \
|
43
|
-
--force %{SOURCE0} --no-rdoc --no-ri
|
44
|
-
%{?scl:"}
|
45
|
-
|
46
|
-
%build
|
47
|
-
|
48
|
-
%install
|
49
|
-
mkdir -p %{buildroot}%{gem_dir}
|
50
|
-
cp -a .%{gem_dir}/* \
|
51
|
-
%{buildroot}%{gem_dir}/
|
52
|
-
|
53
|
-
mkdir -p %{buildroot}%{katello_bundlerd_dir}
|
54
|
-
cat <<GEMFILE > %{buildroot}%{katello_bundlerd_dir}/foreman.rb
|
55
|
-
gem 'katello-foreman-engine'
|
56
|
-
GEMFILE
|
57
|
-
|
58
|
-
|
59
|
-
%files
|
60
|
-
%dir %{gem_instdir}
|
61
|
-
%{gem_instdir}/lib
|
62
|
-
%{gem_instdir}/script
|
63
|
-
%exclude %{gem_cache}
|
64
|
-
%{gem_spec}
|
65
|
-
%{katello_bundlerd_dir}/foreman.rb
|
66
|
-
%doc %{gem_instdir}/LICENSE
|
67
|
-
|
68
|
-
%exclude %{gem_instdir}/.gitignore
|
69
|
-
%exclude %{gem_instdir}/test
|
70
|
-
#%exclude %{gem_instdir}/.travis.yml
|
71
|
-
%exclude %{gem_dir}/cache/%{gem_name}-%{version}.gem
|
72
|
-
|
73
|
-
%files doc
|
74
|
-
%doc %{gem_instdir}/LICENSE
|
75
|
-
#%doc %{gem_instdir}/README.md
|
76
|
-
%{gem_instdir}/Rakefile
|
77
|
-
%{gem_instdir}/Gemfile
|
78
|
-
%{gem_instdir}/%{gem_name}.gemspec
|
79
|
-
|
80
|
-
%changelog
|
81
|
-
* Thu May 30 2013 Ivan Necas <inecas@redhat.com> 0.0.3-1
|
82
|
-
- Katello admins are admins in foreman too (mhulan@redhat.com)
|
83
|
-
|
84
|
-
* Fri May 17 2013 Ivan Necas <inecas@redhat.com> 0.0.2-1
|
85
|
-
- Installation media integration (inecas@redhat.com)
|
86
|
-
|
87
|
-
* Wed May 08 2013 Ivan Necas <inecas@redhat.com> 0.0.1-1
|
88
|
-
- new package built with tito
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
data/script/rails
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
-
|
4
|
-
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
5
|
-
ENGINE_PATH = File.expand_path('../../lib/os_preference/engine', __FILE__)
|
6
|
-
|
7
|
-
require 'rails/all'
|
8
|
-
require 'rails/engine/commands'
|