mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
(cherry picked from commit 57d74662b12d18aa94053367101f7d03a31b4acb)
This commit is contained in:
parent
27045a8bbb
commit
9253decef1
@ -1846,15 +1846,13 @@ Request::ErrorCode VirtualMachineAttach::request_execute(int id,
|
||||
VirtualMachineTemplate deltas(tmpl);
|
||||
VirtualMachineDisks::extended_info(att.uid, &deltas);
|
||||
|
||||
deltas.add("VMS", 0);
|
||||
|
||||
if (quota_resize_authorization(&deltas, att_quota, vm_perms) == false)
|
||||
{
|
||||
att.resp_msg = std::move(att_quota.resp_msg);
|
||||
return AUTHORIZATION;
|
||||
}
|
||||
|
||||
if (volatile_disk == false)
|
||||
if (!volatile_disk)
|
||||
{
|
||||
if ( quota_authorization(&tmpl, Quotas::IMAGE, att_quota, att.resp_msg) == false )
|
||||
{
|
||||
@ -1863,15 +1861,38 @@ Request::ErrorCode VirtualMachineAttach::request_execute(int id,
|
||||
}
|
||||
}
|
||||
|
||||
// Datastore quotas
|
||||
vector<unique_ptr<Template>> ds_quotas;
|
||||
|
||||
VirtualMachineDisks::image_ds_quotas(&deltas, ds_quotas);
|
||||
|
||||
if ( !ds_quotas.empty() &&
|
||||
!quota_authorization(ds_quotas[0].get(), Quotas::DATASTORE, att_quota, att.resp_msg))
|
||||
{
|
||||
quota_rollback(&deltas, Quotas::VM, att_quota);
|
||||
|
||||
if (!volatile_disk)
|
||||
{
|
||||
quota_rollback(&tmpl, Quotas::IMAGE, att_quota);
|
||||
}
|
||||
|
||||
return AUTHORIZATION;
|
||||
}
|
||||
|
||||
if ( dm->attach(id, &tmpl, att, att.resp_msg) != 0 )
|
||||
{
|
||||
quota_rollback(&deltas, Quotas::VM, att_quota);
|
||||
|
||||
if (volatile_disk == false)
|
||||
if (!volatile_disk)
|
||||
{
|
||||
quota_rollback(&tmpl, Quotas::IMAGE, att_quota);
|
||||
}
|
||||
|
||||
if (!ds_quotas.empty())
|
||||
{
|
||||
quota_rollback(ds_quotas[0].get(), Quotas::DATASTORE, att_quota);
|
||||
}
|
||||
|
||||
return ACTION;
|
||||
}
|
||||
|
||||
|
@ -1030,6 +1030,14 @@ void VirtualMachinePool::delete_attach_disk(std::unique_ptr<VirtualMachine> vm)
|
||||
if (!disk->is_persistent())
|
||||
{
|
||||
Quotas::quota_del(Quotas::VM, uid, gid, &tmpl);
|
||||
|
||||
vector<unique_ptr<Template>> ds_quotas;
|
||||
VirtualMachineDisks::image_ds_quotas(&tmpl, ds_quotas);
|
||||
|
||||
if (!ds_quotas.empty())
|
||||
{
|
||||
Quotas::quota_del(Quotas::DATASTORE, uid, gid, ds_quotas[0].get());
|
||||
}
|
||||
}
|
||||
|
||||
const Snapshots * snaps = disk->get_snapshots();
|
||||
|
Loading…
x
Reference in New Issue
Block a user