问题
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