hammer_cli_katello 1.0.1 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hammer_cli_katello/content_import.rb +16 -1
- data/lib/hammer_cli_katello/content_view_version.rb +0 -273
- data/lib/hammer_cli_katello/docker.rb +13 -0
- data/lib/hammer_cli_katello/docker_manifest.rb +53 -0
- data/lib/hammer_cli_katello/docker_tag.rb +40 -0
- data/lib/hammer_cli_katello/foreman_search_options_creators.rb +12 -0
- data/lib/hammer_cli_katello/host_collection_erratum.rb +10 -0
- data/lib/hammer_cli_katello/host_collection_package.rb +30 -0
- data/lib/hammer_cli_katello/host_collection_package_group.rb +30 -0
- data/lib/hammer_cli_katello/host_errata.rb +8 -0
- data/lib/hammer_cli_katello/host_package.rb +32 -0
- data/lib/hammer_cli_katello/host_package_group.rb +16 -0
- data/lib/hammer_cli_katello/id_resolver.rb +3 -1
- data/lib/hammer_cli_katello/organization.rb +10 -0
- data/lib/hammer_cli_katello/ping.rb +13 -5
- data/lib/hammer_cli_katello/repository.rb +21 -0
- data/lib/hammer_cli_katello/simple_content_access.rb +2 -0
- data/lib/hammer_cli_katello/version.rb +1 -1
- data/lib/hammer_cli_katello.rb +5 -1
- data/locale/hammer-cli-katello.pot +0 -25
- metadata +7 -419
- data/lib/hammer_cli_katello/cv_import_export_helper.rb +0 -187
- data/test/data/2.5/foreman_api.json +0 -1
- data/test/data/3.0/foreman_api.json +0 -1
- data/test/data/3.10/foreman_api.json +0 -1
- data/test/data/3.11/foreman_api.json +0 -1
- data/test/data/3.12/foreman_api.json +0 -1
- data/test/data/3.13/foreman_api.json +0 -1
- data/test/data/3.14/foreman_api.json +0 -1
- data/test/data/3.15/foreman_api.json +0 -1
- data/test/data/3.16/foreman_api.json +0 -1
- data/test/data/3.17/foreman_api.json +0 -1
- data/test/data/3.18/foreman_api.json +0 -1
- data/test/data/3.19/foreman_api.json +0 -1
- data/test/data/3.2/foreman_api.json +0 -1
- data/test/data/3.4/foreman_api.json +0 -1
- data/test/data/3.5/foreman_api.json +0 -1
- data/test/data/3.6/foreman_api.json +0 -1
- data/test/data/3.7/foreman_api.json +0 -1
- data/test/data/3.8/foreman_api.json +0 -1
- data/test/data/3.9/foreman_api.json +0 -1
- data/test/data/4.0/foreman_api.json +0 -1
- data/test/data/Readme.md +0 -5
- data/test/functional/activation_key/add_host_collection_test.rb +0 -62
- data/test/functional/activation_key/content_override_test.rb +0 -92
- data/test/functional/activation_key/create_test.rb +0 -33
- data/test/functional/activation_key/data/activation_key.json +0 -17
- data/test/functional/activation_key/info_test.rb +0 -29
- data/test/functional/activation_key/list_test.rb +0 -68
- data/test/functional/activation_key/product_content_test.rb +0 -23
- data/test/functional/activation_key/remove_host_collection_test.rb +0 -62
- data/test/functional/activation_key/subscriptions_test.rb +0 -71
- data/test/functional/activation_key/update_test.rb +0 -26
- data/test/functional/apipie_helper_test.rb +0 -31
- data/test/functional/capsule/capsule_helpers.rb +0 -13
- data/test/functional/capsule/content/add_lifecycle_environment_test.rb +0 -40
- data/test/functional/capsule/content/cancel_synchronization_test.rb +0 -42
- data/test/functional/capsule/content/capsule_content_helpers.rb +0 -24
- data/test/functional/capsule/content/data/library_env.json +0 -47
- data/test/functional/capsule/content/data/sync_status.json +0 -6
- data/test/functional/capsule/content/data/sync_tasks.json +0 -62
- data/test/functional/capsule/content/info_test.rb +0 -61
- data/test/functional/capsule/content/lifecycle_environments_test.rb +0 -19
- data/test/functional/capsule/content/remove_lifecycle_environment_test.rb +0 -40
- data/test/functional/capsule/content/synchronization_status_test.rb +0 -107
- data/test/functional/capsule/info_test.rb +0 -25
- data/test/functional/capsule/list_test.rb +0 -24
- data/test/functional/content_credentials/create_test.rb +0 -32
- data/test/functional/content_credentials/data/test_cert.json +0 -43
- data/test/functional/content_credentials/info_test.rb +0 -50
- data/test/functional/content_credentials/list_test.rb +0 -66
- data/test/functional/content_export/complete/library_test.rb +0 -155
- data/test/functional/content_export/complete/version_test.rb +0 -217
- data/test/functional/content_export/content_export_helpers.rb +0 -26
- data/test/functional/content_export/generate_metadata_test.rb +0 -64
- data/test/functional/content_export/incremental/library_test.rb +0 -172
- data/test/functional/content_export/incremental/version_test.rb +0 -268
- data/test/functional/content_export/list_test.rb +0 -64
- data/test/functional/content_import/library_test.rb +0 -85
- data/test/functional/content_import/metadata.json +0 -1
- data/test/functional/content_import/version_test.rb +0 -85
- data/test/functional/content_view/add_content_view_version_test.rb +0 -88
- data/test/functional/content_view/add_repository_test.rb +0 -21
- data/test/functional/content_view/component/add_test.rb +0 -177
- data/test/functional/content_view/component/list_test.rb +0 -55
- data/test/functional/content_view/component/remove_test.rb +0 -107
- data/test/functional/content_view/component/update_test.rb +0 -134
- data/test/functional/content_view/content_view_helpers.rb +0 -20
- data/test/functional/content_view/copy_test.rb +0 -53
- data/test/functional/content_view/create_test.rb +0 -34
- data/test/functional/content_view/delete_test.rb +0 -62
- data/test/functional/content_view/filter/create_test.rb +0 -57
- data/test/functional/content_view/filter/delete_test.rb +0 -90
- data/test/functional/content_view/filter/info_test.rb +0 -89
- data/test/functional/content_view/filter/list_test.rb +0 -98
- data/test/functional/content_view/filter/update_test.rb +0 -91
- data/test/functional/content_view/list_test.rb +0 -68
- data/test/functional/content_view/publish_test.rb +0 -24
- data/test/functional/content_view/purge_test.rb +0 -97
- data/test/functional/content_view/remove_content_view_version_test.rb +0 -88
- data/test/functional/content_view/remove_test.rb +0 -79
- data/test/functional/content_view/update_test.rb +0 -53
- data/test/functional/content_view/version/cv_import_export_helper_test.rb +0 -20
- data/test/functional/content_view/version/default_export_test.rb +0 -40
- data/test/functional/content_view/version/export_test.rb +0 -148
- data/test/functional/content_view/version/import_test.rb +0 -346
- data/test/functional/content_view/version/incremental_update_test.rb +0 -108
- data/test/functional/content_view/version/list_test.rb +0 -44
- data/test/functional/content_view/version/promote_test.rb +0 -34
- data/test/functional/content_view/version/republish_repositories_test.rb +0 -34
- data/test/functional/content_view/version/update_test.rb +0 -48
- data/test/functional/erratum/erratum_helpers.rb +0 -91
- data/test/functional/erratum/info_test.rb +0 -29
- data/test/functional/erratum/list_test.rb +0 -108
- data/test/functional/file/file_helpers.rb +0 -13
- data/test/functional/file/info_test.rb +0 -162
- data/test/functional/file/list_test.rb +0 -112
- data/test/functional/filter_rule/create_test.rb +0 -99
- data/test/functional/filter_rule/delete_test.rb +0 -104
- data/test/functional/filter_rule/filter_rule_helpers.rb +0 -12
- data/test/functional/filter_rule/info_test.rb +0 -104
- data/test/functional/filter_rule/list_test.rb +0 -91
- data/test/functional/filter_rule/update_test.rb +0 -104
- data/test/functional/host/errata/apply_test.rb +0 -45
- data/test/functional/host/errata/info_test.rb +0 -27
- data/test/functional/host/errata/list_test.rb +0 -49
- data/test/functional/host/errata/recalculate_test.rb +0 -40
- data/test/functional/host/extensions/create_test.rb +0 -95
- data/test/functional/host/extensions/data/host.json +0 -320
- data/test/functional/host/extensions/data/host_list.json +0 -117
- data/test/functional/host/extensions/info_test.rb +0 -35
- data/test/functional/host/extensions/list_test.rb +0 -21
- data/test/functional/host/extensions/update_test.rb +0 -70
- data/test/functional/host/host_helpers.rb +0 -8
- data/test/functional/host/subscription/attach_test.rb +0 -54
- data/test/functional/host/subscription/auto_attach_test.rb +0 -35
- data/test/functional/host/subscription/content_override_test.rb +0 -96
- data/test/functional/host/subscription/product_content_test.rb +0 -27
- data/test/functional/host/subscription/register_test.rb +0 -53
- data/test/functional/host/subscription/remove_test.rb +0 -52
- data/test/functional/host/subscription/unregister_test.rb +0 -37
- data/test/functional/host/traces/list_test.rb +0 -37
- data/test/functional/host/traces/resolve_test.rb +0 -31
- data/test/functional/host_collection/add_host_test.rb +0 -90
- data/test/functional/host_collection/content_api_expectations.rb +0 -35
- data/test/functional/host_collection/content_install_test.rb +0 -62
- data/test/functional/host_collection/content_remove_test.rb +0 -37
- data/test/functional/host_collection/content_update_test.rb +0 -37
- data/test/functional/host_collection/copy_test.rb +0 -64
- data/test/functional/host_collection/create_test.rb +0 -43
- data/test/functional/host_collection/delete_test.rb +0 -57
- data/test/functional/host_collection/hosts_test.rb +0 -39
- data/test/functional/host_collection/info_test.rb +0 -57
- data/test/functional/host_collection/list_test.rb +0 -63
- data/test/functional/host_collection/remove_host_test.rb +0 -90
- data/test/functional/host_collection/update_test.rb +0 -57
- data/test/functional/hostgroup/create_test.rb +0 -112
- data/test/functional/hostgroup/data/hostgroup.json +0 -50
- data/test/functional/hostgroup/info_test.rb +0 -33
- data/test/functional/hostgroup/update_test.rb +0 -120
- data/test/functional/lifecycle_environment/create_test.rb +0 -14
- data/test/functional/lifecycle_environment/lifecycle_environment_helpers.rb +0 -18
- data/test/functional/lifecycle_environment/list_test.rb +0 -38
- data/test/functional/lifecycle_environment/update_test.rb +0 -14
- data/test/functional/local_helper_test.rb +0 -30
- data/test/functional/module_stream/info_test.rb +0 -58
- data/test/functional/module_stream/list_test.rb +0 -53
- data/test/functional/organization/delete_test.rb +0 -26
- data/test/functional/organization/organization_helpers.rb +0 -10
- data/test/functional/package/list_test.rb +0 -158
- data/test/functional/package_group/list_test.rb +0 -38
- data/test/functional/ping_test.rb +0 -20
- data/test/functional/product/create_test.rb +0 -54
- data/test/functional/product/delete_test.rb +0 -41
- data/test/functional/product/info_test.rb +0 -33
- data/test/functional/product/list_test.rb +0 -58
- data/test/functional/product/product_helpers.rb +0 -24
- data/test/functional/product/remove_sync_plan_test.rb +0 -35
- data/test/functional/product/set_sync_plan_test.rb +0 -49
- data/test/functional/product/update_proxy.rb +0 -48
- data/test/functional/product/update_test.rb +0 -46
- data/test/functional/repository/create_test.rb +0 -21
- data/test/functional/repository/delete_test.rb +0 -95
- data/test/functional/repository/export_test.rb +0 -121
- data/test/functional/repository/info_test.rb +0 -156
- data/test/functional/repository/list_test.rb +0 -68
- data/test/functional/repository/remove_content_test.rb +0 -108
- data/test/functional/repository/repository_helpers.rb +0 -18
- data/test/functional/repository/synchronize_test.rb +0 -57
- data/test/functional/repository/update_test.rb +0 -149
- data/test/functional/repository/upload_test.rb +0 -345
- data/test/functional/repository_set/available_repositories_test.rb +0 -18
- data/test/functional/repository_set/disable_test.rb +0 -42
- data/test/functional/repository_set/enable_test.rb +0 -42
- data/test/functional/repository_set/info_test.rb +0 -17
- data/test/functional/repository_set/list_test.rb +0 -18
- data/test/functional/repository_set/repository_set_helpers.rb +0 -20
- data/test/functional/search_helpers.rb +0 -17
- data/test/functional/simple_content_access/disable_test.rb +0 -48
- data/test/functional/simple_content_access/enable_test.rb +0 -46
- data/test/functional/srpm/list_test.rb +0 -92
- data/test/functional/subscription/list_test.rb +0 -86
- data/test/functional/sync_plan/create_test.rb +0 -60
- data/test/functional/sync_plan/delete_test.rb +0 -46
- data/test/functional/sync_plan/info_test.rb +0 -37
- data/test/functional/sync_plan/list_test.rb +0 -31
- data/test/functional/sync_plan/sync_plan_helpers.rb +0 -8
- data/test/functional/sync_plan/update_test.rb +0 -44
- data/test/functional/test_helper.rb +0 -24
- data/test/task_helper.rb +0 -7
- data/test/test_helper.rb +0 -38
- data/test/unit/id_name_options_validator_test.rb +0 -96
- data/test/unit/id_resolver_test.rb +0 -58
- data/test/unit/messages_test.rb +0 -7
- data/test/unit/search_options_creators_test.rb +0 -145
@@ -1,187 +0,0 @@
|
|
1
|
-
# rubocop:disable Metrics/ModuleLength
|
2
|
-
module HammerCLIKatello
|
3
|
-
module CVImportExportHelper
|
4
|
-
PUBLISHED_REPOS_DIR = "/var/lib/pulp/published/yum/https/repos/".freeze
|
5
|
-
|
6
|
-
def fetch_exportable_cvv_repositories(cvv)
|
7
|
-
immediate = []
|
8
|
-
non_immediate_names = []
|
9
|
-
|
10
|
-
cvv['repositories'].each do |repo|
|
11
|
-
next unless repo['content_type'] == 'yum'
|
12
|
-
|
13
|
-
api_repo = show(:repositories, 'id' => repo['id'], :full_result => true)
|
14
|
-
|
15
|
-
download_policy = if api_repo['library_instance_id']
|
16
|
-
library = show(:repositories, 'id' => api_repo['library_instance_id'])
|
17
|
-
library['download_policy']
|
18
|
-
else
|
19
|
-
api_repo['download_policy']
|
20
|
-
end
|
21
|
-
|
22
|
-
if download_policy == 'immediate'
|
23
|
-
immediate << api_repo
|
24
|
-
else
|
25
|
-
non_immediate_names << api_repo['name']
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
warn_repo_download_policy(non_immediate_names)
|
30
|
-
|
31
|
-
return immediate
|
32
|
-
end
|
33
|
-
|
34
|
-
def find_local_component_id(component_from_export)
|
35
|
-
*name, version = component_from_export.split(' ')
|
36
|
-
name = name.join(' ')
|
37
|
-
existing_component_cv = content_view(name, options['option_organization_id'])
|
38
|
-
found_composite_version = existing_component_cv['versions'].select do |v|
|
39
|
-
v['version'] == version
|
40
|
-
end
|
41
|
-
if found_composite_version.empty?
|
42
|
-
raise _("Unable to find CV version %{cvv} on system. Please ensure it " \
|
43
|
-
"is already imported." % {'cvv' => component_from_export})
|
44
|
-
end
|
45
|
-
found_composite_version.first['id']
|
46
|
-
end
|
47
|
-
|
48
|
-
def warn_repo_download_policy(repository_names)
|
49
|
-
return if repository_names.empty?
|
50
|
-
|
51
|
-
msg = <<~MSG
|
52
|
-
The following repositories could not be exported due to the download policy
|
53
|
-
not being set to 'immediate':
|
54
|
-
#{repository_names.join(', ')}
|
55
|
-
MSG
|
56
|
-
print_message msg
|
57
|
-
end
|
58
|
-
|
59
|
-
def collect_packages(repositories)
|
60
|
-
repositories.each do |repo|
|
61
|
-
per_page = 50
|
62
|
-
repo['packages'] = []
|
63
|
-
repo['errata'] = []
|
64
|
-
repo_packages = repo['content_counts']['rpm']
|
65
|
-
errata_count = repo['content_counts']['erratum']
|
66
|
-
pkg_pages = (repo_packages / per_page.to_f).ceil
|
67
|
-
errata_pages = (errata_count / per_page.to_f).ceil
|
68
|
-
(1..pkg_pages).each do |page|
|
69
|
-
repo['packages'] += index(:packages, 'repository_id' => repo['id'],
|
70
|
-
:page => page, :per_page => 50)
|
71
|
-
end
|
72
|
-
(1..errata_pages).each do |page|
|
73
|
-
repo['errata'] += index(:errata, 'repository_id' => repo['id'],
|
74
|
-
:page => page, :per_page => 50)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def import_checks(cv, import_cv, major, minor)
|
80
|
-
version = "#{major}.#{minor}".to_f
|
81
|
-
|
82
|
-
if import_cv.nil?
|
83
|
-
raise _("The Content View #{cv['name']} is not present on this server,"\
|
84
|
-
" please create the Content View and try the import again.")
|
85
|
-
end
|
86
|
-
|
87
|
-
unless import_cv['default']
|
88
|
-
if import_cv['latest_version'].to_f >= version
|
89
|
-
raise _("The latest version (#{import_cv['latest_version']}) of"\
|
90
|
-
" the Content View '#{cv['name']}'"\
|
91
|
-
" is greater or equal to the version you are trying to import (#{version})")
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
unless import_cv['repository_ids'].nil?
|
96
|
-
repositories = import_cv['repository_ids'].collect do |repo_id|
|
97
|
-
show(:repositories, 'id' => repo_id)
|
98
|
-
end
|
99
|
-
repositories.each do |repo|
|
100
|
-
if repo['mirror_on_sync'] == true
|
101
|
-
raise _("The Repository '#{repo['name']}' is set with Mirror-on-Sync to YES."\
|
102
|
-
" Please change Mirror-on-Sync to NO and try the import again.")
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def untar_export(options)
|
109
|
-
export_tar_file = options[:filename]
|
110
|
-
export_tar_dir = options[:dirname]
|
111
|
-
export_tar_prefix = options[:prefix]
|
112
|
-
|
113
|
-
Dir.chdir(export_tar_dir) do
|
114
|
-
`tar -xf #{export_tar_file}`
|
115
|
-
end
|
116
|
-
|
117
|
-
Dir.chdir("#{export_tar_dir}/#{export_tar_prefix}") do
|
118
|
-
if File.exist?(export_tar_file.gsub('.tar', '-repos.tar'))
|
119
|
-
`tar -xf #{export_tar_file.gsub('.tar', '-repos.tar')}`
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def obtain_export_params(option_export_tar)
|
125
|
-
export_tar_file = File.basename(option_export_tar)
|
126
|
-
{:filename => export_tar_file,
|
127
|
-
:dirname => File.dirname(option_export_tar),
|
128
|
-
:prefix => export_tar_file.gsub('.tar', '')}
|
129
|
-
end
|
130
|
-
|
131
|
-
def read_json(options)
|
132
|
-
export_tar_file = options[:filename]
|
133
|
-
export_tar_dir = options[:dirname]
|
134
|
-
export_tar_prefix = options[:prefix]
|
135
|
-
|
136
|
-
json_file = export_tar_file.gsub('tar', 'json')
|
137
|
-
json_file = "#{export_tar_dir}/#{export_tar_prefix}/#{json_file}"
|
138
|
-
json_file = File.read(json_file)
|
139
|
-
JSON.parse(json_file)
|
140
|
-
end
|
141
|
-
|
142
|
-
def export_json(export_json_options)
|
143
|
-
content_view_version = export_json_options[:cvv]
|
144
|
-
repositories = export_json_options[:repositories]
|
145
|
-
json = {
|
146
|
-
"name" => content_view_version['content_view']['name'],
|
147
|
-
"major" => content_view_version['major'],
|
148
|
-
"minor" => content_view_version['minor']
|
149
|
-
}
|
150
|
-
json["composite_components"] = export_json_options[:component_cvvs]
|
151
|
-
json["repositories"] = repositories.collect do |repo|
|
152
|
-
{
|
153
|
-
"id" => repo['id'],
|
154
|
-
"label" => repo['label'],
|
155
|
-
"content_type" => repo['content_type'],
|
156
|
-
"backend_identifier" => repo['backend_identifier'],
|
157
|
-
"relative_path" => repo['relative_path'],
|
158
|
-
"on_disk_path" => "#{PUBLISHED_REPOS_DIR}/#{repo['relative_path']}",
|
159
|
-
"rpm_filenames" => repo['packages'].collect { |package| package['filename'] },
|
160
|
-
"errata_ids" => repo['errata'].collect { |errata| errata['errata_id'] }
|
161
|
-
}
|
162
|
-
end
|
163
|
-
json
|
164
|
-
end
|
165
|
-
|
166
|
-
def fail_msg_import
|
167
|
-
_("This command is not supported with Pulp 3. Use `hammer content-import` instead.")
|
168
|
-
end
|
169
|
-
|
170
|
-
def fail_msg_export
|
171
|
-
_("This command is not supported with Pulp 3. Use `hammer content-export` instead.")
|
172
|
-
end
|
173
|
-
|
174
|
-
def validate_pulp3_not_enabled(failure_message)
|
175
|
-
pulp3_enabled = HammerCLIForeman
|
176
|
-
.foreman_api_connection
|
177
|
-
.resource(:content_exports)
|
178
|
-
.call(:api_status)['api_usable']
|
179
|
-
if pulp3_enabled
|
180
|
-
raise failure_message
|
181
|
-
end
|
182
|
-
rescue NoMethodError
|
183
|
-
# if the api endpoint isn't there, the validation passes
|
184
|
-
true
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|