hammer_cli_katello 1.3.0 → 1.4.1

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: 70bd64a3e1a162fa1c50c097a5f6c60cff91f6764a91aa715f575387bc02406c
4
- data.tar.gz: 9b75290d2868faa302f15f23022bf310ca7f091ec819da5eba988abb17adda4d
3
+ metadata.gz: d1ff46aa39c3547dea6343f671d10d5ae603ecee1d4e2c416ddea5b1884de3e0
4
+ data.tar.gz: 5c3a848bcf07dba7d725a882a8a5e667841327f08ec738c100375c910466bfef
5
5
  SHA512:
6
- metadata.gz: 0b5ab6e3272b3336bb11ca0b0e200fab63654f90bdafc5c213807fb9928da84e377132a408f826a58b8b58d2d55d9fa5f8b142284ff8f0f310b74b72cfd18ec7
7
- data.tar.gz: a114e7f127f3418cadf0a7f9e06a728a6837013eac2245fe4ca49836441486cb7599146a027f22559376fa0ecaf3f44ecd1a5a587f97a9bc0e19b44e62bc8465
6
+ metadata.gz: 2fe7eddfe5ec1ebb616afeadd16c57ccba45100997b00dd69912284c27fc94467d22bc2d0023685237e7c744f3eb257a2c8d92d31a5589eb520a3f2e5fb2c484
7
+ data.tar.gz: 615ed4f84b86117d9b78543c1d8b5a09b9e21240d4f2fa9d5c2899c5a0d229e4ea1da2d008b03095473c90f9ea5cb43a024d122168a0b29a3578affd0d62b040
@@ -0,0 +1,66 @@
1
+ module HammerCLIKatello
2
+ class ContentUnitsCommand < HammerCLIKatello::Command
3
+ resource :generic_content_units
4
+
5
+ class ListCommand < HammerCLIKatello::ListCommand
6
+ extend RepositoryScopedToProduct
7
+
8
+ validate_repo_name_requires_product_options(:option_repository_name)
9
+
10
+ output do
11
+ field :id, _("Id")
12
+ field :name, _("Name")
13
+ field :version, _("Version")
14
+ field :filename, _("Filename"), Fields::Field, hide_blank: true
15
+ end
16
+
17
+ validate_options :before, 'IdResolution' do
18
+ organization_options = [:option_organization_id, :option_organization_name,
19
+ :option_organization_label]
20
+ if any(:option_product_name, :option_content_view_name).exist?
21
+ any(*organization_options).required
22
+ end
23
+ end
24
+
25
+ build_options do |o|
26
+ o.expand.including(:products, :organizations, :content_views)
27
+ end
28
+ end
29
+
30
+ class InfoCommand < HammerCLIKatello::InfoCommand
31
+ output do
32
+ field :id, _("Id")
33
+ field :name, _("Name")
34
+ field :version, _("Version")
35
+ field :filename, _("Filename"), Fields::Field, hide_blank: true
36
+ end
37
+
38
+ validate_options :before, 'IdResolution' do
39
+ organization_options = [:option_organization_id, :option_organization_name,
40
+ :option_organization_label]
41
+ product_options = [:option_product_id, :option_product_name]
42
+ repository_options = [:option_repository_id, :option_repository_name]
43
+ content_view_version_options = [:option_content_view_version_id,
44
+ :option_content_view_version_version]
45
+
46
+ if option(:option_product_name).exist?
47
+ any(*organization_options).required
48
+ end
49
+
50
+ if option(:option_repository_name).exist?
51
+ any(*product_options).required
52
+ end
53
+
54
+ if option(:option_name).exist?
55
+ any(*(repository_options + content_view_version_options)).required
56
+ end
57
+ end
58
+
59
+ build_options do |o|
60
+ o.expand.including(:products, :organizations, :content_views, :content_view_versions)
61
+ end
62
+ end
63
+
64
+ autoload_subcommands
65
+ end
66
+ end
@@ -84,16 +84,16 @@ module HammerCLIKatello
84
84
  include OrganizationOptions
85
85
  include CompositeContentViewNameResolvable
86
86
  output do
87
- field :id, _("Id")
87
+ field :content_view_id, _("Content View Id")
88
88
  field :content_view_name, _("Name")
89
89
  field :version, _("Version")
90
+ field :id, _("Component Id")
90
91
  field :current_version, _("Current Version")
91
92
  field :version_id, _("Version Id")
92
93
  end
93
94
 
94
95
  def extend_data(mod)
95
96
  if mod['latest']
96
- mod['content_view_name'] = mod["content_view"]["name"]
97
97
  mod['version'] = _("Latest")
98
98
  if mod['content_view_version']
99
99
  mod['current_version'] = mod['content_view_version']['version']
@@ -102,10 +102,11 @@ module HammerCLIKatello
102
102
  mod['current_version'] = _("No Published Version")
103
103
  end
104
104
  else
105
- mod['content_view_name'] = mod["content_view"]["name"]
106
105
  mod['version'] = mod['content_view_version']['version']
107
106
  mod['version_id'] = mod['content_view_version']['id']
108
107
  end
108
+ mod['content_view_name'] = mod["content_view"]["name"]
109
+ mod['content_view_id'] = mod["content_view"]["id"]
109
110
  mod
110
111
  end
111
112
 
@@ -86,7 +86,7 @@ module HammerCLIKatello
86
86
  end
87
87
 
88
88
  label _("GPG Key") do
89
- from :gpg_key do
89
+ from :content_credential do
90
90
  field :id, _("Id"), Fields::Field, :hide_blank => true
91
91
  field :name, _("Name"), Fields::Field, :hide_blank => true
92
92
  end
@@ -110,7 +110,6 @@ module HammerCLIKatello
110
110
  field :docker_manifest_total, _("Container Image Manifests"), Fields::Field,
111
111
  :hide_blank => true
112
112
  field :docker_tag_total, _("Container Image Tags"), Fields::Field, :hide_blank => true
113
- field :ostree_branch_total, _("OSTree Branches"), Fields::Field, :hide_blank => true
114
113
  field :file_total, _("Files"), Fields::Field, :hide_blank => true
115
114
  field :module_stream_total, _("Module Streams"), Fields::Field, :hide_blank => true
116
115
  end
@@ -159,21 +158,11 @@ module HammerCLIKatello
159
158
  data["docker_manifest_list_total"] = content_counts["docker_manifest_list"]
160
159
  data["docker_manifest_total"] = content_counts["docker_manifest"]
161
160
  data["docker_tag_total"] = content_counts["docker_tag"]
162
- when "ostree"
163
- setup_ostree(data)
164
161
  when "file"
165
162
  data["file_total"] = content_counts["file"]
166
163
  end
167
164
  end
168
165
 
169
- def setup_ostree(data)
170
- content_counts = data["content_counts"]
171
- data["ostree_branch_total"] = content_counts["ostree_branch"]
172
- if data["ostree_upstream_sync_policy"] == "custom"
173
- data["_ostree_upstream_sync_depth"] = data["ostree_upstream_sync_depth"]
174
- end
175
- end
176
-
177
166
  def get_sync_status(state)
178
167
  sync_states = {
179
168
  "failed" => _("Failed"), "success" => _("Success"), "finished" => _("Finished"),
@@ -400,6 +389,8 @@ module HammerCLIKatello
400
389
  o.expand.including(:products, :organizations)
401
390
  end
402
391
 
392
+ option "--async", :flag, _("Do not wait for the task.")
393
+
403
394
  option "--ostree-repository-name", "OSTREE REPOSITORY NAME",
404
395
  _("Name of OSTree repository in archive."),
405
396
  :attribute_name => :option_ostree_repository_name,
@@ -426,6 +417,7 @@ module HammerCLIKatello
426
417
  update_content_upload(upload_id, repo_id, file)
427
418
  end
428
419
  opts[:ostree_repository_name] = options["option_ostree_repository_name"]
420
+ opts[:filename] = filename
429
421
  results = import_uploads([
430
422
  {
431
423
  id: upload_id,
@@ -434,7 +426,7 @@ module HammerCLIKatello
434
426
  size: file.size,
435
427
  checksum: checksum
436
428
  }], opts)
437
- print_results(filename, results)
429
+ print_results(filename, results, options["option_async"])
438
430
  ensure
439
431
  if upload_id
440
432
  content_upload_resource.call(:destroy, :repository_id => get_identifier, :id => upload_id)
@@ -479,35 +471,54 @@ module HammerCLIKatello
479
471
  params = {:id => get_identifier,
480
472
  :uploads => uploads,
481
473
  publish_repository: publish_repository,
482
- sync_capsule: sync_capsule
474
+ sync_capsule: sync_capsule,
475
+ async: true
483
476
  }
484
477
  params[:content_type] = options["option_content_type"] if options["option_content_type"]
485
478
  if options["option_ostree_repository_name"]
486
479
  params[:ostree_repository_name] = options["option_ostree_repository_name"]
487
480
  end
488
- resource.call(:import_uploads, params)
481
+ results = if options["option_async"]
482
+ resource.call(:import_uploads, params)
483
+ else
484
+ task_progress(resource.call(:import_uploads, params))
485
+ end
486
+ results
489
487
  end
490
488
 
491
- def print_results(name, results)
492
- if results.empty? || results.dig('output', 'upload_results').empty?
493
- print_message _("Successfully uploaded file '%{name}'") % {
494
- :name => name
495
- }
496
- else
489
+ def task_progress(task_or_id)
490
+ super
491
+ task_id = task_or_id.is_a?(Hash) ? task_or_id['id'] : task_or_id
492
+ load_task(task_id)
493
+ end
494
+
495
+ # rubocop:disable CyclomaticComplexity
496
+ # rubocop:disable PerceivedComplexity
497
+ def print_results(name, results, async)
498
+ if !%w(error warning).include?(results) && !async # task successful && no async flag used
497
499
  upload_results = results.dig('output', 'upload_results') || []
498
- upload_results.each do |result|
499
- if result['type'] == 'docker_manifest'
500
- print_message(
501
- _("Successfully uploaded manifest file '%{name}' with digest '%{digest}'") % {
502
- :name => name, :digest => result['digest'] })
503
- else
504
- print_message _("Successfully uploaded file '%{name}'") % {
505
- :name => name
506
- }
500
+
501
+ if upload_results.empty?
502
+ print_message _("Successfully uploaded file %s" % name)
503
+ else
504
+ upload_results.each do |result|
505
+ if result['type'] == 'docker_manifest'
506
+ print_message(
507
+ _("Successfully uploaded manifest file '%{name}' with digest '%{digest}'") % {
508
+ :name => name, :digest => result['digest'] })
509
+ else
510
+ print_message _("Successfully uploaded file %s" % name)
511
+ end
507
512
  end
508
513
  end
514
+ elsif results&.dig('id') && async # async flag used
515
+ print_message _("Content is being uploaded in task #{results['id']}.")
516
+ else
517
+ print_message _("Could not upload the content.")
509
518
  end
510
519
  end
520
+ # rubocop:enable CyclomaticComplexity
521
+ # rubocop:enable PerceivedComplexity
511
522
 
512
523
  def silence_warnings
513
524
  original_verbose = $VERBOSE
@@ -519,7 +530,6 @@ module HammerCLIKatello
519
530
  end
520
531
  end
521
532
  end
522
- # rubocop:enable ClassLength
523
533
 
524
534
  class RemoveContentCommand < HammerCLIKatello::SingleResourceCommand
525
535
  extend RepositoryScopedToProduct
@@ -547,6 +557,32 @@ module HammerCLIKatello
547
557
  end
548
558
  end
549
559
 
560
+ class ReclaimSpaceCommand < HammerCLIKatello::SingleResourceCommand
561
+ extend RepositoryScopedToProduct
562
+ include HammerCLIForemanTasks::Async
563
+ include OrganizationOptions
564
+ validate_repo_name_requires_product_options
565
+ action :reclaim_space
566
+ command_name "reclaim-space"
567
+ desc _("Reclaim space from an On Demand repository")
568
+
569
+ success_message _("Repository space reclaimed.")
570
+ failure_message _("Could not reclaim the repository")
571
+
572
+ validate_options :before, 'IdResolution' do
573
+ organization_options = [:option_organization_id, :option_organization_name, \
574
+ :option_organization_label]
575
+
576
+ if option(:option_product_name).exist?
577
+ any(*organization_options).required
578
+ end
579
+ end
580
+
581
+ build_options do |o|
582
+ o.expand.including(:products)
583
+ end
584
+ end
585
+ # rubocop:enable ClassLength
550
586
  autoload_subcommands
551
587
  end
552
588
  end
@@ -1,5 +1,5 @@
1
1
  module HammerCLIKatello
2
2
  def self.version
3
- @version ||= Gem::Version.new('1.3.0')
3
+ @version ||= Gem::Version.new('1.4.1')
4
4
  end
5
5
  end
@@ -117,16 +117,16 @@ module HammerCLIKatello
117
117
  'hammer_cli_katello/erratum'
118
118
  )
119
119
 
120
- HammerCLI::MainCommand.lazy_subcommand("ostree-branch", _("Manipulate ostree branches"),
121
- 'HammerCLIKatello::OstreeBranchCommand',
122
- 'hammer_cli_katello/ostree_branch'
123
- )
124
-
125
120
  HammerCLI::MainCommand.lazy_subcommand("file", _("Manipulate files"),
126
121
  'HammerCLIKatello::FileCommand',
127
122
  'hammer_cli_katello/file'
128
123
  )
129
124
 
125
+ HammerCLI::MainCommand.lazy_subcommand("content-units", _("Manipulate content units"),
126
+ 'HammerCLIKatello::ContentUnitsCommand',
127
+ 'hammer_cli_katello/content_units'
128
+ )
129
+
130
130
  HammerCLI::MainCommand.lazy_subcommand("content-export",
131
131
  _("Prepare content for export to a disconnected Katello"),
132
132
  'HammerCLIKatello::ContentExport',