Using the ruby sdk I'm unable to start a VM on a specific host.
According to the API docs at api/v4/model#types/vm_placement_policy :
Name Type
----------------
hosts Host[]
No matter what I specify, I run into this same bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1249521
65: require 'pry'
66: binding.pry
67:
=> 68: machine.start(
69: use_cloud_init: true,
70: vm: vm_configuration
71: )
72:
73: @app.call(env)
[1] pry(#<VagrantPlugins::OVirtProvider::Action::StartVM>)>
vm_configuration[:placement_policy] = { :hosts => [{ :host =>
'server.test.local' }], :affinity => 'pinned' }
[2] pry(#<VagrantPlugins::OVirtProvider::Action::StartVM>)> vm_configuration
=> {:initialization=>
{:host_name=>"test",
:nic_configurations=>[{:name=>"eth0", :on_boot=>true,
:boot_protocol=>"static", :ip=>{:version=>"v4",
:address=>"192.168.2.200",
:gateway=>"192.168.2.1"}}],
:custom_script=>
"write_files:\n - content: |\n wat\n path:
/tmp/something.txt\n permissions: '0644'\nnetwork-interfaces: |\n auto
eth0\n iface eth0 inet static\n address 192.168.2.201\n network
192.168.2.0\n netmask 255.255.255.0\n gateway 192.168.2.1\n
dns-nameservers 192.168.2.113 192.168.2.1\n"},
:placement_policy=>{:hosts=>[{:host=>"server.test.local"}],
:affinity=>"pinned"}}
==> default: An error occured. Recovering..
==> default: Halting VM...
==> default: Waiting for VM to shutdown...
==> default: Removing VM...
/home/myoung/.rvm/gems/ruby-2.2.3/gems/ovirt-engine-sdk-4.1.2/lib/ovirtsdk4/service.rb:52:in
`raise_error': Fault reason is "Incomplete parameters". Fault detail is
"Host [id|name] required for validateAndUpdateHostsInPlacementPolicy". HTTP
response code is 400. (OvirtSDK4::Error)
The same goes with giving an object instead of a hash object
=> 68: machine.start(
69: use_cloud_init: true,
70: vm: vm_configuration
71: )
72:
73: @app.call(env)
[1] pry(#<VagrantPlugins::OVirtProvider::Action::StartVM>)> hosts_service =
env[:connection].system_service.hosts_service
[2] pry(#<VagrantPlugins::OVirtProvider::Action::StartVM>)> host =
hosts_service.list(search: 'name=server.test.local')[0]
[3] pry(#<VagrantPlugins::OVirtProvider::Action::StartVM>)> host.status
=> "up"
[4] pry(#<VagrantPlugins::OVirtProvider::Action::StartVM>)>
vm_configuration[:placement_policy] = { :hosts => [{ :host => host }]}
==> default: An error occured. Recovering..
==> default: Halting VM...
==> default: Waiting for VM to shutdown...
==> default: Removing VM...
/home/myoung/.rvm/gems/ruby-2.2.3/gems/ovirt-engine-sdk-4.1.2/lib/ovirtsdk4/service.rb:52:in
`raise_error': Fault reason is "Incomplete parameters". Fault detail is
"Host [id|name] required for validateAndUpdateHostsInPlacementPolicy". HTTP
response code is 400. (OvirtSDK4::Error)
from
/home/myoung/.rvm/gems/ruby-2.2.3/gems/ovirt-engine-sdk-4.1.2/lib/ovirtsdk4/service.rb:85:in
`check_action'
from
/home/myoung/.rvm/gems/ruby-2.2.3/gems/ovirt-engine-sdk-4.1.2/lib/ovirtsdk4/services.rb:29460:in
`start'