hammer_cli_katello 0.24.4 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hammer_cli_katello.rb +11 -15
  3. data/lib/hammer_cli_katello/activation_key.rb +5 -5
  4. data/lib/hammer_cli_katello/capsule.rb +2 -3
  5. data/lib/hammer_cli_katello/command_extensions/lifecycle_environment.rb +10 -7
  6. data/lib/hammer_cli_katello/command_extensions/lifecycle_environments.rb +11 -8
  7. data/lib/hammer_cli_katello/content_credential.rb +20 -19
  8. data/lib/hammer_cli_katello/content_export.rb +1 -0
  9. data/lib/hammer_cli_katello/content_export_helper.rb +1 -1
  10. data/lib/hammer_cli_katello/content_import.rb +16 -1
  11. data/lib/hammer_cli_katello/content_view.rb +16 -31
  12. data/lib/hammer_cli_katello/content_view_version.rb +4 -273
  13. data/lib/hammer_cli_katello/deb_package.rb +3 -3
  14. data/lib/hammer_cli_katello/docker.rb +13 -0
  15. data/lib/hammer_cli_katello/docker_manifest.rb +53 -0
  16. data/lib/hammer_cli_katello/docker_tag.rb +40 -0
  17. data/lib/hammer_cli_katello/erratum.rb +1 -1
  18. data/lib/hammer_cli_katello/erratum_info_command.rb +1 -1
  19. data/lib/hammer_cli_katello/file.rb +3 -3
  20. data/lib/hammer_cli_katello/filter.rb +2 -2
  21. data/lib/hammer_cli_katello/foreman_search_options_creators.rb +0 -12
  22. data/lib/hammer_cli_katello/host_collection.rb +2 -2
  23. data/lib/hammer_cli_katello/host_collection_erratum.rb +10 -0
  24. data/lib/hammer_cli_katello/host_collection_package.rb +30 -0
  25. data/lib/hammer_cli_katello/host_collection_package_group.rb +30 -0
  26. data/lib/hammer_cli_katello/host_deb.rb +1 -1
  27. data/lib/hammer_cli_katello/host_errata.rb +9 -1
  28. data/lib/hammer_cli_katello/host_extensions.rb +5 -5
  29. data/lib/hammer_cli_katello/host_package.rb +33 -1
  30. data/lib/hammer_cli_katello/host_package_group.rb +16 -0
  31. data/lib/hammer_cli_katello/hostgroup_extensions.rb +4 -4
  32. data/lib/hammer_cli_katello/id_resolver.rb +3 -6
  33. data/lib/hammer_cli_katello/lifecycle_environment.rb +2 -2
  34. data/lib/hammer_cli_katello/module_stream.rb +8 -8
  35. data/lib/hammer_cli_katello/organization.rb +10 -0
  36. data/lib/hammer_cli_katello/organization_options.rb +8 -6
  37. data/lib/hammer_cli_katello/ostree_branch.rb +2 -2
  38. data/lib/hammer_cli_katello/package.rb +5 -5
  39. data/lib/hammer_cli_katello/package_group.rb +4 -4
  40. data/lib/hammer_cli_katello/ping.rb +13 -19
  41. data/lib/hammer_cli_katello/product.rb +3 -3
  42. data/lib/hammer_cli_katello/product_content.rb +2 -2
  43. data/lib/hammer_cli_katello/repository.rb +27 -37
  44. data/lib/hammer_cli_katello/repository_set.rb +4 -4
  45. data/lib/hammer_cli_katello/simple_content_access.rb +42 -0
  46. data/lib/hammer_cli_katello/srpm.rb +2 -2
  47. data/lib/hammer_cli_katello/subscription.rb +2 -3
  48. data/lib/hammer_cli_katello/sync_plan.rb +2 -2
  49. data/lib/hammer_cli_katello/version.rb +1 -1
  50. data/locale/hammer-cli-katello.pot +0 -25
  51. data/test/data/3.18/foreman_api.json +1 -1
  52. data/test/data/3.19/foreman_api.json +1 -0
  53. data/test/data/4.0/foreman_api.json +1 -0
  54. data/test/data/4.1/foreman_api.json +1 -0
  55. data/test/functional/activation_key/subscriptions_test.rb +5 -2
  56. data/test/functional/capsule/content/info_test.rb +1 -2
  57. data/test/functional/content_credentials/create_test.rb +32 -0
  58. data/test/functional/{repository → content_credentials}/data/test_cert.json +0 -0
  59. data/test/functional/content_credentials/list_test.rb +6 -8
  60. data/test/functional/content_export/complete/version_test.rb +35 -0
  61. data/test/functional/content_export/list_test.rb +9 -9
  62. data/test/functional/content_import/list_test.rb +65 -0
  63. data/test/functional/content_import/version_test.rb +6 -6
  64. data/test/functional/content_view/list_test.rb +0 -2
  65. data/test/functional/content_view/publish_test.rb +0 -21
  66. data/test/functional/content_view/version/promote_test.rb +1 -2
  67. data/test/functional/content_view/version/republish_repositories_test.rb +1 -2
  68. data/test/functional/host/errata/apply_test.rb +0 -2
  69. data/test/functional/host/errata/recalculate_test.rb +0 -2
  70. data/test/functional/organization/info_test.rb +22 -0
  71. data/test/functional/ping_test.rb +52 -15
  72. data/test/functional/repository/create_test.rb +0 -30
  73. data/test/functional/repository/info_test.rb +4 -4
  74. data/test/functional/repository/list_test.rb +0 -2
  75. data/test/functional/simple_content_access/disable_test.rb +48 -0
  76. data/test/functional/simple_content_access/enable_test.rb +46 -0
  77. data/test/test_helper.rb +1 -1
  78. metadata +24 -52
  79. data/lib/hammer_cli_katello/content_view_puppet_module.rb +0 -60
  80. data/lib/hammer_cli_katello/cv_import_export_helper.rb +0 -166
  81. data/lib/hammer_cli_katello/gpg_key.rb +0 -67
  82. data/lib/hammer_cli_katello/puppet_module.rb +0 -59
  83. data/test/functional/content_view/puppet_module/add_test.rb +0 -24
  84. data/test/functional/content_view/puppet_module/remove_test.rb +0 -54
  85. data/test/functional/content_view/version/default_export_test.rb +0 -40
  86. data/test/functional/content_view/version/export_test.rb +0 -136
  87. data/test/functional/content_view/version/import_test.rb +0 -318
  88. data/test/functional/gpg_test.rb +0 -39
  89. data/test/functional/repository/data/test_ca.json +0 -43
  90. data/test/functional/repository/data/test_key.json +0 -43
@@ -1,136 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../test_helper')
2
-
3
- describe 'content-view version export' do
4
- include ForemanTaskHelpers
5
-
6
- before do
7
- @cmd = %w(content-view version export)
8
- end
9
-
10
- it "performs export" do
11
- params = [
12
- '--id=5',
13
- '--export-dir=/tmp/exports'
14
- ]
15
-
16
- ex = api_expects(:content_view_versions, :show)
17
- ex.returns(
18
- 'id' => '5',
19
- 'repositories' => [{'id' => '2', 'content_type' => 'yum'}],
20
- 'major' => 1,
21
- 'minor' => 0,
22
- 'content_view' => {'name' => 'cv'},
23
- 'content_view_id' => 4321
24
- )
25
-
26
- ex = api_expects(:content_views, :show)
27
- ex.returns(
28
- 'id' => '4321',
29
- 'composite' => false,
30
- 'label' => 'cv'
31
- )
32
-
33
- ex = api_expects(:repositories, :show).with_params('id' => '2')
34
- ex.returns(
35
- 'id' => '2',
36
- 'label' => 'Test_Repo',
37
- 'content_type' => 'yum',
38
- 'download_policy' => 'immediate',
39
- 'backend_identifier' => 'Default_Organization-Library-Test_Repo',
40
- 'relative_path' => 'Default_Organization/Library/Test_Repo',
41
- 'library_instance_id' => '1',
42
- 'content_counts' => {
43
- 'rpm' => 1,
44
- 'erratum' => 1
45
- }
46
- )
47
-
48
- api_expects(:repositories, :show).with_params('id' => '1').returns(
49
- 'id' => '1',
50
- 'download_policy' => 'immediate'
51
- )
52
- api_expects(:packages, :index).returns('results' => [])
53
- api_expects(:errata, :index).returns('results' => [])
54
-
55
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
56
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
57
-
58
- Dir.expects(:chdir).with("/var/lib/pulp/published/yum/https/repos/").returns(true)
59
- Dir.expects(:mkdir).with('/tmp/exports/export-cv-1.0').returns(0)
60
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
61
- Dir.expects(:chdir).with('/tmp/exports/export-cv-1.0').returns(0)
62
-
63
- result = run_cmd(@cmd + params)
64
- assert_equal(HammerCLI::EX_OK, result.exit_code)
65
- end
66
-
67
- it "performs composite export" do
68
- params = [
69
- '--id=999',
70
- '--export-dir=/tmp/exports'
71
- ]
72
-
73
- ex = api_expects(:content_view_versions, :show)
74
- ex.returns(
75
- 'id' => '999',
76
- 'repositories' => [{'id' => '2'}],
77
- 'major' => 1,
78
- 'minor' => 0,
79
- 'content_view' => {'name' => 'cv'},
80
- 'content_view_id' => 4321
81
- )
82
-
83
- ex = api_expects(:content_views, :show)
84
- ex.returns(
85
- 'id' => '4321',
86
- 'composite' => true,
87
- 'components' => [{ 'name' => "injera 95.5" }, {'name' => 'carrot wot 87.0'}],
88
- 'label' => 'cv'
89
- )
90
-
91
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
92
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
93
-
94
- Dir.expects(:chdir).with("/var/lib/pulp/published/yum/https/repos/").never
95
- Dir.expects(:mkdir).with('/tmp/exports/export-cv-1.0').returns(0)
96
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
97
- Dir.expects(:chdir).with('/tmp/exports/export-cv-1.0').returns(0)
98
-
99
- result = run_cmd(@cmd + params)
100
- assert_equal(HammerCLI::EX_OK, result.exit_code)
101
- end
102
-
103
- it "fails export if content view version has no repository" do
104
- params = [
105
- '--id=5',
106
- '--export-dir=/tmp/exports'
107
- ]
108
-
109
- ex = api_expects(:content_view_versions, :show)
110
- ex.returns(
111
- 'id' => '5',
112
- 'name' => 'Test_version',
113
- 'repositories' => [],
114
- 'major' => 1,
115
- 'minor' => 0,
116
- 'content_view' => {'name' => 'cv'},
117
- 'content_view_id' => 4321,
118
- 'puppet_modules' => []
119
- )
120
-
121
- ex = api_expects(:content_views, :show)
122
- ex.returns(
123
- 'id' => '4321',
124
- 'composite' => false
125
- )
126
-
127
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
128
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
129
-
130
- result = run_cmd(@cmd + params)
131
- assert_equal(result.err, "Could not export the content view:\n"\
132
- " Error: Ensure the content view version 'Test_version'"\
133
- " has at least one repository.\n")
134
- assert_equal(HammerCLI::EX_SOFTWARE, result.exit_code)
135
- end
136
- end
@@ -1,318 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../test_helper')
2
-
3
- describe 'content-view version import' do
4
- include ForemanTaskHelpers
5
-
6
- before do
7
- @cmd = %w(content-view version import)
8
- end
9
-
10
- it "performs import" do
11
- params = [
12
- '--export-tar=/tmp/exports/export-2.tar',
13
- '--organization-id=1'
14
- ]
15
-
16
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
17
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
18
-
19
- File.expects(:exist?).with("/tmp/exports/export-2.tar").returns(true)
20
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
21
- Dir.expects(:chdir).with('/tmp/exports/export-2').returns(0)
22
- File.expects(:read).with("/tmp/exports/export-2/export-2.json").returns(
23
- JSON.dump(
24
- 'name' => 'Foo View',
25
- 'major' => '5',
26
- 'minor' => '0',
27
- 'repositories' => [{
28
- 'label' => 'foo',
29
- 'rpm_filenames' => ['foo-1.0-1.el7']
30
- }]
31
- )
32
- )
33
-
34
- ex = api_expects(:content_views, :index)
35
- ex = ex.with_params('name' => 'Foo View', 'organization_id' => '1')
36
- ex.returns(
37
- 'results' => [{
38
- 'id' => '5',
39
- 'repositories' => [{'id' => '2', 'label' => 'foo'}],
40
- 'content_view' => {'name' => 'cv'}
41
- }]
42
- )
43
-
44
- ex = api_expects(:repositories, :index)
45
- ex = ex.with_params('organization_id' => '1', 'library' => true)
46
- ex.returns(
47
- 'results' => [{
48
- 'id' => '2',
49
- 'label' => 'foo'
50
- }]
51
- )
52
-
53
- ex = api_expects(:repositories, :sync)
54
- ex = ex.with_params('id' => '2', 'source_url' => "file:///tmp/exports/export-2/")
55
- ex.returns('id' => '2', 'state' => 'planned')
56
-
57
- expect_foreman_task('3')
58
-
59
- ex = api_expects(:content_views, :publish)
60
- ex = ex.with_params(
61
- 'id' => '5',
62
- 'major' => '5',
63
- 'minor' => '0',
64
- 'repos_units' => [{
65
- 'label' => 'foo',
66
- 'rpm_filenames' => ['foo-1.0-1.el7']
67
- }]
68
- )
69
- ex.returns('id' => '2', 'state' => 'planned')
70
-
71
- expect_foreman_task('3')
72
-
73
- result = run_cmd(@cmd + params)
74
- assert_equal(HammerCLI::EX_OK, result.exit_code)
75
- end
76
-
77
- it "performs composite import" do
78
- params = [
79
- '--export-tar=/tmp/exports/export-999.tar',
80
- '--organization-id=1'
81
- ]
82
-
83
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
84
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
85
-
86
- File.expects(:exist?).with("/tmp/exports/export-999.tar").returns(true)
87
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
88
- Dir.expects(:chdir).with('/tmp/exports/export-999').returns(0)
89
- File.expects(:read).with("/tmp/exports/export-999/export-999.json").returns(
90
- JSON.dump(
91
- 'name' => 'Foo Composite View',
92
- 'major' => '10',
93
- 'minor' => '0',
94
- 'composite_components' => ["berbere 55.32"]
95
- )
96
- )
97
-
98
- ex = api_expects(:content_views, :index)
99
- ex = ex.with_params('name' => 'berbere', 'organization_id' => '1')
100
- ex.returns(
101
- 'results' => [{'versions' => [{'version' => '10.0', 'id' => '654'},
102
- {'version' => '55.32', 'id' => '876'}]
103
- }]
104
- )
105
-
106
- ex = api_expects(:content_views, :index)
107
- ex = ex.with_params('name' => 'Foo Composite View', 'organization_id' => '1')
108
- ex.returns(
109
- 'results' => [{
110
- 'id' => '5',
111
- 'repositories' => [{'id' => '2', 'label' => 'foo'}],
112
- 'content_view' => {'name' => 'cv'}
113
- }]
114
- )
115
-
116
- ex = api_expects(:content_views, :update)
117
- ex = ex.with_params(
118
- 'id' => '5',
119
- 'component_ids' => ['876']
120
- )
121
- ex.returns('id' => '5', 'state' => 'planned')
122
-
123
- ex = api_expects(:content_views, :publish)
124
- ex = ex.with_params(
125
- 'id' => '5',
126
- 'major' => '10',
127
- 'minor' => '0'
128
- )
129
- ex.returns('id' => '2', 'state' => 'planned')
130
-
131
- expect_foreman_task('3')
132
-
133
- result = run_cmd(@cmd + params)
134
- assert_equal(HammerCLI::EX_OK, result.exit_code)
135
- end
136
-
137
- it "performs composite import, component not found" do
138
- params = [
139
- '--export-tar=/tmp/exports/export-999.tar',
140
- '--organization-id=1'
141
- ]
142
-
143
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
144
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
145
-
146
- File.expects(:exist?).with("/tmp/exports/export-999.tar").returns(true)
147
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
148
- Dir.expects(:chdir).with('/tmp/exports/export-999').returns(0)
149
- File.expects(:read).with("/tmp/exports/export-999/export-999.json").returns(
150
- JSON.dump(
151
- 'name' => 'Foo Composite View',
152
- 'major' => '10',
153
- 'minor' => '0',
154
- 'composite_components' => ["berbere 55.32", "unicorn 99.99"]
155
- )
156
- )
157
-
158
- ex = api_expects(:content_views, :index)
159
- ex = ex.with_params('name' => 'berbere', 'organization_id' => '1')
160
- ex.returns(
161
- 'results' => [{'versions' => [{'version' => '10.0', 'id' => '654'},
162
- {'version' => '55.32', 'id' => '876'}]
163
- }]
164
- )
165
-
166
- ex = api_expects(:content_views, :index)
167
- ex = ex.with_params('name' => 'unicorn', 'organization_id' => '1')
168
- ex.returns(
169
- 'results' => []
170
- )
171
-
172
- ex = api_expects(:content_views, :index)
173
- ex = ex.with_params('name' => 'Foo Composite View', 'organization_id' => '1')
174
- ex.returns(
175
- 'results' => [{
176
- 'id' => '5',
177
- 'repositories' => [{'id' => '2', 'label' => 'foo'}],
178
- 'content_view' => {'name' => 'cv'}
179
- }]
180
- )
181
-
182
- result = run_cmd(@cmd + params)
183
- assert_equal(HammerCLI::EX_SOFTWARE, result.exit_code)
184
- end
185
-
186
- it "fails import if cv has not been created" do
187
- params = [
188
- '--export-tar=/tmp/exports/export-2.tar',
189
- '--organization-id=1'
190
- ]
191
-
192
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
193
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
194
-
195
- File.expects(:exist?).with("/tmp/exports/export-2.tar").returns(true)
196
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
197
- Dir.expects(:chdir).with('/tmp/exports/export-2').returns(0)
198
- File.expects(:read).with("/tmp/exports/export-2/export-2.json").returns(
199
- JSON.dump(
200
- 'name' => 'Foo View'
201
- )
202
- )
203
-
204
- ex = api_expects(:content_views, :index)
205
- ex = ex.with_params('name' => 'Foo View', 'organization_id' => '1')
206
- ex.returns([])
207
-
208
- result = run_cmd(@cmd + params)
209
- assert_equal(HammerCLI::EX_SOFTWARE, result.exit_code)
210
- end
211
-
212
- it "fails import if repo is set to mirror-on-sync" do
213
- params = [
214
- '--export-tar=/tmp/exports/export-2.tar',
215
- '--organization-id=1'
216
- ]
217
-
218
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
219
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
220
-
221
- File.expects(:exist?).with("/tmp/exports/export-2.tar").returns(true)
222
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
223
- Dir.expects(:chdir).with('/tmp/exports/export-2').returns(0)
224
- File.expects(:read).with("/tmp/exports/export-2/export-2.json").returns(
225
- JSON.dump(
226
- 'name' => 'Foo View',
227
- 'major' => '2',
228
- 'minor' => '1'
229
- )
230
- )
231
-
232
- ex = api_expects(:content_views, :index)
233
- ex = ex.with_params('name' => 'Foo View', 'organization_id' => '1')
234
- ex.returns(
235
- 'results' => [{
236
- 'id' => '5',
237
- 'repositories' => [{'id' => '2', 'label' => 'foo', 'mirror_on_sync' => 'true'}],
238
- 'content_view' => {'name' => 'cv'}
239
- }]
240
- )
241
-
242
- result = run_cmd(@cmd + params)
243
- assert_equal(result.exit_code, 70)
244
- end
245
-
246
- it "fails import if cv version already exists" do
247
- params = [
248
- '--export-tar=/tmp/exports/export-2.tar',
249
- '--organization-id=1'
250
- ]
251
-
252
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
253
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
254
-
255
- File.expects(:exist?).with("/tmp/exports/export-2.tar").returns(true)
256
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
257
- Dir.expects(:chdir).with('/tmp/exports/export-2').returns(0)
258
- File.expects(:read).with("/tmp/exports/export-2/export-2.json").returns(
259
- JSON.dump(
260
- 'name' => 'Foo View',
261
- 'major' => '2',
262
- 'minor' => '1'
263
- )
264
- )
265
-
266
- ex = api_expects(:content_views, :index)
267
- ex = ex.with_params('name' => 'Foo View', 'organization_id' => '1')
268
- ex.returns(
269
- 'results' => [{
270
- 'id' => '5',
271
- 'content_view' => {'name' => 'cv'},
272
- 'versions' => [{'version' => '2.1', 'id' => '654'}]
273
- }]
274
- )
275
-
276
- result = run_cmd(@cmd + params)
277
- assert_equal(result.exit_code, 70)
278
- end
279
-
280
- it "fails import if any repository does not exist" do
281
- params = [
282
- '--export-tar=/tmp/exports/export-2.tar',
283
- '--organization-id=1'
284
- ]
285
-
286
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
287
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
288
-
289
- File.expects(:exist?).with("/tmp/exports/export-2.tar").returns(true)
290
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
291
- Dir.expects(:chdir).with('/tmp/exports/export-2').returns(0)
292
- File.expects(:read).with("/tmp/exports/export-2/export-2.json").returns(
293
- JSON.dump(
294
- 'name' => 'Foo View',
295
- 'repositories' => ['label' => 'foo'],
296
- 'major' => '2',
297
- 'minor' => '1'
298
- )
299
- )
300
-
301
- ex = api_expects(:content_views, :index)
302
- ex = ex.with_params('name' => 'Foo View', 'organization_id' => '1')
303
- ex.returns(
304
- 'results' => [{
305
- 'id' => '5',
306
- 'repositories' => [{'id' => '2', 'label' => 'foo'}],
307
- 'content_view' => {'name' => 'cv'}
308
- }]
309
- )
310
-
311
- ex = api_expects(:repositories, :index)
312
- ex = ex.with_params('organization_id' => '1', 'library' => true)
313
- ex.returns([])
314
-
315
- result = run_cmd(@cmd + params)
316
- assert_equal(HammerCLI::EX_SOFTWARE, result.exit_code)
317
- end
318
- end