Hey guys,
I got my first bit of code to work!
I creates a class, instance and method to get dialogs to lookup tags for a user to choose.
I cloned Cloudforms_Essential/Integration/RedHat/Cloudforms/DynamicDialogs/list_cloudforms_tenant_ids, and adjusted from there.
I thought I’d share.
David
=begin
list_tags.rb
Author: David Thornton <david.thornton@scalar.ca>
Description: This method lists tags for a given category, for using dialogs.
=end
dialog_hash = {}
chosencategory = $evm.inputs['category']
$evm.log(:info, "Chosen Category is #{chosencategory}")
tag_classification = $evm.vmdb('classification').find_by_name(chosencategory)
list_of_tags = {}
$evm.vmdb('classification').find_all_by_parent_id(tag_classification.id).each do |tag|
# $evm.log(:info, "list_tags Found #{chosencategory} tag #{tag.name}")
# list_of_tags[tag.name] = tag.description
dialog_hash[tag.name] = tag.description
end
current = dialog_hash.detect {|k,v| v.include?('CURRENT') }
if current
$evm.object['default_value'] = current[0]
else
choose = {''=>'< choose a #{chosencategory} id >'}
dialog_hash = choose.merge!(dialog_hash)
end
unless $evm.execute('category_exists?', chosencategory)
dialog_hash[0] = "Category #{chosencategory} does not exist"
end
$evm.object["values"] = dialog_hash
$evm.log(:info, "$evm.object['values']: #{$evm.object['values'].inspect}")