hammer_cli_katello 1.5.2 → 1.6.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 +5 -5
- data/lib/hammer_cli_katello/acs.rb +7 -4
- data/lib/hammer_cli_katello/content_export.rb +39 -0
- data/lib/hammer_cli_katello/content_export_helper.rb +64 -6
- data/lib/hammer_cli_katello/host_subscription.rb +32 -0
- data/lib/hammer_cli_katello/simple_content_access.rb +10 -0
- data/lib/hammer_cli_katello/version.rb +1 -1
- data/lib/hammer_cli_katello.rb +1 -1
- data/test/data/4.6/foreman_api.json +1 -1
- data/test/functional/acs/create_test.rb +1 -1
- data/test/functional/acs/delete_test.rb +1 -1
- data/test/functional/acs/info_test.rb +54 -15
- data/test/functional/acs/list_test.rb +1 -1
- data/test/functional/acs/update_test.rb +1 -1
- data/test/functional/content_export/complete/version_test.rb +48 -3
- data/test/functional/content_export/generate_listing_test.rb +62 -0
- data/test/functional/host/subscription/enabled_repositories_test.rb +39 -0
- data/test/functional/simple_content_access/status_test.rb +29 -0
- metadata +29 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bfa4a96e3ec666332357da5f6741af1fb78360f60e3016060d8e0ba7a41a38c9
|
4
|
+
data.tar.gz: 2d6fafe5ea4d85dd1551f9274a57cc6e2c65e3155bbabd844a0f12d964c3e7d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3c4c16ed1e4c64d5126810fef1c723490758c1019e820e7cde65f7b6caa663ada32072aa39dcac2964199c5a2a72b2c36f31e4d85dfc64f8b2c9d203154896b
|
7
|
+
data.tar.gz: eeefc161d8fb26803fae890ef79d94c74f1e6ca94d4f0780ba839018890fce56bc5405a932cbeee7edbaa5817bec3de0762d39bc0577ee6e647de673c7c6e5fe
|
@@ -34,14 +34,17 @@ module HammerCLIKatello
|
|
34
34
|
field nil, _('')
|
35
35
|
end
|
36
36
|
|
37
|
+
collection :products, _('Products') do
|
38
|
+
field :id, _('Id')
|
39
|
+
field :organization_id, _('Organization ID')
|
40
|
+
field :name, _('Name')
|
41
|
+
field :label, _('Label')
|
42
|
+
end
|
43
|
+
|
37
44
|
collection :smart_proxies, _('Smart proxies') do
|
38
45
|
field :id, _('Id')
|
39
46
|
field :name, _('Name')
|
40
47
|
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
48
|
field :download_policy, _('Download policy')
|
46
49
|
end
|
47
50
|
end
|
@@ -44,6 +44,45 @@ module HammerCLIKatello
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
class GenerateListingCommand < HammerCLIKatello::Command
|
48
|
+
desc _("Generates listing file on each directory of a syncable export. This command "\
|
49
|
+
+ "only needs to be used if the export was performed asynchronously or "\
|
50
|
+
+ "if the listing files were lost. "\
|
51
|
+
+ "Assumes the syncable export directory is accessible on disk")
|
52
|
+
|
53
|
+
command_name 'generate-listing'
|
54
|
+
|
55
|
+
include ContentExportHelper
|
56
|
+
|
57
|
+
option "--task-id", "TASK_ID",
|
58
|
+
_("Generate listing files for a syncable export task"),
|
59
|
+
:attribute_name => :option_task_id,
|
60
|
+
:required => false
|
61
|
+
|
62
|
+
option "--id", "ID",
|
63
|
+
_("Generate listing files based on specified export history"),
|
64
|
+
:attribute_name => :option_export_id,
|
65
|
+
:required => false
|
66
|
+
|
67
|
+
def execute
|
68
|
+
export_history = if option_task_id
|
69
|
+
export_task = reload_task(option_task_id)
|
70
|
+
fetch_export_history_from_task(export_task)
|
71
|
+
else
|
72
|
+
fetch_export_history(option_export_id)
|
73
|
+
end
|
74
|
+
|
75
|
+
unless export_history
|
76
|
+
raise _("No export history was found. Verify the value given for "\
|
77
|
+
+ "--task-id or --id")
|
78
|
+
end
|
79
|
+
|
80
|
+
make_listing_files(export_history)
|
81
|
+
|
82
|
+
HammerCLI::EX_OK
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
47
86
|
class ListCommand < HammerCLIKatello::ListCommand
|
48
87
|
desc "View content view export histories"
|
49
88
|
output do
|
@@ -1,23 +1,23 @@
|
|
1
1
|
require 'hammer_cli_katello/repository'
|
2
|
-
|
2
|
+
require 'find'
|
3
3
|
# rubocop:disable ModuleLength
|
4
4
|
module HammerCLIKatello
|
5
5
|
module ContentExportHelper
|
6
6
|
include ApipieHelper
|
7
|
-
|
8
7
|
def execute
|
9
8
|
warn_unexportable_repositories
|
10
9
|
response = super
|
11
10
|
if option_async?
|
12
|
-
|
13
|
-
+ "with the command:")
|
14
|
-
output.print_message(" hammer content-export generate-metadata --task-id #{@task['id']}")
|
11
|
+
emit_async_info
|
15
12
|
HammerCLI::EX_OK
|
16
13
|
elsif response != HammerCLI::EX_OK
|
17
14
|
response
|
18
15
|
else
|
19
16
|
export_history = fetch_export_history_from_task(reload_task(@task))
|
20
|
-
if
|
17
|
+
if syncable?
|
18
|
+
make_listing_files(export_history)
|
19
|
+
HammerCLI::EX_OK
|
20
|
+
elsif export_history
|
21
21
|
generate_metadata_json(export_history)
|
22
22
|
HammerCLI::EX_OK
|
23
23
|
else
|
@@ -27,6 +27,22 @@ module HammerCLIKatello
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
def emit_async_info
|
31
|
+
if syncable?
|
32
|
+
output.print_message _("Once the task completes the listing files may be generated "\
|
33
|
+
+ "with the command:")
|
34
|
+
output.print_message(" hammer content-export generate-listing --task-id #{@task['id']}")
|
35
|
+
else
|
36
|
+
output.print_message _("Once the task completes the export metadata must be generated "\
|
37
|
+
+ "with the command:")
|
38
|
+
output.print_message(" hammer content-export generate-metadata --task-id #{@task['id']}")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def syncable?
|
43
|
+
options.key?("option_format") && option_format == 'syncable'
|
44
|
+
end
|
45
|
+
|
30
46
|
def send_request
|
31
47
|
@task = super
|
32
48
|
end
|
@@ -54,6 +70,48 @@ module HammerCLIKatello
|
|
54
70
|
fetch_export_history(export_history_id)
|
55
71
|
end
|
56
72
|
|
73
|
+
def check_export_history_syncable!(export_history)
|
74
|
+
unless export_history["metadata"]["format"] == "syncable"
|
75
|
+
raise _("Cannot generate listing files for this export since "\
|
76
|
+
+ "it is not syncable. It was not generated with --format=syncable.")
|
77
|
+
end
|
78
|
+
|
79
|
+
raise _("Export History does not have the path specified."\
|
80
|
+
+ " The task may have errored out.") unless export_history["path"]
|
81
|
+
end
|
82
|
+
|
83
|
+
def make_listing_files(export_history)
|
84
|
+
check_export_history_syncable!(export_history)
|
85
|
+
output.print_message _("Generated #{export_history['path']}")
|
86
|
+
|
87
|
+
return unless Dir.exist?("#{export_history['path']}/content")
|
88
|
+
|
89
|
+
begin
|
90
|
+
# export history path may look like
|
91
|
+
# "/var/lib/pulp/exports/export-12803/apple/3.0//2022-06-30T17-23-06-00-00"
|
92
|
+
# Generate listing files for all sub directories of
|
93
|
+
# /var/lib/pulp/exports/export-12803/apple/3.0/$date/$org/Library/
|
94
|
+
ignorables = Dir.glob("#{export_history['path']}/content/**/repodata").map do |path|
|
95
|
+
File.dirname(path)
|
96
|
+
end
|
97
|
+
|
98
|
+
paths = Find.find("#{export_history['path']}/content").select do |path|
|
99
|
+
File.directory?(path) &&
|
100
|
+
ignorables.none? { |ignorable| path.start_with?(ignorable) }
|
101
|
+
end
|
102
|
+
|
103
|
+
paths.each do |dir|
|
104
|
+
directories = Dir.chdir(dir) { Dir['*'] }
|
105
|
+
File.write("#{dir}/listing", directories.join("\n"))
|
106
|
+
end
|
107
|
+
rescue SystemCallError
|
108
|
+
output.print_message _("Unable to access/write listing files"\
|
109
|
+
+ " to '#{export_history['path']}'." \
|
110
|
+
+ " To generate listing files run the command below as a root user ")
|
111
|
+
output.print_message(" hammer content-export generate-listing --id #{export_history['id']}")
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
57
115
|
def generate_metadata_json(export_history)
|
58
116
|
metadata_json = export_history["metadata"].to_json
|
59
117
|
begin
|
@@ -102,6 +102,38 @@ module HammerCLIKatello
|
|
102
102
|
setup
|
103
103
|
end
|
104
104
|
|
105
|
+
class EnabledRepositoriesCommand < HammerCLIKatello::ListCommand
|
106
|
+
resource :host_subscriptions, :enabled_repositories
|
107
|
+
command_name 'enabled-repositories'
|
108
|
+
|
109
|
+
output do
|
110
|
+
field :id, _('ID')
|
111
|
+
field :name, _('Name')
|
112
|
+
field :label, _('Label')
|
113
|
+
field :content_type, _('Content type')
|
114
|
+
field :checksum, _("Checksum")
|
115
|
+
|
116
|
+
from :content_view do
|
117
|
+
field :id, _('Content View id')
|
118
|
+
field :name, _("Content View name")
|
119
|
+
end
|
120
|
+
|
121
|
+
from :content_view_version do
|
122
|
+
field :name, _("Content View version")
|
123
|
+
end
|
124
|
+
|
125
|
+
from :kt_environment do
|
126
|
+
field :name, _("Environment name")
|
127
|
+
end
|
128
|
+
|
129
|
+
from :product do
|
130
|
+
field :name, _("Product name")
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
build_options
|
135
|
+
end
|
136
|
+
|
105
137
|
class ContentOverrideCommand < ::HammerCLIKatello::ContentOverrideBase::ContentOverrideCommand
|
106
138
|
resource :host_subscriptions, :content_override
|
107
139
|
setup
|
@@ -13,6 +13,16 @@ module HammerCLIKatello
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
class StatusCommand < HammerCLIKatello::ListCommand
|
17
|
+
resource :simple_content_access, :status
|
18
|
+
command_name "status"
|
19
|
+
output do
|
20
|
+
field :simple_content_access, _('Simple Content Access'), Fields::Boolean
|
21
|
+
end
|
22
|
+
|
23
|
+
build_options
|
24
|
+
end
|
25
|
+
|
16
26
|
class EnableCommand < HammerCLIKatello::SingleResourceCommand
|
17
27
|
include EligibleCheck
|
18
28
|
include HammerCLIForemanTasks::Async
|
data/lib/hammer_cli_katello.rb
CHANGED
@@ -43,7 +43,7 @@ module HammerCLIKatello
|
|
43
43
|
'hammer_cli_katello/organization'
|
44
44
|
)
|
45
45
|
|
46
|
-
HammerCLI::MainCommand.lazy_subcommand!("alternate-content-
|
46
|
+
HammerCLI::MainCommand.lazy_subcommand!("alternate-content-source", _("Manipulate alternate content sources"), # rubocop:disable LineLength
|
47
47
|
'HammerCLIKatello::AcsCommand',
|
48
48
|
'hammer_cli_katello/acs'
|
49
49
|
)
|