mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
B #5867: Fix quotas and fsck
co-author: Pavel Czerny <pczerny@opennebula.systems> (cherry picked from commit e2d4141599ae98f8961023842f7e27a71b05e6e9)
This commit is contained in:
parent
de5bc4be13
commit
7a1a85edb6
@ -242,7 +242,7 @@ private:
|
||||
* image may need to be set to error state.
|
||||
*/
|
||||
void clean_up_vm(VirtualMachine *vm, bool dispose, int& image_id,
|
||||
int uid, int gid, int req_id);
|
||||
int uid, int gid, int req_id, Template& quota_tmpl);
|
||||
};
|
||||
|
||||
#endif /*LIFE_CYCLE_MANAGER_H_*/
|
||||
|
@ -1539,7 +1539,7 @@ public:
|
||||
* @param vm_quotas The SYSTEM_DISK_SIZE freed by the deleted snapshots
|
||||
* @param ds_quotas The DS SIZE freed from image datastores.
|
||||
*/
|
||||
void delete_non_persistent_disk_snapshots(Template **vm_quotas,
|
||||
void delete_non_persistent_disk_snapshots(Template& vm_quotas,
|
||||
std::vector<Template *>& ds_quotas)
|
||||
{
|
||||
disks.delete_non_persistent_snapshots(vm_quotas, ds_quotas);
|
||||
@ -1630,8 +1630,9 @@ public:
|
||||
|
||||
/**
|
||||
* Deletes all SNAPSHOT attributes
|
||||
* @param snapshots Returns template with deleted snapshots
|
||||
*/
|
||||
void delete_snapshots();
|
||||
void delete_snapshots(Template& snapshots);
|
||||
|
||||
/**
|
||||
* Returns size acquired on system DS by VM snapshots
|
||||
|
@ -777,7 +777,7 @@ public:
|
||||
* @param vm_quotas The SYSTEM_DISK_SIZE freed by the deleted snapshots
|
||||
* @param ds_quotas The DS SIZE freed from image datastores.
|
||||
*/
|
||||
void delete_non_persistent_snapshots(Template **vm_quotas,
|
||||
void delete_non_persistent_snapshots(Template &vm_quotas,
|
||||
std::vector<Template *> &ds_quotas);
|
||||
|
||||
/**
|
||||
|
@ -1161,7 +1161,7 @@ int DispatchManager::delete_recreate(unique_ptr<VirtualMachine> vm,
|
||||
|
||||
int rc = 0;
|
||||
|
||||
Template * vm_quotas_snp = nullptr;
|
||||
Template vm_quotas_snp;
|
||||
|
||||
VirtualMachineTemplate quota_tmpl;
|
||||
bool do_quotas = false;
|
||||
@ -1195,7 +1195,7 @@ int DispatchManager::delete_recreate(unique_ptr<VirtualMachine> vm,
|
||||
vm_uid = vm->get_uid();
|
||||
vm_gid = vm->get_gid();
|
||||
|
||||
vm->delete_non_persistent_disk_snapshots(&vm_quotas_snp,
|
||||
vm->delete_non_persistent_disk_snapshots(vm_quotas_snp,
|
||||
ds_quotas_snp);
|
||||
|
||||
do_quotas = true;
|
||||
@ -1239,11 +1239,9 @@ int DispatchManager::delete_recreate(unique_ptr<VirtualMachine> vm,
|
||||
Quotas::ds_del_recreate(vm_uid, vm_gid, ds_quotas_snp);
|
||||
}
|
||||
|
||||
if ( vm_quotas_snp != nullptr )
|
||||
if ( !vm_quotas_snp.empty() )
|
||||
{
|
||||
Quotas::vm_del(vm_uid, vm_gid, vm_quotas_snp);
|
||||
|
||||
delete vm_quotas_snp;
|
||||
Quotas::vm_del(vm_uid, vm_gid, &vm_quotas_snp);
|
||||
}
|
||||
|
||||
if ( do_quotas )
|
||||
|
@ -225,6 +225,7 @@ void LifeCycleManager::trigger_migrate(int vid, const RequestAttributes& ra,
|
||||
|
||||
trigger([this, vid, uid, gid, req_id, vm_action] {
|
||||
HostShareCapacity sr;
|
||||
Template quota_tmpl;
|
||||
|
||||
time_t the_time = time(0);
|
||||
|
||||
@ -313,7 +314,7 @@ void LifeCycleManager::trigger_migrate(int vid, const RequestAttributes& ra,
|
||||
|
||||
if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) )
|
||||
{
|
||||
vm->delete_snapshots();
|
||||
vm->delete_snapshots(quota_tmpl);
|
||||
}
|
||||
|
||||
vm->set_action(VMActions::MIGRATE_ACTION, uid, gid, req_id);
|
||||
@ -345,6 +346,13 @@ void LifeCycleManager::trigger_migrate(int vid, const RequestAttributes& ra,
|
||||
{
|
||||
vm->log("LCM", Log::ERROR, "migrate_action, VM in a wrong state.");
|
||||
}
|
||||
|
||||
vm.reset();
|
||||
|
||||
if (!quota_tmpl.empty())
|
||||
{
|
||||
Quotas::quota_del(Quotas::VM, uid, gid, "a_tmpl);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -846,6 +854,7 @@ void LifeCycleManager::trigger_delete(int vid, const RequestAttributes& ra)
|
||||
|
||||
trigger([this, vid, uid, gid, req_id] {
|
||||
int image_id = -1;
|
||||
Template quota_tmpl;
|
||||
|
||||
if ( auto vm = vmpool->get(vid) )
|
||||
{
|
||||
@ -867,7 +876,7 @@ void LifeCycleManager::trigger_delete(int vid, const RequestAttributes& ra)
|
||||
break;
|
||||
|
||||
default:
|
||||
clean_up_vm(vm.get(), true, image_id, uid, gid, req_id);
|
||||
clean_up_vm(vm.get(), true, image_id, uid, gid, req_id, quota_tmpl);
|
||||
dm->trigger_done(vid);
|
||||
break;
|
||||
}
|
||||
@ -886,6 +895,11 @@ void LifeCycleManager::trigger_delete(int vid, const RequestAttributes& ra)
|
||||
ipool->update(image.get());
|
||||
}
|
||||
}
|
||||
|
||||
if (!quota_tmpl.empty())
|
||||
{
|
||||
Quotas::quota_del(Quotas::VM, uid, gid, "a_tmpl);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -900,7 +914,7 @@ void LifeCycleManager::trigger_delete_recreate(int vid,
|
||||
int req_id = ra.req_id;
|
||||
|
||||
trigger([this, vid, uid, gid, req_id] {
|
||||
Template * vm_quotas_snp = nullptr;
|
||||
Template vm_quotas_snp;
|
||||
|
||||
vector<Template *> ds_quotas_snp;
|
||||
|
||||
@ -931,9 +945,9 @@ void LifeCycleManager::trigger_delete_recreate(int vid,
|
||||
vm_uid = vm->get_uid();
|
||||
vm_gid = vm->get_gid();
|
||||
|
||||
clean_up_vm(vm.get(), false, image_id, uid, gid, req_id);
|
||||
clean_up_vm(vm.get(), false, image_id, uid, gid, req_id, vm_quotas_snp);
|
||||
|
||||
vm->delete_non_persistent_disk_snapshots(&vm_quotas_snp,
|
||||
vm->delete_non_persistent_disk_snapshots(vm_quotas_snp,
|
||||
ds_quotas_snp);
|
||||
|
||||
vmpool->update(vm.get());
|
||||
@ -960,11 +974,9 @@ void LifeCycleManager::trigger_delete_recreate(int vid,
|
||||
Quotas::ds_del_recreate(vm_uid, vm_gid, ds_quotas_snp);
|
||||
}
|
||||
|
||||
if ( vm_quotas_snp != nullptr )
|
||||
if ( !vm_quotas_snp.empty())
|
||||
{
|
||||
Quotas::vm_del(vm_uid, vm_gid, vm_quotas_snp);
|
||||
|
||||
delete vm_quotas_snp;
|
||||
Quotas::vm_del(vm_uid, vm_gid, &vm_quotas_snp);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -973,7 +985,7 @@ void LifeCycleManager::trigger_delete_recreate(int vid,
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose,
|
||||
int& image_id, int uid, int gid, int req_id)
|
||||
int& image_id, int uid, int gid, int req_id, Template& quota_tmpl)
|
||||
{
|
||||
HostShareCapacity sr;
|
||||
|
||||
@ -999,7 +1011,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose,
|
||||
|
||||
if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) )
|
||||
{
|
||||
vm->delete_snapshots();
|
||||
vm->delete_snapshots(quota_tmpl);
|
||||
}
|
||||
|
||||
if (vm->get_etime() == 0)
|
||||
|
@ -40,11 +40,6 @@ void LifeCycleManager::start_prolog_migrate(VirtualMachine* vm)
|
||||
|
||||
vm->set_state(VirtualMachine::PROLOG_MIGRATE);
|
||||
|
||||
if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) )
|
||||
{
|
||||
vm->delete_snapshots();
|
||||
}
|
||||
|
||||
vm->set_previous_etime(the_time);
|
||||
|
||||
vm->set_previous_running_etime(the_time);
|
||||
@ -55,8 +50,6 @@ void LifeCycleManager::start_prolog_migrate(VirtualMachine* vm)
|
||||
|
||||
vmpool->update_history(vm);
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
vm->get_capacity(sr);
|
||||
|
||||
if ( vm->get_hid() != vm->get_previous_hid() )
|
||||
@ -147,8 +140,17 @@ void LifeCycleManager::trigger_save_success(int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
Template quota_tmpl;
|
||||
int uid = vm->get_uid();
|
||||
int gid = vm->get_gid();
|
||||
|
||||
if ( vm->get_lcm_state() == VirtualMachine::SAVE_MIGRATE )
|
||||
{
|
||||
if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) )
|
||||
{
|
||||
vm->delete_snapshots(quota_tmpl);
|
||||
}
|
||||
|
||||
start_prolog_migrate(vm.get());
|
||||
}
|
||||
else if (vm->get_lcm_state() == VirtualMachine::SAVE_SUSPEND)
|
||||
@ -159,7 +161,7 @@ void LifeCycleManager::trigger_save_success(int vid)
|
||||
|
||||
if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) )
|
||||
{
|
||||
vm->delete_snapshots();
|
||||
vm->delete_snapshots(quota_tmpl);
|
||||
|
||||
vmpool->update(vm.get());
|
||||
}
|
||||
@ -180,7 +182,7 @@ void LifeCycleManager::trigger_save_success(int vid)
|
||||
|
||||
if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) )
|
||||
{
|
||||
vm->delete_snapshots();
|
||||
vm->delete_snapshots(quota_tmpl);
|
||||
}
|
||||
|
||||
vm->set_epilog_stime(the_time);
|
||||
@ -199,6 +201,13 @@ void LifeCycleManager::trigger_save_success(int vid)
|
||||
{
|
||||
vm->log("LCM",Log::ERROR,"save_success_action, VM in a wrong state");
|
||||
}
|
||||
|
||||
vm.reset();
|
||||
|
||||
if (!quota_tmpl.empty())
|
||||
{
|
||||
Quotas::quota_del(Quotas::VM, uid, gid, "a_tmpl);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -257,6 +266,10 @@ void LifeCycleManager::trigger_deploy_success(int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
Template quota_tmpl;
|
||||
int uid = vm->get_uid();
|
||||
int gid = vm->get_gid();
|
||||
|
||||
//----------------------------------------------------
|
||||
// RUNNING STATE
|
||||
//----------------------------------------------------
|
||||
@ -285,7 +298,7 @@ void LifeCycleManager::trigger_deploy_success(int vid)
|
||||
|
||||
if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) )
|
||||
{
|
||||
vm->delete_snapshots();
|
||||
vm->delete_snapshots(quota_tmpl);
|
||||
}
|
||||
|
||||
vm->release_previous_vnc_port();
|
||||
@ -320,6 +333,13 @@ void LifeCycleManager::trigger_deploy_success(int vid)
|
||||
{
|
||||
vm->log("LCM",Log::ERROR,"deploy_success_action, VM in a wrong state");
|
||||
}
|
||||
|
||||
vm.reset();
|
||||
|
||||
if (!quota_tmpl.empty())
|
||||
{
|
||||
Quotas::quota_del(Quotas::VM, uid, gid, "a_tmpl);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -447,6 +467,10 @@ void LifeCycleManager::trigger_shutdown_success(int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
Template quota_tmpl;
|
||||
int uid = vm->get_uid();
|
||||
int gid = vm->get_gid();
|
||||
|
||||
if ( vm->get_lcm_state() == VirtualMachine::SHUTDOWN )
|
||||
{
|
||||
//----------------------------------------------------
|
||||
@ -456,7 +480,7 @@ void LifeCycleManager::trigger_shutdown_success(int vid)
|
||||
|
||||
if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) )
|
||||
{
|
||||
vm->delete_snapshots();
|
||||
vm->delete_snapshots(quota_tmpl);
|
||||
}
|
||||
|
||||
vm->set_epilog_stime(the_time);
|
||||
@ -479,7 +503,7 @@ void LifeCycleManager::trigger_shutdown_success(int vid)
|
||||
|
||||
if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) )
|
||||
{
|
||||
vm->delete_snapshots();
|
||||
vm->delete_snapshots(quota_tmpl);
|
||||
|
||||
vmpool->update(vm.get());
|
||||
}
|
||||
@ -498,7 +522,7 @@ void LifeCycleManager::trigger_shutdown_success(int vid)
|
||||
|
||||
if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) )
|
||||
{
|
||||
vm->delete_snapshots();
|
||||
vm->delete_snapshots(quota_tmpl);
|
||||
}
|
||||
|
||||
vm->set_epilog_stime(the_time);
|
||||
@ -515,12 +539,24 @@ void LifeCycleManager::trigger_shutdown_success(int vid)
|
||||
}
|
||||
else if (vm->get_lcm_state() == VirtualMachine::SAVE_MIGRATE)
|
||||
{
|
||||
if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) )
|
||||
{
|
||||
vm->delete_snapshots(quota_tmpl);
|
||||
}
|
||||
|
||||
start_prolog_migrate(vm.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->log("LCM",Log::ERROR,"shutdown_success_action, VM in a wrong state");
|
||||
}
|
||||
|
||||
vm.reset();
|
||||
|
||||
if (!quota_tmpl.empty())
|
||||
{
|
||||
Quotas::quota_del(Quotas::VM, uid, gid, "a_tmpl);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -583,6 +619,10 @@ void LifeCycleManager::trigger_prolog_success(int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
Template quota_tmpl;
|
||||
int uid = vm->get_uid();
|
||||
int gid = vm->get_gid();
|
||||
|
||||
VirtualMachine::LcmState lcm_state = vm->get_lcm_state();
|
||||
|
||||
switch (lcm_state)
|
||||
@ -658,7 +698,7 @@ void LifeCycleManager::trigger_prolog_success(int vid)
|
||||
case VirtualMachine::PROLOG_MIGRATE_SUSPEND_FAILURE: //recover success
|
||||
if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) )
|
||||
{
|
||||
vm->delete_snapshots();
|
||||
vm->delete_snapshots(quota_tmpl);
|
||||
}
|
||||
|
||||
vm->set_prolog_etime(the_time);
|
||||
@ -682,6 +722,13 @@ void LifeCycleManager::trigger_prolog_success(int vid)
|
||||
vm->log("LCM",Log::ERROR,"prolog_success_action, VM in a wrong state");
|
||||
break;
|
||||
}
|
||||
|
||||
vm.reset();
|
||||
|
||||
if (!quota_tmpl.empty())
|
||||
{
|
||||
Quotas::quota_del(Quotas::VM, uid, gid, "a_tmpl);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -982,6 +1029,10 @@ void LifeCycleManager::trigger_monitor_suspend(int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
Template quota_tmpl;
|
||||
int uid = vm->get_uid();
|
||||
int gid = vm->get_gid();
|
||||
|
||||
if ( vm->get_lcm_state() == VirtualMachine::RUNNING ||
|
||||
vm->get_lcm_state() == VirtualMachine::UNKNOWN )
|
||||
{
|
||||
@ -997,7 +1048,7 @@ void LifeCycleManager::trigger_monitor_suspend(int vid)
|
||||
|
||||
if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) )
|
||||
{
|
||||
vm->delete_snapshots();
|
||||
vm->delete_snapshots(quota_tmpl);
|
||||
}
|
||||
|
||||
vm->set_internal_action(VMActions::MONITOR_ACTION);
|
||||
@ -1014,6 +1065,13 @@ void LifeCycleManager::trigger_monitor_suspend(int vid)
|
||||
{
|
||||
vm->log("LCM",Log::ERROR,"monitor_suspend_action, VM in a wrong state");
|
||||
}
|
||||
|
||||
vm.reset();
|
||||
|
||||
if (!quota_tmpl.empty())
|
||||
{
|
||||
Quotas::quota_del(Quotas::VM, uid, gid, "a_tmpl);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1061,6 +1119,10 @@ void LifeCycleManager::trigger_monitor_poweroff(int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
Template quota_tmpl;
|
||||
int uid = vm->get_uid();
|
||||
int gid = vm->get_gid();
|
||||
|
||||
if ( vm->get_lcm_state() == VirtualMachine::RUNNING ||
|
||||
vm->get_lcm_state() == VirtualMachine::UNKNOWN )
|
||||
{
|
||||
@ -1072,7 +1134,7 @@ void LifeCycleManager::trigger_monitor_poweroff(int vid)
|
||||
|
||||
if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) )
|
||||
{
|
||||
vm->delete_snapshots();
|
||||
vm->delete_snapshots(quota_tmpl);
|
||||
}
|
||||
|
||||
vm->set_resched(false);
|
||||
@ -1098,6 +1160,13 @@ void LifeCycleManager::trigger_monitor_poweroff(int vid)
|
||||
|
||||
trigger_shutdown_success(vid);
|
||||
}
|
||||
|
||||
vm.reset();
|
||||
|
||||
if (!quota_tmpl.empty())
|
||||
{
|
||||
Quotas::quota_del(Quotas::VM, uid, gid, "a_tmpl);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1429,9 +1498,11 @@ void LifeCycleManager::trigger_snapshot_create_failure(int vid)
|
||||
if (snap)
|
||||
{
|
||||
Template quota_tmpl;
|
||||
quota_tmpl.set(snap);
|
||||
|
||||
Quotas::vm_del(vm_uid, vm_gid, "a_tmpl);
|
||||
quota_tmpl.set(snap);
|
||||
quota_tmpl.replace("VMS", 0);
|
||||
|
||||
Quotas::quota_del(Quotas::VM, vm_uid, vm_gid, "a_tmpl);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1516,9 +1587,11 @@ void LifeCycleManager::trigger_snapshot_delete_success(int vid)
|
||||
if (snap)
|
||||
{
|
||||
Template quota_tmpl;
|
||||
quota_tmpl.set(snap);
|
||||
|
||||
Quotas::vm_del(vm_uid, vm_gid, "a_tmpl);
|
||||
quota_tmpl.set(snap);
|
||||
quota_tmpl.replace("VMS", 0);
|
||||
|
||||
Quotas::quota_del(Quotas::VM, vm_uid, vm_gid, "a_tmpl);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -2517,6 +2590,16 @@ void LifeCycleManager::trigger_resize_failure(int vid)
|
||||
deltas.add("CPU", ncpu - ocpu);
|
||||
deltas.add("VMS", 0);
|
||||
|
||||
auto state = vm->get_state();
|
||||
|
||||
if (state == VirtualMachine::PENDING || state == VirtualMachine::HOLD ||
|
||||
(state == VirtualMachine::ACTIVE &&
|
||||
vm->get_lcm_state() == VirtualMachine::RUNNING))
|
||||
{
|
||||
deltas.add("RUNNING_MEMORY", nmem - omem);
|
||||
deltas.add("RUNNING_CPU", ncpu - ocpu);
|
||||
}
|
||||
|
||||
vm->resize(ocpu, omem, ovcpu, error);
|
||||
}
|
||||
else
|
||||
|
@ -40,11 +40,11 @@ module OneDBFsck
|
||||
'but it does not exist')
|
||||
|
||||
doc.root.xpath('CLUSTER_ID').each do |e|
|
||||
e.text = '-1'
|
||||
e.content = '-1'
|
||||
end
|
||||
|
||||
doc.root.xpath('CLUSTER').each do |e|
|
||||
e.text = ''
|
||||
e.content = ''
|
||||
end
|
||||
|
||||
hosts_fix[row[:oid]] = { :body => doc.root.to_s, :cid => -1 }
|
||||
@ -57,7 +57,7 @@ module OneDBFsck
|
||||
"It will be changed to #{new_cluster}")
|
||||
|
||||
doc.root.xpath('CLUSTER').each do |e|
|
||||
e.text = new_cluster
|
||||
e.content = new_cluster
|
||||
end
|
||||
|
||||
hosts_fix[row[:oid]] = { :body => doc.root.to_s,
|
||||
|
@ -309,6 +309,16 @@ module OneDBFsck
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vmdoc.root.xpath('TEMPLATE/SNAPSHOT').each do |e|
|
||||
size = 0
|
||||
|
||||
size_e = e.at_xpath('SYSTEM_DISK_SIZE')
|
||||
|
||||
size = size_e.text.to_i unless size_e.nil?
|
||||
|
||||
sys_used += size
|
||||
end
|
||||
end
|
||||
|
||||
vm_elem.xpath('SYSTEM_DISK_SIZE_USED').each do |e|
|
||||
|
@ -291,6 +291,15 @@ Request::ErrorCode VirtualMachineAllocate::pool_allocate(
|
||||
if ( rc < 0 )
|
||||
{
|
||||
vector<unique_ptr<Template>> ds_quotas;
|
||||
std::string memory, cpu;
|
||||
|
||||
tmpl_back.get("MEMORY", memory);
|
||||
tmpl_back.get("CPU", cpu);
|
||||
|
||||
tmpl_back.add("RUNNING_MEMORY", memory);
|
||||
tmpl_back.add("RUNNING_CPU", cpu);
|
||||
tmpl_back.add("RUNNING_VMS", 1);
|
||||
tmpl_back.add("VMS", 1);
|
||||
|
||||
quota_rollback(&tmpl_back, Quotas::VIRTUALMACHINE, att);
|
||||
|
||||
|
@ -2013,6 +2013,7 @@ void VirtualMachineResize::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
float ncpu, ocpu, dcpu;
|
||||
long nmemory, omemory, dmemory;
|
||||
int nvcpu, ovcpu;
|
||||
bool update_running_quota;
|
||||
|
||||
Template deltas;
|
||||
|
||||
@ -2112,6 +2113,12 @@ void VirtualMachineResize::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
{
|
||||
ncpu = nvcpu;
|
||||
}
|
||||
|
||||
auto state = vm->get_state();
|
||||
|
||||
update_running_quota = state == VirtualMachine::PENDING ||
|
||||
state == VirtualMachine::HOLD || (state == VirtualMachine::ACTIVE &&
|
||||
vm->get_lcm_state() == VirtualMachine::RUNNING);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2142,6 +2149,12 @@ void VirtualMachineResize::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
deltas.add("CPU", dcpu);
|
||||
deltas.add("VMS", 0);
|
||||
|
||||
if (update_running_quota)
|
||||
{
|
||||
deltas.add("RUNNING_MEMORY", dmemory);
|
||||
deltas.add("RUNNING_CPU", dcpu);
|
||||
}
|
||||
|
||||
if (quota_resize_authorization(&deltas, att, vm_perms) == false)
|
||||
{
|
||||
failure_response(AUTHORIZATION, att);
|
||||
|
@ -3787,17 +3787,30 @@ void VirtualMachine::decrypt()
|
||||
void VirtualMachine::get_quota_template(VirtualMachineTemplate& quota_tmpl,
|
||||
bool only_running)
|
||||
{
|
||||
std::string memory, cpu;
|
||||
|
||||
get_template_attribute("MEMORY", memory);
|
||||
get_template_attribute("CPU", cpu);
|
||||
|
||||
if ((state == VirtualMachine::ACTIVE) ||
|
||||
(state == VirtualMachine::PENDING) ||
|
||||
if ((state == VirtualMachine::PENDING) ||
|
||||
(state == VirtualMachine::CLONING) ||
|
||||
(state == VirtualMachine::CLONING_FAILURE) ||
|
||||
(state == VirtualMachine::HOLD) )
|
||||
(state == VirtualMachine::HOLD) ||
|
||||
((state == VirtualMachine::ACTIVE &&
|
||||
(lcm_state != VirtualMachine::HOTPLUG_SAVEAS_POWEROFF &&
|
||||
lcm_state != VirtualMachine::HOTPLUG_SAVEAS_SUSPENDED &&
|
||||
lcm_state != VirtualMachine::DISK_SNAPSHOT_POWEROFF &&
|
||||
lcm_state != VirtualMachine::DISK_SNAPSHOT_REVERT_POWEROFF &&
|
||||
lcm_state != VirtualMachine::DISK_SNAPSHOT_DELETE_POWEROFF &&
|
||||
lcm_state != VirtualMachine::DISK_SNAPSHOT_SUSPENDED &&
|
||||
lcm_state != VirtualMachine::DISK_SNAPSHOT_REVERT_SUSPENDED &&
|
||||
lcm_state != VirtualMachine::DISK_SNAPSHOT_DELETE_SUSPENDED &&
|
||||
lcm_state != VirtualMachine::DISK_RESIZE_POWEROFF &&
|
||||
lcm_state != VirtualMachine::DISK_RESIZE_UNDEPLOYED &&
|
||||
lcm_state != VirtualMachine::HOTPLUG_NIC_POWEROFF &&
|
||||
lcm_state != VirtualMachine::HOTPLUG_SAVEAS_UNDEPLOYED &&
|
||||
lcm_state != VirtualMachine::HOTPLUG_SAVEAS_STOPPED ))))
|
||||
{
|
||||
std::string memory, cpu;
|
||||
|
||||
get_template_attribute("MEMORY", memory);
|
||||
get_template_attribute("CPU", cpu);
|
||||
|
||||
quota_tmpl.add("RUNNING_MEMORY", memory);
|
||||
quota_tmpl.add("RUNNING_CPU", cpu);
|
||||
quota_tmpl.add("RUNNING_VMS", 1);
|
||||
|
@ -1467,7 +1467,7 @@ int VirtualMachineDisks::rename_snapshot(int disk_id, int snap_id, const string&
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void VirtualMachineDisks::delete_non_persistent_snapshots(Template **vm_quotas,
|
||||
void VirtualMachineDisks::delete_non_persistent_snapshots(Template &vm_quotas,
|
||||
vector<Template *> &ds_quotas)
|
||||
{
|
||||
long long system_disk = 0;
|
||||
@ -1520,15 +1520,13 @@ void VirtualMachineDisks::delete_non_persistent_snapshots(Template **vm_quotas,
|
||||
|
||||
if ( system_disk > 0 )
|
||||
{
|
||||
*vm_quotas = new Template();
|
||||
|
||||
VectorAttribute * delta_disk = new VectorAttribute("DISK");
|
||||
|
||||
delta_disk->replace("TYPE", "FS");
|
||||
delta_disk->replace("SIZE", system_disk);
|
||||
|
||||
(*vm_quotas)->add("VMS", 0);
|
||||
(*vm_quotas)->set(delta_disk);
|
||||
vm_quotas.add("VMS", 0);
|
||||
vm_quotas.set(delta_disk);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,9 +248,13 @@ void VirtualMachine::delete_active_snapshot()
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void VirtualMachine::delete_snapshots()
|
||||
void VirtualMachine::delete_snapshots(Template& snapshots)
|
||||
{
|
||||
obj_template->erase("SNAPSHOT");
|
||||
vector<VectorAttribute*> attrs;
|
||||
obj_template->remove("SNAPSHOT", attrs);
|
||||
|
||||
snapshots.set(attrs);
|
||||
snapshots.add("VMS", 0);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
Loading…
x
Reference in New Issue
Block a user