Bug #25093
closedProvisioning VMs with Foreman API Not Working for Multiple SCSI Controllers and Volumes
Description
What I'm trying to do is generate a configuration for VM provisioning where multiple VMDK's are added to the VM. The issue I have is that there is no good information or examples out there that I can find on how to structure the host create for the compute_attributes with scsi_controller and volume_attributes. If I create something like below in a JSON structure, which is really my best guess after looking at the production log at the HostsController#create statement when building VM's manually, it doesn't work. If I strip out the volume and scsi_controller key structures, it does work by inheriting the underlying hostgroup values. Does anyone have any insight here as to what the structure needs to look like? I'm running Foreman 1.18.1.
params = {
"host" => {
"name" => "#{outhouse[:name]}",
"operatingsystem_id" => "#{outhouse[:os]}",
"managed" => "true",
"location_id" => 5,
"organization_id" => 3,
"domain_id" => "#{outhouse[:domain]}",
"environment_id" => "#{outhouse[:puppetenv]}",
"puppetclass_ids" => "#{outhouse[:puppetids]}",
"provision_method" => "#{outhouse[:provision]}",
"root_password" => "changeme",
"hostgroup_id" => "#{outhouse[:hostgroup]}",
"compute_resource_id" => "#{outhouse[:compute]}",
"build" => "true",
"ip" => ip,
"interfaces_attributes"=> [ {
"type"=>"Nic::Managed",
"primary"=>"true",
"provision"=>"true",
"managed"=>"#{outhouse[:ipmanaged]}",
"compute_network"=>"#{outhouse[:network]}"
}
],
"compute_attributes" => {
"start" => "1",
"cpus" => "2",
"corespersocket" => "1",
"memory_mb" => "3500",
"firmware" => "bios",
"resource_pool" => "foreman-temp",
"hardware_version" => "Default",
"add_cdrom" => "1",
"scsi_controllers" => {
"scsiControllers" => [ {
"type" => "VirtualLsiLogicController",
"key" => "1000",
}, ],
"volumes" => [ {
"thin" => 1,
"name" => "Hard disk",
"mode" => "persistent",
"controllerKey" => 1000,
"sizeGb" => 150,
"datastore" => "esxa_lun0",
"thin" => 1,
"eagerZero" => 0,
}, {
"thin" => 1,
"name" => "Hard disk 2",
"mode" => "persistent",
"controllerKey" => 1000,
"sizeGb" => 6,
"datastore" => "esxa_lun1",
"thin" => 1,
"eagerZero" => 0,
}
],
},
},
},
}.to_json