1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-23 22:50:09 +03:00

F #4556: Added option to conf VM logs location

Easily share VM logs between HA nodes with the aid of a sync daemon like
lsyncd

Signed-off-by: Kristian Feldsam <feldsam@gmail.com>
This commit is contained in:
Kristián Feldsam 2022-03-02 12:45:04 +01:00 committed by Ruben S. Montero
parent 14d19d7656
commit b9e2dcc4eb
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
5 changed files with 41 additions and 20 deletions

View File

@ -48,12 +48,14 @@
# syslog to use the syslog facilities
# std to use the default log stream (stderr) to use with systemd
# debug_level: 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG
# use_vms_location: defines if store VM logs in VMS_LOCATION
#
#*******************************************************************************
LOG = [
SYSTEM = "file",
DEBUG_LEVEL = 3
DEBUG_LEVEL = 3,
USE_VMS_LOCATION = "NO"
]
#MANAGER_TIMER = 15

View File

@ -1272,8 +1272,16 @@ void Nebula::get_ds_location(string& dsloc) const
string Nebula::get_vm_log_filename(int oid) const
{
ostringstream oss;
bool use_vms_location;
if (nebula_location == "/")
const VectorAttribute * log = nebula_configuration->get("LOG");
if ( log != 0 )
{
log->vector_value("USE_VMS_LOCATION", use_vms_location);
}
if (nebula_location == "/" && ! use_vms_location)
{
oss << log_location << oid << ".log";
}

View File

@ -273,28 +273,35 @@ class SunstoneServer < CloudServer
end
############################################################################
# Unused
#
############################################################################
def get_vm_log(id)
resource = retrieve_resource("vm", id)
if OpenNebula.is_error?(resource)
return [404, nil]
else
if !ONE_LOCATION
vm_log_file = LOG_LOCATION + "/#{id}.log"
else
vm_log_file = LOG_LOCATION + "/vms/#{id}/vm.log"
end
begin
log = File.read(vm_log_file)
rescue Exception => e
msg = "Log for VM #{id} not available"
return [200, {:vm_log => msg}.to_json]
end
return [200, {:vm_log => log}.to_json]
return [404, nil]
end
use_vms_location = begin
$conf[:locals][:oned_conf]["LOG"]["USE_VMS_LOCATION"]
rescue
"NO"
end
if !ONE_LOCATION && use_vms_location != "YES"
vm_log_file = LOG_LOCATION + "/#{id}.log"
else
vm_log_file = VMS_LOCATION + "/#{id}/vm.log"
end
begin
log = File.read(vm_log_file)
rescue Exception => e
msg = "Log for VM #{id} not available"
return [200, {:vm_log => msg}.to_json]
end
return [200, {:vm_log => log}.to_json]
end
########################################################################

View File

@ -37,6 +37,8 @@ else
SUNSTONE_LOCATION ||= ONE_LOCATION + '/lib/sunstone'
end
VMS_LOCATION = VAR_LOCATION + "/vms"
SUNSTONE_AUTH = VAR_LOCATION + '/.one/sunstone_auth'
SUNSTONE_LOG = LOG_LOCATION + '/sunstone.log'
CONFIGURATION_FILE = ETC_LOCATION + '/sunstone-server.conf'
@ -107,7 +109,8 @@ ONED_CONF_OPTS = {
'MARKET_MAD_CONF',
'VM_MAD',
'IM_MAD',
'AUTH_MAD'
'AUTH_MAD',
'LOG'
],
# Generate an array if there is only 1 element
'ARRAY_KEYS' => [

View File

@ -411,6 +411,7 @@ void OpenNebulaTemplate::set_conf_default()
vvalue.clear();
vvalue.insert(make_pair("SYSTEM","file"));
vvalue.insert(make_pair("DEBUG_LEVEL","3"));
vvalue.insert(make_pair("USE_VMS_LOCATION","NO"));
vattribute = new VectorAttribute("LOG",vvalue);
conf_default.insert(make_pair(vattribute->name(),vattribute));