hammer_cli_katello 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 186183bd2337627828ad27578924b491161632034de3f51b2896a02312b68519
4
- data.tar.gz: 903b7f9c68fdfcd7538739a1f98aa896e18924806f69d37576a85f935315f7e1
3
+ metadata.gz: b5fa880828d3804a98b06e439b6ea10c6f0784102ac00d5ba686b3ff2e27ced6
4
+ data.tar.gz: 52650dc243f073826a2f47cbe69939a2c8af4e2dd8acf3f1843b0acf3dab4063
5
5
  SHA512:
6
- metadata.gz: ae67f54e90820899048b453b5c6592d0e7ac36ee562d798c74c82365c82de577c158640259eeb222cfb9e5f8ab5e880fd1ce36dcba56eed3f67dadaf2430eef7
7
- data.tar.gz: aae484692b57eb9405e01b2b2f6e01b8254e7903b53fdbe919e829366e0f28ab46e5184e61111fa637655d029cd000197639a1e5919cc5bc59c041ad93108eb0
6
+ metadata.gz: b782ea88258329a25f04d308d7f419328a931e2d8ed9d757da44bc7ce54fc37351635cea13d1d990de6d5a399ba6793c2aeecf5ed65f374dfb4d51a2fded2308
7
+ data.tar.gz: e7883bbd668c0eb608b2ad4dc31191f41f8e0837a4648003d2313a0fc13d425778f0f803a46c1343d25dcd25317c27d8ba2d6fc671be846b7bedeb9b60df0beb
@@ -13,7 +13,7 @@ module HammerCLIKatello
13
13
  :required => false
14
14
 
15
15
  base.build_options do |o|
16
- o.expand(:all).including(:content_views, :organizations).except(:metadata)
16
+ o.expand(:all).including(:organizations).except(:metadata)
17
17
  end
18
18
 
19
19
  base.validate_options do
@@ -58,6 +58,21 @@ module HammerCLIKatello
58
58
  include ContentImportCommon
59
59
  end
60
60
 
61
+ class ListCommand < HammerCLIKatello::ListCommand
62
+ desc "View content view import histories"
63
+ output do
64
+ field :id, _('ID')
65
+ field :path, _('Path')
66
+ field :type, _('Type')
67
+ field :content_view_version, _('Content View Version')
68
+ field :content_view_version_id, _('Content View Version ID')
69
+ field :created_at, _('Created at')
70
+ field :updated_at, _('Updated at'), Fields::Field, :hide_blank => true
71
+ end
72
+
73
+ build_options
74
+ end
75
+
61
76
  autoload_subcommands
62
77
  end
63
78
  end
@@ -271,279 +271,6 @@ module HammerCLIKatello
271
271
  end
272
272
  end
273
273
 
274
- class ExportDefaultCommand < HammerCLIForeman::Command
275
- include HammerCLIKatello::LocalHelper
276
- include HammerCLIKatello::ApipieHelper
277
- include HammerCLIKatello::CVImportExportHelper
278
-
279
- PUBLISHED_REPOS_DIR = "/var/lib/pulp/published/yum/https/repos/".freeze
280
-
281
- desc _('Export the library default content view')
282
-
283
- command_name "export-default"
284
-
285
- option '--export-dir', 'EXPORT_DIR', _("Directory to put content view version export into.")
286
-
287
- validate_options do
288
- option(:option_export_dir).required
289
- end
290
-
291
- build_options
292
-
293
- def execute
294
- validate_pulp3_not_enabled(fail_msg_export)
295
- export_dir = options['option_export_dir']
296
-
297
- Dir.mkdir(export_dir) unless Dir.exist?(export_dir)
298
- result = Kernel.system("rsync -aL #{PUBLISHED_REPOS_DIR} #{export_dir}")
299
- if result == true
300
- output.print_message _("Default content view export is available at #{export_dir}")
301
- HammerCLI::EX_OK
302
- else
303
- output.print_error _("Could not export the default content view at #{export_dir}")
304
- HammerCLI::EX_CANTCREAT
305
- end
306
- end
307
- end
308
-
309
- class LegacyExportCommand < HammerCLIKatello::SingleResourceCommand
310
- include HammerCLIForemanTasks::Async
311
- include LifecycleEnvironmentNameMapping
312
- include HammerCLIKatello::CVImportExportHelper
313
- desc _('Export a content view (legacy method)')
314
-
315
- action :export
316
- command_name "export-legacy"
317
-
318
- success_message _("Content view is being exported in task %{id}.")
319
- failure_message _("Could not export the content view")
320
- build_options do |o|
321
- o.expand(:all).including(:environments, :content_views, :organizations)
322
- end
323
-
324
- extend_with(HammerCLIKatello::CommandExtensions::LifecycleEnvironment.new)
325
-
326
- def request_params
327
- validate_pulp3_not_enabled(fail_msg_export)
328
- super
329
- end
330
- end
331
-
332
- class ExportCommand < HammerCLIForeman::Command
333
- include HammerCLIKatello::LocalHelper
334
- include HammerCLIKatello::ApipieHelper
335
- include HammerCLIKatello::CVImportExportHelper
336
-
337
- PUBLISHED_REPOS_DIR = "/var/lib/pulp/published/yum/https/repos/".freeze
338
-
339
- desc _('Export a content view version')
340
-
341
- command_name "export"
342
-
343
- success_message _("Content view export is available in %{directory}.")
344
- failure_message _("Could not export the content view")
345
-
346
- option "--id", "ID", _("Content View Version numeric identifier")
347
- option '--export-dir', 'EXPORT_DIR', _("Directory to put content view version export into.")
348
-
349
- validate_options do
350
- option(:option_export_dir).required
351
- option(:option_id).required
352
- end
353
-
354
- build_options
355
-
356
- def execute
357
- cvv = show(:content_view_versions, 'id' => options['option_id'])
358
- cv = show(:content_views, 'id' => cvv['content_view_id'])
359
-
360
- validate_pulp3_not_enabled(fail_msg_export)
361
-
362
- composite = cv["composite"]
363
-
364
- export_json_options = { :cvv => cvv }
365
-
366
- if composite
367
- components = cv['components']
368
- export_json_options[:component_cvvs] = components.collect do |component|
369
- component['name']
370
- end
371
- export_json_options[:repositories] = []
372
- else
373
- repositories = fetch_exportable_cvv_repositories(cvv)
374
- collect_packages(repositories)
375
-
376
- export_json_options[:repositories] = repositories
377
- end
378
-
379
- json = export_json(export_json_options)
380
- if repositories&.any? || cv['composite']
381
- create_tar(cv, cvv, repositories, json)
382
- else
383
- msg = <<~MSG
384
- Ensure the content view version '#{cvv['name']}' has at least one repository.
385
- MSG
386
- raise _(msg)
387
- end
388
- return HammerCLI::EX_OK
389
- end
390
-
391
- def create_tar(cv, cvv, repositories, json)
392
- export_prefix = "export-#{cv['label']}-#{cvv['major']}.#{cvv['minor']}"
393
- export_file = "#{export_prefix}.json"
394
- export_repos_tar = "#{export_prefix}-repos.tar"
395
- export_tar = "#{export_prefix}.tar"
396
- export_dir = File.expand_path(options['option_export_dir'].to_s)
397
-
398
- Dir.mkdir("#{export_dir}/#{export_prefix}")
399
-
400
- if repositories&.any?
401
-
402
- Dir.chdir(PUBLISHED_REPOS_DIR) do
403
- repo_tar = "#{export_dir}/#{export_prefix}/#{export_repos_tar}"
404
- repo_dirs = []
405
-
406
- repositories.each do |repo|
407
- repo_dirs.push(repo['relative_path'])
408
- end
409
-
410
- `tar cvfh #{repo_tar} #{repo_dirs.join(" ")}`
411
- end
412
- end
413
-
414
- Dir.chdir("#{export_dir}/#{export_prefix}") do
415
- File.open(export_file, 'w') do |file|
416
- file.write(JSON.pretty_generate(json))
417
- end
418
- end
419
-
420
- Dir.chdir(export_dir) do
421
- `tar cf #{export_tar} #{export_prefix}`
422
- FileUtils.rm_rf(export_prefix)
423
- end
424
- end
425
- end
426
-
427
- class ImportCommand < HammerCLIForeman::Command
428
- include HammerCLIForemanTasks::Async
429
- include HammerCLIKatello::LocalHelper
430
- include HammerCLIKatello::ApipieHelper
431
- include HammerCLIKatello::CVImportExportHelper
432
-
433
- attr_accessor :export_tar_dir, :export_tar_file, :export_tar_prefix
434
-
435
- desc _('Import a content view version')
436
-
437
- command_name "import"
438
-
439
- success_message _("Content view imported.")
440
- failure_message _("Could not import the content view")
441
-
442
- option "--organization-id", "ORGANIZATION_ID", _("Organization numeric identifier")
443
- option(
444
- '--export-tar', 'EXPORT_TAR',
445
- _("Location of export tar on disk")
446
- )
447
-
448
- validate_options do
449
- option(:option_export_tar).required
450
- option(:option_organization_id).required
451
- end
452
-
453
- build_options
454
-
455
- # rubocop:disable Metrics/AbcSize
456
- def execute
457
- validate_pulp3_not_enabled(fail_msg_import)
458
-
459
- unless File.exist?(options['option_export_tar'])
460
- raise _("Export tar #{options['option_export_tar']} does not exist.")
461
- end
462
-
463
- import_tar_params = obtain_export_params(options['option_export_tar'])
464
- untar_export(import_tar_params)
465
-
466
- export_json = read_json(import_tar_params)
467
- cv = content_view(export_json['name'], options['option_organization_id'])
468
- major = export_json['major'].to_s
469
- minor = export_json['minor'].to_s
470
- import_checks(export_json, cv, major, minor)
471
-
472
- if export_json['composite_components']
473
- composite_version_ids = export_json['composite_components'].map do |component|
474
- find_local_component_id(component)
475
- end
476
- update(:content_views, 'id' => cv['id'], 'component_ids' => composite_version_ids)
477
- publish(cv['id'], export_json['major'], export_json['minor'])
478
- else
479
- sync_repositories(export_json['repositories'], options['option_organization_id'],
480
- import_tar_params)
481
-
482
- unless cv['default']
483
- publish(
484
- cv['id'], export_json['major'],
485
- export_json['minor'], repos_units(export_json['repositories'])
486
- )
487
- end
488
- end
489
- return HammerCLI::EX_OK
490
- end
491
- # rubocop:enable Metrics/AbcSize
492
-
493
- def sync_repositories(repositories, organization_id, options)
494
- export_tar_dir = options[:dirname]
495
- export_tar_prefix = options[:prefix]
496
-
497
- repositories.each do |repo|
498
- library_repos = index(
499
- :repositories,
500
- 'organization_id' => organization_id,
501
- 'library' => true,
502
- 'label' => repo['label']
503
- )
504
-
505
- library_repo = library_repos.select do |candidate_repo|
506
- candidate_repo['label'] == repo['label']
507
- end
508
-
509
- library_repo = library_repo.first
510
-
511
- if library_repo.nil?
512
- msg = _("Unable to sync repositories, no library repository found for %s")
513
- raise msg % repo['label']
514
- end
515
-
516
- synchronize(
517
- library_repo['id'],
518
- "file://#{export_tar_dir}/#{export_tar_prefix}/#{repo['relative_path']}"
519
- )
520
- end
521
- end
522
-
523
- def repos_units(repositories)
524
- repositories.collect do |repo|
525
- {
526
- 'label' => repo['label'],
527
- 'rpm_filenames' => repo['rpm_filenames']
528
- }
529
- end
530
- end
531
-
532
- def content_view(name, organization_id)
533
- index(:content_views, 'name' => name, 'organization_id' => organization_id).first
534
- end
535
-
536
- def synchronize(id, source_url)
537
- task_progress(call(:sync, :repositories, 'id' => id, 'source_url' => source_url))
538
- end
539
-
540
- def publish(id, major, minor, repos_units = nil)
541
- params = {'id' => id, 'major' => major, 'minor' => minor }
542
- params['repos_units'] = repos_units if repos_units
543
- task_progress(call(:publish, :content_views, params))
544
- end
545
- end
546
-
547
274
  autoload_subcommands
548
275
  end
549
276
  end
@@ -0,0 +1,13 @@
1
+ module HammerCLIKatello
2
+ class DockerCommand < HammerCLI::AbstractCommand
3
+ require 'hammer_cli_katello/docker_manifest'
4
+ subcommand 'manifest',
5
+ HammerCLIKatello::DockerManifestCommand.desc,
6
+ HammerCLIKatello::DockerManifestCommand
7
+
8
+ require 'hammer_cli_katello/docker_tag'
9
+ subcommand 'tag',
10
+ HammerCLIKatello::DockerTagCommand.desc,
11
+ HammerCLIKatello::DockerTagCommand
12
+ end
13
+ end
@@ -0,0 +1,53 @@
1
+ module HammerCLIKatello
2
+ class DockerManifestCommand < HammerCLIForeman::Command
3
+ resource :docker_manifests
4
+ command_name 'manifest'
5
+ desc _('Manage docker manifests')
6
+
7
+ class ListCommand < HammerCLIKatello::ListCommand
8
+ include HammerCLIKatello::LifecycleEnvironmentNameMapping
9
+
10
+ output do
11
+ field :id, _("ID")
12
+ field :name, _("Name")
13
+ field :schema_version, _("Schema Version")
14
+ field :digest, _("Digest")
15
+ field :downloaded, _("Downloaded"), Fields::Boolean
16
+ field :_tags, _("Tags")
17
+ end
18
+
19
+ def extend_data(manifest)
20
+ manifest['_tags'] = manifest['tags'].map { |e| e["name"] }.join(", ")
21
+ manifest
22
+ end
23
+
24
+ build_options do |o|
25
+ o.expand.including(:products, :organizations, :content_views)
26
+ end
27
+
28
+ extend_with(HammerCLIKatello::CommandExtensions::LifecycleEnvironment.new)
29
+ end
30
+
31
+ class InfoCommand < HammerCLIKatello::InfoCommand
32
+ output do
33
+ field :id, _("ID")
34
+ field :name, _("Name")
35
+ field :schema_version, _("Schema Version")
36
+ field :digest, _("Digest")
37
+ field :downloaded, _("Downloaded"), Fields::Boolean
38
+ collection :tags, _("Tags") do
39
+ field :name, _("Name")
40
+ end
41
+ end
42
+
43
+ def extend_data(manifest)
44
+ manifest['_tags'] = manifest['tags'].map { |e| { name: e["name"] } }.join(", ")
45
+ manifest
46
+ end
47
+
48
+ build_options
49
+ end
50
+
51
+ autoload_subcommands
52
+ end
53
+ end
@@ -0,0 +1,40 @@
1
+ module HammerCLIKatello
2
+ class DockerTagCommand < HammerCLIForeman::Command
3
+ resource :docker_tags
4
+ command_name 'tag'
5
+ desc _('Manage docker tags')
6
+
7
+ class ListCommand < HammerCLIKatello::ListCommand
8
+ include HammerCLIKatello::LifecycleEnvironmentNameMapping
9
+
10
+ output do
11
+ field :id, _("ID")
12
+ field :name, _("Tag")
13
+ field :repository_id, _("Repository ID")
14
+ end
15
+
16
+ build_options do |o|
17
+ o.expand.including(:products, :organizations, :content_views)
18
+ end
19
+
20
+ extend_with(HammerCLIKatello::CommandExtensions::LifecycleEnvironment.new)
21
+ end
22
+
23
+ class InfoCommand < HammerCLIKatello::InfoCommand
24
+ output do
25
+ field :id, _("ID")
26
+ field :name, _("Tag")
27
+ field :repository_id, _("Repository ID")
28
+
29
+ from :manifest do
30
+ field :id, _("Docker Manifest ID")
31
+ field :name, _("Docker Manifest Name")
32
+ end
33
+ end
34
+
35
+ build_options
36
+ end
37
+
38
+ autoload_subcommands
39
+ end
40
+ end
@@ -28,7 +28,9 @@ module HammerCLIKatello
28
28
  :subscription => [s_name(_("Subscription name to search by"))],
29
29
  :sync_plan => [s_name(_("Sync plan name to search by"))],
30
30
  :task => [s_name(_("Task name to search by"))],
31
- :content_view_version => [s("version", _("Content view version number"))]
31
+ :content_view_version => [s("version", _("Content view version number"))],
32
+ :content_export => [],
33
+ :content_import => []
32
34
  }.freeze
33
35
 
34
36
  DEFAULT_SEARCHABLES = [s_name(_("Name to search by"))].freeze
@@ -21,9 +21,19 @@ module HammerCLIKatello
21
21
  field :label, _("Label")
22
22
  field :description, _("Description")
23
23
  field :redhat_repository_url, _("Red Hat Repository URL")
24
+ field :simple_content_access_label, _("Simple Content Access")
24
25
  field :service_levels, _("Service Levels"), Fields::List
25
26
  end
26
27
 
28
+ def extend_data(data)
29
+ data["simple_content_access_label"] = if data["simple_content_access"]
30
+ _("Enabled")
31
+ else
32
+ _("Disabled")
33
+ end
34
+ data
35
+ end
36
+
27
37
  build_options
28
38
  end
29
39
 
@@ -6,6 +6,14 @@ module HammerCLIKatello
6
6
 
7
7
  output do
8
8
  from "services" do
9
+ label "katello_agent", hide_blank: true do
10
+ from "katello_agent" do
11
+ field "status", _("Status"), Fields::Field, hide_blank: true
12
+ field "message", _("message"), Fields::Field, hide_blank: true
13
+ field "_response", _("Server Response"), Fields::Field, hide_blank: true
14
+ end
15
+ end
16
+
9
17
  label "candlepin" do
10
18
  from "candlepin" do
11
19
  field "status", _("Status")
@@ -13,17 +21,17 @@ module HammerCLIKatello
13
21
  end
14
22
  end
15
23
 
16
- label "candlepin_events" do
17
- from "candlepin_events" do
24
+ label "candlepin_auth" do
25
+ from "candlepin_auth" do
18
26
  field "status", _("Status")
19
- field "message", _("message")
20
27
  field "_response", _("Server Response")
21
28
  end
22
29
  end
23
30
 
24
- label "candlepin_auth" do
25
- from "candlepin_auth" do
31
+ label "candlepin_events" do
32
+ from "candlepin_events" do
26
33
  field "status", _("Status")
34
+ field "message", _("message")
27
35
  field "_response", _("Server Response")
28
36
  end
29
37
  end
@@ -2,6 +2,25 @@ module HammerCLIKatello
2
2
  class Repository < HammerCLIKatello::Command
3
3
  resource :repositories
4
4
 
5
+ module AnsibleCollectionRequirementsHelper
6
+ def self.included(base)
7
+ base.option "--ansible-collection-requirements-file",
8
+ "REQUIREMENTS_FILE", _("Location of the ansible collections "\
9
+ "requirements.yml file. "),
10
+ :attribute_name => :option_ansible_collection_requirements_file,
11
+ :required => false
12
+ end
13
+
14
+ def request_params
15
+ super.tap do |opts|
16
+ requirements_file = option_ansible_collection_requirements_file
17
+ if requirements_file
18
+ opts["ansible_collection_requirements"] = File.read(requirements_file)
19
+ end
20
+ end
21
+ end
22
+ end
23
+
5
24
  class ListCommand < HammerCLIKatello::ListCommand
6
25
  include LifecycleEnvironmentNameMapping
7
26
 
@@ -192,6 +211,7 @@ module HammerCLIKatello
192
211
  end
193
212
 
194
213
  class CreateCommand < HammerCLIKatello::CreateCommand
214
+ include AnsibleCollectionRequirementsHelper
195
215
  success_message _("Repository created.")
196
216
  failure_message _("Could not create the repository")
197
217
 
@@ -204,6 +224,7 @@ module HammerCLIKatello
204
224
 
205
225
  class UpdateCommand < HammerCLIKatello::UpdateCommand
206
226
  extend RepositoryScopedToProduct
227
+ include AnsibleCollectionRequirementsHelper
207
228
 
208
229
  validate_repo_name_requires_product_options
209
230
  include OrganizationOptions
@@ -15,6 +15,7 @@ module HammerCLIKatello
15
15
 
16
16
  class EnableCommand < HammerCLIKatello::SingleResourceCommand
17
17
  include EligibleCheck
18
+ include HammerCLIForemanTasks::Async
18
19
  resource :simple_content_access, :enable
19
20
  command_name "enable"
20
21
 
@@ -26,6 +27,7 @@ module HammerCLIKatello
26
27
 
27
28
  class DisableCommand < HammerCLIKatello::SingleResourceCommand
28
29
  include EligibleCheck
30
+ include HammerCLIForemanTasks::Async
29
31
  resource :simple_content_access, :disable
30
32
  command_name "disable"
31
33
 
@@ -1,5 +1,5 @@
1
1
  module HammerCLIKatello
2
2
  def self.version
3
- @version ||= Gem::Version.new('1.0.1')
3
+ @version ||= Gem::Version.new('1.1.0')
4
4
  end
5
5
  end
@@ -30,7 +30,6 @@ module HammerCLIKatello
30
30
  require 'hammer_cli_katello/id_name_options_validator'
31
31
  require 'hammer_cli_katello/local_helper'
32
32
  require 'hammer_cli_katello/apipie_helper'
33
- require 'hammer_cli_katello/cv_import_export_helper'
34
33
  require 'hammer_cli_katello/content_export_helper'
35
34
 
36
35
  # commands
@@ -156,6 +155,11 @@ module HammerCLIKatello
156
155
  'hammer_cli_katello/simple_content_access'
157
156
  )
158
157
 
158
+ HammerCLI::MainCommand.lazy_subcommand("docker", _("Manipulate docker content"),
159
+ 'HammerCLIKatello::DockerCommand',
160
+ 'hammer_cli_katello/docker'
161
+ )
162
+
159
163
  # subcommands to hammer_cli_foreman commands
160
164
  require 'hammer_cli_katello/host'
161
165
  require 'hammer_cli_katello/hostgroup'
@@ -1195,31 +1195,6 @@ msgstr ""
1195
1195
  msgid "Unable to sync repositories, no library repository found for %s"
1196
1196
  msgstr ""
1197
1197
 
1198
- #: ../lib/hammer_cli_katello/cv_import_export_helper.rb:19
1199
- msgid ""
1200
- "Unable to find CV version %{cvv} on system. Please ensure it is already import"
1201
- "ed."
1202
- msgstr ""
1203
-
1204
- #: ../lib/hammer_cli_katello/cv_import_export_helper.rb:29
1205
- msgid ""
1206
- "The Content View #{cv['name']} is not present on this server, please create th"
1207
- "e Content View and try the import again."
1208
- msgstr ""
1209
-
1210
- #: ../lib/hammer_cli_katello/cv_import_export_helper.rb:34
1211
- msgid ""
1212
- "The latest version (#{import_cv['latest_version']}) of the Content View '#{cv["
1213
- "'name']}' is greater or equal to the version you are trying to import (#{versi"
1214
- "on})"
1215
- msgstr ""
1216
-
1217
- #: ../lib/hammer_cli_katello/cv_import_export_helper.rb:45
1218
- msgid ""
1219
- "The Repository '#{repo['name']}' is set with Mirror-on-Sync to YES. Please cha"
1220
- "nge Mirror-on-Sync to NO and try the import again."
1221
- msgstr ""
1222
-
1223
1198
  #: ../lib/hammer_cli_katello/erratum.rb:14
1224
1199
  #: ../lib/hammer_cli_katello/erratum_info_command.rb:11
1225
1200
  #: ../lib/hammer_cli_katello/filter.rb:47