hammer_cli_foreman 2.4.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: efc47b1a544eaf1e63d7328b51210b5d0b4d153bb6ff35156a8e55b9527aa207
4
- data.tar.gz: dd374b8958f6a171a43b6b6521ff6f9d919a85c0b5b5daf5d099a49c08b4c2ec
3
+ metadata.gz: 12d3353f9d530459e2a7f58e8f5603b1f52af4b2ee28aa51c6252bda84f5a5b3
4
+ data.tar.gz: cb323fd78217f8d5b5b1e7b69dd691ea85b3d332dcbbc2e375a668fc7043c298
5
5
  SHA512:
6
- metadata.gz: d8d2cd3f5b7232c92a2a6133b23592dca23556f7738de97b8dfc5553306332ec93fefd9e00970c139b630563b08563afc2bd5c1112f1177db34b904c61ebe99e
7
- data.tar.gz: 67d74339e57bd0c0e61942ad4ff94d7399877db33e2a2e0f190a4ab6eec4bf8f6070bad6adb7624009c2ecbd0dd7ed54f8589c1438293efc9c62970af65a7845
6
+ metadata.gz: 04b1444a37f464ab35afdfd3832cf0549448484e9932972603ca5d29d7660a4bd599ab0cae461730a7fca5735712451553983724cbe5a23d8f6ffb0135e5510e
7
+ data.tar.gz: b625099ac29545814e7c73a1d74f0b20559b117bfabac2e2074c448557386c40e81a280ae2fb31271e3e5bd60b1c29c4a60881acfe4d5cbcad3f91cda05ca21c
data/doc/release_notes.md CHANGED
@@ -1,5 +1,45 @@
1
1
  Release notes
2
2
  =============
3
+ ### 3.1.0 (2021-11-10)
4
+ * Update test data for 3.1
5
+ * Make sure provided options override defaults, [#33711](http://projects.theforeman.org/issues/33711)
6
+ * Make template create/update commands use resolver, [#33721](http://projects.theforeman.org/issues/33721)
7
+ * Revert fix rake version
8
+ * Fix rake version
9
+ * Show status once for proxy info ([PR #581](https://github.com/theforeman/hammer-cli-foreman/pull/581)), [#19510](http://projects.theforeman.org/issues/19510)
10
+ * Add proxy status and version to info command ([PR #572](https://github.com/theforeman/hammer-cli-foreman/pull/572))
11
+ * Associate a vm via hammer to a compute resource, [#33047](http://projects.theforeman.org/issues/33047)
12
+ * Fix option builders and tests, [#33226](http://projects.theforeman.org/issues/33226)
13
+ * Bump to 3.1.0-develop
14
+ * Add parent title option for hostgroup, [#32878](http://projects.theforeman.org/issues/32878)
15
+
16
+ ### 3.0.0 (2021-08-04)
17
+ * Puppet extraction ([PR #571](https://github.com/theforeman/hammer-cli-foreman/pull/571)), [#33174](http://projects.theforeman.org/issues/33174)
18
+ * Update rel-eng notebook ([PR #573](https://github.com/theforeman/hammer-cli-foreman/pull/573))
19
+ * Bump version to 3.0-develop
20
+ * Deprecate root-pass and remove deprecation warning, [#22574](http://projects.theforeman.org/issues/22574)
21
+ * Return org and loc options to all hammer commands ([PR #575](https://github.com/theforeman/hammer-cli-foreman/pull/575)), [#32872](http://projects.theforeman.org/issues/32872)
22
+ * prevent full-help from failure if apidoc not available ([PR #574](https://github.com/theforeman/hammer-cli-foreman/pull/574)), [#32861](http://projects.theforeman.org/issues/32861)
23
+ * Show new msg for empty update commands, [#32454](http://projects.theforeman.org/issues/32454)
24
+ * Remove --environment deprecations ([PR #569](https://github.com/theforeman/hammer-cli-foreman/pull/569)), [#28862](http://projects.theforeman.org/issues/28862)
25
+ * Force name resolving due defaults, [#32392](http://projects.theforeman.org/issues/32392)
26
+ * Bump to 2.6.0-develop
27
+
28
+ ### 2.5.0 (2021-05-04)
29
+ * Update test data to latest foreman
30
+ * change to resource_type_label, [#11454](http://projects.theforeman.org/issues/11454)
31
+ * Display the report origin, [#32428](http://projects.theforeman.org/issues/32428)
32
+ * Apply option family on searchablesoptionbuilder, [#30996](http://projects.theforeman.org/issues/30996)
33
+ * Add associate vms command for compute resource ([PR #563](https://github.com/theforeman/hammer-cli-foreman/pull/563)), [#32271](http://projects.theforeman.org/issues/32271)
34
+ * Support unrecognized services in ping, [#32265](http://projects.theforeman.org/issues/32265)
35
+ * Change --owner_type's default to user ([PR #562](https://github.com/theforeman/hammer-cli-foreman/pull/562)), [#30814](http://projects.theforeman.org/issues/30814)
36
+ * Drop puppetrun command from hammer ([PR #561](https://github.com/theforeman/hammer-cli-foreman/pull/561)), [#31806](http://projects.theforeman.org/issues/31806)
37
+ * Global registration module ([PR #558](https://github.com/theforeman/hammer-cli-foreman/pull/558)), [#31630](http://projects.theforeman.org/issues/31630)
38
+ * Add support for vnic profile ([PR #552](https://github.com/theforeman/hammer-cli-foreman/pull/552)), [#31493](http://projects.theforeman.org/issues/31493)
39
+ * Bump to 2.5.0-develop
40
+ * Bump to 2.4.0
41
+ * Correct descriptions for resources, [#31668](http://projects.theforeman.org/issues/31668)
42
+
3
43
 
4
44
  ### 2.4.0 (2021-02-01)
5
45
  * 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)
@@ -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
 
@@ -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,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 expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
34
+ build_options
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 expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
42
+ build_options
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 expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
50
+ build_options
51
51
  end
52
52
 
53
53
  HammerCLIForeman::AssociatingCommands::OperatingSystem.extend_command(self)
@@ -53,30 +53,6 @@ module HammerCLIForeman
53
53
  end
54
54
  end
55
55
 
56
- module PuppetEnvironment
57
- extend CommandExtension
58
-
59
- class AddPuppetEnvironmentCommand < HammerCLIForeman::AddAssociatedCommand
60
- associated_resource :environments
61
- desc _('Associate a Puppet environment')
62
-
63
- success_message _("The environment has been associated.")
64
- failure_message _("Could not associate the environment")
65
-
66
- extend_with(HammerCLIForeman::CommandExtensions::PuppetEnvironment.new)
67
- end
68
-
69
- class RemovePuppetEnvironmentCommand < HammerCLIForeman::RemoveAssociatedCommand
70
- associated_resource :environments
71
- desc _('Disassociate a Puppet environment')
72
-
73
- success_message _("The environment has been disassociated.")
74
- failure_message _("Could not disassociate the environment")
75
-
76
- extend_with(HammerCLIForeman::CommandExtensions::PuppetEnvironment.new)
77
- end
78
- end
79
-
80
56
  module Domain
81
57
  extend CommandExtension
82
58
 
@@ -15,34 +15,34 @@ module HammerCLIForeman
15
15
  field :owner_type, _('Owner Type')
16
16
  end
17
17
 
18
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
18
+ build_options
19
19
  end
20
20
 
21
21
  class InfoCommand < HammerCLIForeman::InfoCommand
22
22
  output ListCommand.output_definition
23
23
 
24
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
24
+ build_options
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 expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
31
+ build_options
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 expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
38
+ build_options
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 expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
45
+ build_options
46
46
  end
47
47
 
48
48
  autoload_subcommands
@@ -6,8 +6,7 @@ module HammerCLIForeman
6
6
 
7
7
  module RequestParams
8
8
  def request_params
9
- combination_params = { 'hostgroup_id' => params['hostgroup_id'].to_s,
10
- 'environment_id' => params['environment_id'].to_s }
9
+ combination_params = { 'hostgroup_id' => params['hostgroup_id'].to_s }
11
10
  super.merge('template_combination' => combination_params)
12
11
  end
13
12
  end
@@ -21,8 +20,6 @@ module HammerCLIForeman
21
20
  field :provisioning_template_name, _('Provisioning template name')
22
21
  field :hostgroup_id, _('Hostgroup ID')
23
22
  field :hostgroup_name, _('Hostgroup name')
24
- field :environment_id, _('Environment ID')
25
- field :environment_name, _('Environment name')
26
23
 
27
24
  HammerCLIForeman::References.taxonomies(self)
28
25
  HammerCLIForeman::References.timestamps(self)
@@ -31,8 +28,6 @@ module HammerCLIForeman
31
28
  build_options do |o|
32
29
  o.expand(:all)
33
30
  end
34
-
35
- extend_with(HammerCLIForeman::CommandExtensions::PuppetEnvironment.new)
36
31
  end
37
32
 
38
33
  class ListCombination < HammerCLIForeman::ListCommand
@@ -40,12 +35,11 @@ module HammerCLIForeman
40
35
  field :id, _('ID')
41
36
  field nil, _('Provisioning Template'), Fields::SingleReference, :key => :provisioning_template
42
37
  field nil, _('Hostgroup'), Fields::SingleReference, :key => :hostgroup
43
- field nil, _('Environment'), Fields::SingleReference, :key => :environment
44
38
  end
45
39
 
46
40
  build_options do |o|
47
- o.expand(:all).except(:hostgroups, :environments)
48
- o.without(:hostgroup_id, :environment_id)
41
+ o.expand(:all).except(:hostgroups)
42
+ o.without(:hostgroup_id)
49
43
  end
50
44
  end
51
45
 
@@ -58,8 +52,6 @@ module HammerCLIForeman
58
52
  build_options do |o|
59
53
  o.expand(:all)
60
54
  end
61
-
62
- extend_with(HammerCLIForeman::CommandExtensions::PuppetEnvironment.new)
63
55
  end
64
56
 
65
57
  class CreateCombination < HammerCLIForeman::CreateCommand
@@ -71,8 +63,6 @@ module HammerCLIForeman
71
63
  build_options do |o|
72
64
  o.expand(:all)
73
65
  end
74
-
75
- extend_with(HammerCLIForeman::CommandExtensions::PuppetEnvironment.new)
76
66
  end
77
67
 
78
68
  class DeleteCombination < HammerCLIForeman::DeleteCommand
@@ -10,9 +10,28 @@ module HammerCLIForeman
10
10
  end
11
11
  end
12
12
 
13
+ def self.check_for_unrecognized(plugins, output_definition)
14
+ failed = plugins.select { |_, data| data['services'] }
15
+ .each_with_object([]) { |(_, d), s| s << d['services'] }
16
+ .reduce({}, :merge)
17
+ .select do |name, data|
18
+ begin
19
+ output_definition.find_field(name)
20
+ false
21
+ rescue ArgumentError
22
+ data['status'] == _('FAIL')
23
+ end
24
+ end
25
+ return if failed.empty?
26
+
27
+ warn [_('%{count} more service(s) failed, but not shown:') % { count: failed.size },
28
+ failed.keys.join(', '),
29
+ ''].join("\n")
30
+ end
31
+
13
32
  def self.failed?(services)
14
- services.each_value.any? { |s| s['status'] == _('FAIL') } ||
15
- services['foreman']['database']['active'] == 'FAIL'
33
+ services['foreman']['database']['active'] == 'FAIL' ||
34
+ services.each_value.any? { |s| s['status'] == _('FAIL') }
16
35
  end
17
36
 
18
37
  request_options do |options|
@@ -1,16 +1,7 @@
1
1
  module HammerCLIForeman
2
2
  module CommandExtensions
3
3
  class Subnet < HammerCLI::CommandExtensions
4
- option "--dns", "DNS_NAME", _("DNS Proxy to use within this subnet"),
5
- attribute_name: :option_dns_name,
6
- referenced_resource: :smart_proxy
7
- option "--dhcp", "DHCP_NAME", _("DHCP Proxy to use within this subnet"),
8
- attribute_name: :option_dhcp_name,
9
- referenced_resource: :smart_proxy
10
- option "--tftp", "TFTP_NAME", _("TFTP Proxy to use within this subnet"),
11
- attribute_name: :option_tftp_name,
12
- referenced_resource: :smart_proxy
13
- option "--prefix", "PREFIX", _("Network prefix in CIDR notation (e.g. 64) for this subnet")
4
+ option '--prefix', 'PREFIX', _('Network prefix in CIDR notation (e.g. 64) for this subnet')
14
5
 
15
6
  option_sources do |sources, command|
16
7
  sources.find_by_name('IdResolution').insert_relative(
@@ -20,6 +11,30 @@ module HammerCLIForeman
20
11
  )
21
12
  sources
22
13
  end
14
+
15
+ option_family associate: 'tftp' do
16
+ child '--tftp', 'TFTP_NAME', _('TFTP Proxy to use within this subnet'),
17
+ attribute_name: :option_tftp_name,
18
+ referenced_resource: :smart_proxy
19
+ end
20
+
21
+ option_family associate: 'dns' do
22
+ child '--dns', 'DNS_NAME', _('DNS Proxy to use within this subnet'),
23
+ attribute_name: :option_dns_name,
24
+ referenced_resource: :smart_proxy
25
+ end
26
+
27
+ option_family associate: 'dhcp' do
28
+ child '--dhcp', 'DHCP_NAME', _('DHCP Proxy to use within this subnet'),
29
+ attribute_name: :option_dhcp_name,
30
+ referenced_resource: :smart_proxy
31
+ end
32
+
33
+ option_family associate: 'bmc' do
34
+ child '--bmc', 'BMC_NAME', _('BMC Proxy to use within this subnet'),
35
+ attribute_name: :option_bmc_name,
36
+ referenced_resource: :smart_proxy
37
+ end
23
38
  end
24
39
  end
25
40
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HammerCLIForeman
4
+ module CommandExtensions
5
+ class UpdateCommon < HammerCLI::CommandExtensions
6
+ inheritable true
7
+
8
+ request_params do |params, command_object|
9
+ update_params = params[command_object.resource.singular_name]
10
+ command_object.context[:action_message] = :nothing_to_do if update_params && update_params.empty?
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,17 +1,21 @@
1
1
  module HammerCLIForeman
2
2
  module CommandExtensions
3
3
  class User < HammerCLI::CommandExtensions
4
- option '--default-organization', 'DEFAULT_ORGANIZATION_NAME', _('Default organization name'),
5
- aliased_resource: 'default_organization', referenced_resource: 'default_organization'
6
- option '--default-location', 'DEFAULT_LOCATION_NAME', _('Default location name'),
7
- aliased_resource: 'default_location', referenced_resource: 'default_location'
8
-
9
4
  option '--ask-password', 'ASK_PW', ' ', format: HammerCLI::Options::Normalizers::Bool.new
10
5
 
11
6
  option_sources do |sources, command|
12
7
  sources << HammerCLIForeman::OptionSources::UserParams.new(command)
13
8
  sources
14
9
  end
10
+
11
+ option_family associate: 'default_organization' do
12
+ child '--default-organization', 'DEFAULT_ORGANIZATION_NAME', _('Default organization name'),
13
+ aliased_resource: 'default_organization', referenced_resource: 'organization'
14
+ end
15
+ option_family associate: 'default_location' do
16
+ child '--default-location', 'DEFAULT_LOCATION_NAME', _('Default location name'),
17
+ aliased_resource: 'default_location', referenced_resource: 'location'
18
+ end
15
19
  end
16
20
  end
17
21
  end
@@ -1,6 +1,5 @@
1
+ require 'hammer_cli_foreman/command_extensions/update_common'
1
2
  require 'hammer_cli_foreman/command_extensions/fields'
2
- require 'hammer_cli_foreman/command_extensions/puppet_environment'
3
- require 'hammer_cli_foreman/command_extensions/puppet_environments'
4
3
  require 'hammer_cli_foreman/command_extensions/option_sources'
5
4
  require 'hammer_cli_foreman/command_extensions/hosts'
6
5
  require 'hammer_cli_foreman/command_extensions/ping'
@@ -7,16 +7,9 @@ module HammerCLIForeman
7
7
  :usergroups => :user_groups,
8
8
  :ptable => :partition_table,
9
9
  :ptables => :partition_tables,
10
- :puppetclass => :puppet_class,
11
- :puppetclasses => :puppet_classes,
12
- :environment => :puppet_environment,
13
- :environments => :puppet_environments
14
10
  }
15
11
 
16
- RESOURCE_ALIAS_NAME_MAPPING = {
17
- environment: :puppet_environment,
18
- environments: :puppet_environments
19
- }
12
+ RESOURCE_ALIAS_NAME_MAPPING = { }
20
13
 
21
14
  def self.foreman_api
22
15
  foreman_api_connection
@@ -104,9 +97,8 @@ module HammerCLIForeman
104
97
  configurator = BuilderConfigurator.new(searchables, dependency_resolver)
105
98
 
106
99
  builder = ForemanOptionBuilder.new(searchables)
107
- builder.builders = []
100
+ builder.builders = super.builders
108
101
  builder.builders += configurator.builders_for(resource, resource.action(action)) if resource_defined?
109
- builder.builders += super.builders
110
102
  builder
111
103
  end
112
104
 
@@ -294,7 +286,7 @@ module HammerCLIForeman
294
286
  def help
295
287
  return super unless resource
296
288
 
297
- meta = resource.action(action).apidoc[:metadata]
289
+ meta = resource.action(action).apidoc&.dig(:metadata)
298
290
  if meta && meta[:search] && respond_to?(:option_search)
299
291
  self.class.extend_help do |h|
300
292
  h.section(_('Search / Order fields'), id: :search_fields_section) do |h|
@@ -548,6 +540,19 @@ module HammerCLIForeman
548
540
  builder
549
541
  end
550
542
 
543
+ def self.inherited(child)
544
+ child.success_message_for(:nothing_to_do, _('Nothing to update.'))
545
+ end
546
+
547
+ def clean_up_context
548
+ super
549
+ context.delete(:action_message)
550
+ end
551
+
552
+ def success_message
553
+ success_message_for(context[:action_message] || :default)
554
+ end
555
+
551
556
  def method_options_for_params(params, options)
552
557
  opts = super
553
558
  # overwrite searchables with correct values
@@ -560,6 +565,7 @@ module HammerCLIForeman
560
565
  opts
561
566
  end
562
567
 
568
+ extend_with(HammerCLIForeman::CommandExtensions::UpdateCommon.new)
563
569
  end
564
570
 
565
571
 
@@ -12,7 +12,7 @@ module HammerCLIForeman
12
12
  profile = HammerCLIForeman.record_to_common_format(
13
13
  HammerCLIForeman.foreman_resource(:compute_profiles).call(:show, 'id' => options['option_compute_profile_id'] )
14
14
  )
15
- params['compute_attribute'] = profile['compute_attributes'].select { |hash| hash['compute_resource_id'] == options['option_compute_resource_id']}[0] || {}
15
+ params['compute_attribute'] = profile['compute_attributes'].select { |hash| hash['compute_resource_id'].to_s == options['option_compute_resource_id'].to_s}[0] || {}
16
16
  params['compute_attribute'].delete('attributes') if params['compute_attribute']['attributes']
17
17
  params
18
18
  end
@@ -9,7 +9,7 @@ module HammerCLIForeman
9
9
  field :id, _('Id')
10
10
  field :name, _('Name')
11
11
  end
12
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
12
+ build_options
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 expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
28
+ build_options
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 expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
34
+ build_options
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 expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
43
+ build_options
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 expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
52
+ build_options
53
53
  end
54
54
 
55
55
  lazy_subcommand('values', _("Create update and delete Compute profile values"),
@@ -28,7 +28,8 @@ module HammerCLIForeman
28
28
  [
29
29
  ['compute_name', _('Compute name, e.g. eth0')],
30
30
  ['compute_network', _('Select one of available networks for a cluster, must be an ID or a name')],
31
- ['compute_interface', _('Interface type')]
31
+ ['compute_interface', _('Interface type')],
32
+ ['compute_vnic_profile', _('Vnic Profile')]
32
33
  ]
33
34
  end
34
35
 
@@ -104,6 +104,16 @@ module HammerCLIForeman
104
104
  build_options
105
105
  end
106
106
 
107
+ class AssociateVmsCommand < HammerCLIForeman::Command
108
+ action :associate
109
+ command_name 'associate-vms'
110
+ option "--vm-id","VM ID", _("Associate a specific VM")
111
+ success_message _("Virtual machines have been associated.")
112
+ failure_message _("Could not associate the virtual machines")
113
+
114
+ build_options
115
+ end
116
+
107
117
  class AvailableClustersCommand < HammerCLIForeman::ListCommand
108
118
  action :available_clusters
109
119
  command_name 'clusters'
@@ -128,6 +138,19 @@ module HammerCLIForeman
128
138
  build_options
129
139
  end
130
140
 
141
+ class AvailableVnicProfilesCommand < HammerCLIForeman::ListCommand
142
+ action :available_vnic_profiles
143
+ command_name 'vnic-profiles'
144
+
145
+ output do
146
+ field :id, _('VNIC profile ID'), Fields::Field, :max_width => 200, :hide_blank => true
147
+ field :name, _('Name')
148
+ field :network, _('Network ID')
149
+ end
150
+
151
+ build_options
152
+ end
153
+
131
154
  class AvailableImagesCommand < HammerCLIForeman::ListCommand
132
155
  action :available_images
133
156
  command_name 'images'
@@ -10,6 +10,7 @@ module HammerCLIForeman
10
10
  field :id, _("Id")
11
11
  field :host_name, _("Host")
12
12
  field :reported_at, _("Last report"), Fields::Date
13
+ field :origin, _("Origin")
13
14
  from "status" do
14
15
  field :applied, _("Applied")
15
16
  field :restarted, _("Restarted")
@@ -30,6 +31,7 @@ module HammerCLIForeman
30
31
  field :id, _("Id")
31
32
  field :host_name, _("Host")
32
33
  field :reported_at, _("Reported at"), Fields::Date
34
+ field :origin, _("Origin")
33
35
  label _("Report status") do
34
36
  from "status" do
35
37
  field :applied, _("Applied")
@@ -78,7 +78,7 @@ module HammerCLIForeman
78
78
  class CreateCommand < HammerCLIForeman::CreateCommand
79
79
  include TaxonomyCheck
80
80
 
81
- success_message _("Permission filter for [%<resource_type>s] created.")
81
+ success_message _("Permission filter for [%<resource_type_label>s] created.")
82
82
  failure_message _("Could not create the permission filter")
83
83
 
84
84
  def validate_options
@@ -92,7 +92,7 @@ module HammerCLIForeman
92
92
  class UpdateCommand < HammerCLIForeman::UpdateCommand
93
93
  include TaxonomyCheck
94
94
 
95
- success_message _("Permission filter for [%<resource_type>s] updated.")
95
+ success_message _("Permission filter for [%<resource_type_label>s] updated.")
96
96
  failure_message _("Could not update the permission filter")
97
97
 
98
98
  def request_params