hammer_cli_katello 1.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hammer_cli_katello/content_view_version.rb +14 -2
- data/lib/hammer_cli_katello/cv_import_export_helper.rb +21 -0
- data/lib/hammer_cli_katello/version.rb +1 -1
- data/test/functional/content_view/version/cv_import_export_helper_test.rb +20 -0
- data/test/functional/content_view/version/export_test.rb +12 -0
- data/test/functional/content_view/version/import_test.rb +28 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 186183bd2337627828ad27578924b491161632034de3f51b2896a02312b68519
|
4
|
+
data.tar.gz: 903b7f9c68fdfcd7538739a1f98aa896e18924806f69d37576a85f935315f7e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae67f54e90820899048b453b5c6592d0e7ac36ee562d798c74c82365c82de577c158640259eeb222cfb9e5f8ab5e880fd1ce36dcba56eed3f67dadaf2430eef7
|
7
|
+
data.tar.gz: aae484692b57eb9405e01b2b2f6e01b8254e7903b53fdbe919e829366e0f28ab46e5184e61111fa637655d029cd000197639a1e5919cc5bc59c041ad93108eb0
|
@@ -274,6 +274,7 @@ module HammerCLIKatello
|
|
274
274
|
class ExportDefaultCommand < HammerCLIForeman::Command
|
275
275
|
include HammerCLIKatello::LocalHelper
|
276
276
|
include HammerCLIKatello::ApipieHelper
|
277
|
+
include HammerCLIKatello::CVImportExportHelper
|
277
278
|
|
278
279
|
PUBLISHED_REPOS_DIR = "/var/lib/pulp/published/yum/https/repos/".freeze
|
279
280
|
|
@@ -290,6 +291,7 @@ module HammerCLIKatello
|
|
290
291
|
build_options
|
291
292
|
|
292
293
|
def execute
|
294
|
+
validate_pulp3_not_enabled(fail_msg_export)
|
293
295
|
export_dir = options['option_export_dir']
|
294
296
|
|
295
297
|
Dir.mkdir(export_dir) unless Dir.exist?(export_dir)
|
@@ -307,6 +309,7 @@ module HammerCLIKatello
|
|
307
309
|
class LegacyExportCommand < HammerCLIKatello::SingleResourceCommand
|
308
310
|
include HammerCLIForemanTasks::Async
|
309
311
|
include LifecycleEnvironmentNameMapping
|
312
|
+
include HammerCLIKatello::CVImportExportHelper
|
310
313
|
desc _('Export a content view (legacy method)')
|
311
314
|
|
312
315
|
action :export
|
@@ -314,12 +317,16 @@ module HammerCLIKatello
|
|
314
317
|
|
315
318
|
success_message _("Content view is being exported in task %{id}.")
|
316
319
|
failure_message _("Could not export the content view")
|
317
|
-
|
318
320
|
build_options do |o|
|
319
321
|
o.expand(:all).including(:environments, :content_views, :organizations)
|
320
322
|
end
|
321
323
|
|
322
324
|
extend_with(HammerCLIKatello::CommandExtensions::LifecycleEnvironment.new)
|
325
|
+
|
326
|
+
def request_params
|
327
|
+
validate_pulp3_not_enabled(fail_msg_export)
|
328
|
+
super
|
329
|
+
end
|
323
330
|
end
|
324
331
|
|
325
332
|
class ExportCommand < HammerCLIForeman::Command
|
@@ -350,6 +357,8 @@ module HammerCLIKatello
|
|
350
357
|
cvv = show(:content_view_versions, 'id' => options['option_id'])
|
351
358
|
cv = show(:content_views, 'id' => cvv['content_view_id'])
|
352
359
|
|
360
|
+
validate_pulp3_not_enabled(fail_msg_export)
|
361
|
+
|
353
362
|
composite = cv["composite"]
|
354
363
|
|
355
364
|
export_json_options = { :cvv => cvv }
|
@@ -445,6 +454,8 @@ module HammerCLIKatello
|
|
445
454
|
|
446
455
|
# rubocop:disable Metrics/AbcSize
|
447
456
|
def execute
|
457
|
+
validate_pulp3_not_enabled(fail_msg_import)
|
458
|
+
|
448
459
|
unless File.exist?(options['option_export_tar'])
|
449
460
|
raise _("Export tar #{options['option_export_tar']} does not exist.")
|
450
461
|
end
|
@@ -487,7 +498,8 @@ module HammerCLIKatello
|
|
487
498
|
library_repos = index(
|
488
499
|
:repositories,
|
489
500
|
'organization_id' => organization_id,
|
490
|
-
'library' => true
|
501
|
+
'library' => true,
|
502
|
+
'label' => repo['label']
|
491
503
|
)
|
492
504
|
|
493
505
|
library_repo = library_repos.select do |candidate_repo|
|
@@ -162,5 +162,26 @@ module HammerCLIKatello
|
|
162
162
|
end
|
163
163
|
json
|
164
164
|
end
|
165
|
+
|
166
|
+
def fail_msg_import
|
167
|
+
_("This command is not supported with Pulp 3. Use `hammer content-import` instead.")
|
168
|
+
end
|
169
|
+
|
170
|
+
def fail_msg_export
|
171
|
+
_("This command is not supported with Pulp 3. Use `hammer content-export` instead.")
|
172
|
+
end
|
173
|
+
|
174
|
+
def validate_pulp3_not_enabled(failure_message)
|
175
|
+
pulp3_enabled = HammerCLIForeman
|
176
|
+
.foreman_api_connection
|
177
|
+
.resource(:content_exports)
|
178
|
+
.call(:api_status)['api_usable']
|
179
|
+
if pulp3_enabled
|
180
|
+
raise failure_message
|
181
|
+
end
|
182
|
+
rescue NoMethodError
|
183
|
+
# if the api endpoint isn't there, the validation passes
|
184
|
+
true
|
185
|
+
end
|
165
186
|
end
|
166
187
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
describe 'CVImportExportHelper' do
|
3
|
+
describe 'validate_pulp3_not_enabled' do
|
4
|
+
include HammerCLIKatello::CVImportExportHelper
|
5
|
+
it 'returns true when the api endpoint does not return a value' do
|
6
|
+
api_expects(:content_exports, :api_status)
|
7
|
+
assert_equal true, validate_pulp3_not_enabled('fail_msg')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'raises error when the api reports Pulp 3 is enabled' do
|
11
|
+
api_expects(:content_exports, :api_status).returns('api_usable' => true)
|
12
|
+
assert_raises(RuntimeError, 'fail msg') { validate_pulp3_not_enabled('fail msg') }
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'returns nil when the api reports Pulp 3 is not enabled' do
|
16
|
+
api_expects(:content_exports, :api_status).returns('api_usable' => false)
|
17
|
+
assert_equal nil, validate_pulp3_not_enabled('fail_msg')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -8,6 +8,10 @@ describe 'content-view version export' do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it "performs export" do
|
11
|
+
HammerCLIKatello::ContentViewVersion::ExportCommand
|
12
|
+
.any_instance
|
13
|
+
.expects(:validate_pulp3_not_enabled)
|
14
|
+
.returns(true)
|
11
15
|
params = [
|
12
16
|
'--id=5',
|
13
17
|
'--export-dir=/tmp/exports'
|
@@ -65,6 +69,10 @@ describe 'content-view version export' do
|
|
65
69
|
end
|
66
70
|
|
67
71
|
it "performs composite export" do
|
72
|
+
HammerCLIKatello::ContentViewVersion::ExportCommand
|
73
|
+
.any_instance
|
74
|
+
.expects(:validate_pulp3_not_enabled)
|
75
|
+
.returns(true)
|
68
76
|
params = [
|
69
77
|
'--id=999',
|
70
78
|
'--export-dir=/tmp/exports'
|
@@ -101,6 +109,10 @@ describe 'content-view version export' do
|
|
101
109
|
end
|
102
110
|
|
103
111
|
it "fails export if content view version has no repository" do
|
112
|
+
HammerCLIKatello::ContentViewVersion::ExportCommand
|
113
|
+
.any_instance
|
114
|
+
.expects(:validate_pulp3_not_enabled)
|
115
|
+
.returns(true)
|
104
116
|
params = [
|
105
117
|
'--id=5',
|
106
118
|
'--export-dir=/tmp/exports'
|
@@ -8,6 +8,10 @@ describe 'content-view version import' do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it "performs import" do
|
11
|
+
HammerCLIKatello::ContentViewVersion::ImportCommand
|
12
|
+
.any_instance
|
13
|
+
.expects(:validate_pulp3_not_enabled)
|
14
|
+
.returns(true)
|
11
15
|
params = [
|
12
16
|
'--export-tar=/tmp/exports/export-2.tar',
|
13
17
|
'--organization-id=1'
|
@@ -75,6 +79,10 @@ describe 'content-view version import' do
|
|
75
79
|
end
|
76
80
|
|
77
81
|
it "performs composite import" do
|
82
|
+
HammerCLIKatello::ContentViewVersion::ImportCommand
|
83
|
+
.any_instance
|
84
|
+
.expects(:validate_pulp3_not_enabled)
|
85
|
+
.returns(true)
|
78
86
|
params = [
|
79
87
|
'--export-tar=/tmp/exports/export-999.tar',
|
80
88
|
'--organization-id=1'
|
@@ -135,6 +143,10 @@ describe 'content-view version import' do
|
|
135
143
|
end
|
136
144
|
|
137
145
|
it "performs composite import, component not found" do
|
146
|
+
HammerCLIKatello::ContentViewVersion::ImportCommand
|
147
|
+
.any_instance
|
148
|
+
.expects(:validate_pulp3_not_enabled)
|
149
|
+
.returns(true)
|
138
150
|
params = [
|
139
151
|
'--export-tar=/tmp/exports/export-999.tar',
|
140
152
|
'--organization-id=1'
|
@@ -184,6 +196,10 @@ describe 'content-view version import' do
|
|
184
196
|
end
|
185
197
|
|
186
198
|
it "fails import if cv has not been created" do
|
199
|
+
HammerCLIKatello::ContentViewVersion::ImportCommand
|
200
|
+
.any_instance
|
201
|
+
.expects(:validate_pulp3_not_enabled)
|
202
|
+
.returns(true)
|
187
203
|
params = [
|
188
204
|
'--export-tar=/tmp/exports/export-2.tar',
|
189
205
|
'--organization-id=1'
|
@@ -210,6 +226,10 @@ describe 'content-view version import' do
|
|
210
226
|
end
|
211
227
|
|
212
228
|
it "fails import if repo is set to mirror-on-sync" do
|
229
|
+
HammerCLIKatello::ContentViewVersion::ImportCommand
|
230
|
+
.any_instance
|
231
|
+
.expects(:validate_pulp3_not_enabled)
|
232
|
+
.returns(true)
|
213
233
|
params = [
|
214
234
|
'--export-tar=/tmp/exports/export-2.tar',
|
215
235
|
'--organization-id=1'
|
@@ -244,6 +264,10 @@ describe 'content-view version import' do
|
|
244
264
|
end
|
245
265
|
|
246
266
|
it "fails import if cv version already exists" do
|
267
|
+
HammerCLIKatello::ContentViewVersion::ImportCommand
|
268
|
+
.any_instance
|
269
|
+
.expects(:validate_pulp3_not_enabled)
|
270
|
+
.returns(true)
|
247
271
|
params = [
|
248
272
|
'--export-tar=/tmp/exports/export-2.tar',
|
249
273
|
'--organization-id=1'
|
@@ -278,6 +302,10 @@ describe 'content-view version import' do
|
|
278
302
|
end
|
279
303
|
|
280
304
|
it "fails import if any repository does not exist" do
|
305
|
+
HammerCLIKatello::ContentViewVersion::ImportCommand
|
306
|
+
.any_instance
|
307
|
+
.expects(:validate_pulp3_not_enabled)
|
308
|
+
.returns(true)
|
281
309
|
params = [
|
282
310
|
'--export-tar=/tmp/exports/export-2.tar',
|
283
311
|
'--organization-id=1'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hammer_cli_katello
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Price
|
@@ -35,7 +35,7 @@ authors:
|
|
35
35
|
autorequire:
|
36
36
|
bindir: bin
|
37
37
|
cert_chain: []
|
38
|
-
date: 2021-
|
38
|
+
date: 2021-05-13 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: hammer_cli_foreman
|
@@ -402,6 +402,7 @@ files:
|
|
402
402
|
- test/functional/content_view/remove_content_view_version_test.rb
|
403
403
|
- test/functional/content_view/remove_test.rb
|
404
404
|
- test/functional/content_view/update_test.rb
|
405
|
+
- test/functional/content_view/version/cv_import_export_helper_test.rb
|
405
406
|
- test/functional/content_view/version/default_export_test.rb
|
406
407
|
- test/functional/content_view/version/export_test.rb
|
407
408
|
- test/functional/content_view/version/import_test.rb
|
@@ -533,7 +534,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
533
534
|
- !ruby/object:Gem::Version
|
534
535
|
version: '0'
|
535
536
|
requirements: []
|
536
|
-
rubygems_version: 3.1.
|
537
|
+
rubygems_version: 3.1.2
|
537
538
|
signing_key:
|
538
539
|
specification_version: 4
|
539
540
|
summary: Katello commands for Hammer
|
@@ -618,6 +619,7 @@ test_files:
|
|
618
619
|
- test/functional/content_view/remove_content_view_version_test.rb
|
619
620
|
- test/functional/content_view/remove_test.rb
|
620
621
|
- test/functional/content_view/update_test.rb
|
622
|
+
- test/functional/content_view/version/cv_import_export_helper_test.rb
|
621
623
|
- test/functional/content_view/version/default_export_test.rb
|
622
624
|
- test/functional/content_view/version/export_test.rb
|
623
625
|
- test/functional/content_view/version/import_test.rb
|