hammer_cli_foreman 2.3.2 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes.md +6 -3
  3. data/lib/hammer_cli_foreman/architecture.rb +5 -5
  4. data/lib/hammer_cli_foreman/bookmark.rb +6 -6
  5. data/lib/hammer_cli_foreman/command_extensions/status.rb +1 -1
  6. data/lib/hammer_cli_foreman/compute_profile.rb +5 -5
  7. data/lib/hammer_cli_foreman/config_group.rb +5 -5
  8. data/lib/hammer_cli_foreman/hosts/common_update_options.rb +1 -1
  9. data/lib/hammer_cli_foreman/mail_notification.rb +2 -2
  10. data/lib/hammer_cli_foreman/model.rb +5 -5
  11. data/lib/hammer_cli_foreman/operating_system.rb +10 -9
  12. data/lib/hammer_cli_foreman/option_builders.rb +2 -21
  13. data/lib/hammer_cli_foreman/settings.rb +3 -3
  14. data/lib/hammer_cli_foreman/usergroup.rb +5 -5
  15. data/lib/hammer_cli_foreman/version.rb +1 -1
  16. data/test/functional/architecture_test.rb +49 -0
  17. data/test/functional/bookmark_test.rb +20 -0
  18. data/test/functional/compute_profile_test.rb +43 -0
  19. data/test/functional/config_group_test.rb +50 -0
  20. data/test/functional/filter_test.rb +114 -47
  21. data/test/functional/host_test.rb +63 -2
  22. data/test/functional/mail_notification_test.rb +20 -0
  23. data/test/functional/model_test.rb +50 -0
  24. data/test/functional/operating_system_test.rb +51 -0
  25. data/test/functional/settings_test.rb +21 -0
  26. data/test/functional/status_test.rb +79 -13
  27. data/test/functional/usergroup_test.rb +51 -0
  28. data/test/reports/TEST-Minitest-Result.xml +4344 -0
  29. data/test/unit/apipie_resource_mock.rb +21 -0
  30. data/test/unit/architecture_test.rb +10 -1
  31. data/test/unit/bookmark_test.rb +99 -0
  32. data/test/unit/compute_profile_test.rb +87 -0
  33. data/test/unit/config_group_test.rb +10 -0
  34. data/test/unit/mail_notification_test.rb +53 -0
  35. data/test/unit/model_test.rb +10 -0
  36. data/test/unit/operating_system_test.rb +14 -1
  37. data/test/unit/settings_test.rb +4 -0
  38. data/test/unit/usergroup_test.rb +10 -0
  39. metadata +119 -101
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b30a6bc396c149912681a2a600c7dcc84fc5144b90b5b4b8cf45f57690bbaa39
4
- data.tar.gz: de18a4c812f92f1988791f404986a2e7b0c5464d401b001ddedee3c934a1f137
3
+ metadata.gz: efc47b1a544eaf1e63d7328b51210b5d0b4d153bb6ff35156a8e55b9527aa207
4
+ data.tar.gz: dd374b8958f6a171a43b6b6521ff6f9d919a85c0b5b5daf5d099a49c08b4c2ec
5
5
  SHA512:
6
- metadata.gz: 4fe825dd7cb98c62c1093d11d33e1d488b80bd55f6927089cb4a84e9214d3fbedb7add28d5436492c63f6d8b5cf8b7c3f64d6d30de9aac1fc39fdace9324c465
7
- data.tar.gz: 2d317a4070fa04020b10aa0f7c5c43a000c325ac2cde01a888c4d82fe8a6a01e746e0d4d9a66a92a239e4597f7e25daf5399e5b97d892fd84ac43e0b80052f02
6
+ metadata.gz: d8d2cd3f5b7232c92a2a6133b23592dca23556f7738de97b8dfc5553306332ec93fefd9e00970c139b630563b08563afc2bd5c1112f1177db34b904c61ebe99e
7
+ data.tar.gz: 67d74339e57bd0c0e61942ad4ff94d7399877db33e2a2e0f190a4ab6eec4bf8f6070bad6adb7624009c2ecbd0dd7ed54f8589c1438293efc9c62970af65a7845
data/doc/release_notes.md CHANGED
@@ -1,10 +1,13 @@
1
1
  Release notes
2
2
  =============
3
- ### 2.3.2 (2021-05-04)
4
- * Apply option family on searchablesoptionbuilder, [#30996](http://projects.theforeman.org/issues/30996)
5
3
 
6
- ### 2.3.1 (2021-01-27)
4
+ ### 2.4.0 (2021-02-01)
5
+ * Fix hammer list failure when defaults are set ([PR #551](https://github.com/theforeman/hammer-cli-foreman/pull/551)), [#31384](http://projects.theforeman.org/issues/31384)
7
6
  * Deprecating puppetrun command ([PR #554](https://github.com/theforeman/hammer-cli-foreman/pull/554)), [#31536](http://projects.theforeman.org/issues/31536)
7
+ * Set new owner with host update ([PR #556](https://github.com/theforeman/hammer-cli-foreman/pull/556)), [#31609](http://projects.theforeman.org/issues/31609)
8
+ * Consume structured statuses api data ([PR #553](https://github.com/theforeman/hammer-cli-foreman/pull/553)), [#31570](http://projects.theforeman.org/issues/31570)
9
+ * Added missing tests to filter ([PR #549](https://github.com/theforeman/hammer-cli-foreman/pull/549)), [#31074](http://projects.theforeman.org/issues/31074')
10
+ * Bump to 2.4.0-develop
8
11
 
9
12
  ### 2.3.0 (2020-11-03)
10
13
  * Hammer ping skip authentication ([PR #550](https://github.com/theforeman/hammer-cli-foreman/pull/550)), [#31140](http://projects.theforeman.org/issues/31140)
@@ -11,7 +11,7 @@ module HammerCLIForeman
11
11
  field :name, _("Name")
12
12
  end
13
13
 
14
- build_options
14
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
15
15
  end
16
16
 
17
17
 
@@ -23,7 +23,7 @@ module HammerCLIForeman
23
23
  HammerCLIForeman::References.timestamps(self)
24
24
  end
25
25
 
26
- build_options
26
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
27
27
  end
28
28
 
29
29
 
@@ -31,7 +31,7 @@ module HammerCLIForeman
31
31
  success_message _("Architecture created.")
32
32
  failure_message _("Could not create the architecture")
33
33
 
34
- build_options
34
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
35
35
  end
36
36
 
37
37
 
@@ -39,7 +39,7 @@ module HammerCLIForeman
39
39
  success_message _("Architecture deleted.")
40
40
  failure_message _("Could not delete the architecture")
41
41
 
42
- build_options
42
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
43
43
  end
44
44
 
45
45
 
@@ -47,7 +47,7 @@ module HammerCLIForeman
47
47
  success_message _("Architecture updated.")
48
48
  failure_message _("Could not update the architecture")
49
49
 
50
- build_options
50
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
51
51
  end
52
52
 
53
53
  HammerCLIForeman::AssociatingCommands::OperatingSystem.extend_command(self)
@@ -15,34 +15,34 @@ module HammerCLIForeman
15
15
  field :owner_type, _('Owner Type')
16
16
  end
17
17
 
18
- build_options
18
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
19
19
  end
20
20
 
21
21
  class InfoCommand < HammerCLIForeman::InfoCommand
22
22
  output ListCommand.output_definition
23
-
24
- build_options
23
+
24
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
25
25
  end
26
26
 
27
27
  class CreateCommand < HammerCLIForeman::CreateCommand
28
28
  success_message _('Bookmark %<name>s created.')
29
29
  failure_message _('Failed to create %<name>s bookmark')
30
30
 
31
- build_options
31
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
32
32
  end
33
33
 
34
34
  class UpdateCommand < HammerCLIForeman::UpdateCommand
35
35
  success_message _('Bookmark %<name>s updated successfully.')
36
36
  failure_message _('Failed to update %<name>s bookmark')
37
37
 
38
- build_options
38
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
39
39
  end
40
40
 
41
41
  class DeleteCommand < HammerCLIForeman::DeleteCommand
42
42
  success_message _('Bookmark deleted successfully.')
43
43
  failure_message _('Failed to delete bookmark')
44
44
 
45
- build_options
45
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
46
46
  end
47
47
 
48
48
  autoload_subcommands
@@ -4,7 +4,7 @@ module HammerCLIForeman
4
4
  before_print do |data|
5
5
  return if data['results'].nil?
6
6
 
7
- normalize_plugins(data['results']['foreman']['plugins'])
7
+ normalize_plugins(data['results']['foreman']['plugins']) if data['results']['foreman']['plugins'].any?(String)
8
8
  data['results']['foreman']['smart_proxies'].each do |proxy|
9
9
  proxy['features'] = normalize_features(proxy['features'])
10
10
  proxy['failed_features'] = normalize_failed_features(proxy['failed_features'])
@@ -9,7 +9,7 @@ module HammerCLIForeman
9
9
  field :id, _('Id')
10
10
  field :name, _('Name')
11
11
  end
12
- build_options
12
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
13
13
  end
14
14
 
15
15
  class InfoCommand < HammerCLIForeman::InfoCommand
@@ -25,13 +25,13 @@ module HammerCLIForeman
25
25
  field :vm_attrs, _('VM attributes')
26
26
  end
27
27
  end
28
- build_options
28
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
29
29
  end
30
30
 
31
31
  class CreateCommand < HammerCLIForeman::CreateCommand
32
32
  success_message _('Compute profile created.')
33
33
  failure_message _('Could not create a compute profile')
34
- build_options
34
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
35
35
  end
36
36
 
37
37
  class UpdateCommand < HammerCLIForeman::UpdateCommand
@@ -40,7 +40,7 @@ module HammerCLIForeman
40
40
  validate_options do
41
41
  any(:option_name,:option_id).required
42
42
  end
43
- build_options
43
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
44
44
  end
45
45
 
46
46
  class DeleteCommand < HammerCLIForeman::DeleteCommand
@@ -49,7 +49,7 @@ module HammerCLIForeman
49
49
  validate_options do
50
50
  any(:option_name,:option_id).required
51
51
  end
52
- build_options
52
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
53
53
  end
54
54
 
55
55
  lazy_subcommand('values', _("Create update and delete Compute profile values"),
@@ -8,7 +8,7 @@ module HammerCLIForeman
8
8
  field :name, _("Name")
9
9
  end
10
10
 
11
- build_options
11
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
12
12
  end
13
13
 
14
14
  class InfoCommand < HammerCLIForeman::InfoCommand
@@ -16,28 +16,28 @@ module HammerCLIForeman
16
16
  HammerCLIForeman::References.puppetclasses(self)
17
17
  end
18
18
 
19
- build_options
19
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
20
20
  end
21
21
 
22
22
  class CreateCommand < HammerCLIForeman::CreateCommand
23
23
  success_message _("Config group created.")
24
24
  failure_message _("Could not create the config group")
25
25
 
26
- build_options
26
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
27
27
  end
28
28
 
29
29
  class UpdateCommand < HammerCLIForeman::UpdateCommand
30
30
  success_message _("Config group updated.")
31
31
  failure_message _("Could not update the config group")
32
32
 
33
- build_options
33
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
34
34
  end
35
35
 
36
36
  class DeleteCommand < HammerCLIForeman::DeleteCommand
37
37
  success_message _("Config group has been deleted.")
38
38
  failure_message _("Could not delete the config group")
39
39
 
40
- build_options
40
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
41
41
  end
42
42
 
43
43
  autoload_subcommands
@@ -6,7 +6,7 @@ module HammerCLIForeman
6
6
  base.option "--owner", "OWNER_LOGIN", _("Login of the owner"),
7
7
  :attribute_name => :option_user_login
8
8
  base.option "--owner-id", "OWNER_ID", _("ID of the owner"),
9
- :attribute_name => :option_user_id
9
+ :attribute_name => :option_owner_id
10
10
 
11
11
  base.option "--root-password", "ROOT_PW",
12
12
  _("Required if host is managed and value is not inherited from host group or default password in settings")
@@ -11,7 +11,7 @@ module HammerCLIForeman
11
11
  field :name, _("Name")
12
12
  end
13
13
 
14
- build_options
14
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
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
25
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
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
16
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
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
26
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
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
34
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
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
41
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
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
49
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
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
16
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
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
39
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
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
47
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
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
55
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
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
63
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
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
79
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
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
93
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
94
94
  end
95
95
 
96
96
 
@@ -156,7 +156,8 @@ module HammerCLIForeman
156
156
  HammerCLI::EX_OK
157
157
  end
158
158
 
159
- build_options :without => [:template_kind_id, :type]
159
+ build_options expand: { except: %i[organizations locations] },
160
+ without: %i[organization_id location_id template_kind_id type]
160
161
  end
161
162
 
162
163
 
@@ -191,7 +192,7 @@ module HammerCLIForeman
191
192
  {"operatingsystem_id" => option_id}
192
193
  end
193
194
 
194
- build_options
195
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
195
196
  end
196
197
 
197
198
 
@@ -170,34 +170,15 @@ module HammerCLIForeman
170
170
  attr_reader :resource
171
171
 
172
172
  def build(builder_params={})
173
- resource_name_map = builder_params[:resource_mapping] || {}
174
173
  @searchables.for(@resource).collect do |s|
175
- family = HammerCLI::Options::OptionFamily.new
176
- family.parent(
174
+ option(
177
175
  optionamize("--#{s.name}"),
178
176
  s.name.upcase,
179
177
  s.description,
180
- referenced_resource: @resource.singular_name,
181
- aliased_resource: aliased_name(resource_name(s.name), resource_name_map)
178
+ :referenced_resource => @resource.singular_name
182
179
  )
183
180
  end
184
181
  end
185
-
186
- def aliased_name(name, resource_name_map)
187
- return if name.nil?
188
-
189
- resource_name_map[name.to_s] || resource_name_map[name.to_sym] || name
190
- end
191
-
192
- def resource_name(param)
193
- if param =~ /^id[s]?$/
194
- @resource.singular_name
195
- elsif param =~ /_id[s]?$/
196
- param.gsub(/_id[s]?$/, '')
197
- else
198
- nil
199
- end
200
- end
201
182
  end
202
183
 
203
184
 
@@ -20,7 +20,7 @@ module HammerCLIForeman
20
20
  data
21
21
  end
22
22
 
23
- build_options
23
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
24
24
  end
25
25
 
26
26
  class UpdateCommand < HammerCLIForeman::UpdateCommand
@@ -29,7 +29,7 @@ module HammerCLIForeman
29
29
  success_message _("Setting [%{name}] updated to [%{value}].")
30
30
  failure_message _("Could not update the setting")
31
31
 
32
- build_options
32
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
33
33
  end
34
34
 
35
35
  class InfoCommand < HammerCLIForeman::InfoCommand
@@ -42,7 +42,7 @@ module HammerCLIForeman
42
42
  field :value, _("Value")
43
43
  end
44
44
 
45
- build_options
45
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
46
46
  end
47
47
 
48
48
 
@@ -13,7 +13,7 @@ module HammerCLIForeman
13
13
  field :admin, _("Admin"), Fields::Boolean
14
14
  end
15
15
 
16
- build_options
16
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
17
17
  end
18
18
 
19
19
  class InfoCommand < HammerCLIForeman::InfoCommand
@@ -25,28 +25,28 @@ module HammerCLIForeman
25
25
  HammerCLIForeman::References.timestamps(self)
26
26
  end
27
27
 
28
- build_options
28
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
29
29
  end
30
30
 
31
31
  class CreateCommand < HammerCLIForeman::CreateCommand
32
32
  success_message _("User group [%<name>s] created.")
33
33
  failure_message _("Could not create the user group")
34
34
 
35
- build_options
35
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
36
36
  end
37
37
 
38
38
  class UpdateCommand < HammerCLIForeman::UpdateCommand
39
39
  success_message _("User group [%<name>s] updated.")
40
40
  failure_message _("Could not update the user group")
41
41
 
42
- build_options
42
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
43
43
  end
44
44
 
45
45
  class DeleteCommand < HammerCLIForeman::DeleteCommand
46
46
  success_message _("User group [%<name>s] deleted.")
47
47
  failure_message _("Could not delete the user group")
48
48
 
49
- build_options
49
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
50
50
  end
51
51
 
52
52
  HammerCLIForeman::AssociatingCommands::Role.extend_command(self)