hammer_cli_katello 1.4.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +5 -5
  2. data/lib/hammer_cli_katello/acs.rb +79 -0
  3. data/lib/hammer_cli_katello/activation_key.rb +8 -2
  4. data/lib/hammer_cli_katello/content_export_complete.rb +8 -0
  5. data/lib/hammer_cli_katello/content_export_helper.rb +55 -3
  6. data/lib/hammer_cli_katello/content_export_incremental.rb +8 -0
  7. data/lib/hammer_cli_katello/content_import.rb +9 -0
  8. data/lib/hammer_cli_katello/host_collection.rb +2 -0
  9. data/lib/hammer_cli_katello/id_resolver.rb +3 -2
  10. data/lib/hammer_cli_katello/organization.rb +15 -0
  11. data/lib/hammer_cli_katello/repository.rb +40 -3
  12. data/lib/hammer_cli_katello/version.rb +1 -1
  13. data/lib/hammer_cli_katello.rb +5 -0
  14. data/test/data/4.4/foreman_api.json +1 -1
  15. data/test/data/4.5/foreman_api.json +1 -0
  16. data/test/data/4.6/foreman_api.json +1 -0
  17. data/test/functional/acs/create_test.rb +27 -0
  18. data/test/functional/acs/delete_test.rb +13 -0
  19. data/test/functional/acs/info_test.rb +55 -0
  20. data/test/functional/acs/list_test.rb +62 -0
  21. data/test/functional/acs/update_test.rb +23 -0
  22. data/test/functional/content_export/complete/repository_test.rb +226 -0
  23. data/test/functional/content_export/content_export_helpers.rb +7 -0
  24. data/test/functional/content_export/incremental/repository_test.rb +212 -0
  25. data/test/functional/module_stream/info_test.rb +2 -2
  26. data/test/functional/organization/cdn_configuration_test.rb +1 -1
  27. data/test/functional/organization/info_test.rb +8 -2
  28. data/test/functional/repository/info_test.rb +4 -10
  29. data/test/functional/repository/republish_test.rb +37 -0
  30. data/test/functional/repository/update_test.rb +1 -0
  31. data/test/functional/repository_set/disable_test.rb +7 -1
  32. data/test/test_helper.rb +1 -1
  33. metadata +45 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: d1ff46aa39c3547dea6343f671d10d5ae603ecee1d4e2c416ddea5b1884de3e0
4
- data.tar.gz: 5c3a848bcf07dba7d725a882a8a5e667841327f08ec738c100375c910466bfef
2
+ SHA1:
3
+ metadata.gz: 205cdd68504c1fc4b0111f38b2dde15896040933
4
+ data.tar.gz: bf97773c38919f14834c35e32906c19d3cd1b606
5
5
  SHA512:
6
- metadata.gz: 2fe7eddfe5ec1ebb616afeadd16c57ccba45100997b00dd69912284c27fc94467d22bc2d0023685237e7c744f3eb257a2c8d92d31a5589eb520a3f2e5fb2c484
7
- data.tar.gz: 615ed4f84b86117d9b78543c1d8b5a09b9e21240d4f2fa9d5c2899c5a0d229e4ea1da2d008b03095473c90f9ea5cb43a024d122168a0b29a3578affd0d62b040
6
+ metadata.gz: 59f72d7ce8ac083a712dfa10fa9038b636b57bb48b3dbfdbfa691dace6ff7b501495d9b56fb3d8b97e97d90645efa7396f4384afad83eee634270ceaa77274f9
7
+ data.tar.gz: 295e9ea4da56c338d39eb6b3bfb5e3bbab96661fd5d40770a033590e787339f4bb0353a3e49f906a918c253bb63b4c77c9fba1e826074ee84ec12dd50f6c5475
@@ -0,0 +1,79 @@
1
+ module HammerCLIKatello
2
+ class AcsCommand < HammerCLIKatello::Command
3
+ resource :alternate_content_sources
4
+
5
+ class ListCommand < HammerCLIKatello::ListCommand
6
+ output do
7
+ field :id, _('ID')
8
+ field :name, _('Name')
9
+ field :alternate_content_source_type, _('Type')
10
+ end
11
+
12
+ build_options
13
+ end
14
+
15
+ class CreateCommand < HammerCLIKatello::CreateCommand
16
+ success_message _('Alternate Content Source created.')
17
+ failure_message _('Could not create the Alternate Content Source.')
18
+
19
+ build_options
20
+ end
21
+
22
+ class InfoCommand < HammerCLIKatello::InfoCommand
23
+ output do
24
+ field :id, _('ID')
25
+ field :name, _('Name')
26
+ field :label, _('Label')
27
+ field :description, _('Description'), Fields::Field, :hide_blank => true
28
+ field :base_url, _('Base URL')
29
+ field :content_type, _('Content type')
30
+ field :alternate_content_source_type, _('Alternate content source type')
31
+ field :upstream_username, _('Upstream username'), Fields::Field, :hide_blank => true
32
+
33
+ collection :subpaths, _('Subpaths') do
34
+ field nil, _('')
35
+ end
36
+
37
+ collection :smart_proxies, _('Smart proxies') do
38
+ field :id, _('Id')
39
+ field :name, _('Name')
40
+ field :url, _('URL')
41
+ field :created_at, _('Created at')
42
+ field :updated_at, _('Updated at')
43
+ field :expired_logs, _('Expired logs')
44
+ field :puppet_path, _('Puppet path'), Fields::Field, :hide_blank => true
45
+ field :download_policy, _('Download policy')
46
+ end
47
+ end
48
+
49
+ build_options
50
+ end
51
+
52
+ class UpdateCommand < HammerCLIKatello::UpdateCommand
53
+ success_message _('Alternate Content Source updated.')
54
+ failure_message _('Could not update the Alternate Content Source.')
55
+
56
+ build_options
57
+ end
58
+
59
+ class DeleteCommand < HammerCLIKatello::DeleteCommand
60
+ success_message _('Alternate Content Source deleted.')
61
+ failure_message _('Could not delete the Alternate Content Source.')
62
+
63
+ build_options
64
+ end
65
+
66
+ class RefreshCommand < HammerCLIKatello::SingleResourceCommand
67
+ include HammerCLIForemanTasks::Async
68
+
69
+ action :refresh
70
+ command_name 'refresh'
71
+
72
+ success_message _("Alternate content source is being refreshed in task %{id}.")
73
+ failure_message _('Could not refresh the alternate content source')
74
+
75
+ build_options
76
+ end
77
+ autoload_subcommands
78
+ end
79
+ end
@@ -54,10 +54,10 @@ module HammerCLIKatello
54
54
  output do
55
55
  field :name, _("Name")
56
56
  field :id, _("Id")
57
- field :description, _("Description")
57
+ field :description, _("Description"), Fields::Field, :hide_blank => true
58
58
  field :format_limit, _("Host Limit")
59
59
  field :auto_attach, _("Auto Attach")
60
- field :release_version, _("Release Version")
60
+ field :release_version, _("Release Version"), Fields::Field, :hide_blank => true
61
61
 
62
62
  from :environment do
63
63
  field :name, _("Lifecycle Environment")
@@ -71,6 +71,12 @@ module HammerCLIKatello
71
71
  field :name, _("Name")
72
72
  end
73
73
 
74
+ collection :content_overrides, _("Content Overrides") do
75
+ field :content_label, _("Content Label")
76
+ field :name, _("Name")
77
+ field :value, _("Value")
78
+ end
79
+
74
80
  label _("System Purpose") do
75
81
  field :service_level, _('Service Level')
76
82
  field :purpose_usage, _('Purpose Usage')
@@ -20,6 +20,14 @@ module HammerCLIKatello
20
20
  include ContentExportHelper
21
21
  end
22
22
 
23
+ class RepositoryCommand < HammerCLIKatello::SingleResourceCommand
24
+ desc _("Performs a full export of a repository")
25
+ command_name "repository"
26
+
27
+ include HammerCLIForemanTasks::Async
28
+ include ContentExportHelper
29
+ end
30
+
23
31
  autoload_subcommands
24
32
  end
25
33
  end
@@ -1,4 +1,5 @@
1
1
  require 'hammer_cli_katello/repository'
2
+
2
3
  # rubocop:disable ModuleLength
3
4
  module HammerCLIKatello
4
5
  module ContentExportHelper
@@ -40,7 +41,8 @@ module HammerCLIKatello
40
41
  end
41
42
 
42
43
  def fetch_export_history(export_history_id)
43
- index(:content_exports, :id => export_history_id).first if export_history_id
44
+ return unless export_history_id
45
+ index(:content_exports, :id => export_history_id).first
44
46
  end
45
47
 
46
48
  def fetch_export_history_from_task(task)
@@ -48,7 +50,6 @@ module HammerCLIKatello
48
50
  if %w(error warning).include?(task['result'])
49
51
  raise _("Can not fetch export history from an unfinished task")
50
52
  end
51
-
52
53
  export_history_id = task.dig('output', 'export_history_id')
53
54
  fetch_export_history(export_history_id)
54
55
  end
@@ -72,7 +73,16 @@ module HammerCLIKatello
72
73
  self.class.command_name.first.to_sym == :version
73
74
  end
74
75
 
76
+ def repository_command?
77
+ self.class.command_name.first.to_sym == :repository
78
+ end
79
+
75
80
  def fetch_repositories
81
+ if repository_command?
82
+ resp = show(:repositories, id: resolver.repository_id(options))
83
+ return resp["download_policy"] == "immediate" ? [] : [resp]
84
+ end
85
+
76
86
  repo_options = {
77
87
  library: true,
78
88
  content_type: 'yum',
@@ -95,6 +105,10 @@ module HammerCLIKatello
95
105
  " Update the download policy and sync affected repositories."\
96
106
  " Once synced republish the content view"\
97
107
  " and export the generated version.")
108
+ elsif repository_command?
109
+ output.print_message _("NOTE: Unable to fully export this repository because"\
110
+ " it does not have the 'immediate' download policy."\
111
+ " Update the download policy, sync the repository and export.")
98
112
  else
99
113
  output.print_message _("NOTE: Unable to fully export this organization's library because"\
100
114
  " it contains repositories without the 'immediate' download policy."\
@@ -107,7 +121,7 @@ module HammerCLIKatello
107
121
  "--download-policy='immediate'"
108
122
  output.print_message ""
109
123
  print_record(::HammerCLIKatello::Repository::ListCommand.output_definition, repos)
110
- exit(HammerCLI::EX_SOFTWARE) if option_fail_on_missing_content?
124
+ exit(HammerCLI::EX_SOFTWARE) if repository_command? || option_fail_on_missing_content?
111
125
  end
112
126
  end
113
127
 
@@ -116,6 +130,44 @@ module HammerCLIKatello
116
130
  setup_version(base)
117
131
  elsif base.command_name.first.to_sym == :library
118
132
  setup_library(base)
133
+ elsif base.command_name.first.to_sym == :repository
134
+ setup_repository(base)
135
+ end
136
+ end
137
+
138
+ def self.setup_repository(base)
139
+ base.action(:repository)
140
+ base.success_message _("Repository is being exported in task %{id}.")
141
+ base.failure_message _("Could not export the repository")
142
+
143
+ base.option "--name", "NAME", _("Filter repositories by name."),
144
+ :attribute_name => :option_name,
145
+ :required => false
146
+
147
+ base.build_options do |o|
148
+ o.expand(:all).including(:products, :organizations)
149
+ end
150
+
151
+ base.validate_options do
152
+ any(:option_id, :option_name).required
153
+ unless option(:option_id).exist?
154
+ any(
155
+ :option_product_id,
156
+ :option_product_name
157
+ ).required
158
+ unless option(:option_product_id).exist?
159
+ any(:option_organization_id, :option_organization_name, \
160
+ :option_organization_label).required
161
+ end
162
+ end
163
+ end
164
+
165
+ base.class_eval do
166
+ def request_params
167
+ super.tap do |opts|
168
+ opts["id"] = resolver.repository_id(options)
169
+ end
170
+ end
119
171
  end
120
172
  end
121
173
 
@@ -20,6 +20,14 @@ module HammerCLIKatello
20
20
  include ContentExportHelper
21
21
  end
22
22
 
23
+ class RepositoryCommand < HammerCLIKatello::SingleResourceCommand
24
+ desc _("Performs an incremental export of a repository")
25
+ command_name "repository"
26
+
27
+ include HammerCLIForemanTasks::Async
28
+ include ContentExportHelper
29
+ end
30
+
23
31
  autoload_subcommands
24
32
  end
25
33
  end
@@ -58,6 +58,15 @@ module HammerCLIKatello
58
58
  include ContentImportCommon
59
59
  end
60
60
 
61
+ class RepositoryCommand < HammerCLIKatello::SingleResourceCommand
62
+ desc _("Imports a repository")
63
+ action :repository
64
+ command_name "repository"
65
+
66
+ include HammerCLIForemanTasks::Async
67
+ include ContentImportCommon
68
+ end
69
+
61
70
  class ListCommand < HammerCLIKatello::ListCommand
62
71
  desc "View content view import histories"
63
72
  output do
@@ -143,6 +143,8 @@ module HammerCLIKatello
143
143
  success_message _("Host collection updated.")
144
144
  failure_message _("Could not update the the host collection")
145
145
 
146
+ option "--unlimited-hosts", :flag, "Set hosts max to unlimited"
147
+
146
148
  build_options { |o| o.expand(:all).including(:organizations) }
147
149
  end
148
150
 
@@ -29,8 +29,9 @@ module HammerCLIKatello
29
29
  :sync_plan => [s_name(_("Sync plan name to search by"))],
30
30
  :task => [s_name(_("Task name to search by"))],
31
31
  :content_view_version => [s("version", _("Content view version number"))],
32
- :content_export => [],
33
- :content_import => []
32
+ :content_export => [],
33
+ :content_export_incremental => [],
34
+ :content_import => []
34
35
  }.freeze
35
36
 
36
37
  DEFAULT_SEARCHABLES = [s_name(_("Name to search by"))].freeze
@@ -24,9 +24,14 @@ module HammerCLIKatello
24
24
  field :service_levels, _("Service Levels"), Fields::List
25
25
  from :cdn_configuration do
26
26
  label "CDN configuration", hide_blank: true do
27
+ field :type_label, _("Type"), Fields::Field
27
28
  field :url, _("URL"), Fields::Field, hide_blank: true
28
29
  field :upstream_organization_label, _("Upstream Organization"),
29
30
  Fields::Field, hide_blank: true
31
+ field :upstream_lifecycle_environment_label,
32
+ _("Upstream Lifecycle Environment"), Fields::Field, hide_blank: true
33
+ field :upstream_content_view_label, _("Upstream Content View"),
34
+ Fields::Field, hide_blank: true
30
35
  field :username, _("Username"), Fields::Field, hide_blank: true
31
36
  field :ssl_ca_credential_id, _("SSL CA Credential ID"), Fields::Field, hide_blank: true
32
37
  end
@@ -39,9 +44,19 @@ module HammerCLIKatello
39
44
  else
40
45
  _("Disabled")
41
46
  end
47
+ setup_cdn_type(data)
42
48
  data
43
49
  end
44
50
 
51
+ def setup_cdn_type(data)
52
+ types = {
53
+ 'export_sync' => _("Export Sync"),
54
+ 'network_sync' => _("Network Sync"),
55
+ 'redhat_cdn' => _("Red Hat CDN")
56
+ }
57
+ data["cdn_configuration"].merge!("type_label" => types[data["cdn_configuration"]["type"]])
58
+ end
59
+
45
60
  build_options
46
61
  end
47
62
 
@@ -56,7 +56,7 @@ module HammerCLIKatello
56
56
  field :_redhat_repo, _("Red Hat Repository")
57
57
  field :content_type, _("Content Type")
58
58
  field :checksum_type, _("Checksum Type"), Fields::Field, :hide_blank => true
59
- field :_mirror_on_sync, _("Mirror on Sync")
59
+ field :_mirroring_policy, _("Mirroring Policy"), Fields::Field, :hide_blank => true
60
60
  field :url, _("Url")
61
61
  field :_publish_via_http, _("Publish Via HTTP")
62
62
  field :full_path, _("Published At")
@@ -86,7 +86,7 @@ module HammerCLIKatello
86
86
  end
87
87
 
88
88
  label _("GPG Key") do
89
- from :content_credential do
89
+ from :gpg_key do
90
90
  field :id, _("Id"), Fields::Field, :hide_blank => true
91
91
  field :name, _("Name"), Fields::Field, :hide_blank => true
92
92
  end
@@ -126,6 +126,7 @@ module HammerCLIKatello
126
126
 
127
127
  setup_sync_state(data)
128
128
  setup_booleans(data)
129
+ setup_mirroring_policy(data)
129
130
  setup_content_counts(data) if data["content_counts"]
130
131
  data
131
132
  end
@@ -133,7 +134,16 @@ module HammerCLIKatello
133
134
  def setup_booleans(data)
134
135
  data["_redhat_repo"] = data.dig("product", "redhat") ? _("yes") : _("no")
135
136
  data["_publish_via_http"] = data["unprotected"] ? _("yes") : _("no")
136
- data["_mirror_on_sync"] = data["mirror_on_sync"] ? _("yes") : _("no")
137
+ end
138
+
139
+ def setup_mirroring_policy(data)
140
+ policies = {
141
+ 'additive' => _("Additive"),
142
+ 'mirror_content_only' => _("Content Only"),
143
+ 'mirror_complete' => _("Complete Mirroring")
144
+ }
145
+ mirroring_policy = data["mirroring_policy"]
146
+ data["_mirroring_policy"] = policies[mirroring_policy]
137
147
  end
138
148
 
139
149
  def setup_sync_state(data)
@@ -557,6 +567,33 @@ module HammerCLIKatello
557
567
  end
558
568
  end
559
569
 
570
+ class RepublishCommand < HammerCLIKatello::SingleResourceCommand
571
+ extend RepositoryScopedToProduct
572
+ include HammerCLIForemanTasks::Async
573
+ include OrganizationOptions
574
+
575
+ validate_repo_name_requires_product_options
576
+ action :republish
577
+ command_name "republish"
578
+ desc _("Forces a republish of the specified repository.")
579
+
580
+ success_message _("Repository republished.")
581
+ failure_message _("Could not republish the repository.")
582
+
583
+ validate_options :before, 'IdResolution' do
584
+ organization_options = [:option_organization_id, :option_organization_name, \
585
+ :option_organization_label]
586
+
587
+ if option(:option_product_name).exist?
588
+ any(*organization_options).required
589
+ end
590
+ end
591
+
592
+ build_options do |o|
593
+ o.expand.including(:products)
594
+ end
595
+ end
596
+
560
597
  class ReclaimSpaceCommand < HammerCLIKatello::SingleResourceCommand
561
598
  extend RepositoryScopedToProduct
562
599
  include HammerCLIForemanTasks::Async
@@ -1,5 +1,5 @@
1
1
  module HammerCLIKatello
2
2
  def self.version
3
- @version ||= Gem::Version.new('1.4.1')
3
+ @version ||= Gem::Version.new('1.5.2')
4
4
  end
5
5
  end
@@ -43,6 +43,11 @@ module HammerCLIKatello
43
43
  'hammer_cli_katello/organization'
44
44
  )
45
45
 
46
+ HammerCLI::MainCommand.lazy_subcommand!("alternate-content-sources", _("Manipulate alternate content sources"), # rubocop:disable LineLength
47
+ 'HammerCLIKatello::AcsCommand',
48
+ 'hammer_cli_katello/acs'
49
+ )
50
+
46
51
  HammerCLI::MainCommand.lazy_subcommand("content-credentials",
47
52
  _("Manipulate content credentials on the server"),
48
53
  'HammerCLIKatello::ContentCredentialCommand',