hammer_cli_foreman 0.1.3 → 0.1.4

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 (61) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes.md +18 -0
  3. data/lib/hammer_cli_foreman.rb +4 -0
  4. data/lib/hammer_cli_foreman/auth_source.rb +10 -0
  5. data/lib/hammer_cli_foreman/auth_source_ldap.rb +70 -0
  6. data/lib/hammer_cli_foreman/commands.rb +47 -3
  7. data/lib/hammer_cli_foreman/credentials.rb +35 -4
  8. data/lib/hammer_cli_foreman/exceptions.rb +10 -1
  9. data/lib/hammer_cli_foreman/external_usergroup.rb +83 -0
  10. data/lib/hammer_cli_foreman/host.rb +26 -22
  11. data/lib/hammer_cli_foreman/hostgroup.rb +12 -5
  12. data/lib/hammer_cli_foreman/i18n.rb +4 -0
  13. data/lib/hammer_cli_foreman/id_resolver.rb +81 -13
  14. data/lib/hammer_cli_foreman/operating_system.rb +5 -44
  15. data/lib/hammer_cli_foreman/option_builders.rb +64 -5
  16. data/lib/hammer_cli_foreman/organization.rb +3 -3
  17. data/lib/hammer_cli_foreman/param_filters.rb +18 -2
  18. data/lib/hammer_cli_foreman/references.rb +9 -1
  19. data/lib/hammer_cli_foreman/role.rb +2 -5
  20. data/lib/hammer_cli_foreman/usergroup.rb +4 -0
  21. data/lib/hammer_cli_foreman/version.rb +1 -1
  22. data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  23. data/locale/de/hammer-cli-foreman.po +2169 -0
  24. data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  25. data/locale/en/hammer-cli-foreman.po +1 -1
  26. data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  27. data/locale/en_GB/hammer-cli-foreman.po +254 -81
  28. data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  29. data/locale/es/hammer-cli-foreman.po +268 -94
  30. data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  31. data/locale/fr/hammer-cli-foreman.po +258 -84
  32. data/locale/hammer-cli-foreman.pot +428 -321
  33. data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  34. data/locale/it/hammer-cli-foreman.po +2168 -0
  35. data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  36. data/locale/ja/hammer-cli-foreman.po +2167 -0
  37. data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  38. data/locale/ko/hammer-cli-foreman.po +2167 -0
  39. data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  40. data/locale/pt_BR/hammer-cli-foreman.po +2167 -0
  41. data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  42. data/locale/ru/hammer-cli-foreman.po +2166 -0
  43. data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  44. data/locale/zh_CN/hammer-cli-foreman.po +2166 -0
  45. data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  46. data/locale/zh_TW/hammer-cli-foreman.po +2166 -0
  47. data/test/unit/auth_source_ldap_test.rb +95 -0
  48. data/test/unit/credentials_test.rb +20 -7
  49. data/test/unit/data/1.6/foreman_api.json +1 -1
  50. data/test/unit/data/1.6/foreman_api_back.json +1 -0
  51. data/test/unit/data/1.6/whatever.json +1 -0
  52. data/test/unit/external_usergroup_test.rb +103 -0
  53. data/test/unit/helpers/command.rb +5 -1
  54. data/test/unit/host_test.rb +4 -4
  55. data/test/unit/hostgroup_test.rb +5 -5
  56. data/test/unit/media_test.rb +2 -2
  57. data/test/unit/operating_system_test.rb +7 -1
  58. data/test/unit/param_filters_test.rb +65 -0
  59. data/test/unit/smart_class_parameter_test.rb +1 -1
  60. metadata +335 -309
  61. data/lib/hammer_cli_foreman/smart_variables.rb +0 -111
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71742ee24003cbea249ed6b8fcc320a387f0cda6
4
- data.tar.gz: 28009f6cd73936556d260a41d2867ad556fc4dfb
3
+ metadata.gz: 7c465b8794294776b0e5c79cad51f615097d8731
4
+ data.tar.gz: f5fb6f3c7d7bc2a30d3aefdcff70b7f53697225d
5
5
  SHA512:
6
- metadata.gz: 4d28c63a5bbef34bd0366537402327574bf25df138b52e73acaa63033a089f90d774869a33919a81f985a4bc8448c46b5b1ba1ffda74b0491ec198e6f9f2bcbb
7
- data.tar.gz: 4488cc268352a448ad178da5f76d4e1508391ad4d2a1a46cf6f7721c4b47b03a584f50163969ff39313498ace2dbe66ef16ebff5bbdf7abbb007bd5c086acb0b
6
+ metadata.gz: 65664eb6db87d9aad63d1b02474e5511bd45824e07f65f648e27bbc5d6092c4c7a53a56f5775cb2f19587a477e73e7771119304e74f1d588eb9d6c7ba09aa9a2
7
+ data.tar.gz: 386f80dc7f518c543c863228bdc0b73cdaa1ad1b128cbf4b72aa2413ce69d9f91e5a1c9fc1149f935d772042cdd29702d9ed9ad2bf9b3822fbd853638b6fdea6
data/doc/release_notes.md CHANGED
@@ -1,6 +1,24 @@
1
1
  Release notes
2
2
  =============
3
3
 
4
+ ### 0.1.4 (2014-12-11)
5
+ * sending puppet class ids ([#8651](http://projects.theforeman.org/issues/8651))
6
+ * setting --puppet-class-ids on host create/update throws api exception ([#8642](http://projects.theforeman.org/issues/8642))
7
+ * adding name equivalents to params in host/hostgroup create/update ([#8299](http://projects.theforeman.org/issues/8299))
8
+ * id resolution for associted resources ([#8246](http://projects.theforeman.org/issues/8246))
9
+ * added missing search option error message ([#5556](http://projects.theforeman.org/issues/5556))
10
+ * OSs referenced by title ([#8247](http://projects.theforeman.org/issues/8247))
11
+ * credentials definition moved to ApipieBindings ([#7408](http://projects.theforeman.org/issues/7408))
12
+ * listing filters for roles always fail with an exception ([#7913](http://projects.theforeman.org/issues/7913))
13
+ * api for operating systems now uses field 'title' ([#7917](http://projects.theforeman.org/issues/7917))
14
+ * i18n - add zh_CN language
15
+ * i18n - add de, it, pt_BR, zh_TW, ru, ja, ko languages
16
+ * external user groups CLI ([#6879](http://projects.theforeman.org/issues/6879))
17
+ * moved LDAP auth sources to separate command
18
+ * adds command to manage ldap auth sources ([#2924](http://projects.theforeman.org/issues/2924))
19
+ * avoid locale domain name conflict ([#7262](http://projects.theforeman.org/issues/7262))
20
+
21
+
4
22
  ### 0.1.3 (2014-08-20)
5
23
  * Update foreman.yml
6
24
  * Update the zanata.xml file to push to de-DE and es-ES ([#7112](http://projects.theforeman.org/issues/7112))
@@ -35,6 +35,10 @@ module HammerCLIForeman
35
35
  'HammerCLIForeman::Architecture', 'hammer_cli_foreman/architecture'
36
36
  )
37
37
 
38
+ HammerCLI::MainCommand.lazy_subcommand('auth-source', _("Manipulate auth sources."),
39
+ 'HammerCLIForeman::AuthSource', 'hammer_cli_foreman/auth_source'
40
+ )
41
+
38
42
  HammerCLI::MainCommand.lazy_subcommand('compute-resource', _("Manipulate compute resources."),
39
43
  'HammerCLIForeman::ComputeResource', 'hammer_cli_foreman/compute_resource'
40
44
  )
@@ -0,0 +1,10 @@
1
+ require 'hammer_cli_foreman/auth_source_ldap'
2
+
3
+ module HammerCLIForeman
4
+
5
+ class AuthSource < HammerCLIForeman::Command
6
+
7
+ subcommand 'ldap', HammerCLIForeman::AuthSourceLdap.desc, HammerCLIForeman::AuthSourceLdap
8
+ end
9
+
10
+ end
@@ -0,0 +1,70 @@
1
+ module HammerCLIForeman
2
+
3
+ class AuthSourceLdap < HammerCLIForeman::Command
4
+
5
+ resource :auth_source_ldaps
6
+ command_name 'ldap'
7
+ desc _("Manage LDAP auth sources.")
8
+
9
+
10
+ class ListCommand < HammerCLIForeman::ListCommand
11
+
12
+ output do
13
+ field :id , _("Id")
14
+ field :name , _("Name")
15
+ field :tls , _('LDAPS?')
16
+ field :port , _('Port')
17
+ field :type , _("Server Type")
18
+ end
19
+
20
+ build_options
21
+ end
22
+
23
+
24
+ class InfoCommand < HammerCLIForeman::InfoCommand
25
+
26
+ output ListCommand.output_definition do
27
+ field :account , _('Account Username')
28
+ field :base_dn , _('Base DN')
29
+ field :ldap_filter , _('LDAP filter')
30
+ field :onthefly_register , _('Automatically Create Accounts?')
31
+ field :attr_login , _('Login Name Attribute')
32
+ field :attr_firstname , _('First Name Attribute')
33
+ field :attr_lastname , _('Last Name Attribute')
34
+ field :attr_mail , _('Email Address Attribute')
35
+ field :attr_photo , _('Photo Attribute')
36
+ end
37
+
38
+ build_options
39
+ end
40
+
41
+
42
+ class CreateCommand < HammerCLIForeman::CreateCommand
43
+ success_message _("Auth source created")
44
+ failure_message _("Could not create the Auth Source")
45
+
46
+ build_options
47
+ end
48
+
49
+
50
+ class DeleteCommand < HammerCLIForeman::DeleteCommand
51
+ success_message _("Auth source deleted")
52
+ failure_message _("Could not delete the Auth Source")
53
+
54
+ build_options
55
+ end
56
+
57
+
58
+ class UpdateCommand < HammerCLIForeman::UpdateCommand
59
+ success_message _("Auth source updated")
60
+ failure_message _("Could not update the Auth Source")
61
+
62
+ build_options
63
+ end
64
+
65
+ autoload_subcommands
66
+ end
67
+
68
+ end
69
+
70
+
@@ -3,11 +3,16 @@ module HammerCLIForeman
3
3
  CONNECTION_NAME = 'foreman'
4
4
 
5
5
  RESOURCE_NAME_MAPPING = {
6
- :usergroup => :user_group
6
+ :usergroup => :user_group,
7
+ :usergroups => :user_groups,
8
+ :ptable => :partition_table,
9
+ :ptables => :partition_tables,
10
+ :puppetclass => :puppet_class,
11
+ :puppetclasses => :puppet_classes
7
12
  }
8
13
 
9
14
  def self.credentials
10
- @credentials ||= Credentials.new(
15
+ @credentials ||= BasicCredentials.new(
11
16
  :username => (HammerCLI::Settings.get(:_params, :username) || ENV['FOREMAN_USERNAME'] || HammerCLI::Settings.get(:foreman, :username)),
12
17
  :password => (HammerCLI::Settings.get(:_params, :password) || ENV['FOREMAN_PASSWORD'] || HammerCLI::Settings.get(:foreman, :password))
13
18
  )
@@ -25,6 +30,7 @@ module HammerCLIForeman
25
30
  config[:language] = HammerCLI::I18n.locale
26
31
  config[:timeout] = HammerCLI::Settings.get(:foreman, :request_timeout)
27
32
  config[:timeout] = -1 if (config[:timeout] && config[:timeout].to_i < 0)
33
+ config[:apidoc_authenticated] = false
28
34
  config
29
35
  end
30
36
 
@@ -54,7 +60,7 @@ module HammerCLIForeman
54
60
  end
55
61
 
56
62
  def self.param_to_resource(param_name)
57
- HammerCLIForeman.foreman_resource(param_name.gsub(/_id$/, ""), :singular => true)
63
+ HammerCLIForeman.foreman_resource(param_name.gsub(/_id[s]?$/, ""), :singular => true)
58
64
  end
59
65
 
60
66
  def self.collection_to_common_format(data)
@@ -146,6 +152,15 @@ module HammerCLIForeman
146
152
  end
147
153
  end
148
154
 
155
+ def get_resource_ids(resource, options={})
156
+ opts = resolver.scoped_options(resource.singular_name, all_options)
157
+ begin
158
+ resolver.send("#{resource.singular_name}_ids", opts)
159
+ rescue HammerCLIForeman::MissingSeachOptions => e
160
+ raise e unless (options[:required] == false)
161
+ end
162
+ end
163
+
149
164
  def self.resolver
150
165
  api = HammerCLI::Connection.get("foreman").api
151
166
  HammerCLIForeman::IdResolver.new(api, HammerCLIForeman::Searchables.new)
@@ -162,6 +177,25 @@ module HammerCLIForeman
162
177
 
163
178
  def send_request
164
179
  HammerCLIForeman.record_to_common_format(super)
180
+ rescue HammerCLIForeman::MissingSeachOptions => e
181
+
182
+ switches = self.class.find_options(:referenced_resource => e.resource.singular_name).map(&:long_switch)
183
+
184
+ if switches.empty?
185
+ error_message = _("Could not find %{resource}. Some search options were missing, please see --help.")
186
+ elsif switches.length == 1
187
+ error_message = _("Could not find %{resource}, please set option %{switches}.")
188
+ else
189
+ error_message = _("Could not find %{resource}, please set one of options %{switches}.")
190
+ end
191
+
192
+ raise MissingSeachOptions.new(
193
+ error_message % {
194
+ :resource => e.resource.singular_name,
195
+ :switches => switches.join(", ")
196
+ },
197
+ e.resource
198
+ )
165
199
  end
166
200
 
167
201
  def customized_options
@@ -175,6 +209,16 @@ module HammerCLIForeman
175
209
  params[HammerCLI.option_accessor_name(api_param.name)] = resource_id if resource_id
176
210
  end
177
211
  end
212
+
213
+ # resolve all '<resource_name>_ids' parameters if they are defined as options
214
+ IdArrayParamsFilter.new(:only_required => false).for_action(resource.action(action)).each do |api_param|
215
+ param_resource = HammerCLIForeman.param_to_resource(api_param.name)
216
+ if param_resource && respond_to?(HammerCLI.option_accessor_name("#{param_resource.singular_name}_ids"))
217
+ resource_ids = get_resource_ids(param_resource, :scoped => true, :required => api_param.required?)
218
+ params[HammerCLI.option_accessor_name(api_param.name)] = resource_ids if resource_ids
219
+ end
220
+ end
221
+
178
222
  # resolve 'id' parameter if it's defined as an option
179
223
  id_option_name = HammerCLI.option_accessor_name('id')
180
224
  params[id_option_name] ||= get_identifier if respond_to?(id_option_name)
@@ -1,18 +1,36 @@
1
+ require 'highline/import'
1
2
  module HammerCLIForeman
2
- class Credentials < HammerCLI::Apipie::AbstractCredentials
3
+ class BasicCredentials < ApipieBindings::AbstractCredentials
3
4
 
5
+ # Can keep username and passwords credentials and prompt for them when necessary
6
+ # @param [Hash] params
7
+ # @option params [String] :username when nil, user is prompted when the attribute is accessed
8
+ # @option params [String] :password when nil, user is prompted when the attribute is accessed
9
+ # @example use container with prompt
10
+ # c = HammerCLIForeman::BasicCredentials.new()
11
+ # c.username
12
+ # > [Foreman] Username: admin
13
+ # => "admin"
14
+ # @example use container with preset value
15
+ # c = HammerCLIForeman::BasicCredentials.new(:username => 'admin')
16
+ # c.username
17
+ # => "admin"
4
18
  def initialize(params={})
5
19
  @username = params[:username]
6
20
  @password = params[:password]
7
21
  end
8
22
 
23
+ # Get username. Prompt for it when not set
24
+ # @return [String]
9
25
  def username
10
- @username ||= ask_user(_("[Foreman] username: ")) if HammerCLI.interactive?
26
+ @username ||= ask_user(_("[Foreman] Username: ")) if HammerCLI.interactive?
11
27
  @username
12
28
  end
13
29
 
30
+ # Get password. Prompt for it when not set. Password characters are replaced with asterisks on the screen.
31
+ # @return [String]
14
32
  def password
15
- @password ||= ask_user(_("[Foreman] password for %s: ") % @username, true) if HammerCLI.interactive?
33
+ @password ||= ask_user(_("[Foreman] Password for %s: ") % username, true) if HammerCLI.interactive?
16
34
  @password
17
35
  end
18
36
 
@@ -21,16 +39,29 @@ module HammerCLIForeman
21
39
  end
22
40
 
23
41
  def clear
42
+ super
24
43
  @username = nil
25
44
  @password = nil
26
45
  end
27
46
 
47
+ # Convert credentials to hash usable for merging to RestClient configuration.
48
+ # @return [Hash]
28
49
  def to_params
29
50
  {
30
- :username => username,
51
+ :user => username,
31
52
  :password => password
32
53
  }
33
54
  end
34
55
 
56
+ private
57
+
58
+ def ask_user(prompt, silent=false)
59
+ if silent
60
+ ask(prompt) {|q| q.echo = false}
61
+ else
62
+ ask(prompt)
63
+ end
64
+ end
65
+
35
66
  end
36
67
  end
@@ -3,7 +3,16 @@ module HammerCLIForeman
3
3
  class OperationNotSupportedError < StandardError; end
4
4
 
5
5
  # Resolver exceptions
6
- class ResolverError < StandardError; end
6
+ class ResolverError < StandardError
7
+
8
+ attr_reader :resource
9
+
10
+ def initialize(msg, resource)
11
+ @resource = resource
12
+ super(msg)
13
+ end
14
+ end
15
+
7
16
  class MissingSeachOptions < ResolverError; end
8
17
 
9
18
  end
@@ -0,0 +1,83 @@
1
+ require 'hammer_cli_foreman/usergroup'
2
+
3
+ module HammerCLIForeman
4
+ class ExternalUsergroup < HammerCLIForeman::Command
5
+ resource :external_usergroups
6
+ desc _("View and manage user group's external user groups")
7
+
8
+ class ListCommand < HammerCLIForeman::ListCommand
9
+ output do
10
+ field :id, _("Id")
11
+ field :name, _("Name")
12
+ field :_auth_source, _("Auth source"), Fields::Reference
13
+ end
14
+
15
+ def extend_data(record)
16
+ key = record.keys.find{ |k| k =~ /^auth_source/ }
17
+ record['_auth_source'] = record[key]
18
+ record
19
+ end
20
+
21
+ build_options
22
+ end
23
+
24
+ class InfoCommand < HammerCLIForeman::InfoCommand
25
+ output ListCommand.output_definition
26
+
27
+ def extend_data(record)
28
+ key = record.keys.find{ |k| k =~ /^auth_source/ }
29
+ record['_auth_source'] = record[key]
30
+ record
31
+ end
32
+
33
+ build_options
34
+ end
35
+
36
+ class RefreshExternalUsergroupsCommand < HammerCLIForeman::ListCommand
37
+ action :refresh
38
+ command_name 'refresh'
39
+ desc _("Refresh external user group")
40
+
41
+ output do
42
+ field :name, _("Name")
43
+ field :_auth_source, _("Auth source")
44
+ end
45
+
46
+ def extend_data(record)
47
+ key = record.keys.find{ |k| k =~ /^auth_source/ }
48
+ record['_auth_source'] = record[key]
49
+ record
50
+ end
51
+
52
+ build_options
53
+ end
54
+
55
+
56
+ class CreateCommand < HammerCLIForeman::CreateCommand
57
+ success_message _("External user group created")
58
+ failure_message _("Could not create external user group")
59
+
60
+ build_options
61
+ end
62
+
63
+
64
+ class UpdateCommand < HammerCLIForeman::UpdateCommand
65
+ success_message _("External user group updated")
66
+ failure_message _("Could not update external user group")
67
+
68
+ build_options
69
+ end
70
+
71
+
72
+ class DeleteCommand < HammerCLIForeman::DeleteCommand
73
+ success_message _("External user group deleted")
74
+ failure_message _("Could not delete the external user group")
75
+
76
+ build_options
77
+ end
78
+
79
+ autoload_subcommands
80
+ end
81
+
82
+ end
83
+
@@ -9,19 +9,22 @@ module HammerCLIForeman
9
9
  module CommonHostUpdateOptions
10
10
 
11
11
  def self.included(base)
12
- base.option "--environment-id", "ENVIRONMENT_ID", " "
13
- base.option "--architecture-id", "ARCHITECTURE_ID", " "
14
- base.option "--domain-id", "DOMAIN_ID", " "
15
- base.option "--puppet-proxy-id", "PUPPET_PROXY_ID", " "
16
- base.option "--operatingsystem-id", "OPERATINGSYSTEM_ID", " "
17
- base.option "--partition-table-id", "PARTITION_TABLE_ID", " "
18
- base.option "--compute-resource-id", "COMPUTE_RESOURCE", " "
19
- base.option "--puppetclass-ids", "PUPPETCLASS_IDS", " ",
20
- :format => HammerCLI::Options::Normalizers::List.new
12
+ base.option "--owner", "OWNER_LOGIN", _("Login of the owner"),
13
+ :attribute_name => :option_user_login
14
+ base.option "--owner-id", "OWNER_ID", _("ID of the owner"),
15
+ :attribute_name => :option_user_id
16
+
21
17
  base.option "--root-password", "ROOT_PW", " "
22
18
  base.option "--ask-root-password", "ASK_ROOT_PW", " ",
23
19
  :format => HammerCLI::Options::Normalizers::Bool.new
24
20
 
21
+ base.option "--puppet-proxy", "PUPPET_PROXY_NAME", ""
22
+ base.option "--puppet-ca-proxy", "PUPPET_CA_PROXY_NAME", ""
23
+ base.option "--puppet-class-ids", "PUPPET_CLASS_IDS", "",
24
+ :format => HammerCLI::Options::Normalizers::List.new,
25
+ :attribute_name => :option_puppetclass_ids
26
+ base.option "--puppet-classes", "PUPPET_CLASS_NAMES", "",
27
+ :format => HammerCLI::Options::Normalizers::List.new
25
28
 
26
29
  bme_options = {}
27
30
  bme_options[:default] = 'true' if base.action.to_sym == :create
@@ -45,16 +48,11 @@ module HammerCLIForeman
45
48
  :format => HammerCLI::Options::Normalizers::Enum.new(['build', 'image'])
46
49
 
47
50
  base.build_options :without => [
48
- # - temporarily disabled params until they are fixed in API ------------------------
49
- # issue #3884
50
- :puppet_class_ids,
51
51
  # - temporarily disabled params that will be removed from the api ------------------
52
52
  :provision_method, :capabilities, :flavour_ref, :image_ref, :start,
53
53
  :network, :cpus, :memory, :provider, :type, :tenant_id, :image_id,
54
- # - avoids future conflicts as :root_pass is currently missing in the api docs
55
- :root_pass,
56
54
  # ----------------------------------------------------------------------------------
57
- :ptable_id, :host_parameters_attributes]
55
+ :puppet_class_ids, :host_parameters_attributes]
58
56
  end
59
57
 
60
58
  def self.ask_password
@@ -64,15 +62,14 @@ module HammerCLIForeman
64
62
 
65
63
  def request_params
66
64
  params = super
65
+ params['host']['owner_id'] ||= get_resource_id(HammerCLIForeman.foreman_resource(:users), :required => false, :scoped => true)
66
+ params['host']['puppet_proxy_id'] ||= proxy_id(option_puppet_proxy)
67
+ params['host']['puppet_ca_proxy_id'] ||= proxy_id(option_puppet_ca_proxy)
68
+ params['host']['puppetclass_ids'] = option_puppetclass_ids || puppet_class_ids(option_puppet_classes)
67
69
 
68
70
  params['host']['build'] = option_build unless option_build.nil?
69
71
  params['host']['managed'] = option_managed unless option_managed.nil?
70
72
  params['host']['enabled'] = option_enabled unless option_enabled.nil?
71
-
72
- params['host']['puppetclass_ids'] = option_puppetclass_ids unless option_puppetclass_ids.nil?
73
-
74
- params['host']['ptable_id'] = option_partition_table_id unless option_partition_table_id.nil?
75
- params['host']['compute_resource_id'] = option_compute_resource_id unless option_compute_resource_id.nil?
76
73
  params['host']['host_parameters_attributes'] = parameter_attributes
77
74
  params['host']['compute_attributes'] = option_compute_attributes || {}
78
75
  params['host']['compute_attributes']['volumes_attributes'] = nested_attributes(option_volume_list)
@@ -88,12 +85,19 @@ module HammerCLIForeman
88
85
  if option_ask_root_password
89
86
  params['host']['root_pass'] = HammerCLIForeman::CommonHostUpdateOptions::ask_password
90
87
  end
91
-
92
88
  params
93
89
  end
94
90
 
95
91
  private
96
92
 
93
+ def proxy_id(name)
94
+ resolver.smart_proxy_id('option_name' => name) if name
95
+ end
96
+
97
+ def puppet_class_ids(names)
98
+ resolver.puppetclass_ids('option_names' => names) if names
99
+ end
100
+
97
101
  def parameter_attributes
98
102
  return {} unless option_parameters
99
103
  option_parameters.collect do |key, value|
@@ -327,7 +331,7 @@ module HammerCLIForeman
327
331
  if option_managed
328
332
  validator.all(:option_environment_id, :option_architecture_id, :option_domain_id,
329
333
  :option_puppet_proxy_id, :option_operatingsystem_id,
330
- :option_partition_table_id).required
334
+ :option_ptable_id).required
331
335
  else
332
336
  # unmanaged host only requires environment
333
337
  validator.option(:option_environment_id).required