VDI resizing api does not work

戏子无情 提交于 2019-12-11 12:32:38

问题


I am developing a Xen management webapp with Php. The VDI (virtual disk image) renaming API and resizing APIs usage are very same. I haven't managed to succeed resizing the VDI. Do you think what I am doing wrong here.

Renaming function:

function xenapi_set_vdi_name($session, $ref, $name)
{
    $conn = $session[0];
    $sess = new xmlrpcval($session[1]);
    $vdi = new xmlrpcval($ref);
    $name = new xmlrpcval($name);
    $msg = new xmlrpcmsg("VDI.set_name_label", array($sess, $vdi, $name));

    $res = $conn->send($msg);

    if ($res->faultcode())
        return false;
    $val = $res->value();
    $status = $val->structmem("Status");
    if ($status->scalarval() != "Success")
        return false;

    $value = $val->structmem("Value");
    return $value->scalarval();
}

Renaming working usage:

...
xenapi_set_vdi_name($session, $vdi, "NewNameToMyVDI");
...

Resizing function:

function xenapi_set_vdi_virtual_size($session, $ref, $size)
{
    $conn = $session[0];
    $sess = new xmlrpcval($session[1]);
    $vdi = new xmlrpcval($ref);
    $size = new xmlrpcval($size);
    $msg = new xmlrpcmsg("VDI.set_virtual_size", array($sess, $vdi, $size));

    $res = $conn->send($msg);

    if ($res->faultcode())
        return false;
    $val = $res->value();
    $status = $val->structmem("Status");
    if ($status->scalarval() != "Success")
        return false;

    $value = $val->structmem("Value");
    return $value->scalarval();
}

Not working resizing usage:

...
$size = '27011707392';
settype($size, "integer");
xenapi_set_vdi_virtual_size($session, $vdi, $size);
...

New size value works with XEN command on physical server as:

xe vdi-resize uuid="91fe671c-93e1-4162-8128-96fedc3c215c" disk-size="27011707392"

回答1:


From a quick look at this: http://xen.org/files/XenCloud/ocamldoc/apidoc.html?c=VDI

I think that you should try using either "resize" or "resize online" methods instead of "set virtual size".



来源:https://stackoverflow.com/questions/14325306/vdi-resizing-api-does-not-work

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!