hammer_cli_katello 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/hammer_cli_katello.rb +26 -6
- data/lib/hammer_cli_katello/activation_key.rb +176 -0
- data/lib/hammer_cli_katello/associating_commands.rb +67 -0
- data/lib/hammer_cli_katello/capsule.rb +100 -0
- data/lib/hammer_cli_katello/commands.rb +55 -0
- data/lib/hammer_cli_katello/content_host.rb +90 -0
- data/lib/hammer_cli_katello/content_view.rb +193 -0
- data/lib/hammer_cli_katello/content_view_puppet_module.rb +74 -0
- data/lib/hammer_cli_katello/content_view_version.rb +81 -0
- data/lib/hammer_cli_katello/exception_handler.rb +40 -0
- data/lib/hammer_cli_katello/filter.rb +83 -0
- data/lib/hammer_cli_katello/filter_rule.rb +73 -0
- data/lib/hammer_cli_katello/gpg_key.rb +34 -56
- data/lib/hammer_cli_katello/host_collection.rb +91 -0
- data/lib/hammer_cli_katello/i18n.rb +24 -0
- data/lib/hammer_cli_katello/id_resolver.rb +39 -0
- data/lib/hammer_cli_katello/lifecycle_environment.rb +63 -45
- data/lib/hammer_cli_katello/organization.rb +27 -23
- data/lib/hammer_cli_katello/ping.rb +20 -23
- data/lib/hammer_cli_katello/product.rb +69 -62
- data/lib/hammer_cli_katello/puppet_module.rb +47 -0
- data/lib/hammer_cli_katello/repository.rb +147 -0
- data/lib/hammer_cli_katello/repository_set.rb +88 -0
- data/lib/hammer_cli_katello/subscription.rb +59 -12
- data/lib/hammer_cli_katello/sync_plan.rb +74 -0
- data/lib/hammer_cli_katello/version.rb +1 -1
- data/locale/hammer-cli-katello.pot +1215 -0
- data/locale/zanata.xml +29 -0
- metadata +28 -13
- data/lib/hammer_cli_katello/provider.rb +0 -68
- data/lib/hammer_cli_katello/resource.rb +0 -0
- data/lib/hammer_cli_katello/system.rb +0 -94
- data/lib/hammer_cli_katello/system_group.rb +0 -48
@@ -0,0 +1,90 @@
|
|
1
|
+
module HammerCLIKatello
|
2
|
+
|
3
|
+
class ContentHostCommand < HammerCLI::AbstractCommand
|
4
|
+
|
5
|
+
class ListCommand < HammerCLIKatello::ListCommand
|
6
|
+
resource :systems, :index
|
7
|
+
|
8
|
+
output do
|
9
|
+
field :uuid, _("ID")
|
10
|
+
field :name, _("Name")
|
11
|
+
end
|
12
|
+
|
13
|
+
build_options
|
14
|
+
end
|
15
|
+
|
16
|
+
class InfoCommand < HammerCLIKatello::InfoCommand
|
17
|
+
resource :systems, :show
|
18
|
+
|
19
|
+
output do
|
20
|
+
field :name, _("Name")
|
21
|
+
field :uuid, _("ID")
|
22
|
+
field :description, _("Description")
|
23
|
+
field :location, _("Location")
|
24
|
+
from :environment do
|
25
|
+
field :name, _("Lifecycle Environment")
|
26
|
+
end
|
27
|
+
from :content_view do
|
28
|
+
field :name, _("Content View")
|
29
|
+
end
|
30
|
+
field :entitlementStatus, _("Entitlement Status")
|
31
|
+
field :releaseVer, _("Release Version")
|
32
|
+
field :autoheal, _("Autoheal")
|
33
|
+
end
|
34
|
+
|
35
|
+
build_options
|
36
|
+
end
|
37
|
+
|
38
|
+
class CreateCommand < HammerCLIKatello::CreateCommand
|
39
|
+
resource :systems, :create
|
40
|
+
|
41
|
+
output InfoCommand.output_definition
|
42
|
+
|
43
|
+
success_message _("Content host created")
|
44
|
+
failure_message _("Could not create content host")
|
45
|
+
|
46
|
+
def request_params
|
47
|
+
super.tap do |params|
|
48
|
+
params['type'] = "system"
|
49
|
+
params['facts'] = {"uname.machine" => "unknown"}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
build_options :without => [:facts, :type, :installed_products]
|
54
|
+
end
|
55
|
+
|
56
|
+
class UpdateCommand < HammerCLIKatello::UpdateCommand
|
57
|
+
resource :systems, :update
|
58
|
+
|
59
|
+
success_message _("Content host updated")
|
60
|
+
failure_message _("Could not update content host")
|
61
|
+
|
62
|
+
build_options :without => [:facts, :type, :installed_products]
|
63
|
+
end
|
64
|
+
|
65
|
+
class DeleteCommand < HammerCLIKatello::DeleteCommand
|
66
|
+
resource :systems, :destroy
|
67
|
+
|
68
|
+
success_message _("Content host deleted")
|
69
|
+
failure_message _("Could not delete content host")
|
70
|
+
|
71
|
+
build_options
|
72
|
+
end
|
73
|
+
|
74
|
+
class TasksCommand < HammerCLIKatello::ListCommand
|
75
|
+
resource :systems, :tasks
|
76
|
+
|
77
|
+
command_name "tasks"
|
78
|
+
|
79
|
+
build_options
|
80
|
+
end
|
81
|
+
|
82
|
+
autoload_subcommands
|
83
|
+
end
|
84
|
+
|
85
|
+
cmd_name = "content-host"
|
86
|
+
cmd_desc = _("manipulate content hosts on the server")
|
87
|
+
cmd_cls = HammerCLIKatello::ContentHostCommand
|
88
|
+
HammerCLI::MainCommand.subcommand(cmd_name, cmd_desc, cmd_cls)
|
89
|
+
|
90
|
+
end
|
@@ -0,0 +1,193 @@
|
|
1
|
+
require 'hammer_cli_katello/content_view_puppet_module'
|
2
|
+
require 'hammer_cli_katello/filter'
|
3
|
+
require 'hammer_cli_katello/content_view_version'
|
4
|
+
|
5
|
+
module HammerCLIKatello
|
6
|
+
|
7
|
+
class ContentView < HammerCLIKatello::Command
|
8
|
+
resource :content_views
|
9
|
+
|
10
|
+
class ListCommand < HammerCLIKatello::ListCommand
|
11
|
+
output do
|
12
|
+
field :id, _("Content View ID")
|
13
|
+
field :name, _("Name")
|
14
|
+
field :label, _("Label")
|
15
|
+
field :composite, _("Composite")
|
16
|
+
field :repository_ids, _("Repository IDs"), Fields::List
|
17
|
+
end
|
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 :composite, _("Composite")
|
28
|
+
field :description, _("Description")
|
29
|
+
|
30
|
+
from :organization do
|
31
|
+
field :name, _("Organization")
|
32
|
+
end
|
33
|
+
|
34
|
+
collection :repositories, _("Repositories") do
|
35
|
+
field :id, _("ID")
|
36
|
+
field :name, _("Name")
|
37
|
+
field :label, _("Label")
|
38
|
+
end
|
39
|
+
|
40
|
+
collection :puppet_modules, _("Puppet Modules") do
|
41
|
+
field :id, _("ID")
|
42
|
+
field :uuid, _("UUID"), Fields::Field, :hide_blank => true
|
43
|
+
field :name, _("Name")
|
44
|
+
field :author, _("Author")
|
45
|
+
field :created_at, _("Created"), Fields::Date
|
46
|
+
field :updated_at, _("Updated"), Fields::Date
|
47
|
+
end
|
48
|
+
|
49
|
+
collection :environments, _("Environments") do
|
50
|
+
field :id, _("ID")
|
51
|
+
field :name, _("Name")
|
52
|
+
end
|
53
|
+
|
54
|
+
collection :versions, _("Versions") do
|
55
|
+
field :id, _("ID")
|
56
|
+
field :version, _("Version")
|
57
|
+
field :published, _("Published"), Fields::Date
|
58
|
+
end
|
59
|
+
|
60
|
+
collection :components, _("Components") do
|
61
|
+
field :id, _("ID")
|
62
|
+
field :name, _("Name")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
build_options
|
67
|
+
end
|
68
|
+
|
69
|
+
class CreateCommand < HammerCLIKatello::CreateCommand
|
70
|
+
success_message _("Content view created")
|
71
|
+
failure_message _("Could not create the content view")
|
72
|
+
|
73
|
+
option ["--composite"], :flag, _("Create a composite content view")
|
74
|
+
|
75
|
+
def request_params
|
76
|
+
super.tap do |opts|
|
77
|
+
opts['composite'] = option_composite?
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
build_options
|
82
|
+
end
|
83
|
+
|
84
|
+
class UpdateCommand < HammerCLIKatello::UpdateCommand
|
85
|
+
success_message _("Content view updated")
|
86
|
+
failure_message _("Could not update the content view")
|
87
|
+
|
88
|
+
build_options
|
89
|
+
end
|
90
|
+
|
91
|
+
class DeleteCommand < HammerCLIForemanTasks::AsyncCommand
|
92
|
+
action :destroy
|
93
|
+
command_name "delete"
|
94
|
+
|
95
|
+
success_message _("Content view is being deleted with task %{id}")
|
96
|
+
failure_message _("Could not delete the content view")
|
97
|
+
|
98
|
+
build_options
|
99
|
+
end
|
100
|
+
|
101
|
+
class PublishCommand < HammerCLIForemanTasks::AsyncCommand
|
102
|
+
action :publish
|
103
|
+
command_name "publish"
|
104
|
+
|
105
|
+
success_message _("Content view is being published with task %{id}")
|
106
|
+
failure_message _("Could not publish the content view")
|
107
|
+
|
108
|
+
build_options
|
109
|
+
end
|
110
|
+
|
111
|
+
class RemoveFromEnvironmentCommand < HammerCLIForemanTasks::AsyncCommand
|
112
|
+
action :remove_from_environment
|
113
|
+
command_name "remove-from-environment"
|
114
|
+
|
115
|
+
success_message _("Content view is being removed from environment with task %{id}")
|
116
|
+
failure_message _("Could not remove the content view from environment")
|
117
|
+
|
118
|
+
build_options
|
119
|
+
end
|
120
|
+
|
121
|
+
class RemoveCommand < HammerCLIForemanTasks::AsyncCommand
|
122
|
+
# command to remove content view environments and versions from a content view.
|
123
|
+
# corresponds to the UI screen.
|
124
|
+
action :remove
|
125
|
+
command_name "remove"
|
126
|
+
|
127
|
+
option ["--content-view-version-ids"], "VERSION_IDS",
|
128
|
+
_("Comma separated list of version ids to remove")
|
129
|
+
option ["--environment-ids"], "ENVIRONMENT_IDS",
|
130
|
+
_("Comma separated list of environment ids to remove")
|
131
|
+
|
132
|
+
def request_params
|
133
|
+
super.tap do |opts|
|
134
|
+
%w(content_view_version_ids environment_ids).each do |key|
|
135
|
+
opts[key] = opts[key].split(",") if opts[key]
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
success_message _("Content view objects are being removed task %{id}")
|
141
|
+
failure_message _("Could not remove objects from content view")
|
142
|
+
|
143
|
+
build_options :without => %w(content_view_version_ids environment_ids)
|
144
|
+
end
|
145
|
+
|
146
|
+
class AddContentViewVersionCommand < HammerCLIKatello::AddAssociatedCommand
|
147
|
+
command_name 'add-version'
|
148
|
+
|
149
|
+
def association_name(plural = false)
|
150
|
+
plural ? "components" : "component"
|
151
|
+
end
|
152
|
+
|
153
|
+
associated_resource :content_view_versions
|
154
|
+
build_options
|
155
|
+
|
156
|
+
success_message _("The component version has been added")
|
157
|
+
failure_message _("Could not add version")
|
158
|
+
end
|
159
|
+
|
160
|
+
class RemoveContentViewVersionCommand < HammerCLIKatello::RemoveAssociatedCommand
|
161
|
+
command_name 'remove-version'
|
162
|
+
|
163
|
+
def association_name(plural = false)
|
164
|
+
plural ? "components" : "component"
|
165
|
+
end
|
166
|
+
|
167
|
+
associated_resource :content_view_versions
|
168
|
+
build_options
|
169
|
+
|
170
|
+
success_message _("The component version has been removed")
|
171
|
+
failure_message _("Could not remove version")
|
172
|
+
end
|
173
|
+
|
174
|
+
HammerCLIKatello::AssociatingCommands::Repository.extend_command(self)
|
175
|
+
|
176
|
+
autoload_subcommands
|
177
|
+
|
178
|
+
subcommand 'puppet-module',
|
179
|
+
HammerCLIKatello::ContentViewPuppetModule.desc,
|
180
|
+
HammerCLIKatello::ContentViewPuppetModule
|
181
|
+
|
182
|
+
subcommand HammerCLIKatello::Filter.command_name,
|
183
|
+
HammerCLIKatello::Filter.desc,
|
184
|
+
HammerCLIKatello::Filter
|
185
|
+
|
186
|
+
subcommand HammerCLIKatello::ContentViewVersion.command_name,
|
187
|
+
HammerCLIKatello::ContentViewVersion.desc,
|
188
|
+
HammerCLIKatello::ContentViewVersion
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
HammerCLI::MainCommand.subcommand "content-view", _("Manipulate content views."),
|
193
|
+
HammerCLIKatello::ContentView
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module HammerCLIKatello
|
2
|
+
|
3
|
+
class ContentViewPuppetModule < HammerCLIKatello::Command
|
4
|
+
|
5
|
+
resource :content_view_puppet_modules
|
6
|
+
command_name 'puppet-module'
|
7
|
+
desc 'View and manage puppet modules'
|
8
|
+
|
9
|
+
class ListCommand < HammerCLIKatello::ListCommand
|
10
|
+
output do
|
11
|
+
field :id, _("ID")
|
12
|
+
field :uuid, _("UUID")
|
13
|
+
field :name, _("Name")
|
14
|
+
field :author, _("Author")
|
15
|
+
end
|
16
|
+
|
17
|
+
build_options
|
18
|
+
end
|
19
|
+
|
20
|
+
class InfoCommand < HammerCLIKatello::InfoCommand
|
21
|
+
output do
|
22
|
+
field :id, _("ID")
|
23
|
+
field :uuid, _("UUID"), Fields::Field, :hide_blank => true
|
24
|
+
field :name, _("Name")
|
25
|
+
field :author, _("Author")
|
26
|
+
field :created_at, _("Created"), Fields::Date
|
27
|
+
field :updated_at, _("Updated"), Fields::Date
|
28
|
+
end
|
29
|
+
|
30
|
+
def request_params
|
31
|
+
super.merge(method_options)
|
32
|
+
end
|
33
|
+
|
34
|
+
build_options
|
35
|
+
end
|
36
|
+
|
37
|
+
class CreateCommand < HammerCLIKatello::Command
|
38
|
+
action :create
|
39
|
+
command_name "add"
|
40
|
+
|
41
|
+
success_message _("Puppet module added to content view")
|
42
|
+
failure_message _("Could not add the puppet module")
|
43
|
+
|
44
|
+
build_options
|
45
|
+
end
|
46
|
+
|
47
|
+
class UpdateCommand < HammerCLIKatello::UpdateCommand
|
48
|
+
success_message _("Puppet module updated for content view")
|
49
|
+
failure_message _("Could not update the puppet module")
|
50
|
+
|
51
|
+
def request_params
|
52
|
+
super.merge(method_options)
|
53
|
+
end
|
54
|
+
|
55
|
+
build_options
|
56
|
+
end
|
57
|
+
|
58
|
+
class DeleteCommand < HammerCLIKatello::Command
|
59
|
+
action :destroy
|
60
|
+
command_name "remove"
|
61
|
+
|
62
|
+
success_message _("Puppet module removed from content view")
|
63
|
+
failure_message _("Could not delete the filter")
|
64
|
+
|
65
|
+
def request_params
|
66
|
+
super.merge(method_options)
|
67
|
+
end
|
68
|
+
|
69
|
+
build_options
|
70
|
+
end
|
71
|
+
|
72
|
+
autoload_subcommands
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module HammerCLIKatello
|
2
|
+
|
3
|
+
class ContentViewVersion < HammerCLIKatello::Command
|
4
|
+
resource :content_view_versions
|
5
|
+
command_name 'version'
|
6
|
+
desc 'View and manage content view versions'
|
7
|
+
|
8
|
+
class ListCommand < HammerCLIKatello::ListCommand
|
9
|
+
output do
|
10
|
+
field :id, _("ID")
|
11
|
+
field :name, _("Name")
|
12
|
+
field :version, _("Version")
|
13
|
+
|
14
|
+
from :content_view do
|
15
|
+
field :id, _("Content View ID")
|
16
|
+
field :name, _("Content View Name")
|
17
|
+
field :label, _("Content View Label")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
build_options
|
22
|
+
end
|
23
|
+
|
24
|
+
class InfoCommand < HammerCLIKatello::InfoCommand
|
25
|
+
output do
|
26
|
+
field :id, _("ID")
|
27
|
+
field :name, _("Name")
|
28
|
+
field :version, _("Version")
|
29
|
+
|
30
|
+
from :content_view do
|
31
|
+
field :id, _("Content View ID")
|
32
|
+
field :name, _("Content View Name")
|
33
|
+
field :label, _("Content View Label")
|
34
|
+
end
|
35
|
+
|
36
|
+
collection :environments, _("Environments") do
|
37
|
+
field :id, _("ID")
|
38
|
+
field :name, _("Name")
|
39
|
+
field :label, _("Label")
|
40
|
+
end
|
41
|
+
|
42
|
+
collection :repositories, _("Repositories") do
|
43
|
+
field :id, _("ID")
|
44
|
+
field :name, _("Name")
|
45
|
+
field :label, _("Label")
|
46
|
+
end
|
47
|
+
|
48
|
+
collection :puppet_modules, _("Puppet Modules") do
|
49
|
+
field :id, _("ID")
|
50
|
+
field :name, _("Name")
|
51
|
+
field :author, _("Author")
|
52
|
+
field :version, _("Version")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
build_options
|
57
|
+
end
|
58
|
+
|
59
|
+
class PromoteCommand < HammerCLIForemanTasks::AsyncCommand
|
60
|
+
action :promote
|
61
|
+
command_name "promote"
|
62
|
+
|
63
|
+
success_message _("Content view is being promoted with task %{id}")
|
64
|
+
failure_message _("Could not promote the content view")
|
65
|
+
|
66
|
+
build_options
|
67
|
+
end
|
68
|
+
|
69
|
+
class DeleteCommand < HammerCLIForemanTasks::AsyncCommand
|
70
|
+
action :destroy
|
71
|
+
command_name "delete"
|
72
|
+
|
73
|
+
success_message _("Content view is being deleted with task %{id}")
|
74
|
+
failure_message _("Could not delete the content view")
|
75
|
+
|
76
|
+
build_options
|
77
|
+
end
|
78
|
+
|
79
|
+
autoload_subcommands
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
module HammerCLIKatello
|
3
|
+
class ExceptionHandler < HammerCLIForeman::ExceptionHandler
|
4
|
+
|
5
|
+
def mappings
|
6
|
+
super + [
|
7
|
+
[RestClient::InternalServerError, :handle_internal_error]
|
8
|
+
]
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
def handle_internal_error(e)
|
14
|
+
handle_katello_error(e)
|
15
|
+
HammerCLI::EX_SOFTWARE
|
16
|
+
end
|
17
|
+
|
18
|
+
def handle_unprocessable_entity(e)
|
19
|
+
handle_katello_error(e)
|
20
|
+
HammerCLI::EX_DATAERR
|
21
|
+
end
|
22
|
+
|
23
|
+
def handle_not_found(e)
|
24
|
+
handle_katello_error(e)
|
25
|
+
HammerCLI::EX_NOT_FOUND
|
26
|
+
end
|
27
|
+
|
28
|
+
def handle_katello_error(e)
|
29
|
+
response = JSON.parse(e.response)
|
30
|
+
response = HammerCLIForeman.record_to_common_format(response)
|
31
|
+
# Check multiple possible keys that can contain error message:
|
32
|
+
# - displayMessage for katello specific messages
|
33
|
+
# - full_messages for for messages that come from rails
|
34
|
+
# - message for foreman specific messages
|
35
|
+
print_error response["displayMessage"] || response["full_messages"] || response["message"]
|
36
|
+
log_full_error e
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|