diff --git a/share/etc/oned.conf b/share/etc/oned.conf index 665a27d290..55c818c1e9 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -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 diff --git a/src/nebula/Nebula.cc b/src/nebula/Nebula.cc index 7b1196d57c..fd17a661b0 100644 --- a/src/nebula/Nebula.cc +++ b/src/nebula/Nebula.cc @@ -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"; } diff --git a/src/sunstone/models/SunstoneServer.rb b/src/sunstone/models/SunstoneServer.rb index 04d0a249c2..2bd3281649 100644 --- a/src/sunstone/models/SunstoneServer.rb +++ b/src/sunstone/models/SunstoneServer.rb @@ -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 ######################################################################## diff --git a/src/sunstone/sunstone-server.rb b/src/sunstone/sunstone-server.rb index 24667ad9f0..4b504d53c9 100755 --- a/src/sunstone/sunstone-server.rb +++ b/src/sunstone/sunstone-server.rb @@ -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' => [ diff --git a/src/template/OpenNebulaTemplate.cc b/src/template/OpenNebulaTemplate.cc index 1cd6b86e02..ab8500e86e 100644 --- a/src/template/OpenNebulaTemplate.cc +++ b/src/template/OpenNebulaTemplate.cc @@ -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));