hammer_cli_katello 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfa4a96e3ec666332357da5f6741af1fb78360f60e3016060d8e0ba7a41a38c9
4
- data.tar.gz: 2d6fafe5ea4d85dd1551f9274a57cc6e2c65e3155bbabd844a0f12d964c3e7d3
3
+ metadata.gz: 2708ed7f94bc63930cdbfbf1e6b6910224b9ac947a59beb6fd67325de8d13df5
4
+ data.tar.gz: 8e1658c27cab54ba5d45d68b9a2e9eea54df34db5be3316f090ef7bce073f7a3
5
5
  SHA512:
6
- metadata.gz: e3c4c16ed1e4c64d5126810fef1c723490758c1019e820e7cde65f7b6caa663ada32072aa39dcac2964199c5a2a72b2c36f31e4d85dfc64f8b2c9d203154896b
7
- data.tar.gz: eeefc161d8fb26803fae890ef79d94c74f1e6ca94d4f0780ba839018890fce56bc5405a932cbeee7edbaa5817bec3de0762d39bc0577ee6e647de673c7c6e5fe
6
+ metadata.gz: e69050801a50bef32379cce5b0f12b71a2308dac7bd6452a512f077e45b6fcd7e492cc75ed9eac8b425552884bd814857f3394c8aebd919553e54c10a9b5bb9b
7
+ data.tar.gz: cf6ca14b9f61a2f05d310084f2af7207a2a6aba887cd6a69c9a3ff1da1ce3670b450e45645a6d36affdabc9f2532d8a0baeda20e7f722bedfdbbd96fcc9ba086
@@ -78,7 +78,7 @@ module HammerCLIKatello
78
78
  end
79
79
 
80
80
  make_listing_files(export_history)
81
-
81
+ output.print_message _("Generated #{export_history['path']}")
82
82
  HammerCLI::EX_OK
83
83
  end
84
84
  end
@@ -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
- if syncable?
18
- make_listing_files(export_history)
19
- HammerCLI::EX_OK
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
- unless File.exist?(metadata_file)
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(File.read(metadata_file))
48
+ opts["metadata"] = JSON.parse(URI.open(metadata_file).read)
39
49
  end
40
50
  end
41
51
  end
@@ -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
@@ -1,5 +1,5 @@
1
1
  module HammerCLIKatello
2
2
  def self.version
3
- @version ||= Gem::Version.new('1.6.0')
3
+ @version ||= Gem::Version.new('1.7.0')
4
4
  end
5
5
  end