Is there a way to provision a VM against a specific provider using the REST API? I dont see anything related to a provider in the provision_requests API docs
Hi,
In MIQ, you only need to specify a template from which your new VM is provisioned, because a template is always associated with exactly one provider.
For instance, let’s say you have two vmware providers within a single MIQ region, and the two providers both have an identical CentOS7 template.
Because one template (let’s call it A) is associated with one provider (provider 1) and the other template (B) with the other provider (2), they are treated as different templates even though VM images provisioned from them may be identical.
If you specify the template A when calling provision_request, your VM will be provisioned on the provider 1, and vice versa.
Hope this helps,
Ken
Thanks for the answer @ksugawar
I figured it out:
---
- hosts: localhost
tasks:
- name: Clone template
uri:
url: "{{ manageiq.api_url }}/api/provision_requests"
method: POST
body_format: json
body:
version: '1.1'
template_fields:
name: "{{ template_name }}"
request_type: template
vm_fields:
addr_mode: dhcp
number_of_vms: "{{ count }}"
vm_name: "{{ vm_name }}"
provision_type: vmware
vm_auto_start: "{{ autostart }}"
retirement: 0
retirement_warn: 604800
vlan: VM Network
disk_format: unchanged
cpu_limit: -1
memory_limit: -1
number_of_sockets: 2
cores_per_socket: 1
cpu_reserve: 0
vm_memory: "{{ memory }}"
memory_reserve: 0
network_adapters: 1
requester:
owner_first_name: Daniyal
owner_last_name: Javed
owner_email: daniyal.javed@foobar.ca
tags: {}
additional_values:
ems_custom_attributes:
miq_custom_attributes:
validate_certs: no
headers:
X-Auth-Token: "{{ manageiq.api_token }}"
return_content: yes
status_code: 200
Very helpful. Thank you!