hammer_cli_foreman 2.3.1 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes.md +7 -1
  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/settings.rb +3 -3
  13. data/lib/hammer_cli_foreman/usergroup.rb +5 -5
  14. data/lib/hammer_cli_foreman/version.rb +1 -1
  15. data/test/functional/architecture_test.rb +49 -0
  16. data/test/functional/bookmark_test.rb +20 -0
  17. data/test/functional/compute_profile_test.rb +43 -0
  18. data/test/functional/config_group_test.rb +50 -0
  19. data/test/functional/filter_test.rb +114 -47
  20. data/test/functional/host_test.rb +63 -2
  21. data/test/functional/mail_notification_test.rb +20 -0
  22. data/test/functional/model_test.rb +50 -0
  23. data/test/functional/operating_system_test.rb +51 -0
  24. data/test/functional/settings_test.rb +21 -0
  25. data/test/functional/status_test.rb +79 -13
  26. data/test/functional/usergroup_test.rb +51 -0
  27. data/test/unit/apipie_resource_mock.rb +21 -0
  28. data/test/unit/architecture_test.rb +10 -1
  29. data/test/unit/bookmark_test.rb +99 -0
  30. data/test/unit/compute_profile_test.rb +87 -0
  31. data/test/unit/config_group_test.rb +10 -0
  32. data/test/unit/mail_notification_test.rb +53 -0
  33. data/test/unit/model_test.rb +10 -0
  34. data/test/unit/operating_system_test.rb +14 -1
  35. data/test/unit/settings_test.rb +4 -0
  36. data/test/unit/usergroup_test.rb +10 -0
  37. metadata +20 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3602bf5d1cda5fed0ace9196b7aa5dbd0622079db5ab77f252cd134d0e05d5d
4
- data.tar.gz: e341fb0eb8b606c519199c36fc1a14a520661a010f62bd946cb0b3c394fdd267
3
+ metadata.gz: efc47b1a544eaf1e63d7328b51210b5d0b4d153bb6ff35156a8e55b9527aa207
4
+ data.tar.gz: dd374b8958f6a171a43b6b6521ff6f9d919a85c0b5b5daf5d099a49c08b4c2ec
5
5
  SHA512:
6
- metadata.gz: 75f923de0d55217bf30a6c6d12afe19e5b806b360892f1d429d18aa39bab2443151c7317ed5d39f979af8c934edd8134d1767efacfe52a353b9546a29f1983de
7
- data.tar.gz: 833444008fa0f26d711708980a65f39e8cc485409acdb6c23e6afff8998645c2f2c34acd3cf70b84638fe0569c299ee11a5aabb2ba916d5524abcc19b9c78be2
6
+ metadata.gz: d8d2cd3f5b7232c92a2a6133b23592dca23556f7738de97b8dfc5553306332ec93fefd9e00970c139b630563b08563afc2bd5c1112f1177db34b904c61ebe99e
7
+ data.tar.gz: 67d74339e57bd0c0e61942ad4ff94d7399877db33e2a2e0f190a4ab6eec4bf8f6070bad6adb7624009c2ecbd0dd7ed54f8589c1438293efc9c62970af65a7845
data/doc/release_notes.md CHANGED
@@ -1,7 +1,13 @@
1
1
  Release notes
2
2
  =============
3
- ### 2.3.1 (2021-01-27)
3
+
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)
4
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
5
11
 
6
12
  ### 2.3.0 (2020-11-03)
7
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
 
@@ -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)
@@ -1,5 +1,5 @@
1
1
  module HammerCLIForeman
2
2
  def self.version
3
- @version ||= Gem::Version.new "2.3.1"
3
+ @version ||= Gem::Version.new "2.4.0"
4
4
  end
5
5
  end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.join(File.dirname(__FILE__), 'test_helper')
4
+
5
+ describe 'architecture' do
6
+ describe 'list' do
7
+ before do
8
+ @cmd = %w[architecture list]
9
+ @architectures = [{
10
+ id: 1,
11
+ name: 'i386',
12
+ }]
13
+ end
14
+
15
+ it 'should return a list of architectures' do
16
+ api_expects(:architectures, :index, 'List architectures').returns(@architectures)
17
+
18
+ output = IndexMatcher.new([
19
+ %w[ID NAME],
20
+ %w[1 i386]
21
+ ])
22
+ expected_result = success_result(output)
23
+
24
+ result = run_cmd(@cmd)
25
+ assert_cmd(expected_result, result)
26
+ end
27
+
28
+ it 'should run list command with defaults' do
29
+ providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.1')) }
30
+ defaults = HammerCLI::Defaults.new(
31
+ {
32
+ organization_id: {
33
+ provider: 'foreman'
34
+ },
35
+ location_id: {
36
+ provider: 'foreman'
37
+ }
38
+ }
39
+ )
40
+ defaults.stubs(:write_to_file).returns(true)
41
+ defaults.stubs(:providers).returns(providers)
42
+ api_expects(:architectures, :index, 'List architectures').returns(@architectures)
43
+
44
+ result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
45
+ _(result.exit_code).must_equal HammerCLI::EX_OK
46
+ end
47
+ end
48
+ end
49
+