如何使用ovirt API创建VM映像的快照

时间:2019-07-17 06:52:15

标签: php api virtual-machine ovirt

我想使用ovirt API创建vm的快照。我在域中设置了ovirt引擎。我在配置插件时设置了url。 我正在使用curl处理请求。这是我的代码:

public function vmSnapshot() {

    $data = array();

    $xmlStr = '
         <snapshot>
            <description>BACKUP</description>
        </snapshot>' ;

    $curlParam = array(
        "url" => "/vms/60b98649-a8cb-4f1b-b00f-5a728a89fc00/snapshots/",
        "method" => "POST",
        "data" => $xmlStr,
    );

    $data = $this->processCurlRequest($curlParam);

    // if instance update failed
    if ($data['status'] != 'success') {
        Common::ovirtLog(array(
            "requestParam" => $curlParam,
            "responseParam" => $data,
        ));
    }

    return $data;
}

期望的是创建虚拟机快照。但这会引发错误。

{
  "detail" : "For correct usage, see: [url]/ovirt-engine/api/v4/model#services/snapshots/methods/add",
  "reason" : "Request syntactically incorrect."
}

0 个答案:

没有答案