How to specify finishing template when creating a host via Foreman API?

I'm trying to create a host using the foreman API (using hammer, but
POSTing the host payload gives me the same result). Each time, it complains
that I'm lacking a finishing template.

The error message from the API is this: No finish templates were found for
this host, make sure you define at least one in your CentOS 6.7 settings

How do I specify a finishing template when creating a host via Foreman API?

Nothing in the documentation tells me how to provide a finishing template
selection when creating the host. Doing this in the Foreman UI with the
same settings works just fine. When I click on "Resolve" in the
provisioning templates section, I can see my finishing template as well.

Some details: this is Foreman 1.10.1 against a VMWare Cluster

Here's my host payload

"host" => {
"name" => "ez-apitesthost",
"location_id" => 1,
"organization_id" => 5,
"environment_id" => 9,
"architecture_id" => 1,
"operatingsystem_id" => 2,
"compute_resource_id" => 2,
"root_pass" => "password",
"hostgroup_id" => 73,
"image_id" => 19,
"build" => true,
"enabled" => true,
"provision_method" => "image",
"managed" => true,
"compute_profile_id" => 11,
"compute_attributes" => {
"cpus" => "1",
"corespersocket" => "2",
"memory_mb" => "4096",
"cluster" => "MYCLUSTER01",
"path" => "/Datacenters/MYDC/vm",
"guest_id" => "centos64Guest",
"scsi_controller-type" => "ParaVirtualSCSIController"
"volumes_attributes" => {
"0" => {
"datastore" => "dc_sata_01"
}
}
},
"owner_id" => "75",
"overwrite" => true,
"host_parameters_attributes" => {},
"interfaces_attributes" => {
"0" => {
"type" => "interface",
"name" => "ez-apitesthost",
"domain_id" => "1",
"subnet_id" => "2",
"managed" => "false",
"primary" => "true",
"provision" => "true",
"compute_attributes" => {
"type" => "VirtualVmxnet3",
"network" => "internal vlan"
}
}
}
}

here's the response

{
"error" => {
"id" => nil,
"errors" => {
"base" => [
[0] "No finish templates were found for this host, make sure you define at least one in your CentOS 6.7 settings"
],
"conflict" => [],
"interfaces.conflict" => []
},
"full_messages" => [
[0] "No finish templates were found for this host, make sure you define at least one in your CentOS 6.7 settings"
]
}

Hello,

does it work from UI? Note that you can't select the template directly, it's
auto-selected according to OS configuration so you might be missing some
associations there.

Hope this helps

··· -- Marek

On Sunday 21 of February 2016 09:29:07 seafoodbuffet wrote:

I’m trying to create a host using the foreman API (using hammer, but
POSTing the host payload gives me the same result). Each time, it complains
that I’m lacking a finishing template.

The error message from the API is this: No finish templates were found for
this host, make sure you define at least one in your CentOS 6.7 settings

How do I specify a finishing template when creating a host via Foreman API?

Nothing in the documentation tells me how to provide a finishing template
selection when creating the host. Doing this in the Foreman UI with the
same settings works just fine. When I click on “Resolve” in the
provisioning templates section, I can see my finishing template as well.

Some details: this is Foreman 1.10.1 against a VMWare Cluster

Here’s my host payload

“host” => {
“name” => “ez-apitesthost”,
“location_id” => 1,
“organization_id” => 5,
“environment_id” => 9,
“architecture_id” => 1,
“operatingsystem_id” => 2,
“compute_resource_id” => 2,
“root_pass” => “password”,
“hostgroup_id” => 73,
“image_id” => 19,
“build” => true,
“enabled” => true,
“provision_method” => “image”,
“managed” => true,
“compute_profile_id” => 11,
“compute_attributes” => {
“cpus” => “1”,
“corespersocket” => “2”,
“memory_mb” => “4096”,
“cluster” => “MYCLUSTER01”,
“path” => “/Datacenters/MYDC/vm”,
“guest_id” => “centos64Guest”,
“scsi_controller-type” => “ParaVirtualSCSIController”
“volumes_attributes” => {
“0” => {
“datastore” => “dc_sata_01”
}
}
},
“owner_id” => “75”,
“overwrite” => true,
“host_parameters_attributes” => {},
“interfaces_attributes” => {
“0” => {
“type” => “interface”,
“name” => “ez-apitesthost”,
“domain_id” => “1”,
“subnet_id” => “2”,
“managed” => “false”,
“primary” => “true”,
“provision” => “true”,
“compute_attributes” => {
“type” => “VirtualVmxnet3”,
“network” => “internal vlan”
}
}
}
}

here’s the response

{
“error” => {
“id” => nil,
“errors” => {
“base” => [
[0] “No finish templates were found for this host, make sure you
define at least one in your CentOS 6.7 settings” ],
“conflict” => [],
“interfaces.conflict” => []
},
“full_messages” => [
[0] “No finish templates were found for this host, make sure you
define at least one in your CentOS 6.7 settings” ]
}