hammer_cli_foreman 0.19.6 → 0.19.7
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b06761047f5cbd13606444872d97853870f28cdc4117a54fc450b250f036a770
|
4
|
+
data.tar.gz: ffa9cb3168c98dce349a8ef32d1046db74887d7e03e65025bd4a8dec7717a46e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 364b646af39ecf1f87f73b570b8c6db56259abe6fafe1a9c991a03201dabfdb2a3764fd8bc8b91b64112b5e3dd2a876607cf85c10922bd8b3d1e740347619851
|
7
|
+
data.tar.gz: f73cd97db5ba463e2a6e54041bce9be796190da7fe9ea4198c7b210ae6604a163e172246bf099ed32987553c9192cb8d61e9dbff9792df95955ecf22bff51176
|
data/doc/release_notes.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
Release notes
|
2
2
|
=============
|
3
|
+
### 0.19.7 (2020-01-16)
|
4
|
+
* Fix host creation from image and hostgroup ([PR #471](https://github.com/theforeman/hammer-cli-foreman/pull/471)), [#28541](http://projects.theforeman.org/issues/28541)
|
5
|
+
|
3
6
|
### 0.19.6 (2020-01-10)
|
4
7
|
* Add auth source external command ([PR #480](https://github.com/theforeman/hammer-cli-foreman/pull/480)), [#28704](http://projects.theforeman.org/issues/28704)
|
5
8
|
* Fix undefined method on wrong oidc token endpoint ([PR #479](https://github.com/theforeman/hammer-cli-foreman/pull/479)), [#28196](http://projects.theforeman.org/issues/28196)
|
@@ -8,6 +8,22 @@ module HammerCLIForeman
|
|
8
8
|
)
|
9
9
|
end
|
10
10
|
|
11
|
+
def self.get_hostgroup_compute_resource_id(hostgroup_id)
|
12
|
+
hostgroup = HammerCLIForeman.record_to_common_format(
|
13
|
+
HammerCLIForeman.foreman_resource(:hostgroups).call(:show, 'id' => hostgroup_id)
|
14
|
+
)
|
15
|
+
compute_resource_id = hostgroup['compute_resource_id']
|
16
|
+
if !hostgroup['compute_resource_name'].to_s.strip.empty? && compute_resource_id.nil?
|
17
|
+
compute_resource= HammerCLIForeman.record_to_common_format(
|
18
|
+
HammerCLIForeman.foreman_resource(:compute_resources).call(
|
19
|
+
:index, :search => "name = \"#{hostgroup['compute_resource_name']}\""
|
20
|
+
)
|
21
|
+
)
|
22
|
+
compute_resource_id = compute_resource['results'][0]['id'] if compute_resource['results'][0]
|
23
|
+
end
|
24
|
+
compute_resource_id
|
25
|
+
end
|
26
|
+
|
11
27
|
def self.get_host_compute_resource_id(host_id)
|
12
28
|
HammerCLIForeman.record_to_common_format(
|
13
29
|
HammerCLIForeman.foreman_resource(:hosts).call(
|
@@ -98,9 +98,14 @@ module HammerCLIForeman
|
|
98
98
|
params['host']['compute_attributes']['volumes_attributes'] = nested_attributes(option_volume_list)
|
99
99
|
params['host']['interfaces_attributes'] = interfaces_attributes
|
100
100
|
end
|
101
|
-
|
102
|
-
|
103
|
-
|
101
|
+
if options['option_image_id']
|
102
|
+
if params['host']['compute_resource_id']
|
103
|
+
compute_resource_id = params['host']['compute_resource_id']
|
104
|
+
elsif params['id']
|
105
|
+
compute_resource_id = ::HammerCLIForeman::ComputeResources.get_host_compute_resource_id(params['id'])
|
106
|
+
elsif params['host']['hostgroup_id']
|
107
|
+
compute_resource_id = ::HammerCLIForeman::ComputeResources.get_hostgroup_compute_resource_id(params['host']['hostgroup_id'])
|
108
|
+
end
|
104
109
|
raise ArgumentError, "Missing argument for 'compute_resource'" if compute_resource_id.nil?
|
105
110
|
image_uuid = ::HammerCLIForeman::ComputeResources.get_image_uuid(compute_resource_id, options["option_image_id"])
|
106
111
|
params['host']['compute_attributes']['image_id'] = image_uuid
|
@@ -236,6 +236,67 @@ describe "host create" do
|
|
236
236
|
result = run_cmd(cmd + minimal_params_without_hostgroup + params)
|
237
237
|
assert_cmd(expected_result, result)
|
238
238
|
end
|
239
|
+
|
240
|
+
it "Creates host in case the image is provided from the hostgroup and hostgroup is not nested" do
|
241
|
+
params = ['--name=test',
|
242
|
+
'--provision-method=image',
|
243
|
+
'--image-id=8' ,
|
244
|
+
'--managed=true',
|
245
|
+
'--hostgroup-id=1',
|
246
|
+
'--organization-id=1',
|
247
|
+
'--location-id=1'
|
248
|
+
]
|
249
|
+
|
250
|
+
api_expects(:hostgroups, :show).with_params(
|
251
|
+
{}
|
252
|
+
).returns({'compute_resource_name' => "cr", 'compute_resource_id' => 33 })
|
253
|
+
|
254
|
+
api_expects(:images, :show).with_params(
|
255
|
+
{"compute_resource_id" => 33, "id" => 8}
|
256
|
+
).returns(results: {'uuid' => '111111'})
|
257
|
+
|
258
|
+
api_expects(:hosts, :create).with_params(
|
259
|
+
{"location_id" => 1, "organization_id" => 1, "host" => {"name" => "test", "location_id" => 1, "organization_id" => 1, "puppetclass_ids" => [], "hostgroup_id" => 1, "image_id" => 8, "provision_method" => "image", "managed" => true, "compute_attributes" => {"volumes_attributes" => {}, "image_id" => nil}, "build" => true, "enabled" => true, "overwrite" => true, "interfaces_attributes" => []}}
|
260
|
+
).returns(results: {'uuid' => '111111'})
|
261
|
+
|
262
|
+
expected_result = success_result("Host created.\n")
|
263
|
+
result = run_cmd(cmd + params)
|
264
|
+
assert_cmd(expected_result, result)
|
265
|
+
end
|
266
|
+
|
267
|
+
it "Creates host in case the image is provided from the hostgroup and hostgroup is nested" do
|
268
|
+
params = ['--name=test',
|
269
|
+
'--provision-method=image',
|
270
|
+
'--image-id=8' ,
|
271
|
+
'--managed=true',
|
272
|
+
'--hostgroup-id=1',
|
273
|
+
'--organization-id=1',
|
274
|
+
'--location-id=1'
|
275
|
+
]
|
276
|
+
|
277
|
+
# nested hostgroup will return nil in compute_resource_id
|
278
|
+
api_expects(:hostgroups, :show).with_params(
|
279
|
+
{}
|
280
|
+
).returns({'compute_resource_name' => "cr", 'compute_resource_id' => nil})
|
281
|
+
|
282
|
+
api_expects(:compute_resources, :index).with_params(
|
283
|
+
{:search => "name = \"cr\""}
|
284
|
+
).returns(results: {'results' => [{'id' => 33, 'name' => "cr"}]})
|
285
|
+
|
286
|
+
api_expects(:images, :show).with_params(
|
287
|
+
{"compute_resource_id" => 33, "id" => 8}
|
288
|
+
).returns(results: {'uuid' => '111111'})
|
289
|
+
|
290
|
+
api_expects(:hosts, :create).with_params(
|
291
|
+
{"location_id" => 1, "organization_id" => 1, "host" => {"name" => "test", "location_id" => 1, "organization_id" => 1, "puppetclass_ids" => [], "hostgroup_id" => 1, "image_id" => 8, "provision_method" => "image", "managed" => true, "compute_attributes" => {"volumes_attributes" => {}, "image_id" => nil}, "build" => true, "enabled" => true, "overwrite" => true, "interfaces_attributes" => []}}
|
292
|
+
).returns(results: {'uuid' => '111111'})
|
293
|
+
|
294
|
+
|
295
|
+
expected_result = success_result("Host created.\n")
|
296
|
+
result = run_cmd(cmd + params)
|
297
|
+
assert_cmd(expected_result, result)
|
298
|
+
end
|
299
|
+
|
239
300
|
end
|
240
301
|
|
241
302
|
describe 'host update' do
|
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: 0.19.
|
4
|
+
version: 0.19.7
|
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: 2020-01-
|
12
|
+
date: 2020-01-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hammer_cli
|
@@ -371,7 +371,6 @@ test_files:
|
|
371
371
|
- test/functional/personal_access_token_test.rb
|
372
372
|
- test/functional/proxy_test.rb
|
373
373
|
- test/functional/settings_test.rb
|
374
|
-
- test/functional/smart_variable_test.rb
|
375
374
|
- test/functional/ssh_keys_test.rb
|
376
375
|
- test/functional/subnet/create_test.rb
|
377
376
|
- test/functional/subnet/update_test.rb
|
@@ -380,12 +379,13 @@ test_files:
|
|
380
379
|
- test/functional/ping_test.rb
|
381
380
|
- test/functional/status_test.rb
|
382
381
|
- test/functional/compute_resource_test.rb
|
383
|
-
- test/functional/host_test.rb
|
384
382
|
- test/functional/http_proxy_test.rb
|
385
383
|
- test/functional/report_template_test.rb
|
386
384
|
- test/functional/role_test.rb
|
387
385
|
- test/functional/smart_class_parameter_test.rb
|
386
|
+
- test/functional/smart_variable_test.rb
|
388
387
|
- test/functional/template_test.rb
|
388
|
+
- test/functional/host_test.rb
|
389
389
|
- test/unit/api/void_auth_test.rb
|
390
390
|
- test/unit/api/interactive_basic_auth_test.rb
|
391
391
|
- test/unit/api/oauth/oauth_authentication_code_grant_test.rb
|
@@ -407,11 +407,9 @@ test_files:
|
|
407
407
|
- test/unit/exception_handler_test.rb
|
408
408
|
- test/unit/external_usergroup_test.rb
|
409
409
|
- test/unit/fact_test.rb
|
410
|
-
- test/unit/filter_test.rb
|
411
410
|
- test/unit/helpers/command.rb
|
412
411
|
- test/unit/helpers/fake_searchables.rb
|
413
412
|
- test/unit/helpers/resource_disabled.rb
|
414
|
-
- test/unit/hostgroup_test.rb
|
415
413
|
- test/unit/id_resolver_test.rb
|
416
414
|
- test/unit/image_test.rb
|
417
415
|
- test/unit/location_test.rb
|
@@ -426,22 +424,24 @@ test_files:
|
|
426
424
|
- test/unit/output/formatters_test.rb
|
427
425
|
- test/unit/param_filters_test.rb
|
428
426
|
- test/unit/partition_table_test.rb
|
429
|
-
- test/unit/puppet_class_test.rb
|
430
427
|
- test/unit/puppet_environment_test.rb
|
431
428
|
- test/unit/realm_test.rb
|
432
429
|
- test/unit/role_test.rb
|
433
430
|
- test/unit/settings_test.rb
|
434
431
|
- test/unit/smart_proxy_test.rb
|
435
|
-
- test/unit/smart_variable_test.rb
|
436
432
|
- test/unit/subnet_test.rb
|
437
433
|
- test/unit/test_helper.rb
|
438
434
|
- test/unit/user_test.rb
|
439
435
|
- test/unit/usergroup_test.rb
|
440
436
|
- test/unit/sessions_test.rb
|
437
|
+
- test/unit/apipie_resource_mock.rb
|
438
|
+
- test/unit/auth_source_external.rb
|
439
|
+
- test/unit/filter_test.rb
|
441
440
|
- test/unit/host_test.rb
|
441
|
+
- test/unit/hostgroup_test.rb
|
442
|
+
- test/unit/puppet_class_test.rb
|
442
443
|
- test/unit/smart_class_parameter_test.rb
|
444
|
+
- test/unit/smart_variable_test.rb
|
443
445
|
- test/unit/template_test.rb
|
444
446
|
- test/unit/test_output_adapter.rb
|
445
|
-
- test/unit/apipie_resource_mock.rb
|
446
|
-
- test/unit/auth_source_external.rb
|
447
447
|
- test/test_helper.rb
|