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.
- checksums.yaml +4 -4
- data/doc/release_notes.md +40 -0
- data/lib/hammer_cli_foreman/architecture.rb +5 -5
- data/lib/hammer_cli_foreman/associating_commands.rb +0 -24
- data/lib/hammer_cli_foreman/bookmark.rb +5 -5
- data/lib/hammer_cli_foreman/combination.rb +3 -13
- data/lib/hammer_cli_foreman/command_extensions/ping.rb +21 -2
- data/lib/hammer_cli_foreman/command_extensions/subnet.rb +25 -10
- data/lib/hammer_cli_foreman/command_extensions/update_common.rb +14 -0
- data/lib/hammer_cli_foreman/command_extensions/user.rb +9 -5
- data/lib/hammer_cli_foreman/command_extensions.rb +1 -2
- data/lib/hammer_cli_foreman/commands.rb +17 -11
- data/lib/hammer_cli_foreman/compute_attribute.rb +1 -1
- data/lib/hammer_cli_foreman/compute_profile.rb +5 -5
- data/lib/hammer_cli_foreman/compute_resource/ovirt.rb +2 -1
- data/lib/hammer_cli_foreman/compute_resource.rb +23 -0
- data/lib/hammer_cli_foreman/config_report.rb +2 -0
- data/lib/hammer_cli_foreman/filter.rb +2 -2
- data/lib/hammer_cli_foreman/host.rb +1 -47
- data/lib/hammer_cli_foreman/hostgroup.rb +14 -58
- data/lib/hammer_cli_foreman/hosts/common_update_options.rb +10 -31
- data/lib/hammer_cli_foreman/id_resolver.rb +7 -68
- data/lib/hammer_cli_foreman/location.rb +0 -6
- data/lib/hammer_cli_foreman/mail_notification.rb +2 -2
- data/lib/hammer_cli_foreman/model.rb +5 -5
- data/lib/hammer_cli_foreman/operating_system.rb +10 -10
- data/lib/hammer_cli_foreman/option_builders.rb +84 -52
- data/lib/hammer_cli_foreman/option_sources/id_params.rb +41 -11
- data/lib/hammer_cli_foreman/option_sources/ids_params.rb +39 -7
- data/lib/hammer_cli_foreman/option_sources.rb +0 -1
- data/lib/hammer_cli_foreman/organization.rb +0 -6
- data/lib/hammer_cli_foreman/ping.rb +6 -1
- data/lib/hammer_cli_foreman/references.rb +0 -16
- data/lib/hammer_cli_foreman/registration.rb +18 -0
- data/lib/hammer_cli_foreman/settings.rb +3 -3
- data/lib/hammer_cli_foreman/smart_proxy.rb +7 -57
- data/lib/hammer_cli_foreman/template.rb +3 -15
- data/lib/hammer_cli_foreman/user.rb +4 -4
- data/lib/hammer_cli_foreman/usergroup.rb +5 -5
- data/lib/hammer_cli_foreman/version.rb +1 -1
- data/lib/hammer_cli_foreman.rb +3 -21
- data/lib/minitest/coverage_reporter.rb +1 -1
- data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/test/data/2.4/foreman_api.json +1 -0
- data/test/data/2.5/foreman_api.json +1 -0
- data/test/data/3.1/foreman_api.json +1 -0
- data/test/functional/architecture_test.rb +37 -5
- data/test/functional/bookmark_test.rb +5 -2
- data/test/functional/compute_attribute_test.rb +20 -20
- data/test/functional/compute_profile_test.rb +14 -1
- data/test/functional/compute_resource_test.rb +37 -0
- data/test/functional/filter_test.rb +2 -1
- data/test/functional/host_test.rb +65 -11
- data/test/functional/hostgroup/create_test.rb +11 -117
- data/test/functional/hostgroup/update_test.rb +11 -79
- data/test/functional/http_proxy_test.rb +12 -0
- data/test/functional/location_test.rb +13 -3
- data/test/functional/mail_notification_test.rb +3 -1
- data/test/functional/media_test.rb +11 -0
- data/test/functional/model_test.rb +3 -1
- data/test/functional/operating_system_test.rb +3 -1
- data/test/functional/personal_access_token_test.rb +4 -4
- data/test/functional/ping_test.rb +33 -0
- data/test/functional/realm_test.rb +11 -0
- data/test/functional/registration_test.rb +8 -0
- data/test/functional/report_template_test.rb +11 -0
- data/test/functional/settings_test.rb +4 -4
- data/test/functional/template_test.rb +87 -48
- data/test/functional/user_mail_notification_test.rb +3 -3
- data/test/functional/user_test.rb +11 -0
- data/test/functional/usergroup_test.rb +3 -1
- data/test/test_helper.rb +1 -1
- data/test/unit/apipie_resource_mock.rb +1 -39
- data/test/unit/architecture_test.rb +10 -10
- data/test/unit/bookmark_test.rb +10 -14
- data/test/unit/commands_test.rb +1 -2
- data/test/unit/compute_profile_test.rb +10 -10
- data/test/unit/config_report_test.rb +1 -0
- data/test/unit/helpers/command.rb +0 -8
- data/test/unit/host_test.rb +14 -61
- data/test/unit/hostgroup_test.rb +7 -26
- data/test/unit/id_resolver_test.rb +0 -28
- data/test/unit/mail_notification_test.rb +4 -4
- data/test/unit/model_test.rb +47 -47
- data/test/unit/operating_system_test.rb +10 -16
- data/test/unit/option_builders_test.rb +88 -83
- data/test/unit/settings_test.rb +4 -4
- data/test/unit/smart_proxy_test.rb +0 -12
- data/test/unit/usergroup_test.rb +10 -10
- metadata +115 -128
- data/lib/hammer_cli_foreman/command_extensions/puppet_environment.rb +0 -29
- data/lib/hammer_cli_foreman/command_extensions/puppet_environments.rb +0 -29
- data/lib/hammer_cli_foreman/config_group.rb +0 -45
- data/lib/hammer_cli_foreman/option_sources/puppet_environment_params.rb +0 -59
- data/lib/hammer_cli_foreman/puppet_class.rb +0 -61
- data/lib/hammer_cli_foreman/puppet_environment.rb +0 -65
- data/lib/hammer_cli_foreman/smart_class_parameter.rb +0 -189
- data/test/functional/config_group_test.rb +0 -50
- data/test/functional/proxy_test.rb +0 -86
- data/test/functional/smart_class_parameter_test.rb +0 -97
- data/test/reports/TEST-Minitest-Result.xml +0 -4344
- data/test/unit/config_group_test.rb +0 -82
- data/test/unit/puppet_class_test.rb +0 -72
- data/test/unit/puppet_environment_test.rb +0 -114
- data/test/unit/smart_class_parameter_test.rb +0 -113
|
@@ -7,9 +7,9 @@ describe 'architecture' do
|
|
|
7
7
|
before do
|
|
8
8
|
@cmd = %w[architecture list]
|
|
9
9
|
@architectures = [{
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
id: 1,
|
|
11
|
+
name: 'i386'
|
|
12
|
+
}]
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it 'should return a list of architectures' do
|
|
@@ -26,7 +26,7 @@ describe 'architecture' do
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
it 'should run list command with defaults' do
|
|
29
|
-
providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.
|
|
29
|
+
providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.5')) }
|
|
30
30
|
defaults = HammerCLI::Defaults.new(
|
|
31
31
|
{
|
|
32
32
|
organization_id: {
|
|
@@ -39,11 +39,43 @@ describe 'architecture' do
|
|
|
39
39
|
)
|
|
40
40
|
defaults.stubs(:write_to_file).returns(true)
|
|
41
41
|
defaults.stubs(:providers).returns(providers)
|
|
42
|
+
api_expects(:users, :index, 'Find user').with_params(search: 'login=admin').returns(index_response([{ 'default_organization' => { 'id' => 2 } }]))
|
|
43
|
+
api_expects(:users, :index, 'Find user').with_params(search: 'login=admin').returns(index_response([{ 'default_location' => { 'id' => 1 } }]))
|
|
42
44
|
api_expects(:architectures, :index, 'List architectures').returns(@architectures)
|
|
43
45
|
|
|
44
46
|
result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
|
|
45
47
|
_(result.exit_code).must_equal HammerCLI::EX_OK
|
|
46
48
|
end
|
|
47
49
|
end
|
|
48
|
-
end
|
|
49
50
|
|
|
51
|
+
describe 'update' do
|
|
52
|
+
before do
|
|
53
|
+
@cmd = %w[architecture update]
|
|
54
|
+
@architecture = {
|
|
55
|
+
id: 1,
|
|
56
|
+
name: 'x86_64',
|
|
57
|
+
}
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it 'should update an architecture with id' do
|
|
61
|
+
params = %w[--id=1 --new-name=x86_64]
|
|
62
|
+
api_expects(:architectures, :update, 'Update architecture').returns(@architecture)
|
|
63
|
+
|
|
64
|
+
expected_result = success_result("Architecture updated.\n")
|
|
65
|
+
|
|
66
|
+
result = run_cmd(@cmd + params)
|
|
67
|
+
assert_cmd(expected_result, result)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it 'updates nothing without architecture related parameters' do
|
|
71
|
+
params = %w[--id=1]
|
|
72
|
+
api_expects(:architectures, :update, 'Update architecture with no params').returns({})
|
|
73
|
+
|
|
74
|
+
expected_result = success_result("Nothing to update.\n")
|
|
75
|
+
|
|
76
|
+
result = run_cmd(@cmd + params)
|
|
77
|
+
assert_cmd(expected_result, result)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -29,7 +29,7 @@ describe 'bookmark' do
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
it 'should run list command with defaults' do
|
|
32
|
-
providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.
|
|
32
|
+
providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.5')) }
|
|
33
33
|
defaults = HammerCLI::Defaults.new(
|
|
34
34
|
{
|
|
35
35
|
organization_id: {
|
|
@@ -42,6 +42,8 @@ describe 'bookmark' do
|
|
|
42
42
|
)
|
|
43
43
|
defaults.stubs(:write_to_file).returns(true)
|
|
44
44
|
defaults.stubs(:providers).returns(providers)
|
|
45
|
+
api_expects(:users, :index, 'Find user').with_params(search: 'login=admin').returns(index_response([{ 'default_organization' => { 'id' => 2 } }]))
|
|
46
|
+
api_expects(:users, :index, 'Find user').with_params(search: 'login=admin').returns(index_response([{ 'default_location' => { 'id' => 1 } }]))
|
|
45
47
|
api_expects(:bookmarks, :index, 'List bookmarks').returns(@bookmarks)
|
|
46
48
|
|
|
47
49
|
result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
|
|
@@ -158,7 +160,8 @@ describe 'bookmark' do
|
|
|
158
160
|
api_expects(:bookmarks, :update) do |par|
|
|
159
161
|
par['id'] == '1'
|
|
160
162
|
end
|
|
161
|
-
run_cmd(%w[bookmark update --id 1])
|
|
163
|
+
result = run_cmd(%w[bookmark update --id 1])
|
|
164
|
+
assert_cmd(success_result("Nothing to update.\n"), result)
|
|
162
165
|
end
|
|
163
166
|
|
|
164
167
|
it 'update bookmark' do
|
|
@@ -11,11 +11,11 @@ describe "parameters" do
|
|
|
11
11
|
}
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
it
|
|
14
|
+
it 'should print error on missing --compute-profile-id or --compute-profile' do
|
|
15
15
|
expected_result = common_error_result(
|
|
16
16
|
@cmd,
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
'Could not find compute_profile, please set one of options --compute-profile-id, --compute-profile.',
|
|
18
|
+
'Could not set the compute profile attributes'
|
|
19
19
|
)
|
|
20
20
|
|
|
21
21
|
api_expects_no_call
|
|
@@ -23,12 +23,12 @@ describe "parameters" do
|
|
|
23
23
|
assert_cmd(expected_result, result)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
it
|
|
26
|
+
it 'should print error on missing --compute-resource-id or --compute-resource' do
|
|
27
27
|
params = ['--compute-profile-id=1']
|
|
28
28
|
expected_result = common_error_result(
|
|
29
29
|
@cmd,
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
'Could not find compute_resource, please set one of options --compute-resource-id, --compute-resource.',
|
|
31
|
+
'Could not set the compute profile attributes'
|
|
32
32
|
)
|
|
33
33
|
|
|
34
34
|
api_expects_no_call
|
|
@@ -103,11 +103,11 @@ describe "parameters" do
|
|
|
103
103
|
params = ['--compute-profile-id=1', '--compute-resource-id=1', '--compute-attributes', 'cores=1']
|
|
104
104
|
|
|
105
105
|
api_expects(:compute_profiles, :show) do |par|
|
|
106
|
-
par['id'] == 1
|
|
106
|
+
par['id'] == '1'
|
|
107
107
|
end.returns(@compute_profile)
|
|
108
108
|
|
|
109
109
|
api_expects(:compute_resources, :show) do |par|
|
|
110
|
-
par['id'] == 1
|
|
110
|
+
par['id'] == '1'
|
|
111
111
|
end.returns(@compute_resource)
|
|
112
112
|
|
|
113
113
|
api_expects(:compute_attributes, :update) do |par|
|
|
@@ -177,7 +177,7 @@ describe "parameters" do
|
|
|
177
177
|
expected_result.expected_exit_code = HammerCLI::EX_USAGE
|
|
178
178
|
|
|
179
179
|
api_expects(:compute_profiles, :show) do |par|
|
|
180
|
-
par['id'] == 1
|
|
180
|
+
par['id'] == '1'
|
|
181
181
|
end.returns(@compute_profile)
|
|
182
182
|
|
|
183
183
|
result = run_cmd(@cmd + params)
|
|
@@ -189,7 +189,7 @@ describe "parameters" do
|
|
|
189
189
|
params = ['--compute-profile-id=1', '--compute-resource-id=1', '--volume', 'size_gb=1']
|
|
190
190
|
|
|
191
191
|
api_expects(:compute_profiles, :show) do |par|
|
|
192
|
-
par['id'] == 1
|
|
192
|
+
par['id'] == '1'
|
|
193
193
|
end.returns(@compute_profile)
|
|
194
194
|
|
|
195
195
|
api_expects(:compute_attributes, :update) do |par|
|
|
@@ -261,7 +261,7 @@ describe "parameters" do
|
|
|
261
261
|
params = ['--compute-profile-id=1', '--compute-resource-id=1', '--volume-id=1', '--volume', 'size_gb=1']
|
|
262
262
|
|
|
263
263
|
api_expects(:compute_profiles, :show) do |par|
|
|
264
|
-
par['id'] == 1
|
|
264
|
+
par['id'] == '1'
|
|
265
265
|
end.returns(@compute_profile)
|
|
266
266
|
|
|
267
267
|
api_expects(:compute_attributes, :update) do |par|
|
|
@@ -339,7 +339,7 @@ describe "parameters" do
|
|
|
339
339
|
params = ['--compute-profile-id=1', '--compute-resource-id=1', '--volume-id=1']
|
|
340
340
|
|
|
341
341
|
api_expects(:compute_profiles, :show) do |par|
|
|
342
|
-
par['id'] == 1
|
|
342
|
+
par['id'] == '1'
|
|
343
343
|
end.returns(@compute_profile)
|
|
344
344
|
|
|
345
345
|
api_expects(:compute_attributes, :update) do |par|
|
|
@@ -438,7 +438,7 @@ describe "parameters" do
|
|
|
438
438
|
expected_result.expected_exit_code = HammerCLI::EX_USAGE
|
|
439
439
|
|
|
440
440
|
api_expects(:compute_profiles, :show) do |par|
|
|
441
|
-
par['id'] == 1
|
|
441
|
+
par['id'] == '1'
|
|
442
442
|
end.returns(@compute_profile)
|
|
443
443
|
result = run_cmd(@cmd + params)
|
|
444
444
|
assert_cmd(expected_result, result)
|
|
@@ -455,7 +455,7 @@ describe "parameters" do
|
|
|
455
455
|
response = HammerCLIForeman.foreman_api.api.send(:create_fake_response, 404,
|
|
456
456
|
expected_message, "GET", "http://example.com/", {})
|
|
457
457
|
api_expects(:compute_profiles, :show) do |par|
|
|
458
|
-
par['id'] == 200
|
|
458
|
+
par['id'] == '200'
|
|
459
459
|
end.raises(RestClient::NotFound, response)
|
|
460
460
|
|
|
461
461
|
result = run_cmd(@cmd + params)
|
|
@@ -465,11 +465,11 @@ describe "parameters" do
|
|
|
465
465
|
it "should add interface" do
|
|
466
466
|
params = [ '--interface', 'name=eth0', '--compute-profile-id=1', '--compute-resource-id=1']
|
|
467
467
|
api_expects(:compute_profiles, :show) do |par|
|
|
468
|
-
par['id'] == 1
|
|
468
|
+
par['id'] == '1'
|
|
469
469
|
end.returns(@compute_profile)
|
|
470
470
|
|
|
471
471
|
api_expects(:compute_resources, :show) do |par|
|
|
472
|
-
par['id'] == 1
|
|
472
|
+
par['id'] == '1'
|
|
473
473
|
end.returns(@compute_resource)
|
|
474
474
|
|
|
475
475
|
api_expects(:compute_attributes, :update) do |par|
|
|
@@ -548,11 +548,11 @@ describe "parameters" do
|
|
|
548
548
|
params = ['--compute-profile-id=1', '--compute-resource-id=1', '--interface-id=1', '--interface', 'compute_name=eth0']
|
|
549
549
|
|
|
550
550
|
api_expects(:compute_profiles, :show) do |par|
|
|
551
|
-
par['id'] == 1
|
|
551
|
+
par['id'] == '1'
|
|
552
552
|
end.returns(@compute_profile)
|
|
553
553
|
|
|
554
554
|
api_expects(:compute_resources, :show) do |par|
|
|
555
|
-
par['id'] == 1
|
|
555
|
+
par['id'] == '1'
|
|
556
556
|
end.returns(@compute_resource)
|
|
557
557
|
|
|
558
558
|
api_expects(:compute_attributes, :update) do |par|
|
|
@@ -637,11 +637,11 @@ describe "parameters" do
|
|
|
637
637
|
params = ['--compute-profile-id=1', '--compute-resource-id=1', '--interface-id=1']
|
|
638
638
|
|
|
639
639
|
api_expects(:compute_profiles, :show) do |par|
|
|
640
|
-
par['id'] == 1
|
|
640
|
+
par['id'] == '1'
|
|
641
641
|
end.returns(@compute_profile)
|
|
642
642
|
|
|
643
643
|
api_expects(:compute_resources, :show) do |par|
|
|
644
|
-
par['id'] == 1
|
|
644
|
+
par['id'] == '1'
|
|
645
645
|
end.returns(@compute_resource)
|
|
646
646
|
|
|
647
647
|
api_expects(:compute_attributes, :update) do |par|
|
|
@@ -40,6 +40,17 @@ describe "parameters" do
|
|
|
40
40
|
result = run_cmd(@cmd + params)
|
|
41
41
|
assert_cmd(success_result("Compute profile updated.\n"), result)
|
|
42
42
|
end
|
|
43
|
+
|
|
44
|
+
it 'updates nothing without profile related parameters' do
|
|
45
|
+
params = %w[--id=1]
|
|
46
|
+
api_expects(:compute_profiles, :update, 'Update profile with no params').returns({})
|
|
47
|
+
|
|
48
|
+
expected_result = success_result("Nothing to update.\n")
|
|
49
|
+
|
|
50
|
+
result = run_cmd(@cmd + params)
|
|
51
|
+
assert_cmd(expected_result, result)
|
|
52
|
+
end
|
|
53
|
+
|
|
43
54
|
end
|
|
44
55
|
|
|
45
56
|
describe "delete compute profile" do
|
|
@@ -121,7 +132,7 @@ describe "parameters" do
|
|
|
121
132
|
end
|
|
122
133
|
|
|
123
134
|
it 'should run list command with defaults' do
|
|
124
|
-
providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.
|
|
135
|
+
providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.5')) }
|
|
125
136
|
defaults = HammerCLI::Defaults.new(
|
|
126
137
|
{
|
|
127
138
|
organization_id: {
|
|
@@ -134,6 +145,8 @@ describe "parameters" do
|
|
|
134
145
|
)
|
|
135
146
|
defaults.stubs(:write_to_file).returns(true)
|
|
136
147
|
defaults.stubs(:providers).returns(providers)
|
|
148
|
+
api_expects(:users, :index, 'Find user').with_params(search: 'login=admin').returns(index_response([{ 'default_organization' => { 'id' => 2 } }]))
|
|
149
|
+
api_expects(:users, :index, 'Find user').with_params(search: 'login=admin').returns(index_response([{ 'default_location' => { 'id' => 1 } }]))
|
|
137
150
|
api_expects(:compute_profiles, :index, 'List compute profiles').returns(@compute_profiles)
|
|
138
151
|
|
|
139
152
|
result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
|
|
@@ -51,6 +51,18 @@ describe 'compute-resource' do
|
|
|
51
51
|
assert_cmd(expected_result, result)
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
+
describe 'associate VMs to hosts' do
|
|
55
|
+
it 'successful associate vms to hosts' do
|
|
56
|
+
expected_result = success_result("Virtual machines have been associated.\n")
|
|
57
|
+
api_expects(:compute_resources, :associate, 'Associate VMs') do |p|
|
|
58
|
+
p['id'] == '1'
|
|
59
|
+
end
|
|
60
|
+
result = run_cmd(%w(compute-resource associate-vms --id 1))
|
|
61
|
+
assert_cmd(expected_result, result)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
|
|
54
66
|
it 'should print error for blank --provider option' do
|
|
55
67
|
params = %w(--provider= --name=new'')
|
|
56
68
|
expected_result = CommandExpectation.new
|
|
@@ -198,6 +210,31 @@ end
|
|
|
198
210
|
end
|
|
199
211
|
end
|
|
200
212
|
|
|
213
|
+
describe 'vnic profiles' do
|
|
214
|
+
let(:cmd) { base_cmd << 'vnic-profiles' }
|
|
215
|
+
let(:vnic_profile_1) { { id: 1, name: 'network1', network: 2 } }
|
|
216
|
+
let(:vnic_profile_2) { { id: 2, name: 'network2', network: 2 } }
|
|
217
|
+
let(:vnic_profiles) { [vnic_profile_1, vnic_profile_2] }
|
|
218
|
+
|
|
219
|
+
it 'lists available vnic profiles for a compute resource' do
|
|
220
|
+
api_expects(:compute_resources, :available_vnic_profiles, 'vnic-profiles').with_params(
|
|
221
|
+
'id' => '1'
|
|
222
|
+
).returns(index_response(vnic_profiles))
|
|
223
|
+
|
|
224
|
+
output = IndexMatcher.new(
|
|
225
|
+
[
|
|
226
|
+
['VNIC PROFILE ID', 'NAME', 'NETWORK ID'],
|
|
227
|
+
['1', 'network1','2'],
|
|
228
|
+
['2', 'network2','2']
|
|
229
|
+
]
|
|
230
|
+
)
|
|
231
|
+
expected_result = success_result(output)
|
|
232
|
+
|
|
233
|
+
result = run_cmd(cmd + base_params)
|
|
234
|
+
assert_cmd(expected_result, result)
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
|
|
201
238
|
describe 'images' do
|
|
202
239
|
let(:cmd) { base_cmd << 'images' }
|
|
203
240
|
let(:image1) { { uuid: 1, name: 'image1' } }
|
|
@@ -45,7 +45,7 @@ describe 'filter' do
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
result = run_cmd(@cmd + params)
|
|
48
|
-
assert_cmd(success_result("Permission filter for [%<
|
|
48
|
+
assert_cmd(success_result("Permission filter for [%<resource_type_label>s] created.\n"), result)
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
|
|
@@ -106,6 +106,7 @@ describe 'filter' do
|
|
|
106
106
|
@cmd = %w[filter update]
|
|
107
107
|
@filter = {
|
|
108
108
|
'search' => nil,
|
|
109
|
+
'resource_type_label' => 'User',
|
|
109
110
|
'resource_type' => 'User',
|
|
110
111
|
'unlimited?' => false,
|
|
111
112
|
'created_at' => '2017-07-18 14:34:09 UTC',
|
|
@@ -312,6 +312,39 @@ describe "host create" do
|
|
|
312
312
|
|
|
313
313
|
assert_cmd(expected_result, result)
|
|
314
314
|
end
|
|
315
|
+
|
|
316
|
+
it 'should create a host and set owner-type' do
|
|
317
|
+
params = ['--owner=admin']
|
|
318
|
+
|
|
319
|
+
api_expects_search(:users, {login: 'admin'}).returns(index_response([{ 'id' => 1 }]))
|
|
320
|
+
|
|
321
|
+
api_expects(:hosts, :create, 'Create a host with an owner').with_params(
|
|
322
|
+
'location_id' => 1, 'organization_id' => 1, 'host' => {
|
|
323
|
+
'owner_id' => 1, 'name' => 'test'
|
|
324
|
+
}
|
|
325
|
+
).returns(results: { 'owner' => 'admin', 'name' => 'test' })
|
|
326
|
+
|
|
327
|
+
expected_result = success_result("Host created.\n")
|
|
328
|
+
|
|
329
|
+
result = run_cmd(cmd + minimal_params_without_hostgroup + params)
|
|
330
|
+
|
|
331
|
+
assert_cmd(expected_result, result)
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
it 'should create a host with default owner-type User' do
|
|
335
|
+
|
|
336
|
+
api_expects(:hosts, :create, 'Create a host with an owner').with_params(
|
|
337
|
+
'location_id' => 1, 'organization_id' => 1, 'host' => {
|
|
338
|
+
'name' => 'test'
|
|
339
|
+
}
|
|
340
|
+
).returns(results: { 'owner_type' => 'User', 'name' => 'test' })
|
|
341
|
+
|
|
342
|
+
expected_result = success_result("Host created.\n")
|
|
343
|
+
|
|
344
|
+
result = run_cmd(cmd + minimal_params_without_hostgroup)
|
|
345
|
+
|
|
346
|
+
assert_cmd(expected_result, result)
|
|
347
|
+
end
|
|
315
348
|
end
|
|
316
349
|
|
|
317
350
|
describe 'host update' do
|
|
@@ -323,7 +356,6 @@ describe 'host update' do
|
|
|
323
356
|
'organization_id' => '5',
|
|
324
357
|
'location_id' => '5',
|
|
325
358
|
'compute_attributes' => {},
|
|
326
|
-
'puppetclass_ids' => [],
|
|
327
359
|
'owner_id' => '1',
|
|
328
360
|
'owner_name' => 'adminGroup',
|
|
329
361
|
'owner_type' => 'Usergroup'
|
|
@@ -371,7 +403,7 @@ describe 'host update' do
|
|
|
371
403
|
it 'updates nothing without host related parameters' do
|
|
372
404
|
api_expects(:hosts, :update, 'Update host with no host params').returns({})
|
|
373
405
|
|
|
374
|
-
expected_result = success_result("
|
|
406
|
+
expected_result = success_result("Nothing to update.\n")
|
|
375
407
|
|
|
376
408
|
result = run_cmd(cmd + minimal_params)
|
|
377
409
|
assert_cmd(expected_result, result)
|
|
@@ -536,17 +568,39 @@ describe 'disassociate host from vm' do
|
|
|
536
568
|
end
|
|
537
569
|
end
|
|
538
570
|
|
|
539
|
-
describe '
|
|
540
|
-
let(:cmd) { [
|
|
541
|
-
let(:
|
|
571
|
+
describe 'defaults' do
|
|
572
|
+
let(:cmd) { %w[host list] }
|
|
573
|
+
let(:defaults) do
|
|
574
|
+
HammerCLI::Defaults.new(
|
|
575
|
+
{
|
|
576
|
+
organization_id: {
|
|
577
|
+
value: '1'
|
|
578
|
+
},
|
|
579
|
+
organization: {
|
|
580
|
+
value: 'Default Organization'
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
)
|
|
584
|
+
end
|
|
542
585
|
|
|
543
|
-
it
|
|
544
|
-
|
|
545
|
-
expected_result.expected_err = "The puppetrun feature has been removed, however you can use the Remote Execution Plugin to run Puppet commands\n"
|
|
546
|
-
expected_result.expected_exit_code = HammerCLI::EX_SOFTWARE
|
|
586
|
+
it 'works with default org name overridden via cli' do
|
|
587
|
+
params = %w[--organization=Org2]
|
|
547
588
|
|
|
548
|
-
|
|
549
|
-
|
|
589
|
+
api_expects_search(:organizations, name: 'Org2').returns(index_response([{ 'id' => '2' }]))
|
|
590
|
+
api_expects(:hosts, :index) do |p|
|
|
591
|
+
p['organization_id'] == '2'
|
|
592
|
+
end
|
|
593
|
+
|
|
594
|
+
run_cmd(cmd + params, { use_defaults: true, defaults: defaults })
|
|
595
|
+
end
|
|
596
|
+
it 'works with default org id overridden via cli' do
|
|
597
|
+
params = %w[--organization-id=2]
|
|
598
|
+
|
|
599
|
+
api_expects(:hosts, :index) do |p|
|
|
600
|
+
p['organization_id'] == '2'
|
|
601
|
+
end
|
|
602
|
+
|
|
603
|
+
run_cmd(cmd + params, { use_defaults: true, defaults: defaults })
|
|
550
604
|
end
|
|
551
605
|
end
|
|
552
606
|
|
|
@@ -68,25 +68,6 @@ module HammerCLIForeman
|
|
|
68
68
|
run_cmd(%w(hostgroup create --name hg1 --domain d1))
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
-
it 'allows environment id' do
|
|
72
|
-
api_expects(:hostgroups, :create) do |p|
|
|
73
|
-
p['hostgroup']['environment_id'] == 1 &&
|
|
74
|
-
p['hostgroup']['name'] == 'hg1'
|
|
75
|
-
end
|
|
76
|
-
run_cmd(%w(hostgroup create --name hg1 --environment-id 1))
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
it 'allows environment name' do
|
|
80
|
-
api_expects(:environments, :index) do |p|
|
|
81
|
-
p[:search] = "name = \"env1\""
|
|
82
|
-
end.returns(index_response([{'id' => 1}]))
|
|
83
|
-
api_expects(:hostgroups, :create) do |p|
|
|
84
|
-
p['hostgroup']['environment_id'] == 1 &&
|
|
85
|
-
p['hostgroup']['name'] == 'hg1'
|
|
86
|
-
end
|
|
87
|
-
run_cmd(%w(hostgroup create --name hg1 --environment env1))
|
|
88
|
-
end
|
|
89
|
-
|
|
90
71
|
it 'allows location ids' do
|
|
91
72
|
api_expects(:hostgroups, :create) do |p|
|
|
92
73
|
p['hostgroup']['location_ids'] == ['1','4'] &&
|
|
@@ -184,6 +165,17 @@ module HammerCLIForeman
|
|
|
184
165
|
run_cmd(%w(hostgroup create --name hg1 --parent parent_hg))
|
|
185
166
|
end
|
|
186
167
|
|
|
168
|
+
it 'allows parent hostgroup title' do
|
|
169
|
+
api_expects(:hostgroups, :index) do |p|
|
|
170
|
+
p[:search] = 'title = "parent_hg"'
|
|
171
|
+
end.returns(index_response([{ 'id' => 1 }]))
|
|
172
|
+
api_expects(:hostgroups, :create) do |p|
|
|
173
|
+
p['hostgroup']['parent_id'] == 1 &&
|
|
174
|
+
p['hostgroup']['name'] == 'hg1'
|
|
175
|
+
end
|
|
176
|
+
run_cmd(%w[hostgroup create --name hg1 --parent parent_hg])
|
|
177
|
+
end
|
|
178
|
+
|
|
187
179
|
it 'allows partition table id' do
|
|
188
180
|
api_expects(:hostgroups, :create) do |p|
|
|
189
181
|
p['hostgroup']['ptable_id'] == 1 &&
|
|
@@ -203,104 +195,6 @@ module HammerCLIForeman
|
|
|
203
195
|
run_cmd(%w(hostgroup create --name hg1 --partition-table pt1))
|
|
204
196
|
end
|
|
205
197
|
|
|
206
|
-
it 'allows puppet ca proxy id' do
|
|
207
|
-
api_expects(:hostgroups, :create).with_params({
|
|
208
|
-
:hostgroup => {
|
|
209
|
-
:name => 'hg1',
|
|
210
|
-
:puppet_ca_proxy_id => 1
|
|
211
|
-
}
|
|
212
|
-
})
|
|
213
|
-
run_cmd(%w(hostgroup create --name hg1 --puppet-ca-proxy-id 1))
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
it 'allows puppet ca proxy name' do
|
|
217
|
-
api_expects(:smart_proxies, :index) do |p|
|
|
218
|
-
p[:search] = "name = \"sp1\""
|
|
219
|
-
end.returns(index_response([{'id' => 1}]))
|
|
220
|
-
api_expects(:hostgroups, :create) do |p|
|
|
221
|
-
p['hostgroup']['puppet_ca_proxy_id'] == 1 &&
|
|
222
|
-
p['hostgroup']['name'] == 'hg1'
|
|
223
|
-
end
|
|
224
|
-
run_cmd(%w(hostgroup create --name hg1 --puppet-ca-proxy sp1))
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
it 'allows puppet class ids' do
|
|
228
|
-
api_expects(:hostgroups, :create) do |p|
|
|
229
|
-
p['hostgroup']['puppetclass_ids'] == ['1','2'] &&
|
|
230
|
-
p['hostgroup']['name'] == 'hg1'
|
|
231
|
-
end
|
|
232
|
-
run_cmd(%w(hostgroup create --name hg1 --puppet-class-ids 1,2))
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
it 'allows puppet class names' do
|
|
236
|
-
api_expects(:puppetclasses, :index) do |p|
|
|
237
|
-
p[:search] = "name = \"pc1\" or name = \"pc2\""
|
|
238
|
-
end.returns(index_response('puppetclasses' => [
|
|
239
|
-
{'id' => 1, 'name' => 'pc1'},
|
|
240
|
-
{'id' => 2, 'name' => 'pc2'}
|
|
241
|
-
]))
|
|
242
|
-
api_expects(:hostgroups, :create) do |p|
|
|
243
|
-
p['hostgroup']['puppetclass_ids'] == [1,2] &&
|
|
244
|
-
p['hostgroup']['name'] == 'hg1'
|
|
245
|
-
end
|
|
246
|
-
run_cmd(%w(hostgroup create --name hg1 --puppet-classes pc1,pc2))
|
|
247
|
-
end
|
|
248
|
-
|
|
249
|
-
it 'allows puppet class names that exceeds entries_per_page' do
|
|
250
|
-
search_objects = []
|
|
251
|
-
response_objects = []
|
|
252
|
-
ids = []
|
|
253
|
-
names = []
|
|
254
|
-
1100.times.with_object('pc').each do |id, name|
|
|
255
|
-
next_name = "\"#{name}#{id}\""
|
|
256
|
-
search_objects << "name = #{next_name}"
|
|
257
|
-
response_objects << { 'id' => id, 'name' => next_name }
|
|
258
|
-
ids << id
|
|
259
|
-
names << next_name
|
|
260
|
-
end
|
|
261
|
-
|
|
262
|
-
api_expects(:puppetclasses, :index) do |p|
|
|
263
|
-
p[:search] == search_objects.join(' or ') &&
|
|
264
|
-
p[:page].to_i == 1 &&
|
|
265
|
-
p[:per_page].to_i == HammerCLIForeman::IdResolver::ALL_PER_PAGE
|
|
266
|
-
end.returns(
|
|
267
|
-
index_response('puppetclasses' => response_objects[0...1000]))
|
|
268
|
-
|
|
269
|
-
api_expects(:puppetclasses, :index) do |p|
|
|
270
|
-
p[:search] == search_objects.join(' or ') &&
|
|
271
|
-
p[:page].to_i == 2 &&
|
|
272
|
-
p[:per_page].to_i == HammerCLIForeman::IdResolver::ALL_PER_PAGE
|
|
273
|
-
end.returns(index_response('puppetclasses' => response_objects[1000...1100]))
|
|
274
|
-
|
|
275
|
-
api_expects(:hostgroups, :create) do |p|
|
|
276
|
-
p['hostgroup']['name'] == 'hg1' &&
|
|
277
|
-
p['hostgroup']['puppetclass_ids'] == ids
|
|
278
|
-
end
|
|
279
|
-
|
|
280
|
-
run_cmd(%w[hostgroup create --name hg1 --puppet-classes] << names.join(',').tr('"', ''))
|
|
281
|
-
end
|
|
282
|
-
|
|
283
|
-
it 'allows puppet proxy id' do
|
|
284
|
-
api_expects(:hostgroups, :create).with_params({
|
|
285
|
-
:hostgroup => {
|
|
286
|
-
:name => 'hg1',
|
|
287
|
-
:puppet_proxy_id => 1
|
|
288
|
-
}
|
|
289
|
-
})
|
|
290
|
-
run_cmd(%w(hostgroup create --name hg1 --puppet-proxy-id 1))
|
|
291
|
-
end
|
|
292
|
-
|
|
293
|
-
it 'allows puppet proxy name' do
|
|
294
|
-
api_expects(:smart_proxies, :index) do |p|
|
|
295
|
-
p[:search] = "name = \"sp1\""
|
|
296
|
-
end.returns(index_response([{'id' => 1}]))
|
|
297
|
-
api_expects(:hostgroups, :create) do |p|
|
|
298
|
-
p['hostgroup']['puppet_proxy_id'] == 1 &&
|
|
299
|
-
p['hostgroup']['name'] == 'hg1'
|
|
300
|
-
end
|
|
301
|
-
run_cmd(%w(hostgroup create --name hg1 --puppet-proxy sp1))
|
|
302
|
-
end
|
|
303
|
-
|
|
304
198
|
it 'allows realm id' do
|
|
305
199
|
api_expects(:hostgroups, :create) do |p|
|
|
306
200
|
p['hostgroup']['realm_id'] == 1 &&
|