I try to create a new VM with Foreman (version 1.23) API on our Libvirt instance. According to API documentation Foreman :: API v2, I don’t need to provide MAC address:
required for managed host that is bare metal, not required if it’s a virtual machine
Unfortunately, I get a response Mac can't be blank
. Do you have any advice on how to deal with it? I wanted to create new VMs as easily as it possible and almost everything should be inherited from hostgroup_id
.
MAC address is not required only if you are creating the VM via Foreman’s libvirt compute resource.
So, I have configured libvirt compute resource in Foreman and this is assigned to one of my host groups.
I wanted to create a new VM in this compute resource with API. So, do I need to provide MAC address in this scenario? If I good understand API documentation MAC is not required. I wanted to create VM with providing minimum configuration: name
, location_id
, organization_id
and hostgroup_id
.
This is everything what I need to provide if I’m creating new VMs with Foreman’s web UI.
You need to provide a compute resource, otherwise you are actually creating a bare-metal host which always require a MAC address of the provisioning interface.
Compute resource (libvirt instance) is assigned to host group. So, I assume it should inherit compute resource from host group if I provide hostgroup_id
. Of course, I tried to create a new VM with the following parameters: create_host(data={'name':'am2-testapi005', 'location_id':4, 'organization_id':5, 'hostgroup_id':2, 'compute_resource_id':1})
but still I’m getting the same response Mac can't be blank
.
You can’t assign compute resource to a host group. Only to host.
If I can’t do that, how you will explain this thing?
I thought that Deploy on
this is an assignment to Host Group
. So, it means that if I choose Host Group
called CentOS 7 group small
it will automatically choose am2-infravmhost001
.
No, I don’t have to provide compute resource
to create a new VM. The following data, this is almost minimum what I should provide to create a new VM:
f.create_host(data={'name':'am2-testapi016', 'organization_id':'5', 'location_id':'4', 'hostgroup_id':'3', 'interfaces_attributes':{'0':{'name':'am2-testapi016', 'primary':'1', 'compute_attributes':{'type':'bridge', 'bridge':'br0', 'model':'virtio'}}}, 'compute_attributes':{'cpus':'1', 'memory':'2147483648', 'start':'1', 'volumes_attributes':{'0':{'pool_name':'images', 'capacity':'10G', 'allocation':'0G', 'format_type':'qcow2'}}}, 'architecture_id':'1', 'build':'1'})