1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-02-01 05:47:01 +03:00

M #-: Remove unneeded counters. Review start/end times of history records

This commit is contained in:
Ruben S. Montero 2020-05-10 02:35:46 +02:00
parent 7c123fb75d
commit e0355f886c
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
7 changed files with 44 additions and 161 deletions

View File

@ -297,19 +297,8 @@ public:
};
/**
* Clears the VM monitor information usage counters (MEMORY, CPU),
* last_poll, custom attributes, and copies it to the history record
* for acct.
* @return monitor info
*/
void reset_info()
{
monitoring.reset_info();
set_vm_info();
clear_template_monitor_error();
}
VirtualMachineMonitorInfo& get_info()
{
return monitoring;
@ -721,21 +710,26 @@ public:
};
/**
* Sets end time of a VM.
* Sets end time of a VM. It also sets the vm_info when the record is closed
* @param _etime time when the VM finished
*/
void set_etime(time_t _etime)
{
history->etime = _etime;
to_xml_extended(history->vm_info, 0);
};
/**
* Sets end time of a VM in the previous Host.
* Sets end time of a VM in the previous Host. It also sets the vm_info
* when the record is closed
* @param _etime time when the VM finished
*/
void set_previous_etime(time_t _etime)
{
previous_history->etime = _etime;
to_xml_extended(previous_history->vm_info, 0);
};
/**

View File

@ -85,11 +85,6 @@ public:
*/
int from_template(const Template &tmpl);
/**
* Reset monitoring data to zero
*/
void reset_info();
// -------------------------------------------------------------------------
// Class set/getters
// -------------------------------------------------------------------------

View File

@ -297,32 +297,25 @@ void LifeCycleManager::migrate_action(const LCMAction& la)
if (vm->get_state() == VirtualMachine::POWEROFF)
{
vm->set_state(VirtualMachine::PROLOG_MIGRATE_POWEROFF);
vm->set_action(VMActions::MIGRATE_ACTION, la.uid(), la.gid(),
la.req_id());
}
else if (vm->get_state() == VirtualMachine::SUSPENDED)
{
vm->set_state(VirtualMachine::PROLOG_MIGRATE_SUSPEND);
vm->set_action(VMActions::MIGRATE_ACTION, la.uid(), la.gid(),
la.req_id());
}
else //VirtualMachine::UNKNOWN
{
vm->set_state(VirtualMachine::PROLOG_MIGRATE_UNKNOWN);
vm->set_previous_running_etime(the_time);
vm->set_previous_etime(the_time);
vm->set_previous_action(VMActions::MIGRATE_ACTION, la.uid(), la.gid(),
la.req_id());
vm->set_previous_vm_info();
vmpool->update_previous_history(vm);
vm->set_previous_action(VMActions::MIGRATE_ACTION, la.uid(),
la.gid(), la.req_id());
}
vm->set_previous_running_etime(the_time);
vm->set_previous_etime(the_time);
vmpool->update_previous_history(vm);
vm->set_state(VirtualMachine::ACTIVE);
vm->set_resched(false);
@ -332,7 +325,7 @@ void LifeCycleManager::migrate_action(const LCMAction& la)
vm->delete_snapshots();
}
vm->reset_info();
vm->set_action(VMActions::MIGRATE_ACTION, la.uid(), la.gid(), la.req_id());
vm->get_capacity(sr);
@ -400,9 +393,6 @@ void LifeCycleManager::live_migrate_action(const LCMAction& la)
vm->set_stime(time(0));
vm->set_action(VMActions::LIVE_MIGRATE_ACTION, la.uid(), la.gid(),
la.req_id());
vmpool->update_history(vm);
vm->set_previous_action(VMActions::LIVE_MIGRATE_ACTION, la.uid(),la.gid(),
@ -734,6 +724,12 @@ void LifeCycleManager::restore_action(const LCMAction& la)
vm->set_state(VirtualMachine::BOOT_SUSPENDED);
vm->set_etime(the_time);
vm->set_running_etime(the_time);
vmpool->update_history(vm);
vm->cp_history();
vm->set_stime(the_time);
@ -791,6 +787,12 @@ void LifeCycleManager::restart_action(const LCMAction& la)
vm->set_state(VirtualMachine::BOOT_POWEROFF);
vm->set_etime(the_time);
vm->set_running_etime(the_time);
vmpool->update_history(vm);
vm->cp_history();
vm->set_stime(the_time);
@ -989,10 +991,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose,
vm->delete_snapshots();
}
vm->reset_info();
vm->set_etime(the_time);
vm->set_vm_info();
vm->get_capacity(sr);

View File

@ -37,12 +37,8 @@ void LifeCycleManager::start_prolog_migrate(VirtualMachine* vm)
vm->delete_snapshots();
}
vm->reset_info();
vm->set_previous_etime(the_time);
vm->set_previous_vm_info();
vm->set_previous_running_etime(the_time);
vmpool->update_previous_history(vm);
@ -81,8 +77,6 @@ void LifeCycleManager::revert_migrate_after_failure(VirtualMachine* vm)
vm->set_etime(the_time);
vm->set_vm_info();
vmpool->update_history(vm);
vm->get_capacity(sr);
@ -94,8 +88,6 @@ void LifeCycleManager::revert_migrate_after_failure(VirtualMachine* vm)
vm->set_previous_etime(the_time);
vm->set_previous_vm_info();
vm->set_previous_running_etime(the_time);
vmpool->update_previous_history(vm);
@ -144,16 +136,10 @@ void LifeCycleManager::save_success_action(int vid)
if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) )
{
vm->delete_snapshots();
vmpool->update(vm);
}
vm->reset_info();
vm->set_vm_info();
vmpool->update_history(vm);
vmpool->update(vm);
//----------------------------------------------------
dm->trigger(DMAction::SUSPEND_SUCCESS,vid);
@ -173,8 +159,6 @@ void LifeCycleManager::save_success_action(int vid)
vm->delete_snapshots();
}
vm->reset_info();
vm->set_epilog_stime(the_time);
vm->set_running_etime(the_time);
@ -269,8 +253,6 @@ void LifeCycleManager::deploy_success_action(int vid)
vm->set_previous_etime(the_time);
vm->set_previous_vm_info();
vm->set_previous_running_etime(the_time);
vmpool->update_previous_history(vm);
@ -355,14 +337,10 @@ void LifeCycleManager::deploy_failure_action(int vid)
vm->set_etime(the_time);
vm->set_vm_info();
vmpool->update_history(vm);
vm->set_previous_etime(the_time);
vm->set_previous_vm_info();
vm->set_previous_running_etime(the_time);
vmpool->update_previous_history(vm);
@ -469,8 +447,6 @@ void LifeCycleManager::shutdown_success_action(int vid)
vm->delete_snapshots();
}
vm->reset_info();
vm->set_epilog_stime(the_time);
vm->set_running_etime(the_time);
@ -492,18 +468,10 @@ void LifeCycleManager::shutdown_success_action(int vid)
if ( !vmm->is_keep_snapshots(vm->get_vmm_mad()) )
{
vm->delete_snapshots();
vmpool->update(vm);
}
vm->reset_info();
vm->set_running_etime(the_time);
vm->set_vm_info();
vmpool->update_history(vm);
vmpool->update(vm);
//----------------------------------------------------
dm->trigger(DMAction::POWEROFF_SUCCESS,vid);
@ -521,8 +489,6 @@ void LifeCycleManager::shutdown_success_action(int vid)
vm->delete_snapshots();
}
vm->reset_info();
vm->set_epilog_stime(the_time);
vm->set_running_etime(the_time);
@ -690,12 +656,8 @@ void LifeCycleManager::prolog_success_action(int vid)
vm->delete_snapshots();
}
vm->reset_info();
vm->set_prolog_etime(the_time);
vm->set_vm_info();
vmpool->update_history(vm);
vmpool->update(vm);
@ -784,8 +746,6 @@ void LifeCycleManager::prolog_failure_action(int vid)
vm->set_prolog_etime(t);
vm->set_etime(t);
vm->set_vm_info();
vmpool->update_history(vm);
switch (vm->get_lcm_state())
@ -914,8 +874,6 @@ void LifeCycleManager::epilog_success_action(int vid)
vm->set_etime(the_time);
vm->set_vm_info();
VectorAttribute * graphics = vm->get_template_attribute("GRAPHICS");
//Do not free VNC ports for STOP as it is stored in checkpoint file
@ -1058,10 +1016,6 @@ void LifeCycleManager::monitor_suspend_action(int vid)
vm->delete_snapshots();
}
vm->reset_info();
vm->set_vm_info();
vm->set_internal_action(VMActions::MONITOR_ACTION);
vmpool->update_history(vm);
@ -1141,14 +1095,10 @@ void LifeCycleManager::monitor_poweroff_action(int vid)
vm->delete_snapshots();
}
vm->reset_info();
vm->set_resched(false);
vm->set_state(VirtualMachine::SHUTDOWN_POWEROFF);
vm->set_vm_info();
vm->set_internal_action(VMActions::MONITOR_ACTION);
vmpool->update_history(vm);
@ -1189,27 +1139,27 @@ void LifeCycleManager::monitor_poweron_action(int vid)
if ( vm->get_state() == VirtualMachine::POWEROFF ||
vm->get_state() == VirtualMachine::SUSPENDED )
{
vm->log("VMM",Log::INFO,"VM found again by the drivers");
vm->log("VMM",Log::INFO,"VM found again by the drivers");
time_t the_time = time(0);
time_t the_time = time(0);
vm->set_state(VirtualMachine::ACTIVE);
vm->set_state(VirtualMachine::ACTIVE);
vm->set_state(VirtualMachine::RUNNING);
vm->set_state(VirtualMachine::RUNNING);
vm->set_etime(the_time);
vm->set_etime(the_time);
vmpool->update_history(vm);
vmpool->update_history(vm);
vm->cp_history();
vm->cp_history();
vm->set_stime(the_time);
vm->set_stime(the_time);
vm->set_running_stime(the_time);
vm->set_running_stime(the_time);
vmpool->insert_history(vm);
vmpool->insert_history(vm);
vmpool->update(vm);
vmpool->update(vm);
}
else if ( vm->get_state() == VirtualMachine::ACTIVE )
{

View File

@ -2705,21 +2705,6 @@ void VirtualMachine::clear_template_error_message()
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void VirtualMachine::set_template_monitor_error(const string& message)
{
set_template_error_message("ERROR_MONITOR", message);
}
/* -------------------------------------------------------------------------- */
void VirtualMachine::clear_template_monitor_error()
{
user_obj_template->erase("ERROR_MONITOR");
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void VirtualMachine::get_public_clouds(const string& pname, set<string> &clouds) const
{
vector<VectorAttribute *> attrs;

View File

@ -95,20 +95,3 @@ int VirtualMachineMonitorInfo::from_template(const Template &tmpl)
return 0;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void VirtualMachineMonitorInfo::reset_info()
{
_timestamp = time(0);
monitoring.clear();
monitoring.replace("CPU","0.0");
monitoring.replace("MEMORY","0");
monitoring.replace("TIMESTAMP", _timestamp);
monitoring.replace("ID", _oid);
}

View File

@ -190,29 +190,6 @@ static void log_error(VirtualMachine* vm,
vm->log("VMM",Log::ERROR,os);
}
/* -------------------------------------------------------------------------- */
// static void log_monitor_error(VirtualMachine* vm,
// ostringstream& os,
// istringstream& is,
// const char * msg)
// {
// string info;
// getline(is,info);
// os.str("");
// os << msg;
// if (!info.empty() && info[0] != '-')
// {
// os << ": " << info;
// vm->set_template_monitor_error(os.str());
// }
// vm->log("VMM",Log::ERROR,os);
// }
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */