大多数所需的功能ovirt-engine并未提供,所以研究了一下,发现ovirt-engine向外提供了多个api,均可完成ovirt控制。
一、api类型
- Restful API
- java API
- python API
详见:https://ovirt-engine/ovirt-engine/apidoc/
二、文档简介
三、举例
1、通过api,实现指定虚拟机开机
一、默认自启动 curl --insecure --user 'admin@internal:password' --request POST --header 'Version: 4' --header 'Content-Type: application/xml' --header 'Accept: application/xml' --data '<action><vm></vm></action>' https://host1.server.com/ovirt-engine/api/vms/902b395c-bfda-4ea7-8c38-fd9dc2d1e858/start 二、从硬盘启动 curl --insecure --user 'admin@internal:password' --request POST --header 'Version: 4' --header 'Content-Type: application/xml' --header 'Accept: application/xml' --data '<action><vm><os><boot><devices><device>hd</device></devices></boot></os></vm></action>' https://host1.server.com/ovirt-engine/api/vms/902b395c-bfda-4ea7-8c38-fd9dc2d1e858/start 三、从CD-ROM启动 curl --insecure --user 'admin@internal:password' --request POST --header 'Version: 4' --header 'Content-Type: application/xml' --header 'Accept: application/xml' --data '<action><vm><os><boot><devices><device>cdrom</device></devices></boot></os></vm></action>' https://host1.server.com/ovirt-engine/api/vms/902b395c-bfda-4ea7-8c38-fd9dc2d1e858/start
2、获取虚拟机状态
curl --insecure --user 'admin@internal:password' --request GET --header 'Version: 4' --header 'Content-Type: application/xml' --header 'Accept: application/json' --data '<action><vm></vm></action>' https://host1.server.com/ovirt-engine/api/vms/902b395c-bfda-4ea7-8c38-fd9dc2d1e858