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

Merge branch 'feature-200' of dsa-research.org:one into feature-200

This commit is contained in:
Ruben S. Montero 2010-07-01 13:34:50 +02:00
commit 8763162b16
5 changed files with 46 additions and 49 deletions

View File

@ -118,11 +118,6 @@ protected:
*/
int remove_attribute(SqlDB * db, const string& name);
/**
* Callback to set the template id (TemplateSQL::insert)
*/
int insert_cb(void *nil, int num, char **values, char **names);
/**
* Callback to recover template attributes (TemplateSQL::select)
*/

View File

@ -1001,18 +1001,17 @@ protected:
UID = 1,
NAME = 2,
LAST_POLL = 3,
TEMPLATE_ID = 4,
STATE = 5,
LCM_STATE = 6,
STIME = 7,
ETIME = 8,
DEPLOY_ID = 9,
MEMORY = 10,
CPU = 11,
NET_TX = 12,
NET_RX = 13,
LAST_SEQ = 14,
LIMIT = 15
STATE = 4,
LCM_STATE = 5,
STIME = 6,
ETIME = 7,
DEPLOY_ID = 8,
MEMORY = 9,
CPU = 10,
NET_TX = 11,
NET_RX = 12,
LAST_SEQ = 13,
LIMIT = 14
};
static const char * table;

View File

@ -257,6 +257,28 @@ TM_MAD = [
HM_MAD = [
executable = "one_hm" ]
#-------------------------------- Image Hook -----------------------------------
# This hook is used to handle image saving and overwriting when virtual machines
# reach the DONE state after being shutdown.
#
# Uncomment one of the following:
#
# Self-contained (substitute [ONE_LOCATION] with its proper path)
# VM_HOOK = [
# name = "image",
# on = "SHUTDOWN",
# command = "[ONE_LOCATION]/share/hooks/image.rb",
# arguments = "$VMID" ]
#
# System-wide
# VM_HOOK = [
# name = "image",
# on = "SHUTDOWN",
# command = "/usr/share/doc/opennebula/hooks/image.rb",
# arguments = "$VMID" ]
#-------------------------------------------------------------------------------
#-------------------------------- Hook Examples --------------------------------
#VM_HOOK = [

View File

@ -27,36 +27,10 @@ const char * TemplateSQL::db_names = "(id,name,type,value)";
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int TemplateSQL::insert_cb(void *nil, int num, char **values, char **names)
{
if ( num<=0 )
{
return -1;
}
if ( values[0] == 0 )
{
id = 0;
}
else
{
id = atoi(values[0]) + 1;
}
return 0;
}
/* ------------------------------------------------------------------------ */
int TemplateSQL::insert(SqlDB * db)
{
int rc;
if ( rc != 0 )
{
return -1;
}
rc = insert_replace(db, false);
return rc;

View File

@ -83,13 +83,13 @@ VirtualMachine::~VirtualMachine()
const char * VirtualMachine::table = "vm_pool";
const char * VirtualMachine::db_names =
"(oid,uid,name,last_poll,template_id,state,lcm_state,stime,etime,deploy_id"
",memory,cpu,net_tx,net_rx,last_seq)";
"(oid,uid,name,last_poll, state,lcm_state,stime,etime,deploy_id"
",memory,cpu,net_tx,net_rx,last_seq)";
const char * VirtualMachine::db_bootstrap = "CREATE TABLE IF NOT EXISTS "
"vm_pool ("
"oid INTEGER PRIMARY KEY,uid INTEGER,name TEXT,"
"last_poll INTEGER, template_id INTEGER,state INTEGER,lcm_state INTEGER,"
"last_poll INTEGER, state INTEGER,lcm_state INTEGER,"
"stime INTEGER,etime INTEGER,deploy_id TEXT,memory INTEGER,cpu INTEGER,"
"net_tx INTEGER,net_rx INTEGER, last_seq INTEGER)";
@ -102,7 +102,6 @@ int VirtualMachine::select_cb(void *nil, int num, char **values, char **names)
(values[UID] == 0) ||
(values[NAME] == 0) ||
(values[LAST_POLL] == 0) ||
(values[TEMPLATE_ID] == 0) ||
(values[STATE] == 0) ||
(values[LCM_STATE] == 0) ||
(values[STIME] == 0) ||
@ -140,7 +139,8 @@ int VirtualMachine::select_cb(void *nil, int num, char **values, char **names)
net_rx = atoi(values[NET_RX]);
last_seq = atoi(values[LAST_SEQ]);
vm_template.id = atoi(values[TEMPLATE_ID]);
// Virtual Machine template ID is the VM ID
vm_template.id = oid;
return 0;
}
@ -266,6 +266,14 @@ int VirtualMachine::insert(SqlDB * db)
SingleAttribute * attr;
string value;
ostringstream oss;
// -----------------------------------------------------------------------
// Set a template ID if it wasn't already assigned
// ------------------------------------------------------------------------
if ( vm_template.id == -1 )
{
vm_template.id = oid;
}
// -----------------------------------------------------------------------
// Set a name if the VM has not got one and VM_ID
@ -593,7 +601,6 @@ int VirtualMachine::insert_replace(SqlDB *db, bool replace)
<< uid << ","
<< "'" << sql_name << "',"
<< last_poll << ","
<< vm_template.id << ","
<< state << ","
<< lcm_state << ","
<< stime << ","