hammer_cli_foreman 0.0.18 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of hammer_cli_foreman might be problematic. Click here for more details.

Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hammer_cli_foreman.rb +39 -27
  3. data/lib/hammer_cli_foreman/architecture.rb +14 -14
  4. data/lib/hammer_cli_foreman/associating_commands.rb +46 -40
  5. data/lib/hammer_cli_foreman/auth.rb +49 -0
  6. data/lib/hammer_cli_foreman/commands.rb +82 -29
  7. data/lib/hammer_cli_foreman/common_parameter.rb +13 -17
  8. data/lib/hammer_cli_foreman/compute_resource.rb +23 -23
  9. data/lib/hammer_cli_foreman/credentials.rb +36 -0
  10. data/lib/hammer_cli_foreman/domain.rb +32 -35
  11. data/lib/hammer_cli_foreman/environment.rb +14 -19
  12. data/lib/hammer_cli_foreman/exception_handler.rb +30 -8
  13. data/lib/hammer_cli_foreman/fact.rb +5 -5
  14. data/lib/hammer_cli_foreman/host.rb +178 -105
  15. data/lib/hammer_cli_foreman/hostgroup.rb +59 -37
  16. data/lib/hammer_cli_foreman/i18n.rb +24 -0
  17. data/lib/hammer_cli_foreman/image.rb +24 -24
  18. data/lib/hammer_cli_foreman/location.rb +13 -13
  19. data/lib/hammer_cli_foreman/media.rb +21 -16
  20. data/lib/hammer_cli_foreman/model.rb +16 -16
  21. data/lib/hammer_cli_foreman/operating_system.rb +39 -39
  22. data/lib/hammer_cli_foreman/organization.rb +13 -13
  23. data/lib/hammer_cli_foreman/output/fields.rb +2 -2
  24. data/lib/hammer_cli_foreman/output/formatters.rb +15 -4
  25. data/lib/hammer_cli_foreman/parameter.rb +13 -11
  26. data/lib/hammer_cli_foreman/partition_table.rb +17 -18
  27. data/lib/hammer_cli_foreman/puppet_class.rb +9 -9
  28. data/lib/hammer_cli_foreman/report.rb +38 -38
  29. data/lib/hammer_cli_foreman/resource_supported_test.rb +1 -1
  30. data/lib/hammer_cli_foreman/smart_class_parameter.rb +36 -36
  31. data/lib/hammer_cli_foreman/smart_proxy.rb +22 -21
  32. data/lib/hammer_cli_foreman/subnet.rb +29 -31
  33. data/lib/hammer_cli_foreman/template.rb +45 -43
  34. data/lib/hammer_cli_foreman/user.rb +20 -23
  35. data/lib/hammer_cli_foreman/version.rb +1 -1
  36. data/locale/Makefile +64 -0
  37. data/locale/hammer-cli-foreman.pot +1573 -0
  38. data/locale/zanata.xml +29 -0
  39. data/test/unit/apipie_resource_mock.rb +44 -72
  40. data/test/unit/architecture_test.rb +1 -2
  41. data/test/unit/commands_test.rb +23 -21
  42. data/test/unit/common_parameter_test.rb +15 -10
  43. data/test/unit/compute_resource_test.rb +1 -2
  44. data/test/unit/credentials_test.rb +46 -0
  45. data/test/unit/data/1.4/foreman_api.json +10387 -0
  46. data/test/unit/domain_test.rb +2 -5
  47. data/test/unit/environment_test.rb +2 -3
  48. data/test/unit/exception_handler_test.rb +29 -4
  49. data/test/unit/fact_test.rb +0 -1
  50. data/test/unit/helpers/command.rb +20 -4
  51. data/test/unit/helpers/resource_disabled.rb +2 -2
  52. data/test/unit/host_test.rb +24 -12
  53. data/test/unit/hostgroup_test.rb +7 -8
  54. data/test/unit/image_test.rb +6 -7
  55. data/test/unit/location_test.rb +9 -5
  56. data/test/unit/media_test.rb +1 -9
  57. data/test/unit/model_test.rb +1 -3
  58. data/test/unit/operating_system_test.rb +7 -9
  59. data/test/unit/organization_test.rb +12 -6
  60. data/test/unit/output/formatters_test.rb +5 -0
  61. data/test/unit/partition_table_test.rb +1 -2
  62. data/test/unit/puppet_class_test.rb +2 -3
  63. data/test/unit/report_test.rb +1 -2
  64. data/test/unit/smart_class_parameter_test.rb +9 -4
  65. data/test/unit/smart_proxy_test.rb +1 -2
  66. data/test/unit/subnet_test.rb +2 -3
  67. data/test/unit/template_test.rb +23 -8
  68. data/test/unit/test_helper.rb +13 -0
  69. data/test/unit/test_output_adapter.rb +1 -1
  70. data/test/unit/user_test.rb +1 -2
  71. metadata +17 -7
@@ -1,5 +1,44 @@
1
1
  module HammerCLIForeman
2
2
 
3
+ CONNECTION_NAME = 'foreman'
4
+
5
+ def self.credentials
6
+ @credentials ||= Credentials.new(
7
+ :username => (HammerCLI::Settings.get(:_params, :username) || ENV['FOREMAN_USERNAME'] || HammerCLI::Settings.get(:foreman, :username)),
8
+ :password => (HammerCLI::Settings.get(:_params, :password) || ENV['FOREMAN_PASSWORD'] || HammerCLI::Settings.get(:foreman, :password))
9
+ )
10
+ @credentials
11
+ end
12
+
13
+ def self.resource_config
14
+ config = {}
15
+ config[:uri] = HammerCLI::Settings.get(:foreman, :host)
16
+ config[:credentials] = credentials
17
+ config[:logger] = Logging.logger['API']
18
+ config[:api_version] = 2
19
+ config[:aggressive_cache_checking] = HammerCLI::Settings.get(:foreman, :refresh_cache) || true
20
+ config[:headers] = { "Accept-Language" => HammerCLI::I18n.locale }
21
+ config[:timeout] = HammerCLI::Settings.get(:foreman, :request_timeout)
22
+ config
23
+ end
24
+
25
+ def self.foreman_resource(resource)
26
+ HammerCLI::Connection.create(
27
+ CONNECTION_NAME,
28
+ HammerCLI::Apipie::Command.resource_config.merge(resource_config),
29
+ HammerCLI::Apipie::Command.connection_options).api.resource(resource)
30
+ end
31
+
32
+ module ConnectionSetup
33
+ def connection_name(resource_class)
34
+ CONNECTION_NAME
35
+ end
36
+
37
+ def resource_config
38
+ super.merge(HammerCLIForeman.resource_config)
39
+ end
40
+ end
41
+
3
42
  def self.collection_to_common_format(data)
4
43
  if data.class <= Hash && data.has_key?('total') && data.has_key?('results')
5
44
  col = HammerCLI::Output::RecordCollection.new(data['results'],
@@ -17,7 +56,7 @@ module HammerCLIForeman
17
56
  # produce [ { 'attr' => 'val' }, ... ]
18
57
  col = HammerCLI::Output::RecordCollection.new(data.map { |r| r.keys.length == 1 ? r[r.keys[0]] : r })
19
58
  else
20
- raise RuntimeError.new("Received data of unknown format")
59
+ raise RuntimeError.new(_("Received data of unknown format"))
21
60
  end
22
61
  col
23
62
  end
@@ -26,15 +65,23 @@ module HammerCLIForeman
26
65
  data.class <= Hash && data.keys.length == 1 ? data[data.keys[0]] : data
27
66
  end
28
67
 
68
+ class ReadCommand < HammerCLI::Apipie::ReadCommand
69
+ extend HammerCLIForeman::ConnectionSetup
70
+ end
71
+
72
+ class Command < ReadCommand
73
+ end
74
+
29
75
  class WriteCommand < HammerCLI::Apipie::WriteCommand
76
+ extend HammerCLIForeman::ConnectionSetup
30
77
 
31
78
  def send_request
32
- HammerCLIForeman.record_to_common_format(resource.call(action, request_params, request_headers)[0])
79
+ HammerCLIForeman.record_to_common_format(super)
33
80
  end
34
81
 
35
82
  end
36
83
 
37
- class ListCommand < HammerCLI::Apipie::ReadCommand
84
+ class ListCommand < ReadCommand
38
85
 
39
86
  action :index
40
87
 
@@ -60,9 +107,9 @@ module HammerCLIForeman
60
107
  end
61
108
 
62
109
  def execute
63
- if respond_to?(:page) && respond_to?(:per_page)
64
- self.page ||= 1
65
- self.per_page ||= HammerCLI::Settings.get(:ui, :per_page) || DEFAULT_PER_PAGE
110
+ if respond_to?(:option_page) && respond_to?(:option_per_page)
111
+ self.option_page ||= 1
112
+ self.option_per_page ||= HammerCLI::Settings.get(:ui, :per_page) || DEFAULT_PER_PAGE
66
113
  browse_collection
67
114
  else
68
115
  retrieve_and_print
@@ -79,10 +126,10 @@ module HammerCLIForeman
79
126
  while list_next do
80
127
  d = retrieve_and_print
81
128
 
82
- if (d.size >= self.per_page.to_i) && interactive?
83
- answer = ask("List next page? (Y/n): ").downcase
129
+ if (d.size >= self.option_per_page.to_i) && interactive?
130
+ answer = ask(_("List next page? (%s): ") % 'Y/n').downcase
84
131
  list_next = (answer == 'y' || answer == '')
85
- self.page += 1
132
+ self.option_page += 1
86
133
  else
87
134
  list_next = false
88
135
  end
@@ -99,7 +146,7 @@ module HammerCLIForeman
99
146
  end
100
147
 
101
148
 
102
- class InfoCommand < HammerCLI::Apipie::ReadCommand
149
+ class InfoCommand < ReadCommand
103
150
 
104
151
  action :show
105
152
 
@@ -110,7 +157,8 @@ module HammerCLIForeman
110
157
  identifiers :id, :name
111
158
 
112
159
  def request_params
113
- {'id' => get_identifier[0]}
160
+ params = method_options
161
+ params.update('id' => get_identifier[0])
114
162
  end
115
163
 
116
164
  def retrieve_data
@@ -153,7 +201,7 @@ module HammerCLIForeman
153
201
 
154
202
  def self.setup_identifier_options
155
203
  super
156
- option "--new-name", "NEW_NAME", "new name for the resource", :attribute_name => :option_name if identifier? :name
204
+ option "--new-name", "NEW_NAME", _("new name for the resource"), :attribute_name => :option_name if identifier? :name
157
205
  end
158
206
 
159
207
  def request_params
@@ -199,7 +247,7 @@ module HammerCLIForeman
199
247
  end
200
248
 
201
249
  def self.setup_associated_identifier_options
202
- name = associated_resource.name.to_s
250
+ name = associated_resource.singular_name
203
251
  option_switch = "--"+name.gsub('_', '-')
204
252
 
205
253
  option option_switch, name.upcase, " ", :attribute_name => :associated_name do |value|
@@ -210,11 +258,11 @@ module HammerCLIForeman
210
258
 
211
259
 
212
260
  def associated_resource
213
- HammerCLI::Apipie::ResourceInstance.from_definition(self.class.associated_resource, resource_config)
261
+ self.class.associated_resource
214
262
  end
215
263
 
216
264
  def self.associated_resource(resource_class=nil)
217
- @associated_api_resource = HammerCLI::Apipie::ResourceDefinition.new(resource_class) unless resource_class.nil?
265
+ @associated_api_resource = HammerCLIForeman.foreman_resource(resource_class) unless resource_class.nil?
218
266
  return @associated_api_resource
219
267
  end
220
268
 
@@ -241,41 +289,45 @@ module HammerCLIForeman
241
289
  end
242
290
 
243
291
  def get_current_ids
244
- item = HammerCLIForeman.record_to_common_format(resource.call('show', {'id' => get_identifier[0]})[0])
245
- if item.has_key?(associated_resource.plural_name)
246
- item[associated_resource.plural_name].map { |assoc| assoc['id'] }
292
+ item = HammerCLIForeman.record_to_common_format(resource.call(:show, {:id => get_identifier[0]}))
293
+ if item.has_key?(association_name(true))
294
+ item[association_name(true)].map { |assoc| assoc['id'] }
247
295
  else
248
- item[associated_resource.name+'_ids'] || []
296
+ item[association_name+'_ids'] || []
249
297
  end
250
298
  end
251
299
 
252
300
  def get_required_id
253
- item = HammerCLIForeman.record_to_common_format(associated_resource.call('show', {'id' => associated_id || associated_name})[0])
301
+ item = HammerCLIForeman.record_to_common_format(associated_resource.call(:show, {:id => associated_id || associated_name}))
254
302
  item['id']
255
303
  end
256
304
 
257
305
  def request_params
258
- params = {}
259
- if params.key?(resource.name)
260
- params[resource.name] = {"#{associated_resource.name}_ids" => get_new_ids }
306
+ params = super
307
+ if params.key?(resource.singular_name)
308
+ params[resource.singular_name] = {"#{association_name}_ids" => get_new_ids }
261
309
  else
262
- params["#{associated_resource.name}_ids"] = get_new_ids
310
+ params["#{association_name}_ids"] = get_new_ids
263
311
  end
264
-
265
312
  params['id'] = get_identifier[0]
266
313
  params
267
314
  end
268
315
 
316
+ def association_name(plural = false)
317
+ plural ? associated_resource.name.to_s : associated_resource.singular_name.to_s
318
+ end
319
+
269
320
  end
270
321
 
271
322
  class AddAssociatedCommand < AssociatedCommand
272
323
 
273
324
  def self.command_name(name=nil)
274
- super(name) || (associated_resource ? "add_"+associated_resource.name : nil)
325
+ name = super(name) || (associated_resource ? "add-"+associated_resource.singular_name : nil)
326
+ name.respond_to?(:gsub) ? name.gsub('_', '-') : name
275
327
  end
276
328
 
277
329
  def self.desc(desc=nil)
278
- "Associate a resource"
330
+ _("Associate a resource")
279
331
  end
280
332
 
281
333
  def get_new_ids
@@ -291,11 +343,12 @@ module HammerCLIForeman
291
343
  class RemoveAssociatedCommand < AssociatedCommand
292
344
 
293
345
  def self.command_name(name=nil)
294
- super(name) || (associated_resource ? "remove_"+associated_resource.name : nil)
346
+ name = super(name) || (associated_resource ? "remove-"+associated_resource.singular_name : nil)
347
+ name.respond_to?(:gsub) ? name.gsub('_', '-') : name
295
348
  end
296
349
 
297
350
  def self.desc(desc=nil)
298
- "Disassociate a resource"
351
+ _("Disassociate a resource")
299
352
  end
300
353
 
301
354
  def get_new_ids
@@ -1,17 +1,16 @@
1
1
  require 'hammer_cli'
2
- require 'foreman_api'
3
2
 
4
3
  module HammerCLIForeman
5
4
 
6
- class CommonParameter < HammerCLI::AbstractCommand
5
+ class CommonParameter < HammerCLIForeman::Command
7
6
 
7
+ resource :common_parameters
8
8
 
9
9
  class ListCommand < HammerCLIForeman::ListCommand
10
- resource ForemanApi::Resources::CommonParameter, "index"
11
10
 
12
11
  output do
13
- field :name, "Name"
14
- field :value, "Value"
12
+ field :name, _("Name")
13
+ field :value, _("Value")
15
14
  end
16
15
 
17
16
  apipie_options
@@ -20,15 +19,13 @@ module HammerCLIForeman
20
19
  class SetCommand < HammerCLIForeman::WriteCommand
21
20
 
22
21
  command_name "set"
23
- desc "Set a global parameter."
22
+ desc _("Set a global parameter.")
24
23
 
25
- success_message_for :create, "Created parameter [%{name}s] with value [%{value}s]."
26
- success_message_for :update, "Parameter [%{name}s] updated to [%{value}s]."
24
+ success_message_for :create, _("Created parameter [%{name}s] with value [%{value}s].")
25
+ success_message_for :update, _("Parameter [%{name}s] updated to [%{value}s].")
27
26
 
28
- resource ForemanApi::Resources::CommonParameter
29
-
30
- option "--name", "NAME", "parameter name", :required => true
31
- option "--value", "VALUE", "parameter value", :required => true
27
+ option "--name", "NAME", _("parameter name"), :required => true
28
+ option "--value", "VALUE", _("parameter value"), :required => true
32
29
 
33
30
  def action
34
31
  @action ||= parameter_exist? ? :update : :create
@@ -40,7 +37,7 @@ module HammerCLIForeman
40
37
  end
41
38
 
42
39
  def parameter_exist?
43
- params = resource.call(:index)[0]
40
+ params = resource.call(:index)
44
41
  params = HammerCLIForeman.collection_to_common_format(params)
45
42
  params.find { |p| p["name"] == option_name }
46
43
  end
@@ -58,9 +55,8 @@ module HammerCLIForeman
58
55
 
59
56
  identifiers :name
60
57
 
61
- success_message "Global parameter [%{name}s] deleted."
62
- failure_message "Could not delete the global parameter [%{name}s]"
63
- resource ForemanApi::Resources::CommonParameter, "destroy"
58
+ success_message _("Global parameter [%{name}s] deleted.")
59
+ failure_message _("Could not delete the global parameter [%{name}s]")
64
60
 
65
61
  apipie_options :without => :id
66
62
  end
@@ -69,4 +65,4 @@ module HammerCLIForeman
69
65
  end
70
66
  end
71
67
 
72
- HammerCLI::MainCommand.subcommand 'global_parameter', "Manipulate global parameters.", HammerCLIForeman::CommonParameter
68
+ HammerCLI::MainCommand.subcommand 'global-parameter', _("Manipulate global parameters."), HammerCLIForeman::CommonParameter
@@ -2,15 +2,15 @@ require 'hammer_cli_foreman/image'
2
2
 
3
3
  module HammerCLIForeman
4
4
 
5
- class ComputeResource < HammerCLI::Apipie::Command
6
- resource ForemanApi::Resources::ComputeResource
5
+ class ComputeResource < HammerCLIForeman::Command
6
+ resource :compute_resources
7
7
 
8
8
  class ListCommand < HammerCLIForeman::ListCommand
9
9
 
10
10
  output do
11
- field :id, "Id"
12
- field :name, "Name"
13
- field :provider, "Provider"
11
+ field :id, _("Id")
12
+ field :name, _("Name")
13
+ field :provider, _("Provider")
14
14
  end
15
15
 
16
16
  apipie_options
@@ -21,31 +21,31 @@ module HammerCLIForeman
21
21
 
22
22
  PROVIDER_SPECIFIC_FIELDS = {
23
23
  'ovirt' => [
24
- Fields::DataField.new(:label => 'UUID', :path => ["compute_resource", "uuid"])
24
+ Fields::Field.new(:label => _('UUID'), :path => ["compute_resource", "uuid"])
25
25
  ],
26
26
  'ec2' => [
27
- Fields::DataField.new(:label => 'Region', :path => ["compute_resource", "region"])
27
+ Fields::Field.new(:label => _('Region'), :path => ["compute_resource", "region"])
28
28
  ],
29
29
  'vmware' => [
30
- Fields::DataField.new(:label => 'UUID', :path => ["compute_resource", "uuid"]),
31
- Fields::DataField.new(:label => 'Server', :path => ["compute_resource", "server"])
30
+ Fields::Field.new(:label => _('UUID'), :path => ["compute_resource", "uuid"]),
31
+ Fields::Field.new(:label => _('Server'), :path => ["compute_resource", "server"])
32
32
  ],
33
33
  'openstack' => [
34
- Fields::DataField.new(:label => 'Tenant', :path => ["compute_resource", "tenant"])
34
+ Fields::Field.new(:label => _('Tenant'), :path => ["compute_resource", "tenant"])
35
35
  ],
36
36
  'rackspace' => [
37
- Fields::DataField.new(:label => 'Region', :path => ["compute_resource", "region"])
37
+ Fields::Field.new(:label => _('Region'), :path => ["compute_resource", "region"])
38
38
  ],
39
39
  'libvirt' => [
40
40
  ]
41
41
  }
42
42
 
43
43
  output ListCommand.output_definition do
44
- field :url, "Url"
45
- field :description, "Description"
46
- field :user, "User"
47
- field :created_at, "Created at", Fields::Date
48
- field :updated_at, "Updated at", Fields::Date
44
+ field :url, _("Url")
45
+ field :description, _("Description")
46
+ field :user, _("User")
47
+ field :created_at, _("Created at"), Fields::Date
48
+ field :updated_at, _("Updated at"), Fields::Date
49
49
  end
50
50
 
51
51
  def print_data(data)
@@ -60,8 +60,8 @@ module HammerCLIForeman
60
60
 
61
61
  class CreateCommand < HammerCLIForeman::CreateCommand
62
62
 
63
- success_message "Compute resource created"
64
- failure_message "Could not create the compute resource"
63
+ success_message _("Compute resource created")
64
+ failure_message _("Could not create the compute resource")
65
65
 
66
66
  apipie_options
67
67
 
@@ -73,8 +73,8 @@ module HammerCLIForeman
73
73
 
74
74
  class UpdateCommand < HammerCLIForeman::UpdateCommand
75
75
 
76
- success_message "Compute resource updated"
77
- failure_message "Could not update the compute resource"
76
+ success_message _("Compute resource updated")
77
+ failure_message _("Could not update the compute resource")
78
78
 
79
79
  apipie_options
80
80
  end
@@ -82,8 +82,8 @@ module HammerCLIForeman
82
82
 
83
83
  class DeleteCommand < HammerCLIForeman::DeleteCommand
84
84
 
85
- success_message "Compute resource deleted"
86
- failure_message "Could not delete the compute resource"
85
+ success_message _("Compute resource deleted")
86
+ failure_message _("Could not delete the compute resource")
87
87
 
88
88
  apipie_options
89
89
  end
@@ -95,6 +95,6 @@ module HammerCLIForeman
95
95
 
96
96
  end
97
97
 
98
- HammerCLI::MainCommand.subcommand 'compute_resource', "Manipulate compute resources.", HammerCLIForeman::ComputeResource
98
+ HammerCLI::MainCommand.subcommand 'compute-resource', _("Manipulate compute resources."), HammerCLIForeman::ComputeResource
99
99
 
100
100
 
@@ -0,0 +1,36 @@
1
+ module HammerCLIForeman
2
+ class Credentials < HammerCLI::Apipie::AbstractCredentials
3
+
4
+ def initialize(params={})
5
+ @username = params[:username]
6
+ @password = params[:password]
7
+ end
8
+
9
+ def username
10
+ @username ||= ask_user(_("[Foreman] username: ")) if HammerCLI.interactive?
11
+ @username
12
+ end
13
+
14
+ def password
15
+ @password ||= ask_user(_("[Foreman] password for %s: ") % @username, true) if HammerCLI.interactive?
16
+ @password
17
+ end
18
+
19
+ def empty?
20
+ !@username && !@password
21
+ end
22
+
23
+ def clear
24
+ @username = nil
25
+ @password = nil
26
+ end
27
+
28
+ def to_params
29
+ {
30
+ :username => username,
31
+ :password => password
32
+ }
33
+ end
34
+
35
+ end
36
+ end
@@ -1,12 +1,14 @@
1
1
  module HammerCLIForeman
2
2
 
3
- class Domain < HammerCLI::AbstractCommand
3
+ class Domain < HammerCLIForeman::Command
4
+
5
+ resource :domains
6
+
4
7
  class ListCommand < HammerCLIForeman::ListCommand
5
- resource ForemanApi::Resources::Domain, "index"
6
8
 
7
9
  output do
8
- field :id, "Id"
9
- field :name, "Name"
10
+ field :id, _("Id")
11
+ field :name, _("Name")
10
12
  end
11
13
 
12
14
  apipie_options
@@ -15,14 +17,12 @@ module HammerCLIForeman
15
17
 
16
18
  class InfoCommand < HammerCLIForeman::InfoCommand
17
19
 
18
- resource ForemanApi::Resources::Domain, "show"
19
-
20
20
  output ListCommand.output_definition do
21
- field :fullname, "Description"
22
- field :dns_id, "DNS Id"
23
- field :created_at, "Created at", Fields::Date
24
- field :updated_at, "Updated at", Fields::Date
25
- collection :parameters, "Parameters" do
21
+ field :fullname, _("Description")
22
+ field :dns_id, _("DNS Id")
23
+ field :created_at, _("Created at"), Fields::Date
24
+ field :updated_at, _("Updated at"), Fields::Date
25
+ collection :parameters, _("Parameters") do
26
26
  field nil, nil, Fields::KeyValue
27
27
  end
28
28
  end
@@ -38,31 +38,28 @@ module HammerCLIForeman
38
38
 
39
39
  class CreateCommand < HammerCLIForeman::CreateCommand
40
40
 
41
- success_message "Domain [%{name}s] created"
42
- failure_message "Could not create the domain"
43
- resource ForemanApi::Resources::Domain, "create"
41
+ success_message _("Domain [%{name}s] created")
42
+ failure_message _("Could not create the domain")
44
43
 
45
44
  apipie_options :without => [:domain_parameters_attributes, :fullname]
46
- option "--description", "DESC", "Full name describing the domain", :attribute_name => :option_fullname
45
+ option "--description", "DESC", _("Full name describing the domain"), :attribute_name => :option_fullname
47
46
  end
48
47
 
49
48
 
50
49
  class UpdateCommand < HammerCLIForeman::UpdateCommand
51
50
 
52
- success_message "Domain [%{name}s] updated"
53
- failure_message "Could not update the domain"
54
- resource ForemanApi::Resources::Domain, "update"
51
+ success_message _("Domain [%{name}s] updated")
52
+ failure_message _("Could not update the domain")
55
53
 
56
54
  apipie_options :without => [:domain_parameters_attributes, :name, :id, :fullname]
57
- option "--description", "DESC", "Full name describing the domain", :attribute_name => :option_fullname
55
+ option "--description", "DESC", _("Full name describing the domain"), :attribute_name => :option_fullname
58
56
  end
59
57
 
60
58
 
61
59
  class DeleteCommand < HammerCLIForeman::DeleteCommand
62
60
 
63
- success_message "Domain [%{name}s] deleted"
64
- failure_message "Could not delete the domain"
65
- resource ForemanApi::Resources::Domain, "destroy"
61
+ success_message _("Domain [%{name}s] deleted")
62
+ failure_message _("Could not delete the domain")
66
63
 
67
64
  apipie_options
68
65
  end
@@ -70,16 +67,16 @@ module HammerCLIForeman
70
67
 
71
68
  class SetParameterCommand < HammerCLIForeman::Parameter::SetCommand
72
69
 
73
- resource ForemanApi::Resources::Parameter
70
+ resource :parameters
74
71
 
75
- desc "Create or update parameter for a domain."
72
+ desc _("Create or update parameter for a domain.")
76
73
 
77
- option "--domain-name", "DOMAIN_NAME", "name of the domain the parameter is being set for"
78
- option "--domain-id", "DOMAIN_ID", "id of the domain the parameter is being set for"
74
+ option "--domain-name", "DOMAIN_NAME", _("name of the domain the parameter is being set for")
75
+ option "--domain-id", "DOMAIN_ID", _("id of the domain the parameter is being set for")
79
76
 
80
- success_message_for :update, "Domain parameter updated"
81
- success_message_for :create, "New domain parameter created"
82
- failure_message "Could not set domain parameter"
77
+ success_message_for :update, _("Domain parameter updated")
78
+ success_message_for :create, _("New domain parameter created")
79
+ failure_message _("Could not set domain parameter")
83
80
 
84
81
  def validate_options
85
82
  super
@@ -96,14 +93,14 @@ module HammerCLIForeman
96
93
 
97
94
  class DeleteParameterCommand < HammerCLIForeman::Parameter::DeleteCommand
98
95
 
99
- resource ForemanApi::Resources::Parameter
96
+ resource :parameters
100
97
 
101
- desc "Delete parameter for a domain."
98
+ desc _("Delete parameter for a domain.")
102
99
 
103
- option "--domain-name", "DOMAIN_NAME", "name of the domain the parameter is being deleted for"
104
- option "--domain-id", "DOMAIN_ID", "id of the domain the parameter is being deleted for"
100
+ option "--domain-name", "DOMAIN_NAME", _("name of the domain the parameter is being deleted for")
101
+ option "--domain-id", "DOMAIN_ID", _("id of the domain the parameter is being deleted for")
105
102
 
106
- success_message "Domain parameter deleted"
103
+ success_message _("Domain parameter deleted")
107
104
 
108
105
  def validate_options
109
106
  super
@@ -122,5 +119,5 @@ module HammerCLIForeman
122
119
 
123
120
  end
124
121
 
125
- HammerCLI::MainCommand.subcommand 'domain', "Manipulate domains.", HammerCLIForeman::Domain
122
+ HammerCLI::MainCommand.subcommand 'domain', _("Manipulate domains."), HammerCLIForeman::Domain
126
123