Hello,
I am trying to create a customized service catalog for our operations team to use to provision VMs on certain templates, datastores and networks. There are quite a lot of templates, datastores and networks and going the conventional way of using lifecycle isn’t practical. Within the lifecycle screen it takes a lot of time to select each item under Environment tab (i.e. Datacenter, Cluster, Folder, and Datastore).
In order to shorten the process I would like to create service catalog where I provide a drop down of templates, datastores and networks to choose from. I got the template drop down to work, but not the datastores. on the datastores drop down I get Script Error message when I run the service catalog
Here is the code:
# list_datastores.rb
#
# Description: List the datastores associated with a provider
#
# Get vm object from root
vm = $evm.root['vm']
raise "Missing $evm.root['vm'] object" if vm.nil?
provider = vm.ext_management_system.name
$evm.log(:info, "Detected Provider: #{provider.name}")
datastores_hash = {}
provider.storages.each do |storage|
#next unless template.tagged_with?('prov_scope', 'all')
#next unless template.vendor.downcase == 'vmware'
if vm.storage.ems_ref == storage.ems_ref
datastores_hash[storage[:ems_ref]] = "<current> #{storage[:name]}"
else
datastores_hash[storage[:ems_ref]] = storage[:name]
end
end
$evm.object['values'] = datastores_hash
$evm.log(:info, "Dialog Values: #{$evm.object['values'].inspect}")
Can someone guide me on how to troubleshoot this? also what am I doing wrong here?