3.9. 创建虚拟机
这个 Ruby 示例创建一个虚拟机。这个示例使用带有符号和嵌套哈希的哈希值作为其值。另一种方法是直接使用对应对象的构造者,更加详细。如需更多信息 ,请参阅使用属性 创建虚拟机实例。
# Get the reference to the "vms" service:
vms_service = connection.system_service.vms_service
# Use the "add" method to create a new virtual machine:
vms_service.add(
OvirtSDK4::Vm.new(
name: 'myvm',
cluster: {
name: 'mycluster'
},
template: {
name: 'Blank'
}
)
)
创建虚拟机后,建议 轮询虚拟机的状态,以确保已创建所有磁盘。
如需更多信息,请参阅 VmsService:add。