hammer_cli_foreman 2.4.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes.md +40 -0
  3. data/lib/hammer_cli_foreman/architecture.rb +5 -5
  4. data/lib/hammer_cli_foreman/associating_commands.rb +0 -24
  5. data/lib/hammer_cli_foreman/bookmark.rb +5 -5
  6. data/lib/hammer_cli_foreman/combination.rb +3 -13
  7. data/lib/hammer_cli_foreman/command_extensions/ping.rb +21 -2
  8. data/lib/hammer_cli_foreman/command_extensions/subnet.rb +25 -10
  9. data/lib/hammer_cli_foreman/command_extensions/update_common.rb +14 -0
  10. data/lib/hammer_cli_foreman/command_extensions/user.rb +9 -5
  11. data/lib/hammer_cli_foreman/command_extensions.rb +1 -2
  12. data/lib/hammer_cli_foreman/commands.rb +17 -11
  13. data/lib/hammer_cli_foreman/compute_attribute.rb +1 -1
  14. data/lib/hammer_cli_foreman/compute_profile.rb +5 -5
  15. data/lib/hammer_cli_foreman/compute_resource/ovirt.rb +2 -1
  16. data/lib/hammer_cli_foreman/compute_resource.rb +23 -0
  17. data/lib/hammer_cli_foreman/config_report.rb +2 -0
  18. data/lib/hammer_cli_foreman/filter.rb +2 -2
  19. data/lib/hammer_cli_foreman/host.rb +1 -47
  20. data/lib/hammer_cli_foreman/hostgroup.rb +14 -58
  21. data/lib/hammer_cli_foreman/hosts/common_update_options.rb +10 -31
  22. data/lib/hammer_cli_foreman/id_resolver.rb +7 -68
  23. data/lib/hammer_cli_foreman/location.rb +0 -6
  24. data/lib/hammer_cli_foreman/mail_notification.rb +2 -2
  25. data/lib/hammer_cli_foreman/model.rb +5 -5
  26. data/lib/hammer_cli_foreman/operating_system.rb +10 -10
  27. data/lib/hammer_cli_foreman/option_builders.rb +84 -52
  28. data/lib/hammer_cli_foreman/option_sources/id_params.rb +41 -11
  29. data/lib/hammer_cli_foreman/option_sources/ids_params.rb +39 -7
  30. data/lib/hammer_cli_foreman/option_sources.rb +0 -1
  31. data/lib/hammer_cli_foreman/organization.rb +0 -6
  32. data/lib/hammer_cli_foreman/ping.rb +6 -1
  33. data/lib/hammer_cli_foreman/references.rb +0 -16
  34. data/lib/hammer_cli_foreman/registration.rb +18 -0
  35. data/lib/hammer_cli_foreman/settings.rb +3 -3
  36. data/lib/hammer_cli_foreman/smart_proxy.rb +7 -57
  37. data/lib/hammer_cli_foreman/template.rb +3 -15
  38. data/lib/hammer_cli_foreman/user.rb +4 -4
  39. data/lib/hammer_cli_foreman/usergroup.rb +5 -5
  40. data/lib/hammer_cli_foreman/version.rb +1 -1
  41. data/lib/hammer_cli_foreman.rb +3 -21
  42. data/lib/minitest/coverage_reporter.rb +1 -1
  43. data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  44. data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  45. data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  46. data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  47. data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  48. data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  49. data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  50. data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  51. data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  52. data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  53. data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  54. data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  55. data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  56. data/test/data/2.4/foreman_api.json +1 -0
  57. data/test/data/2.5/foreman_api.json +1 -0
  58. data/test/data/3.1/foreman_api.json +1 -0
  59. data/test/functional/architecture_test.rb +37 -5
  60. data/test/functional/bookmark_test.rb +5 -2
  61. data/test/functional/compute_attribute_test.rb +20 -20
  62. data/test/functional/compute_profile_test.rb +14 -1
  63. data/test/functional/compute_resource_test.rb +37 -0
  64. data/test/functional/filter_test.rb +2 -1
  65. data/test/functional/host_test.rb +65 -11
  66. data/test/functional/hostgroup/create_test.rb +11 -117
  67. data/test/functional/hostgroup/update_test.rb +11 -79
  68. data/test/functional/http_proxy_test.rb +12 -0
  69. data/test/functional/location_test.rb +13 -3
  70. data/test/functional/mail_notification_test.rb +3 -1
  71. data/test/functional/media_test.rb +11 -0
  72. data/test/functional/model_test.rb +3 -1
  73. data/test/functional/operating_system_test.rb +3 -1
  74. data/test/functional/personal_access_token_test.rb +4 -4
  75. data/test/functional/ping_test.rb +33 -0
  76. data/test/functional/realm_test.rb +11 -0
  77. data/test/functional/registration_test.rb +8 -0
  78. data/test/functional/report_template_test.rb +11 -0
  79. data/test/functional/settings_test.rb +4 -4
  80. data/test/functional/template_test.rb +87 -48
  81. data/test/functional/user_mail_notification_test.rb +3 -3
  82. data/test/functional/user_test.rb +11 -0
  83. data/test/functional/usergroup_test.rb +3 -1
  84. data/test/test_helper.rb +1 -1
  85. data/test/unit/apipie_resource_mock.rb +1 -39
  86. data/test/unit/architecture_test.rb +10 -10
  87. data/test/unit/bookmark_test.rb +10 -14
  88. data/test/unit/commands_test.rb +1 -2
  89. data/test/unit/compute_profile_test.rb +10 -10
  90. data/test/unit/config_report_test.rb +1 -0
  91. data/test/unit/helpers/command.rb +0 -8
  92. data/test/unit/host_test.rb +14 -61
  93. data/test/unit/hostgroup_test.rb +7 -26
  94. data/test/unit/id_resolver_test.rb +0 -28
  95. data/test/unit/mail_notification_test.rb +4 -4
  96. data/test/unit/model_test.rb +47 -47
  97. data/test/unit/operating_system_test.rb +10 -16
  98. data/test/unit/option_builders_test.rb +88 -83
  99. data/test/unit/settings_test.rb +4 -4
  100. data/test/unit/smart_proxy_test.rb +0 -12
  101. data/test/unit/usergroup_test.rb +10 -10
  102. metadata +115 -128
  103. data/lib/hammer_cli_foreman/command_extensions/puppet_environment.rb +0 -29
  104. data/lib/hammer_cli_foreman/command_extensions/puppet_environments.rb +0 -29
  105. data/lib/hammer_cli_foreman/config_group.rb +0 -45
  106. data/lib/hammer_cli_foreman/option_sources/puppet_environment_params.rb +0 -59
  107. data/lib/hammer_cli_foreman/puppet_class.rb +0 -61
  108. data/lib/hammer_cli_foreman/puppet_environment.rb +0 -65
  109. data/lib/hammer_cli_foreman/smart_class_parameter.rb +0 -189
  110. data/test/functional/config_group_test.rb +0 -50
  111. data/test/functional/proxy_test.rb +0 -86
  112. data/test/functional/smart_class_parameter_test.rb +0 -97
  113. data/test/reports/TEST-Minitest-Result.xml +0 -4344
  114. data/test/unit/config_group_test.rb +0 -82
  115. data/test/unit/puppet_class_test.rb +0 -72
  116. data/test/unit/puppet_environment_test.rb +0 -114
  117. data/test/unit/smart_class_parameter_test.rb +0 -113
@@ -1,7 +1,5 @@
1
1
  require 'hammer_cli_foreman/fact'
2
2
  require 'hammer_cli_foreman/config_report'
3
- require 'hammer_cli_foreman/puppet_class'
4
- require 'hammer_cli_foreman/smart_class_parameter'
5
3
  require 'hammer_cli_foreman/interface'
6
4
  require 'hammer_cli_foreman/hosts/common_update_options'
7
5
  require 'hammer_cli_foreman/compute_resource/register_compute_resources'
@@ -31,8 +29,6 @@ module HammerCLIForeman
31
29
  end
32
30
 
33
31
  build_options :without => [:include]
34
-
35
- extend_with(HammerCLIForeman::CommandExtensions::PuppetEnvironment.new)
36
32
  end
37
33
 
38
34
 
@@ -58,9 +54,6 @@ module HammerCLIForeman
58
54
  field nil, _("Host Group"), Fields::SingleReference, :key => :hostgroup, :display_field => 'title'
59
55
  field nil, _("Compute Resource"), Fields::SingleReference, :key => :compute_resource
60
56
  field nil, _("Compute Profile"), Fields::SingleReference, :key => :compute_profile, :hide_blank => true
61
- field nil, _("Puppet Environment"), Fields::SingleReference, :key => :environment
62
- field nil, _("Puppet CA Proxy"), Fields::SingleReference, :key => :puppet_ca_proxy
63
- field nil, _("Puppet Master Proxy"), Fields::SingleReference, :key => :puppet_proxy
64
57
  field :certname, _("Cert name")
65
58
  field :managed, _("Managed"), Fields::Boolean
66
59
 
@@ -171,18 +164,7 @@ module HammerCLIForeman
171
164
  end
172
165
 
173
166
 
174
- class PuppetRunCommand < HammerCLIForeman::SingleResourceCommand
175
- command_name "puppetrun"
176
- resource :puppet_hosts
177
- action :puppetrun
178
-
179
- def execute
180
- warn _('The puppetrun feature has been removed, however you can use the Remote Execution Plugin to run Puppet commands')
181
- HammerCLI::EX_SOFTWARE
182
- end
183
-
184
- build_options
185
- end
167
+
186
168
 
187
169
 
188
170
  class FactsCommand < HammerCLIForeman::AssociatedResourceListCommand
@@ -202,23 +184,6 @@ module HammerCLIForeman
202
184
  build_options
203
185
  end
204
186
 
205
-
206
- class PuppetClassesCommand < HammerCLIForeman::ListCommand
207
- command_name "puppet-classes"
208
- resource :puppetclasses
209
-
210
- output HammerCLIForeman::PuppetClass::ListCommand.output_definition
211
-
212
- def send_request
213
- HammerCLIForeman::PuppetClass::ListCommand.unhash_classes(super)
214
- end
215
-
216
- build_options do |o|
217
- o.without(:hostgroup_id, :environment_id)
218
- o.expand.only(:hosts)
219
- end
220
- end
221
-
222
187
  class ConfigReportsCommand < HammerCLIForeman::ListCommand
223
188
  command_name 'config-reports'
224
189
  resource :config_reports, :index
@@ -304,7 +269,6 @@ module HammerCLIForeman
304
269
  end
305
270
  end
306
271
 
307
- extend_with(HammerCLIForeman::CommandExtensions::PuppetEnvironment.new)
308
272
  extend_with(HammerCLIForeman::CommandExtensions::Hosts::Help::Interfaces.new)
309
273
  extend_with(HammerCLIForeman::CommandExtensions::Hosts::Help::ComputeResources.custom(add_host_specific_attrs: true).new)
310
274
  end
@@ -335,7 +299,6 @@ module HammerCLIForeman
335
299
  sources
336
300
  end
337
301
 
338
- extend_with(HammerCLIForeman::CommandExtensions::PuppetEnvironment.new)
339
302
  extend_with(HammerCLIForeman::CommandExtensions::Hosts::Help::Interfaces.new)
340
303
  extend_with(HammerCLIForeman::CommandExtensions::Hosts::Help::ComputeResources.custom(add_host_specific_attrs: true).new)
341
304
  end
@@ -468,15 +431,6 @@ module HammerCLIForeman
468
431
  build_options without: [:power_action]
469
432
  end
470
433
 
471
- class SCParamsCommand < HammerCLIForeman::SmartClassParametersList
472
- build_options_for :hosts
473
-
474
- def validate_options
475
- super
476
- validator.any(:option_host_name, :option_host_id).required
477
- end
478
- end
479
-
480
434
  class RebuildConfigCommand < HammerCLIForeman::SingleResourceCommand
481
435
  action :rebuild_config
482
436
  command_name "rebuild-config"
@@ -1,28 +1,22 @@
1
- require 'hammer_cli_foreman/smart_class_parameter'
2
- require 'hammer_cli_foreman/puppet_class'
3
-
4
1
  module HammerCLIForeman
5
2
 
6
3
  module HostgroupUpdateCreateCommons
7
4
 
8
5
  def self.included(base)
9
- base.option "--puppet-class-ids", "PUPPETCLASS_IDS", _("List of puppetclass ids"),
10
- :format => HammerCLI::Options::Normalizers::List.new,
11
- :attribute_name => :option_puppetclass_ids
12
- base.option "--puppet-classes", "PUPPET_CLASS_NAMES", "",
13
- :format => HammerCLI::Options::Normalizers::List.new,
14
- :attribute_name => :option_puppetclass_names
15
- base.option "--puppet-ca-proxy", "PUPPET_CA_PROXY_NAME", _("Name of puppet CA proxy")
16
- base.option "--puppet-proxy", "PUPPET_PROXY_NAME", _("Name of puppet proxy")
17
- base.option "--parent", "PARENT_NAME", _("Name of parent hostgroup")
18
- base.option ["--root-password", "--root-pass"], "ROOT_PASSWORD", _("Root password"),
19
- deprecated: { '--root-pass' => _("Use --root-password instead") }
20
- base.option ["--ask-root-password", "--ask-root-pass"], "ASK_ROOT_PW", "",
21
- format: HammerCLI::Options::Normalizers::Bool.new,
22
- deprecated: { '--ask-root-pass' => _("Use --ask-root-password instead") }
23
- base.option "--subnet6", "SUBNET6_NAME", _("Subnet IPv6 name")
6
+ base.option '--root-password', 'ROOT_PASSWORD', _('Root password')
7
+ base.option '--ask-root-password', 'ASK_ROOT_PW', '',
8
+ format: HammerCLI::Options::Normalizers::Bool.new
24
9
 
25
10
  base.build_options without: %i[root_pass]
11
+
12
+ base.option_family associate: 'subnet6' do
13
+ child '--subnet6', 'SUBNET6_NAME', _('Subnet IPv6 name')
14
+ end
15
+
16
+ base.option_family associate: 'parent' do
17
+ child '--parent', 'PARENT_NAME', _('Name of parent hostgroup')
18
+ child '--parent-title', 'PARENT_TITLE', _('Title of parent hostgroup')
19
+ end
26
20
  end
27
21
 
28
22
  def self.ask_password
@@ -32,10 +26,8 @@ module HammerCLIForeman
32
26
 
33
27
  def request_params
34
28
  params = super
35
- params['hostgroup']["parent_id"] ||= resolver.hostgroup_id('option_name' => option_parent) if option_parent
36
- params['hostgroup']["puppet_proxy_id"] ||= proxy_id(option_puppet_proxy) if option_puppet_proxy
37
- params['hostgroup']["puppet_ca_proxy_id"] ||= proxy_id(option_puppet_ca_proxy) if option_puppet_ca_proxy
38
-
29
+ params['hostgroup']['parent_id'] ||= resolver.hostgroup_id('option_name' => option_parent) if option_parent
30
+ params['hostgroup']['parent_id'] ||= resolver.hostgroup_id('option_title' => option_parent_title) if option_parent_title
39
31
  params['hostgroup']['root_pass'] = option_root_password if option_root_password
40
32
  params['hostgroup']['root_pass'] = HammerCLIForeman::HostgroupUpdateCreateCommons::ask_password if option_ask_root_password
41
33
 
@@ -61,7 +53,6 @@ module HammerCLIForeman
61
53
  field :name, _("Name")
62
54
  field :title, _("Title")
63
55
  field nil, _("Operating System"), Fields::SingleReference, :key => :operatingsystem
64
- field nil, _("Puppet Environment"), Fields::SingleReference, :key => :environment
65
56
  field nil, _("Model"), Fields::SingleReference, :key => :model
66
57
  end
67
58
 
@@ -75,13 +66,10 @@ module HammerCLIForeman
75
66
  field :id, _("Id")
76
67
  field :name, _("Name")
77
68
  field :title, _("Title")
78
- field nil, _("Puppet Environment"), Fields::SingleReference, :key => :environment
79
69
  field nil, _("Model"), Fields::SingleReference, :key => :model
80
70
 
81
71
  field :description, _("Description"), Fields::LongText, :hide_blank => true
82
72
  field nil, _("Parent"), Fields::SingleReference, :key => :parent, :hide_blank => true
83
- field nil, _("Puppet CA Proxy"), Fields::SingleReference, :key => :puppet_ca_proxy
84
- field nil, _("Puppet Master Proxy"), Fields::SingleReference, :key => :puppet_proxy
85
73
  field nil, _("Compute Profile"), Fields::SingleReference, :key => :compute_profile
86
74
  field nil, _("Compute Resource"), Fields::SingleReference, :key => :compute_resource
87
75
  label _('Network') do
@@ -97,7 +85,6 @@ module HammerCLIForeman
97
85
  field nil, _("Partition Table"), Fields::SingleReference, :key => :ptable
98
86
  field :pxe_loader, _("PXE Loader"), Fields::Field, :hide_blank => true
99
87
  end
100
- HammerCLIForeman::References.puppetclasses(self)
101
88
  HammerCLIForeman::References.parameters(self)
102
89
  HammerCLIForeman::References.taxonomies(self)
103
90
  end
@@ -111,8 +98,6 @@ module HammerCLIForeman
111
98
 
112
99
  success_message _("Hostgroup created.")
113
100
  failure_message _("Could not create the hostgroup")
114
-
115
- extend_with(HammerCLIForeman::CommandExtensions::PuppetEnvironment.new)
116
101
  end
117
102
 
118
103
 
@@ -121,8 +106,6 @@ module HammerCLIForeman
121
106
 
122
107
  success_message _("Hostgroup updated.")
123
108
  failure_message _("Could not update the hostgroup")
124
-
125
- extend_with(HammerCLIForeman::CommandExtensions::PuppetEnvironment.new)
126
109
  end
127
110
 
128
111
 
@@ -133,24 +116,6 @@ module HammerCLIForeman
133
116
  build_options
134
117
  end
135
118
 
136
-
137
- class PuppetClassesCommand < HammerCLIForeman::ListCommand
138
- command_name "puppet-classes"
139
- resource :puppetclasses
140
-
141
- output HammerCLIForeman::PuppetClass::ListCommand.output_definition
142
-
143
- def send_request
144
- HammerCLIForeman::PuppetClass::ListCommand.unhash_classes(super)
145
- end
146
-
147
- build_options do |o|
148
- o.without(:host_id, :environment_id)
149
- o.expand.only(:hostgroups)
150
- end
151
- end
152
-
153
-
154
119
  class SetParameterCommand < HammerCLIForeman::Parameter::SetCommand
155
120
  desc _("Create or update parameter for a hostgroup")
156
121
 
@@ -170,15 +135,6 @@ module HammerCLIForeman
170
135
  build_options
171
136
  end
172
137
 
173
- class SCParamsCommand < HammerCLIForeman::SmartClassParametersList
174
- build_options_for :hostgroups
175
-
176
- def validate_options
177
- super
178
- validator.any(:option_hostgroup_name, :option_hostgroup_id).required
179
- end
180
- end
181
-
182
138
  class RebuildConfigCommand < HammerCLIForeman::SingleResourceCommand
183
139
  action :rebuild_config
184
140
  command_name "rebuild-config"
@@ -3,33 +3,18 @@ module HammerCLIForeman
3
3
  module CommonUpdateOptions
4
4
 
5
5
  def self.included(base)
6
- base.option "--owner", "OWNER_LOGIN", _("Login of the owner"),
7
- :attribute_name => :option_user_login
8
- base.option "--owner-id", "OWNER_ID", _("ID of the owner"),
9
- :attribute_name => :option_owner_id
10
-
6
+ base.option_family do
7
+ parent '--owner-id', 'OWNER_ID', _('ID of the owner'),
8
+ attribute_name: :option_owner_id
9
+ child '--owner', 'OWNER_LOGIN', _('Login of the owner'),
10
+ attribute_name: :option_user_login
11
+ end
11
12
  base.option "--root-password", "ROOT_PW",
12
13
  _("Required if host is managed and value is not inherited from host group or default password in settings")
13
14
 
14
15
  base.option "--ask-root-password", "ASK_ROOT_PW", " ",
15
16
  :format => HammerCLI::Options::Normalizers::Bool.new
16
17
 
17
- base.option '--puppet-proxy', 'PUPPET_PROXY_NAME', '',
18
- referenced_resource: 'puppet_proxy',
19
- aliased_resource: 'puppet_proxy'
20
- base.option '--puppet-ca-proxy', 'PUPPET_CA_PROXY_NAME', '',
21
- referenced_resource: 'puppet_ca_proxy',
22
- aliased_resource: 'puppet_ca_proxy'
23
- base.option_family(
24
- format: HammerCLI::Options::Normalizers::List.new,
25
- aliased_resource: 'puppet-class',
26
- description: 'Names/Ids of associated puppet classes'
27
- ) do
28
- parent '--puppet-class-ids', 'PUPPET_CLASS_IDS', '',
29
- attribute_name: :option_puppetclass_ids
30
- child '--puppet-classes', 'PUPPET_CLASS_NAMES', '',
31
- attribute_name: :option_puppetclass_names
32
- end
33
18
  bme_options = {}
34
19
  bme_options[:default] = 'true' if base.action.to_sym == :create
35
20
 
@@ -56,7 +41,7 @@ module HammerCLIForeman
56
41
  :capabilities, :flavour_ref, :image_ref, :start,
57
42
  :network, :cpus, :memory, :provider, :type, :tenant_id, :image_id,
58
43
  # ----------------------------------------------------------------------------------
59
- :puppet_class_ids, :host_parameters_attributes, :interfaces_attributes, :root_pass]
44
+ :host_parameters_attributes, :interfaces_attributes, :root_pass]
60
45
  end
61
46
 
62
47
  def self.ask_password
@@ -69,12 +54,6 @@ module HammerCLIForeman
69
54
  owner_id = owner_id(option_user_login, params['host']['owner_type'])
70
55
  params['host']['owner_id'] ||= owner_id unless owner_id.nil?
71
56
 
72
- puppet_proxy_id = proxy_id(option_puppet_proxy)
73
- params['host']['puppet_proxy_id'] ||= puppet_proxy_id unless puppet_proxy_id.nil?
74
-
75
- puppet_ca_proxy_id = proxy_id(option_puppet_ca_proxy)
76
- params['host']['puppet_ca_proxy_id'] ||= puppet_ca_proxy_id unless puppet_ca_proxy_id.nil?
77
-
78
57
  if action == :create
79
58
  params['host']['build'] = true if option_build.nil?
80
59
  params['host']['managed'] = true if option_managed.nil?
@@ -134,11 +113,11 @@ module HammerCLIForeman
134
113
 
135
114
  private
136
115
 
137
- def owner_id(name, type = 'User')
116
+ def owner_id(name, type)
138
117
  return unless name
139
- return resolver.user_id('option_login' => name) if type == 'User'
118
+ return resolver.usergroup_id('option_name' => name) if type == 'Usergroup'
140
119
 
141
- resolver.usergroup_id('option_name' => name)
120
+ resolver.user_id('option_login' => name)
142
121
  end
143
122
 
144
123
  def proxy_id(name)
@@ -1,14 +1,12 @@
1
1
  module HammerCLIForeman
2
2
 
3
3
  class Searchable
4
- attr_reader :name, :description, :format
4
+ attr_reader :name, :description
5
5
 
6
6
  def initialize(name, description, options={})
7
7
  @name = name
8
8
  @description = description
9
9
  @editable = options[:editable].nil? ? true : options[:editable]
10
- @format = options[:format]
11
- @parent = options[:parent]
12
10
  end
13
11
 
14
12
  def plural_name
@@ -18,10 +16,6 @@ module HammerCLIForeman
18
16
  def editable?
19
17
  @editable
20
18
  end
21
-
22
- def parent?
23
- @parent
24
- end
25
19
  end
26
20
 
27
21
  class Searchables
@@ -42,8 +36,6 @@ module HammerCLIForeman
42
36
  :compute_resource => [ s_name(_("Compute resource name")) ],
43
37
  :compute_profile => [ s_name(_("Compute profile name")) ],
44
38
  :domain => [ s_name(_("Domain name")) ],
45
- :environment => [s_name(_('Puppet environment name'))],
46
- :puppet_environment => [s_name(_('Puppet environment name'))],
47
39
  :fact_value => [],
48
40
  :filter => [],
49
41
  :host => [ s_name(_("Host name")) ],
@@ -66,7 +58,6 @@ module HammerCLIForeman
66
58
  :override_value => [],
67
59
  :ptable => [ s_name(_("Partition table name")) ],
68
60
  :proxy => [ s_name(_("Proxy name")) ],
69
- :puppetclass => [ s_name(_("Puppet class name")) ],
70
61
  :config_report => [],
71
62
  :role => [ s_name(_("User role name")) ],
72
63
  :setting => [ s_name(_("Setting name"), :editable => false) ],
@@ -74,7 +65,6 @@ module HammerCLIForeman
74
65
  :template => [],
75
66
  :user => [ s("login", _("User's login to search by")) ],
76
67
  :common_parameter => [ s_name(_("Common parameter name")) ],
77
- :smart_class_parameter => [ s_name(_("Smart class parameter name"), :editable => false) ],
78
68
  :template_combination => [],
79
69
  :compute_attribute => []
80
70
  }
@@ -129,49 +119,17 @@ module HammerCLIForeman
129
119
  scoped_options
130
120
  end
131
121
 
132
- def puppetclass_ids(options)
133
- resource_name = :puppetclasses
134
- resource = @api.resource(resource_name)
135
- results = if (ids = options[HammerCLI.option_accessor_name("ids")])
136
- ids
137
- elsif (ids = nil_from_searchables(resource_name, options, :plural => true))
138
- ids
139
- elsif options_not_set?(resource, options)
140
- raise MissingSearchOptions.new(_("Missing options to search %s") % resource.name, resource)
141
- elsif options_empty?(resource, options)
142
- []
143
- else
144
- require('hammer_cli_foreman/puppet_class')
145
- results = HammerCLIForeman::PuppetClass::ListCommand.unhash_classes(
146
- resolved_call(resource_name, :index, options, :multi)
147
- )
148
- raise ResolverError.new(_("one of %s not found.") % resource.name, resource) if results.count < expected_record_count(options, resource, :multi)
149
-
150
- results.map { |r| r['id'] }
151
- end
152
- end
153
-
154
- def environment_id(options)
155
- puppet_environment_id(options)
156
- end
157
-
158
- def puppet_environment_id(options)
159
- get_id(:environments, options)
160
- end
161
-
162
- def environment_ids(options)
163
- puppet_environment_ids(options)
164
- end
165
-
166
- def puppet_environment_ids(options)
167
- get_ids(:environments, options)
168
- end
169
-
170
122
  def searchables(resource)
171
123
  resource = @api.resource(resource) if resource.is_a? Symbol
172
124
  @searchables.for(resource)
173
125
  end
174
126
 
127
+ def template_kind_id(options = {})
128
+ name = options['option_type'] == 'snippet' ? nil : options['option_type']
129
+ options['option_name'] = name
130
+ get_id(:template_kinds, options)
131
+ end
132
+
175
133
  protected
176
134
 
177
135
  def define_id_finders
@@ -331,17 +289,6 @@ module HammerCLIForeman
331
289
  0
332
290
  end
333
291
 
334
- # puppet class search results are in non-standard format
335
- # and needs to be un-hashed first
336
- def puppetclass_id(options)
337
- return options[HammerCLI.option_accessor_name("id")] if options[HammerCLI.option_accessor_name("id")]
338
- resource = @api.resource(:puppetclasses)
339
- results = find_resource_raw(:puppetclasses, options)
340
- require('hammer_cli_foreman/puppet_class')
341
- results = HammerCLIForeman::PuppetClass::ListCommand.unhash_classes(results)
342
- pick_result(results, resource)['id']
343
- end
344
-
345
292
  def options_empty?(resource, options)
346
293
  searchables(resource).all? do |s|
347
294
  values = options[HammerCLI.option_accessor_name(s.plural_name.to_s)]
@@ -356,14 +303,6 @@ module HammerCLIForeman
356
303
  end
357
304
  end
358
305
 
359
- def create_smart_class_parameters_search_options(options, mode = nil)
360
- search_options = {}
361
- value = options[HammerCLI.option_accessor_name('name')]
362
- search_options[:search] = "key = \"#{value}\""
363
- search_options[:puppetclass_id] = puppetclass_id(scoped_options("puppetclass", options))
364
- search_options
365
- end
366
-
367
306
  # @param mode [Symbol] mode in which ids are searched :single, :multi, nil for old beahvior
368
307
  def create_search_options(options, resource, mode = nil)
369
308
  searchables(resource).each do |s|
@@ -36,7 +36,6 @@ module HammerCLIForeman
36
36
  HammerCLIForeman::References.partition_tables(self)
37
37
  HammerCLIForeman::References.domains(self)
38
38
  HammerCLIForeman::References.realms(self)
39
- HammerCLIForeman::References.environments(self)
40
39
  HammerCLIForeman::References.hostgroups(self)
41
40
  HammerCLIForeman::References.parameters(self)
42
41
  collection :organizations, _("Organizations"), :numbered => false, :hide_blank => true do
@@ -58,8 +57,6 @@ module HammerCLIForeman
58
57
  failure_message _("Could not create the location")
59
58
 
60
59
  build_options
61
-
62
- extend_with(HammerCLIForeman::CommandExtensions::PuppetEnvironments.new)
63
60
  end
64
61
 
65
62
 
@@ -72,8 +69,6 @@ module HammerCLIForeman
72
69
  failure_message _("Could not update the location")
73
70
 
74
71
  build_options
75
-
76
- extend_with(HammerCLIForeman::CommandExtensions::PuppetEnvironments.new)
77
72
  end
78
73
 
79
74
 
@@ -112,7 +107,6 @@ module HammerCLIForeman
112
107
  end
113
108
 
114
109
  HammerCLIForeman::AssociatingCommands::Hostgroup.extend_command(self)
115
- HammerCLIForeman::AssociatingCommands::PuppetEnvironment.extend_command(self)
116
110
  HammerCLIForeman::AssociatingCommands::Domain.extend_command(self)
117
111
  HammerCLIForeman::AssociatingCommands::Medium.extend_command(self)
118
112
  HammerCLIForeman::AssociatingCommands::Subnet.extend_command(self)
@@ -11,7 +11,7 @@ module HammerCLIForeman
11
11
  field :name, _("Name")
12
12
  end
13
13
 
14
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
14
+ build_options
15
15
  end
16
16
 
17
17
  class InfoCommand < HammerCLIForeman::InfoCommand
@@ -22,7 +22,7 @@ module HammerCLIForeman
22
22
  field :subscription_type, _("Subscription type")
23
23
  end
24
24
 
25
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
25
+ build_options
26
26
  end
27
27
 
28
28
  autoload_subcommands
@@ -13,7 +13,7 @@ module HammerCLIForeman
13
13
  field :hardware_model, _("HW model")
14
14
  end
15
15
 
16
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
16
+ build_options
17
17
  end
18
18
 
19
19
 
@@ -23,7 +23,7 @@ module HammerCLIForeman
23
23
  HammerCLIForeman::References.timestamps(self)
24
24
  end
25
25
 
26
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
26
+ build_options
27
27
  end
28
28
 
29
29
 
@@ -31,14 +31,14 @@ module HammerCLIForeman
31
31
  success_message _("Hardware model created.")
32
32
  failure_message _("Could not create the hardware model")
33
33
 
34
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
34
+ build_options
35
35
  end
36
36
 
37
37
  class DeleteCommand < HammerCLIForeman::DeleteCommand
38
38
  success_message _("Hardware model deleted.")
39
39
  failure_message _("Could not delete the hardware model")
40
40
 
41
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
41
+ build_options
42
42
  end
43
43
 
44
44
 
@@ -46,7 +46,7 @@ module HammerCLIForeman
46
46
  success_message _("Hardware model updated.")
47
47
  failure_message _("Could not update the hardware model")
48
48
 
49
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
49
+ build_options
50
50
  end
51
51
 
52
52
 
@@ -13,7 +13,7 @@ module HammerCLIForeman
13
13
  field :family, _("Family")
14
14
  end
15
15
 
16
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
16
+ build_options
17
17
  end
18
18
 
19
19
 
@@ -36,7 +36,7 @@ module HammerCLIForeman
36
36
  HammerCLIForeman::References.parameters(self)
37
37
  end
38
38
 
39
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
39
+ build_options
40
40
  end
41
41
 
42
42
 
@@ -44,7 +44,7 @@ module HammerCLIForeman
44
44
  success_message _("Operating system created.")
45
45
  failure_message _("Could not create the operating system")
46
46
 
47
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
47
+ build_options
48
48
  end
49
49
 
50
50
 
@@ -52,7 +52,7 @@ module HammerCLIForeman
52
52
  success_message _("Operating system updated.")
53
53
  failure_message _("Could not update the operating system")
54
54
 
55
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
55
+ build_options
56
56
  end
57
57
 
58
58
 
@@ -60,7 +60,7 @@ module HammerCLIForeman
60
60
  success_message _("Operating system deleted.")
61
61
  failure_message _("Could not delete the operating system")
62
62
 
63
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
63
+ build_options
64
64
  end
65
65
 
66
66
 
@@ -76,7 +76,7 @@ module HammerCLIForeman
76
76
  validator.any(:option_operatingsystem_id, :option_operatingsystem_title).required
77
77
  end
78
78
 
79
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
79
+ build_options
80
80
  end
81
81
 
82
82
 
@@ -90,7 +90,7 @@ module HammerCLIForeman
90
90
  validator.any(:option_operatingsystem_id, :option_operatingsystem_title).required
91
91
  end
92
92
 
93
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
93
+ build_options
94
94
  end
95
95
 
96
96
 
@@ -156,8 +156,8 @@ module HammerCLIForeman
156
156
  HammerCLI::EX_OK
157
157
  end
158
158
 
159
- build_options expand: { except: %i[organizations locations] },
160
- without: %i[organization_id location_id template_kind_id type]
159
+ build_options without: [:template_kind_id, :type]
160
+
161
161
  end
162
162
 
163
163
 
@@ -192,7 +192,7 @@ module HammerCLIForeman
192
192
  {"operatingsystem_id" => option_id}
193
193
  end
194
194
 
195
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
195
+ build_options
196
196
  end
197
197
 
198
198