hammer_cli_foreman 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 12d3353f9d530459e2a7f58e8f5603b1f52af4b2ee28aa51c6252bda84f5a5b3
4
- data.tar.gz: cb323fd78217f8d5b5b1e7b69dd691ea85b3d332dcbbc2e375a668fc7043c298
3
+ metadata.gz: 87407ba2c43be96a076220e9500050007447596f6d14024932fa85a7c9046f20
4
+ data.tar.gz: 2987c54ab5fef04cc45629754a55c62d16a252b6cd950e7de461a989712a79ca
5
5
  SHA512:
6
- metadata.gz: 04b1444a37f464ab35afdfd3832cf0549448484e9932972603ca5d29d7660a4bd599ab0cae461730a7fca5735712451553983724cbe5a23d8f6ffb0135e5510e
7
- data.tar.gz: b625099ac29545814e7c73a1d74f0b20559b117bfabac2e2074c448557386c40e81a280ae2fb31271e3e5bd60b1c29c4a60881acfe4d5cbcad3f91cda05ca21c
6
+ metadata.gz: 030d7c3ff4d19fb767e771c123b8cb0de2a6166cec3ec2012b689f7d920d3049a234f7900ee43141c2af97ce0d5aaf403ea9a9f3962072bdffc181126de57e70
7
+ data.tar.gz: 6acaf9a9b06c59b4c7db28b73bdc7dfe31170ac3b621adb2b85a5a501090e310a4fcfc703e2b6dc48170a693ff675507b8b9c478a8c344ff7793bfe778a8f3f3
data/doc/release_notes.md CHANGED
@@ -1,5 +1,13 @@
1
1
  Release notes
2
2
  =============
3
+ ### 3.2.0 (2022-02-10)
4
+ * Domain update doesn't reset dns implicitly ([PR #591](https://github.com/theforeman/hammer-cli-foreman/pull/591)), [#34177](http://projects.theforeman.org/issues/34177)
5
+ * Send filter's tax params only when required ([PR #592](https://github.com/theforeman/hammer-cli-foreman/pull/592)), [#34199](http://projects.theforeman.org/issues/34199)
6
+ * Add boot_order to compute-attribute ([PR #588](https://github.com/theforeman/hammer-cli-foreman/pull/588)), [#33910](http://projects.theforeman.org/issues/33910)
7
+ * Add mail_enabled to user list/info command ([PR #589](https://github.com/theforeman/hammer-cli-foreman/pull/589)), [#34180](http://projects.theforeman.org/issues/34180)
8
+ * Add token to host info command ([PR #586](https://github.com/theforeman/hammer-cli-foreman/pull/586)), [#34120](http://projects.theforeman.org/issues/34120)
9
+ * Bump to 3.2.0-develop
10
+
3
11
  ### 3.1.0 (2021-11-10)
4
12
  * Update test data for 3.1
5
13
  * Make sure provided options override defaults, [#33711](http://projects.theforeman.org/issues/33711)
@@ -0,0 +1,20 @@
1
+ module HammerCLIForeman
2
+ module CommandExtensions
3
+ class Domain < HammerCLI::CommandExtensions
4
+ option_sources do |sources, command|
5
+ sources.find_by_name('IdResolution').insert_relative(
6
+ :after,
7
+ 'IdParams',
8
+ HammerCLIForeman::OptionSources::ReferencedResourceIdParams.new(command)
9
+ )
10
+ sources
11
+ end
12
+
13
+ option_family associate: 'dns' do
14
+ child '--dns', 'DNS_NAME', _('Name of DNS proxy to use within this domain'),
15
+ attribute_name: :option_dns_name,
16
+ referenced_resource: :smart_proxy
17
+ end
18
+ end
19
+ end
20
+ end
@@ -6,3 +6,4 @@ require 'hammer_cli_foreman/command_extensions/ping'
6
6
  require 'hammer_cli_foreman/command_extensions/status'
7
7
  require 'hammer_cli_foreman/command_extensions/user'
8
8
  require 'hammer_cli_foreman/command_extensions/subnet'
9
+ require 'hammer_cli_foreman/command_extensions/domain'
@@ -9,7 +9,8 @@ module HammerCLIForeman
9
9
  [
10
10
  ['cpus', _('Number of CPUs'), { bold: true }],
11
11
  ['memory', _('String, amount of memory, value in bytes'), { bold: true }],
12
- ['cpu_mode', _('Possible values: %{modes}') % { modes: 'default, host-model, host-passthrough' }]
12
+ ['cpu_mode', _('Possible values: %{modes}') % { modes: 'default, host-model, host-passthrough' }],
13
+ ['boot_order', _('Device names to specify the boot order')]
13
14
  ]
14
15
  end
15
16
 
@@ -48,7 +49,8 @@ module HammerCLIForeman
48
49
  Fields::Field.new(:label => _('Status'), :path => [:state]),
49
50
  Fields::Field.new(:label => _('OS Type'), :path => [:os_type]),
50
51
  Fields::Field.new(:label => _('Domain Type'), :path => [:domain_type]),
51
- Fields::Field.new(:label => _('Persistent'), :path => [:persistent])
52
+ Fields::Field.new(:label => _('Persistent'), :path => [:persistent]),
53
+ Fields::List.new(:label => _('Boot order'), :path => [:boot_order])
52
54
  ]
53
55
  end
54
56
 
@@ -25,7 +25,8 @@ module HammerCLIForeman
25
25
  ['scsi_controllers', [_('List with SCSI controllers definitions'),
26
26
  ' type - ' + _('ID of the controller from VMware'),
27
27
  ' key - ' + _('Key of the controller (e.g. 1000)')
28
- ].flatten(1).join("\n")]
28
+ ].flatten(1).join("\n")],
29
+ ['boot_order', _('Device names to specify the boot order')]
29
30
  ]
30
31
  end
31
32
 
@@ -76,7 +77,8 @@ module HammerCLIForeman
76
77
  Fields::Field.new(:label => _('Connection Status'), :path => [:connection_status]),
77
78
  Fields::Field.new(:label => _('Hardware Version'), :path => [:hardware_version]),
78
79
  Fields::Field.new(:label => _('Path'), :path => [:path]),
79
- Fields::Field.new(:label => _('Operating System'), :path => [:operatingsystem])
80
+ Fields::Field.new(:label => _('Operating System'), :path => [:operatingsystem]),
81
+ Fields::List.new(:label => _('Boot order'), :path => [:boot_order])
80
82
  ]
81
83
  end
82
84
 
@@ -1,28 +1,5 @@
1
1
  module HammerCLIForeman
2
-
3
- module DomainUpdateCreateCommons
4
-
5
- def self.included(base)
6
- base.option "--dns-id", "DNS_ID", _("ID of DNS proxy to use within this domain")
7
- base.option "--dns", "DNS_NAME", _("Name of DNS proxy to use within this domain")
8
- end
9
-
10
- def request_params
11
- params = super
12
- params['domain']["dns_id"] = option_dns_id || dns_id(option_dns)
13
- params
14
- end
15
-
16
- private
17
-
18
- def dns_id(name)
19
- resolver.smart_proxy_id('option_name' => name) if name
20
- end
21
-
22
- end
23
-
24
2
  class Domain < HammerCLIForeman::Command
25
-
26
3
  resource :domains
27
4
 
28
5
  class ListCommand < HammerCLIForeman::ListCommand
@@ -52,24 +29,24 @@ module HammerCLIForeman
52
29
 
53
30
 
54
31
  class CreateCommand < HammerCLIForeman::CreateCommand
55
- include DomainUpdateCreateCommons
56
-
57
32
  success_message _("Domain [%{name}] created.")
58
33
  failure_message _("Could not create the domain")
59
34
 
60
35
  option "--description", "DESC", _("Full name describing the domain"), :attribute_name => :option_fullname
61
- build_options :without => [:domain_parameters_attributes, :fullname, :dns_id]
36
+ build_options :without => [:domain_parameters_attributes, :fullname]
37
+
38
+ extend_with(HammerCLIForeman::CommandExtensions::Domain.new)
62
39
  end
63
40
 
64
41
 
65
42
  class UpdateCommand < HammerCLIForeman::UpdateCommand
66
- include DomainUpdateCreateCommons
67
-
68
43
  success_message _("Domain [%{name}] updated.")
69
44
  failure_message _("Could not update the domain")
70
45
 
71
46
  option "--description", "DESC", _("Full name describing the domain"), :attribute_name => :option_fullname
72
47
  build_options :without => [:domain_parameters_attributes, :fullname]
48
+
49
+ extend_with(HammerCLIForeman::CommandExtensions::Domain.new)
73
50
  end
74
51
 
75
52
 
@@ -97,10 +97,10 @@ module HammerCLIForeman
97
97
 
98
98
  def request_params
99
99
  params = super
100
- if !override?
100
+ unless override?
101
101
  # Clear taxonomies in case the filter is switching override from true to false
102
- params['filter']['location_ids'] = []
103
- params['filter']['organization_ids'] = []
102
+ params['filter']['location_ids'] = [] if !@filter || !@filter['locations'].empty?
103
+ params['filter']['organization_ids'] = [] if !@filter || !@filter['organizations'].empty?
104
104
  end
105
105
  params
106
106
  end
@@ -55,6 +55,7 @@ module HammerCLIForeman
55
55
  field nil, _("Compute Resource"), Fields::SingleReference, :key => :compute_resource
56
56
  field nil, _("Compute Profile"), Fields::SingleReference, :key => :compute_profile, :hide_blank => true
57
57
  field :certname, _("Cert name")
58
+ field :token, _("Token")
58
59
  field :managed, _("Managed"), Fields::Boolean
59
60
 
60
61
  field :installed_at, _("Installed at"), Fields::Date
@@ -29,6 +29,7 @@ module HammerCLIForeman
29
29
  class InfoCommand < HammerCLIForeman::InfoCommand
30
30
 
31
31
  output ListCommand.output_definition do
32
+ field :mail_enabled, _("Email enabled"), Fields::Boolean
32
33
  field :effective_admin, _("Effective admin"), Fields::Boolean
33
34
  field :locale, _("Locale")
34
35
  field :timezone, _("Timezone")
@@ -1,5 +1,5 @@
1
1
  module HammerCLIForeman
2
2
  def self.version
3
- @version ||= Gem::Version.new "3.1.0"
3
+ @version ||= Gem::Version.new "3.2.0"
4
4
  end
5
5
  end
@@ -0,0 +1,91 @@
1
+ require_relative '../test_helper'
2
+
3
+ describe 'Domain' do
4
+ describe 'CreateCommand' do
5
+ let(:cmd) { %w[domain create] }
6
+ let(:minimal_params) { %w[--name=dom1.com] }
7
+
8
+ def domain_params(additional_params = {})
9
+ params = {
10
+ domain: {
11
+ name: 'dom1.com'
12
+ }
13
+ }
14
+ params[:domain].merge!(additional_params)
15
+ params
16
+ end
17
+
18
+ it 'should print error on missing --name' do
19
+ expected_result = missing_args_error_result(cmd, '--name')
20
+
21
+ api_expects_no_call
22
+
23
+ result = run_cmd(cmd)
24
+ assert_cmd(expected_result, result)
25
+ end
26
+
27
+ it 'allows minimal options' do
28
+ api_expects(:domains, :create).with_params(domain_params)
29
+
30
+ run_cmd(cmd + minimal_params)
31
+ end
32
+
33
+ it 'allows description' do
34
+ params = %w[--description=shortdesc]
35
+ api_expects(:domains, :create).with_params(domain_params(fullname: 'shortdesc'))
36
+
37
+ run_cmd(cmd + minimal_params + params)
38
+ end
39
+
40
+ it 'allows dns id' do
41
+ params = %w[--dns-id=1]
42
+ api_expects(:domains, :create).with_params(domain_params(dns_id: 1))
43
+
44
+ run_cmd(cmd + minimal_params + params)
45
+ end
46
+
47
+ it 'allows dns name' do
48
+ params = %w[--dns=sp1]
49
+ api_expects_search(:smart_proxies, { name: 'sp1' }).returns(
50
+ index_response([{ 'id' => 1 }])
51
+ )
52
+ api_expects(:domains, :create).with_params(domain_params(dns_id: 1))
53
+
54
+ run_cmd(cmd + minimal_params + params)
55
+ end
56
+
57
+ it 'allows location ids' do
58
+ params = %w[--location-ids=1,4]
59
+ api_expects(:domains, :create).with_params(domain_params(location_ids: %w[1 4]))
60
+
61
+ run_cmd(cmd + minimal_params + params)
62
+ end
63
+
64
+ it 'allows location names' do
65
+ params = %w[--locations=loc1,loc2]
66
+ api_expects(:locations, :index) do |p|
67
+ p[:search] == 'name = "loc1" or name = "loc2"'
68
+ end.returns(index_response([{ 'id' => 1 }, { 'id' => 2 }]))
69
+ api_expects(:domains, :create).with_params(domain_params(location_ids: [1, 2]))
70
+
71
+ run_cmd(cmd + minimal_params + params)
72
+ end
73
+
74
+ it 'allows organization ids' do
75
+ params = %w[--organization-ids=1,4]
76
+ api_expects(:domains, :create).with_params(domain_params(organization_ids: %w[1 4]))
77
+
78
+ run_cmd(cmd + minimal_params + params)
79
+ end
80
+
81
+ it 'allows organization names' do
82
+ params = %w[--organizations=org1,org2]
83
+ api_expects(:organizations, :index) do |p|
84
+ p[:search] == 'name = "org1" or name = "org2"'
85
+ end.returns(index_response([{ 'id' => 1 }, { 'id' => 2 }]))
86
+ api_expects(:domains, :create).with_params(domain_params(organization_ids: [1, 2]))
87
+
88
+ run_cmd(cmd + minimal_params + params)
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,90 @@
1
+ require_relative '../test_helper'
2
+
3
+ describe 'Domain' do
4
+ describe 'UpdateCommand' do
5
+ let(:cmd) { %w[domain update] }
6
+ let(:minimal_params) { %w[--id=1] }
7
+
8
+ def domain_params(additional_params = {})
9
+ params = {
10
+ id: '1',
11
+ domain: {}
12
+ }
13
+ params[:domain].merge!(additional_params)
14
+ params
15
+ end
16
+
17
+ it 'should print error on missing --id' do
18
+ expected_result = missing_args_error_result(cmd, '--id')
19
+
20
+ api_expects_no_call
21
+
22
+ result = run_cmd(cmd)
23
+ assert_cmd(expected_result, result)
24
+ end
25
+
26
+ it 'allows minimal options' do
27
+ api_expects(:domains, :update).with_params(domain_params)
28
+
29
+ run_cmd(cmd + minimal_params)
30
+ end
31
+
32
+ it 'allows description' do
33
+ params = %w[--description=shortdesc]
34
+ api_expects(:domains, :update).with_params(domain_params(fullname: 'shortdesc'))
35
+
36
+ run_cmd(cmd + minimal_params + params)
37
+ end
38
+
39
+ it 'allows dns id' do
40
+ params = %w[--dns-id=1]
41
+ api_expects(:domains, :update).with_params(domain_params(dns_id: 1))
42
+
43
+ run_cmd(cmd + minimal_params + params)
44
+ end
45
+
46
+ it 'allows dns name' do
47
+ params = %w[--dns=sp1]
48
+ api_expects_search(:smart_proxies, { name: 'sp1' }).returns(
49
+ index_response([{ 'id' => 1 }])
50
+ )
51
+ api_expects(:domains, :update).with_params(domain_params(dns_id: 1))
52
+
53
+ run_cmd(cmd + minimal_params + params)
54
+ end
55
+
56
+ it 'allows location ids' do
57
+ params = %w[--location-ids=1,4]
58
+ api_expects(:domains, :update).with_params(domain_params(location_ids: %w[1 4]))
59
+
60
+ run_cmd(cmd + minimal_params + params)
61
+ end
62
+
63
+ it 'allows location names' do
64
+ params = %w[--locations=loc1,loc2]
65
+ api_expects(:locations, :index) do |p|
66
+ p[:search] == 'name = "loc1" or name = "loc2"'
67
+ end.returns(index_response([{ 'id' => 1 }, { 'id' => 2 }]))
68
+ api_expects(:domains, :update).with_params(domain_params(location_ids: [1, 2]))
69
+
70
+ run_cmd(cmd + minimal_params + params)
71
+ end
72
+
73
+ it 'allows organization ids' do
74
+ params = %w[--organization-ids=1,4]
75
+ api_expects(:domains, :update).with_params(domain_params(organization_ids: %w[1 4]))
76
+
77
+ run_cmd(cmd + minimal_params + params)
78
+ end
79
+
80
+ it 'allows organization names' do
81
+ params = %w[--organizations=org1,org2]
82
+ api_expects(:organizations, :index) do |p|
83
+ p[:search] == 'name = "org1" or name = "org2"'
84
+ end.returns(index_response([{ 'id' => 1 }, { 'id' => 2 }]))
85
+ api_expects(:domains, :update).with_params(domain_params(organization_ids: [1, 2]))
86
+
87
+ run_cmd(cmd + minimal_params + params)
88
+ end
89
+ end
90
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammer_cli_foreman
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomáš Strachota
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-11-10 00:00:00.000000000 Z
12
+ date: 2022-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hammer_cli
@@ -123,6 +123,7 @@ files:
123
123
  - lib/hammer_cli_foreman/bookmark.rb
124
124
  - lib/hammer_cli_foreman/combination.rb
125
125
  - lib/hammer_cli_foreman/command_extensions.rb
126
+ - lib/hammer_cli_foreman/command_extensions/domain.rb
126
127
  - lib/hammer_cli_foreman/command_extensions/fields.rb
127
128
  - lib/hammer_cli_foreman/command_extensions/hosts.rb
128
129
  - lib/hammer_cli_foreman/command_extensions/hosts/help.rb
@@ -253,6 +254,8 @@ files:
253
254
  - test/functional/compute_attribute_test.rb
254
255
  - test/functional/compute_profile_test.rb
255
256
  - test/functional/compute_resource_test.rb
257
+ - test/functional/domain/create_test.rb
258
+ - test/functional/domain/update_test.rb
256
259
  - test/functional/filter_test.rb
257
260
  - test/functional/host_test.rb
258
261
  - test/functional/hostgroup/create_test.rb
@@ -382,14 +385,13 @@ test_files:
382
385
  - test/data/3.1/foreman_api.json
383
386
  - test/functional/auth_source_test.rb
384
387
  - test/functional/commands/list_test.rb
388
+ - test/functional/usergroup_test.rb
385
389
  - test/functional/hostgroup/create_test.rb
386
390
  - test/functional/hostgroup/update_test.rb
387
- - test/functional/compute_profile_test.rb
388
- - test/functional/model_test.rb
389
- - test/functional/operating_system_test.rb
390
391
  - test/functional/personal_access_token_test.rb
391
- - test/functional/user_mail_notification_test.rb
392
392
  - test/functional/template_test.rb
393
+ - test/functional/compute_attribute_test.rb
394
+ - test/functional/model_test.rb
393
395
  - test/functional/ssh_keys_test.rb
394
396
  - test/functional/subnet/update_test.rb
395
397
  - test/functional/subnet/create_test.rb
@@ -398,32 +400,35 @@ test_files:
398
400
  - test/functional/http_proxy_test.rb
399
401
  - test/functional/media_test.rb
400
402
  - test/functional/registration_test.rb
401
- - test/functional/usergroup_test.rb
402
- - test/functional/architecture_test.rb
403
- - test/functional/bookmark_test.rb
403
+ - test/functional/user_mail_notification_test.rb
404
+ - test/functional/domain/create_test.rb
405
+ - test/functional/domain/update_test.rb
406
+ - test/functional/operating_system_test.rb
404
407
  - test/functional/compute_resource_test.rb
405
408
  - test/functional/organization_test.rb
406
409
  - test/functional/report_template_test.rb
407
410
  - test/functional/user_test.rb
408
411
  - test/functional/virtual_machine_test.rb
412
+ - test/functional/host_test.rb
409
413
  - test/functional/mail_notification_test.rb
410
- - test/functional/settings_test.rb
411
- - test/functional/compute_attribute_test.rb
414
+ - test/functional/bookmark_test.rb
415
+ - test/functional/location_test.rb
412
416
  - test/functional/associating_commands_test.rb
413
417
  - test/functional/audit_test.rb
414
418
  - test/functional/ping_test.rb
415
419
  - test/functional/realm_test.rb
416
420
  - test/functional/role_test.rb
417
421
  - test/functional/status_test.rb
418
- - test/functional/host_test.rb
419
- - test/functional/location_test.rb
422
+ - test/functional/architecture_test.rb
423
+ - test/functional/compute_profile_test.rb
424
+ - test/functional/settings_test.rb
420
425
  - test/unit/api/void_auth_test.rb
421
426
  - test/unit/api/interactive_basic_auth_test.rb
422
427
  - test/unit/api/oauth/oauth_authentication_code_grant_test.rb
423
428
  - test/unit/api/oauth/oauth_password_grant_test.rb
424
429
  - test/unit/api/session_authenticator_wrapper_test.rb
425
430
  - test/unit/test_output_adapter.rb
426
- - test/unit/smart_proxy_test.rb
431
+ - test/unit/settings_test.rb
427
432
  - test/unit/auth_source_ldap_test.rb
428
433
  - test/unit/config_report_test.rb
429
434
  - test/unit/compute_resource_test.rb
@@ -443,18 +448,20 @@ test_files:
443
448
  - test/unit/output/formatters_test.rb
444
449
  - test/unit/common_parameter_test.rb
445
450
  - test/unit/realm_test.rb
446
- - test/unit/mail_notification_test.rb
447
- - test/unit/option_builders_test.rb
451
+ - test/unit/compute_profile_test.rb
452
+ - test/unit/host_test.rb
448
453
  - test/unit/subnet_test.rb
449
454
  - test/unit/test_helper.rb
450
455
  - test/unit/user_test.rb
451
456
  - test/unit/param_filters_test.rb
452
457
  - test/unit/partition_table_test.rb
453
458
  - test/unit/role_test.rb
459
+ - test/unit/hostgroup_test.rb
460
+ - test/unit/id_resolver_test.rb
461
+ - test/unit/mail_notification_test.rb
462
+ - test/unit/model_test.rb
454
463
  - test/unit/operating_system_test.rb
455
- - test/unit/apipie_resource_mock.rb
456
- - test/unit/architecture_test.rb
457
- - test/unit/settings_test.rb
464
+ - test/unit/option_builders_test.rb
458
465
  - test/unit/audit_test.rb
459
466
  - test/unit/auth_source_external.rb
460
467
  - test/unit/dependency_resolver_test.rb
@@ -462,15 +469,13 @@ test_files:
462
469
  - test/unit/filter_test.rb
463
470
  - test/unit/media_test.rb
464
471
  - test/unit/sessions_test.rb
465
- - test/unit/bookmark_test.rb
472
+ - test/unit/apipie_resource_mock.rb
466
473
  - test/unit/commands_test.rb
467
474
  - test/unit/api_test.rb
468
- - test/unit/compute_profile_test.rb
469
- - test/unit/host_test.rb
470
- - test/unit/hostgroup_test.rb
471
- - test/unit/id_resolver_test.rb
472
- - test/unit/model_test.rb
473
- - test/unit/template_test.rb
475
+ - test/unit/architecture_test.rb
476
+ - test/unit/smart_proxy_test.rb
474
477
  - test/unit/usergroup_test.rb
478
+ - test/unit/template_test.rb
479
+ - test/unit/bookmark_test.rb
475
480
  - test/unit/domain_test.rb
476
481
  - test/test_helper.rb