hammer_cli_katello 1.6.0 → 1.7.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_export.rb +1 -1
- data/lib/hammer_cli_katello/content_export_helper.rb +4 -7
- data/lib/hammer_cli_katello/content_import.rb +13 -3
- data/lib/hammer_cli_katello/content_view_purge.rb +12 -1
- data/lib/hammer_cli_katello/organization.rb +2 -1
- data/lib/hammer_cli_katello/repository.rb +46 -0
- data/lib/hammer_cli_katello/version.rb +1 -1
- data/test/data/4.6/foreman_api.json +1 -1
- data/test/data/4.7/foreman_api.json +1 -0
- data/test/functional/content_export/complete/repository_test.rb +3 -1
- data/test/functional/content_export/incremental/repository_test.rb +3 -1
- data/test/functional/organization/cdn_configuration_test.rb +1 -0
- data/test/functional/repository/list_test.rb +38 -0
- data/test/functional/repository/remove_content_test.rb +2 -1
- data/test/functional/repository/types_test.rb +120 -0
- data/test/test_helper.rb +1 -1
- metadata +10 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9309f47ea0b63ca56cdacd94e195798ee4c3afa62fde8c5a1cbcd76e3c604913
|
4
|
+
data.tar.gz: efb2ffb0a999161323e0329dd970f76bff1dfcc34c705f4d76e24b86586620ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a6a670b61cb35738beca14f5575025cca2b5203de26f7274e6077c822ffb5c66323666742d2bf58467f30d86f017a94a14eb4963e0bc2f831789236ed0a0721
|
7
|
+
data.tar.gz: cc2d3bdd3202760ffd3952a03e7c2bfec9edd7c5fa66f4265929a568c7c859becd134b6158108214e69b44e542bfd9af7a1b9d5aca4838273f6a22deb2031088
|
@@ -14,10 +14,9 @@ module HammerCLIKatello
|
|
14
14
|
response
|
15
15
|
else
|
16
16
|
export_history = fetch_export_history_from_task(reload_task(@task))
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
elsif export_history
|
17
|
+
|
18
|
+
if export_history
|
19
|
+
make_listing_files(export_history) if syncable?
|
21
20
|
generate_metadata_json(export_history)
|
22
21
|
HammerCLI::EX_OK
|
23
22
|
else
|
@@ -82,8 +81,6 @@ module HammerCLIKatello
|
|
82
81
|
|
83
82
|
def make_listing_files(export_history)
|
84
83
|
check_export_history_syncable!(export_history)
|
85
|
-
output.print_message _("Generated #{export_history['path']}")
|
86
|
-
|
87
84
|
return unless Dir.exist?("#{export_history['path']}/content")
|
88
85
|
|
89
86
|
begin
|
@@ -138,7 +135,7 @@ module HammerCLIKatello
|
|
138
135
|
def fetch_repositories
|
139
136
|
if repository_command?
|
140
137
|
resp = show(:repositories, id: resolver.repository_id(options))
|
141
|
-
return resp["download_policy"] == "immediate" ? [] : [resp]
|
138
|
+
return resp["content_type"] != "yum" || resp["download_policy"] == "immediate" ? [] : [resp]
|
142
139
|
end
|
143
140
|
|
144
141
|
repo_options = {
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'open-uri'
|
1
2
|
module HammerCLIKatello
|
2
3
|
class ContentImport < HammerCLIKatello::Command
|
3
4
|
desc "Import content from a content archive"
|
@@ -18,10 +19,11 @@ module HammerCLIKatello
|
|
18
19
|
|
19
20
|
base.validate_options do
|
20
21
|
option(:option_path).required
|
21
|
-
|
22
22
|
metadata_file = option(:option_metadata_file).value ||
|
23
23
|
File.join(option(:option_path).value, "metadata.json")
|
24
|
-
|
24
|
+
begin
|
25
|
+
URI.open(metadata_file)
|
26
|
+
rescue Errno::ENOENT
|
25
27
|
msg = _("Unable to find '#{metadata_file}'. "\
|
26
28
|
"If the metadata.json file is at a different location "\
|
27
29
|
"provide it to the --metadata-file option ")
|
@@ -32,10 +34,18 @@ module HammerCLIKatello
|
|
32
34
|
base.failure_message _("Could not import the archive.")
|
33
35
|
end
|
34
36
|
|
37
|
+
def fetch_metadata_from_url(metadata_file:, url:)
|
38
|
+
if metadata_file.nil?
|
39
|
+
metadata_file = "/tmp/metadata.json"
|
40
|
+
IO.copy_stream(URI.open(url), metadata_file)
|
41
|
+
end
|
42
|
+
metadata_file
|
43
|
+
end
|
44
|
+
|
35
45
|
def request_params
|
36
46
|
super.tap do |opts|
|
37
47
|
metadata_file = option_metadata_file || File.join(option_path, "metadata.json")
|
38
|
-
opts["metadata"] = JSON.parse(
|
48
|
+
opts["metadata"] = JSON.parse(URI.open(metadata_file).read)
|
39
49
|
end
|
40
50
|
end
|
41
51
|
end
|
@@ -84,7 +84,18 @@ module HammerCLIKatello
|
|
84
84
|
private def old_unused_versions
|
85
85
|
return @old_unused_versions if @old_unused_versions
|
86
86
|
|
87
|
-
all_versions =
|
87
|
+
all_versions = []
|
88
|
+
per_page = 100
|
89
|
+
page = 1
|
90
|
+
|
91
|
+
loop do
|
92
|
+
versions = index(:content_view_versions, :content_view_id => options['option_id'],
|
93
|
+
:per_page => per_page, :page => page)
|
94
|
+
all_versions << versions
|
95
|
+
break if versions.count < per_page
|
96
|
+
page += 1
|
97
|
+
end
|
98
|
+
all_versions.flatten!
|
88
99
|
all_versions.sort_by! { |v| [v['major'], v['minor']] }
|
89
100
|
@old_unused_versions = all_versions.select do |v|
|
90
101
|
v["environments"].empty? &&
|
@@ -52,7 +52,8 @@ module HammerCLIKatello
|
|
52
52
|
types = {
|
53
53
|
'export_sync' => _("Export Sync"),
|
54
54
|
'network_sync' => _("Network Sync"),
|
55
|
-
'redhat_cdn' => _("Red Hat CDN")
|
55
|
+
'redhat_cdn' => _("Red Hat CDN"),
|
56
|
+
'custom_cdn' => _("Custom CDN")
|
56
57
|
}
|
57
58
|
data["cdn_configuration"].merge!("type_label" => types[data["cdn_configuration"]["type"]])
|
58
59
|
end
|
@@ -34,6 +34,18 @@ module HammerCLIKatello
|
|
34
34
|
field :url, _("Url")
|
35
35
|
end
|
36
36
|
|
37
|
+
content_type_msg = _("Limit the repository type to return." \
|
38
|
+
" View available types with \"hammer repository types\"")
|
39
|
+
option "--content-type", "CONTENT TYPE",
|
40
|
+
content_type_msg,
|
41
|
+
:attribute_name => :option_content_type
|
42
|
+
|
43
|
+
with_content_msg = _("Limit the repository type to return." \
|
44
|
+
" View available types with \"hammer repository types\"")
|
45
|
+
option "--with-content", "WITH CONTENT",
|
46
|
+
with_content_msg,
|
47
|
+
:attribute_name => :option_with_content
|
48
|
+
|
37
49
|
build_options
|
38
50
|
|
39
51
|
extend_with(HammerCLIKatello::CommandExtensions::LifecycleEnvironment.new)
|
@@ -214,6 +226,12 @@ module HammerCLIKatello
|
|
214
226
|
:attribute_name => :option_unprotected,
|
215
227
|
:format => HammerCLI::Options::Normalizers::Bool.new
|
216
228
|
|
229
|
+
content_type_msg = _("Type of repository to create." \
|
230
|
+
" View available types with \"hammer repository types\"")
|
231
|
+
option "--content-type", "CONTENT TYPE",
|
232
|
+
content_type_msg,
|
233
|
+
:attribute_name => :option_content_type
|
234
|
+
|
217
235
|
build_options :without => [:unprotected]
|
218
236
|
end
|
219
237
|
|
@@ -321,6 +339,22 @@ module HammerCLIKatello
|
|
321
339
|
end
|
322
340
|
end
|
323
341
|
|
342
|
+
class RepositoryTypesCommand < HammerCLIKatello::InfoCommand
|
343
|
+
resource :repositories, :repository_types
|
344
|
+
command_name "types"
|
345
|
+
|
346
|
+
output do
|
347
|
+
field :name, _("Name")
|
348
|
+
collection :content_types, _('Content types') do
|
349
|
+
field :label, _('Type')
|
350
|
+
field :generic, _('Generic?')
|
351
|
+
field :removable, _('Removable?')
|
352
|
+
field :uploadable, _('Uploadable?')
|
353
|
+
field :indexed, _('Indexed?')
|
354
|
+
end
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
324
358
|
# rubocop:disable ClassLength
|
325
359
|
class UploadContentCommand < HammerCLIKatello::InfoCommand
|
326
360
|
extend RepositoryScopedToProduct
|
@@ -331,6 +365,12 @@ module HammerCLIKatello
|
|
331
365
|
command_name "upload-content"
|
332
366
|
CONTENT_CHUNK_SIZE = 2_500_000 # bytes to make sure it's lower than django's default 2621440
|
333
367
|
|
368
|
+
content_type_msg = _("The type of content unit to upload (srpm, file, etc.)." \
|
369
|
+
" View uploadable types with \"hammer repository types\"")
|
370
|
+
option "--content-type", "CONTENT TYPE",
|
371
|
+
content_type_msg,
|
372
|
+
:attribute_name => :option_content_type
|
373
|
+
|
334
374
|
class BinaryPath < HammerCLI::Options::Normalizers::File
|
335
375
|
def format(path)
|
336
376
|
fullpath = ::File.expand_path(path)
|
@@ -562,6 +602,12 @@ module HammerCLIKatello
|
|
562
602
|
end
|
563
603
|
end
|
564
604
|
|
605
|
+
content_type_msg = _("The type of content unit to remove (srpm, docker_manifest, etc.)." \
|
606
|
+
" View removable types with \"hammer repository types\"")
|
607
|
+
option "--content-type", "CONTENT TYPE",
|
608
|
+
content_type_msg,
|
609
|
+
:attribute_name => :option_content_type
|
610
|
+
|
565
611
|
build_options do |o|
|
566
612
|
o.expand.including(:products)
|
567
613
|
end
|