Skip to content
This repository was archived by the owner on Oct 24, 2022. It is now read-only.

Commit 91caed1

Browse files
author
Tom McKay
committed
fixes #18384 - namify Guests of Host column
1 parent b42ced7 commit 91caed1

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

lib/hammer_cli_csv/content_hosts.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ def update_or_create(name, line)
244244
},
245245
'subscription_facet_attributes' => {
246246
'installed_products' => products(line),
247-
'service_level' => line[SLA]
247+
'service_level' => line[SLA],
248+
'autoheal' => true
248249
}
249250
}
250251
}
@@ -595,6 +596,7 @@ def columns_to_csv(csv)
595596
def hypervisor_from_line(line)
596597
hypervisor = line[HOST] if !line[HOST].nil? && !line[HOST].empty?
597598
hypervisor ||= line[GUESTOF] if !line[GUESTOF].nil? && !line[GUESTOF].empty?
599+
hypervisor = namify(hypervisor, 1) if !hypervisor.nil? && !hypervisor.empty?
598600
hypervisor
599601
end
600602
end

test/resources/content_hosts_test.rb

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,43 @@ def config_restore
389389
config[:csv].delete(:columns)
390390
# HammerCLI::Settings.load_from_file(File.dirname(__FILE__) + "/../config.yml")
391391
end
392+
393+
def test_hypervisor_prefix
394+
start_vcr
395+
set_user 'admin'
396+
397+
prefix = "abc"
398+
hypervisorname = "prefixhv"
399+
guestname = "prefixguest"
400+
401+
file = Tempfile.new('content_hosts_test')
402+
file.write <<-EOF
403+
Name,Count,Organization,Environment,Content View,Virtual,Guest of Host,OS,Arch,Sockets,RAM,Cores,SLA,Products,Subscriptions
404+
#{hypervisorname},1,Test Corporation,Library,Default Organization View,No,,RHEL 6.4,x86_64,1,4,1,,,
405+
#{guestname},1,Test Corporation,Library,Default Organization View,Yes,#{hypervisorname},RHEL 6.4,x86_64,1,4,1,,,
406+
EOF
407+
file.rewind
408+
409+
stdout,stderr = capture {
410+
hammer.run(%W{--reload-cache csv content-hosts --verbose --prefix #{prefix} --file #{file.path}})
411+
}
412+
assert_equal '', stderr
413+
lines = stdout.split("\n")
414+
assert_equal lines[0], "Creating content host '#{prefix}#{hypervisorname}'...done"
415+
assert_equal lines[1], "Creating content host '#{prefix}#{guestname}'...done"
416+
417+
stdout,stderr = capture {
418+
hammer.run(%W(--reload-cache csv content-hosts --export --organization Test\ Corporation --search name~#{prefix}))
419+
}
420+
assert_equal '', stderr
421+
lines = stdout.split("\n")
422+
assert_match(/#{prefix}#{hypervisorname}.*/, lines[1])
423+
assert_match(/#{prefix}#{guestname}.*#{prefix}#{hypervisorname}.*/, lines[2])
424+
host_delete("#{prefix}#{hypervisorname}")
425+
host_delete("#{prefix}#{guestname}")
426+
427+
stop_vcr
428+
end
392429
end
393430
end
394431
# rubocop:enable LineLength

0 commit comments

Comments
 (0)