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

feature #575: Support for TM drivers, also tyoe of log messages from the drivers have the right type.

This commit is contained in:
Ruben S. Montero 2011-04-15 00:49:42 +02:00
parent cd163f2a54
commit aebb1cd6a7
3 changed files with 39 additions and 27 deletions

View File

@ -26,6 +26,8 @@
#include <unistd.h>
#include "Log.h"
using namespace std;
/**
@ -89,6 +91,32 @@ protected:
write(os);
};
/**
* Sets the log message type as specify by the driver.
* @param first character of the type string
* @return the message type
*/
Log::MessageType log_type(const char r)
{
Log::MessageType lt;
switch (r)
{
case 'E':
lt = Log::ERROR;
break;
case 'I':
lt = Log::INFO;
break;
case 'D':
lt = Log::DEBUG;
break;
default:
lt = Log::INFO;
}
return lt;
}
private:
friend class MadManager;
@ -141,7 +169,7 @@ private:
* @return 0 on success
*/
int reload();
/**
* Implements the driver specific protocol, this function should trigger
* actions on the associated manager.

View File

@ -79,7 +79,7 @@ void TransferManagerDriver::protocol(
is.clear();
getline(is,info);
NebulaLog::log("TM",Log::INFO, info.c_str());
NebulaLog::log("TM",log_type(result[0]), info.c_str());
}
return;
@ -142,8 +142,14 @@ void TransferManagerDriver::protocol(
getline(is,info);
os.str("");
os << "Error excuting image transfer script: " << info;
os << "Error excuting image transfer script";
if (info[0] != '-')
{
os << ": " << info;
vm->set_error_message(os.str());
}
vm->log("TM",Log::ERROR,os);
switch (vm->get_lcm_state())
@ -171,7 +177,7 @@ void TransferManagerDriver::protocol(
string info;
getline(is,info);
vm->log("TM",Log::INFO,info.c_str());
vm->log("TM",log_type(result[0]),info.c_str());
}
vm->unlock();

View File

@ -252,28 +252,6 @@ static void log_error(VirtualMachine* vm,
vm->log("VMM",Log::ERROR,os);
}
static Log::MessageType log_type(const char r)
{
Log::MessageType lt;
switch (r)
{
case 'E':
lt = Log::ERROR;
break;
case 'I':
lt = Log::INFO;
break;
case 'D':
lt = Log::DEBUG;
break;
default:
lt = Log::INFO;
}
return lt;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */