ManageIQ create multiple services with the same name

When call REST to create a service from the service catalog which create one or more vmware vms.

In the json payload we name the service - let’s say - “www” .

data_json = {
“href”:manageiq_url + “/api/service_catalogs/”+ service_catalogs_id +"/service_templates/"+ cf_template,
“service_name”: ‘www’,

[ … ]

Then we call the API:
url = manageiq_url+’/api/service_catalogs/’+ service_catalogs_id +’/service_templates’

The result is that each call create a new service www, with the requested vms inside, so we have lots of “www” services with one or 2 VMs inside.

The purpose was to add VMs in the existing service www (and if it does not exist, create it) , not to create new ones.

What should we do instead?

@abellotti can you review this question from @gquentin and forward to a SME if necessary.

Your help would be usefull.

@gmccullough can you review this question from @gquentin,…feel free to bring in another SME if necessary.


The logic you are describing will always order a new service, there is no out-of-the-box way to order a new service provision and have the results applied to an existing service.

However, using an automate method you could perform a post-provision step on the service which would need to do the following:

  1. Determine if there is an existing service. (For example: $evm.vmdb('service').where(:name => "www"))
  2. Move the newly created VMs from the new service to the pre-existing service using the add_to_service method available on the VM object.
  3. Delete the new service using the remove_from_vmdb method on the service object.

and if i want to add 10 VMs in an existing service, should i add a “:number_of_vms” option the service provisioning dialog?

@gquentin Yes, you can add the number_of_vms field to the dialog to adjust the count.