[Solved] AWS AMI and Provider selection


I am looking at setting up service catalog & catalog item based provisioning requests to aws. Ideally via a generic catalog item. So far I have been able to set most options (az, sec group, flav) in the amazon_Customization method via queries to vmdb. Getting the list of AMIs from vmdb is however eluding, where are they stored?

$evm.root[‘miq_provision’].options[:src_vm_id] = [34, “RHEL-7.3_HVM_GA-20161026-x86_64-1-Hourly2-GP2”] (type: Array)

Hopefully once I select the desired ami from vmdb, I’ll set_option(:src_vm_id)?

Also since its generic catalog item, I’ll probably need to set/select the provider?
$evm.root[‘miq_provision’].options[:src_ems_id] = [1, “AWSDev”] (type: Array)


Try to make your question easy. I dont know whether you are asking the question or replying the answer of your question. :slight_smile:

You Want To Create A Service Dialog In Which User Can Put Parameters As He Like. Such as Instance Name, Ip address, Sec group etc. Is That your question ??

Hey @Asad_Rajput

Yes. I have a service dialog and am parsing user inputs from there. Based on those inputs I want code in amazon_CustomizeRequest to make certain selections for security group, flavor, etc. I am making these selections from vmdb. The question is where in vmdb are the AWS AMIs available listed?

After that my assumption is that I’ll be able to do $evm.root[‘miq_provision’].set_option(:src_vm_id, object) to set it?


There are a few posts that mention ems_ref but I havent been able to figure how or if to use it?

vpc id

ami id

Essentially I want to use $evm.root[‘miq_provision’].set_availability_zone, set_cloud_network, set_cloud_subnet, set_security_group Then also $evm.root[‘miq_provision’].options[:instance_type] and of course $evm.root[‘miq_provision’].options[:src_vm_id]


@prattvd @pemcg @bhelgeson Hi All, hoping you might have a few pointers to get me going?

I need to customize a provision to amazon, so want to use $evm.root[‘miq_provision’].set_availability_zone, set_cloud_network, set_cloud_subnet, set_security_group. What objects should be provided to these sets? Object, Array?

Same question for $evm.root[‘miq_provision’].options[:instance_type] and $evm.root[‘miq_provision’].options[:src_vm_id]


Hi Dan

set_availability_zone, set_cloud_network, set_cloud_subnet, set_security_group and set_instance_type all take a service model object as an argument, for example:

cloud_network = $evm.vmdb('CloudNetwork').find_by_name('private_3')
unless cloud_network.nil?

The instance_type you can lookup as ‘flavor’, for example:

instance_type = $evm.vmdb(:flavor).where(:name => "t2.small").first

It looks like you’d need to set src_vm_id as an [object_id, name] array yourself, for example:

prov.set_option(:src_vm_id, [1000000000125, "CentOS Linux 7 x86_64 EBS 20150928_01-b7ee8a69-ee97-4a49-9e68-afaee214db2e-ami-69327e0c.2"])

…but I think you can just get away with the object ID, so

prov.set_option(:src_vm_id, 1000000000125)

The srv_vm_id you can lookup as ‘vm_or_template’, for example:

$evm.vmdb(:vm_or_template).where(:name => "CentOS Linux 7 x86_64 EBS 20150928_01-b7ee8a69-ee97-4a49-9e68-afaee214db2e-ami-69327e0c.2").first.id

Hope this helps,

Thanks @pemcg

I ended up looking at objectwalker logs to find the object formats the various options use. In most cases Array, each element of the array could be built out of the vmdb objects. So I am not using any of the set_availability/cloud_net/security_grouo/etc options. I am just using prov.set_option.

Yes, vm_or_template, is indeed where I can find the AMIs.

Thanks for the pointers they have, especially on finding the AMI.