mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-22 13:33:52 +03:00
This commit is contained in:
parent
8b9313699d
commit
7221ae061c
@ -869,11 +869,9 @@ private:
|
|||||||
static void bootstrap(SqlDB * db)
|
static void bootstrap(SqlDB * db)
|
||||||
{
|
{
|
||||||
ostringstream oss_vm(VirtualMachine::db_bootstrap);
|
ostringstream oss_vm(VirtualMachine::db_bootstrap);
|
||||||
ostringstream oss_tmpl(VirtualMachineTemplate::db_bootstrap);
|
|
||||||
ostringstream oss_hist(History::db_bootstrap);
|
ostringstream oss_hist(History::db_bootstrap);
|
||||||
|
|
||||||
db->exec(oss_vm);
|
db->exec(oss_vm);
|
||||||
db->exec(oss_tmpl);
|
|
||||||
db->exec(oss_hist);
|
db->exec(oss_hist);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -928,40 +926,39 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Updates the template of a VM, adding a new attribute (replacing it if
|
* Updates the template of a VM, adding a new attribute (replacing it if
|
||||||
* already defined), the vm's mutex SHOULD be locked
|
* already defined), the vm's mutex SHOULD be locked
|
||||||
* @param db pointer to the database
|
|
||||||
* @param name of the new attribute
|
* @param name of the new attribute
|
||||||
* @param value of the new attribute
|
* @param value of the new attribute
|
||||||
* @return 0 on success
|
* @return 0 on success
|
||||||
*/
|
*/
|
||||||
int update_template_attribute(
|
int update_template_attribute(
|
||||||
SqlDB * db,
|
|
||||||
string& name,
|
string& name,
|
||||||
string& value)
|
string& value)
|
||||||
{
|
{
|
||||||
SingleAttribute * sattr;
|
SingleAttribute * sattr;
|
||||||
int rc;
|
|
||||||
|
vm_template->erase(name);
|
||||||
|
|
||||||
sattr = new SingleAttribute(name,value);
|
sattr = new SingleAttribute(name,value);
|
||||||
rc = vm_template->replace_attribute(db,sattr);
|
vm_template->set(sattr);
|
||||||
|
|
||||||
if (rc != 0)
|
return 0;
|
||||||
{
|
|
||||||
delete sattr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts a new attribute in the template of a VM, also the DB is
|
* Inserts a new attribute in the template of a VM.
|
||||||
* updated. The vm's mutex SHOULD be locked
|
* The vm's mutex SHOULD be locked.
|
||||||
* @param db pointer to the database
|
|
||||||
* @param attribute the new attribute for the template
|
* @param attribute the new attribute for the template
|
||||||
* @return 0 on success
|
* @return 0 on success
|
||||||
*/
|
*/
|
||||||
int insert_template_attribute(SqlDB * db, Attribute * attribute)
|
int insert_template_attribute(Attribute * attribute)
|
||||||
{
|
{
|
||||||
return vm_template->insert_attribute(db,attribute);
|
if( attribute == 0 )
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
vm_template->set(attribute);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
@ -1023,7 +1020,8 @@ protected:
|
|||||||
NET_TX = 11,
|
NET_TX = 11,
|
||||||
NET_RX = 12,
|
NET_RX = 12,
|
||||||
LAST_SEQ = 13,
|
LAST_SEQ = 13,
|
||||||
LIMIT = 14
|
TEMPLATE = 14,
|
||||||
|
LIMIT = 15
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char * table;
|
static const char * table;
|
||||||
|
@ -103,7 +103,7 @@ public:
|
|||||||
string& name,
|
string& name,
|
||||||
string& value)
|
string& value)
|
||||||
{
|
{
|
||||||
return vm->update_template_attribute(db,name,value);
|
return vm->update_template_attribute(name,value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,29 +17,25 @@
|
|||||||
#ifndef VIRTUAL_MACHINE_TEMPLATE_H_
|
#ifndef VIRTUAL_MACHINE_TEMPLATE_H_
|
||||||
#define VIRTUAL_MACHINE_TEMPLATE_H_
|
#define VIRTUAL_MACHINE_TEMPLATE_H_
|
||||||
|
|
||||||
#include "TemplateSQL.h"
|
#include "Template.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Virtual Machine Template class, it represents a VM configuration file.
|
* Virtual Machine Template class, it represents a VM configuration file.
|
||||||
*/
|
*/
|
||||||
class VirtualMachineTemplate : public TemplateSQL
|
class VirtualMachineTemplate : public Template
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VirtualMachineTemplate(int tid = -1):
|
VirtualMachineTemplate():
|
||||||
TemplateSQL(table,tid,false,'=',"TEMPLATE"){};
|
Template(false,'=',"TEMPLATE"){};
|
||||||
|
|
||||||
~VirtualMachineTemplate(){};
|
~VirtualMachineTemplate(){};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class VirtualMachine;
|
friend class VirtualMachine;
|
||||||
|
|
||||||
static const char * table;
|
|
||||||
|
|
||||||
static const char * db_bootstrap;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
@ -40,7 +40,6 @@ source_files=[
|
|||||||
'vm_var_parser.c',
|
'vm_var_parser.c',
|
||||||
'vm_var_syntax.cc',
|
'vm_var_syntax.cc',
|
||||||
'VirtualMachinePool.cc',
|
'VirtualMachinePool.cc',
|
||||||
'VirtualMachineTemplate.cc',
|
|
||||||
'VirtualMachineHook.cc'
|
'VirtualMachineHook.cc'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -96,14 +96,14 @@ const char * VirtualMachine::table = "vm_pool";
|
|||||||
|
|
||||||
const char * VirtualMachine::db_names =
|
const char * VirtualMachine::db_names =
|
||||||
"(oid,uid,name,last_poll, state,lcm_state,stime,etime,deploy_id"
|
"(oid,uid,name,last_poll, state,lcm_state,stime,etime,deploy_id"
|
||||||
",memory,cpu,net_tx,net_rx,last_seq)";
|
",memory,cpu,net_tx,net_rx,last_seq, template)";
|
||||||
|
|
||||||
const char * VirtualMachine::db_bootstrap = "CREATE TABLE IF NOT EXISTS "
|
const char * VirtualMachine::db_bootstrap = "CREATE TABLE IF NOT EXISTS "
|
||||||
"vm_pool ("
|
"vm_pool ("
|
||||||
"oid INTEGER PRIMARY KEY,uid INTEGER,name TEXT,"
|
"oid INTEGER PRIMARY KEY,uid INTEGER,name TEXT,"
|
||||||
"last_poll 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,"
|
"stime INTEGER,etime INTEGER,deploy_id TEXT,memory INTEGER,cpu INTEGER,"
|
||||||
"net_tx INTEGER,net_rx INTEGER, last_seq INTEGER)";
|
"net_tx INTEGER,net_rx INTEGER, last_seq INTEGER, template TEXT)";
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
@ -123,6 +123,7 @@ int VirtualMachine::select_cb(void *nil, int num, char **values, char **names)
|
|||||||
(values[NET_TX] == 0) ||
|
(values[NET_TX] == 0) ||
|
||||||
(values[NET_RX] == 0) ||
|
(values[NET_RX] == 0) ||
|
||||||
(values[LAST_SEQ] == 0) ||
|
(values[LAST_SEQ] == 0) ||
|
||||||
|
(values[TEMPLATE] == 0) ||
|
||||||
(num != LIMIT ))
|
(num != LIMIT ))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
@ -151,8 +152,8 @@ int VirtualMachine::select_cb(void *nil, int num, char **values, char **names)
|
|||||||
net_rx = atoi(values[NET_RX]);
|
net_rx = atoi(values[NET_RX]);
|
||||||
last_seq = atoi(values[LAST_SEQ]);
|
last_seq = atoi(values[LAST_SEQ]);
|
||||||
|
|
||||||
// Virtual Machine template ID is the VM ID
|
// Virtual Machine template
|
||||||
vm_template->id = oid;
|
vm_template->from_xml(values[TEMPLATE]);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -187,14 +188,6 @@ int VirtualMachine::select(SqlDB * db)
|
|||||||
goto error_id;
|
goto error_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get the template
|
|
||||||
rc = vm_template->select(db);
|
|
||||||
|
|
||||||
if (rc != 0)
|
|
||||||
{
|
|
||||||
goto error_template;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Get the History Records
|
//Get the History Records
|
||||||
|
|
||||||
if ( last_seq != -1 )
|
if ( last_seq != -1 )
|
||||||
@ -221,7 +214,7 @@ int VirtualMachine::select(SqlDB * db)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Create support directory fo this VM
|
//Create support directory for this VM
|
||||||
|
|
||||||
oss.str("");
|
oss.str("");
|
||||||
oss << nd.get_var_location() << oid;
|
oss << nd.get_var_location() << oid;
|
||||||
@ -229,7 +222,7 @@ int VirtualMachine::select(SqlDB * db)
|
|||||||
mkdir(oss.str().c_str(), 0777);
|
mkdir(oss.str().c_str(), 0777);
|
||||||
chmod(oss.str().c_str(), 0777);
|
chmod(oss.str().c_str(), 0777);
|
||||||
|
|
||||||
//Create Log support fo this VM
|
//Create Log support for this VM
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -250,11 +243,6 @@ error_id:
|
|||||||
log("VMM", Log::ERROR, ose);
|
log("VMM", Log::ERROR, ose);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
error_template:
|
|
||||||
ose << "Can not get template for VM id: " << oid;
|
|
||||||
log("ONE", Log::ERROR, ose);
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
error_history:
|
error_history:
|
||||||
ose << "Can not get history for VM id: " << oid;
|
ose << "Can not get history for VM id: " << oid;
|
||||||
log("ONE", Log::ERROR, ose);
|
log("ONE", Log::ERROR, ose);
|
||||||
@ -279,13 +267,6 @@ int VirtualMachine::insert(SqlDB * db)
|
|||||||
string value;
|
string value;
|
||||||
ostringstream oss;
|
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
|
// Set a name if the VM has not got one and VM_ID
|
||||||
@ -354,16 +335,9 @@ int VirtualMachine::insert(SqlDB * db)
|
|||||||
parse_graphics();
|
parse_graphics();
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// Insert the template first, so we get a valid template ID. Then the VM
|
// Insert the VM
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
rc = vm_template->insert(db);
|
|
||||||
|
|
||||||
if ( rc != 0 )
|
|
||||||
{
|
|
||||||
goto error_template;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = insert_replace(db, false);
|
rc = insert_replace(db, false);
|
||||||
|
|
||||||
if ( rc != 0 )
|
if ( rc != 0 )
|
||||||
@ -375,11 +349,6 @@ int VirtualMachine::insert(SqlDB * db)
|
|||||||
|
|
||||||
error_update:
|
error_update:
|
||||||
NebulaLog::log("ONE",Log::ERROR, "Can not update VM in the database");
|
NebulaLog::log("ONE",Log::ERROR, "Can not update VM in the database");
|
||||||
vm_template->drop(db);
|
|
||||||
goto error_common;
|
|
||||||
|
|
||||||
error_template:
|
|
||||||
NebulaLog::log("ONE",Log::ERROR, "Can not insert template in the database");
|
|
||||||
goto error_common;
|
goto error_common;
|
||||||
|
|
||||||
error_leases:
|
error_leases:
|
||||||
@ -590,24 +559,34 @@ int VirtualMachine::insert_replace(SqlDB *db, bool replace)
|
|||||||
ostringstream oss;
|
ostringstream oss;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
string xml_template;
|
||||||
char * sql_deploy_id;
|
char * sql_deploy_id;
|
||||||
char * sql_name;
|
char * sql_name;
|
||||||
|
char * sql_template;
|
||||||
|
|
||||||
sql_deploy_id = db->escape_str(deploy_id.c_str());
|
sql_deploy_id = db->escape_str(deploy_id.c_str());
|
||||||
|
|
||||||
if ( sql_deploy_id == 0 )
|
if ( sql_deploy_id == 0 )
|
||||||
{
|
{
|
||||||
return -1;
|
goto error_deploy;
|
||||||
}
|
}
|
||||||
|
|
||||||
sql_name = db->escape_str(name.c_str());
|
sql_name = db->escape_str(name.c_str());
|
||||||
|
|
||||||
if ( sql_name == 0 )
|
if ( sql_name == 0 )
|
||||||
{
|
{
|
||||||
db->free_str(sql_deploy_id);
|
goto error_name;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vm_template->to_xml(xml_template);
|
||||||
|
sql_template = db->escape_str(xml_template.c_str());
|
||||||
|
|
||||||
|
if ( sql_template == 0 )
|
||||||
|
{
|
||||||
|
goto error_template;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(replace)
|
if(replace)
|
||||||
{
|
{
|
||||||
oss << "REPLACE";
|
oss << "REPLACE";
|
||||||
@ -631,14 +610,23 @@ int VirtualMachine::insert_replace(SqlDB *db, bool replace)
|
|||||||
<< cpu << ","
|
<< cpu << ","
|
||||||
<< net_tx << ","
|
<< net_tx << ","
|
||||||
<< net_rx << ","
|
<< net_rx << ","
|
||||||
<< last_seq << ")";
|
<< last_seq << ","
|
||||||
|
<< "'" << sql_template << "')";
|
||||||
|
|
||||||
db->free_str(sql_deploy_id);
|
db->free_str(sql_deploy_id);
|
||||||
db->free_str(sql_name);
|
db->free_str(sql_name);
|
||||||
|
db->free_str(sql_template);
|
||||||
|
|
||||||
rc = db->exec(oss);
|
rc = db->exec(oss);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
error_template:
|
||||||
|
db->free_str(sql_name);
|
||||||
|
error_name:
|
||||||
|
db->free_str(sql_deploy_id);
|
||||||
|
error_deploy:
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
@ -660,6 +648,7 @@ int VirtualMachine::dump(ostringstream& oss,int num,char **values,char **names)
|
|||||||
(!values[NET_TX])||
|
(!values[NET_TX])||
|
||||||
(!values[NET_RX])||
|
(!values[NET_RX])||
|
||||||
(!values[LAST_SEQ])||
|
(!values[LAST_SEQ])||
|
||||||
|
(!values[TEMPLATE])||
|
||||||
(num != (LIMIT + History::LIMIT + 1)))
|
(num != (LIMIT + History::LIMIT + 1)))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
@ -681,7 +670,8 @@ int VirtualMachine::dump(ostringstream& oss,int num,char **values,char **names)
|
|||||||
"<CPU>" << values[CPU] << "</CPU>" <<
|
"<CPU>" << values[CPU] << "</CPU>" <<
|
||||||
"<NET_TX>" << values[NET_TX] << "</NET_TX>" <<
|
"<NET_TX>" << values[NET_TX] << "</NET_TX>" <<
|
||||||
"<NET_RX>" << values[NET_RX] << "</NET_RX>" <<
|
"<NET_RX>" << values[NET_RX] << "</NET_RX>" <<
|
||||||
"<LAST_SEQ>" << values[LAST_SEQ] << "</LAST_SEQ>";
|
"<LAST_SEQ>" << values[LAST_SEQ] << "</LAST_SEQ>" <<
|
||||||
|
values[TEMPLATE];
|
||||||
|
|
||||||
History::dump(oss, num-LIMIT-1, values+LIMIT+1, names+LIMIT+1);
|
History::dump(oss, num-LIMIT-1, values+LIMIT+1, names+LIMIT+1);
|
||||||
|
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
|
|
||||||
/* */
|
|
||||||
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
|
|
||||||
/* not use this file except in compliance with the License. You may obtain */
|
|
||||||
/* a copy of the License at */
|
|
||||||
/* */
|
|
||||||
/* http://www.apache.org/licenses/LICENSE-2.0 */
|
|
||||||
/* */
|
|
||||||
/* Unless required by applicable law or agreed to in writing, software */
|
|
||||||
/* distributed under the License is distributed on an "AS IS" BASIS, */
|
|
||||||
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
|
|
||||||
/* See the License for the specific language governing permissions and */
|
|
||||||
/* limitations under the License. */
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
#include "VirtualMachineTemplate.h"
|
|
||||||
|
|
||||||
const char * VirtualMachineTemplate::table = "vm_attributes";
|
|
||||||
|
|
||||||
const char * VirtualMachineTemplate::db_bootstrap = "CREATE TABLE IF NOT EXISTS"
|
|
||||||
" vm_attributes (id INTEGER, name TEXT, type INTEGER, value TEXT)";
|
|
||||||
|
|
@ -70,13 +70,14 @@ const string xmls[] =
|
|||||||
|
|
||||||
// This xml dump result has the STIMEs modified to 0000000000
|
// This xml dump result has the STIMEs modified to 0000000000
|
||||||
const string xml_dump =
|
const string xml_dump =
|
||||||
"<VM_POOL><VM><ID>0</ID><UID>1</UID><USERNAME>A user</USERNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><LAST_SEQ>-1</LAST_SEQ></VM><VM><ID>1</ID><UID>2</UID><USERNAME>B user</USERNAME><NAME>Second VM</NAME><LAST_POLL>0</LAST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><LAST_SEQ>-1</LAST_SEQ></VM></VM_POOL>";
|
"<VM_POOL><VM><ID>0</ID><UID>1</UID><USERNAME>A user</USERNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><LAST_SEQ>-1</LAST_SEQ><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[0]]></VMID></TEMPLATE></VM><VM><ID>1</ID><UID>2</UID><USERNAME>B user</USERNAME><NAME>Second VM</NAME><LAST_POLL>0</LAST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><LAST_SEQ>-1</LAST_SEQ><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second VM]]></NAME><VMID><![CDATA[1]]></VMID></TEMPLATE></VM></VM_POOL>";
|
||||||
|
|
||||||
const string xml_dump_where =
|
const string xml_dump_where =
|
||||||
"<VM_POOL><VM><ID>0</ID><UID>1</UID><USERNAME>A user</USERNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><LAST_SEQ>-1</LAST_SEQ></VM></VM_POOL>";
|
"<VM_POOL><VM><ID>0</ID><UID>1</UID><USERNAME>A user</USERNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><LAST_SEQ>-1</LAST_SEQ><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[0]]></VMID></TEMPLATE></VM></VM_POOL>";
|
||||||
|
|
||||||
const string xml_history_dump =
|
const string xml_history_dump =
|
||||||
"<VM_POOL><VM><ID>0</ID><UID>0</UID><USERNAME>one_user_test</USERNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><LAST_SEQ>-1</LAST_SEQ></VM><VM><ID>1</ID><UID>0</UID><USERNAME>one_user_test</USERNAME><NAME>Second VM</NAME><LAST_POLL>0</LAST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><LAST_SEQ>0</LAST_SEQ><HISTORY><SEQ>0</SEQ><HOSTNAME>A_hostname</HOSTNAME><HID>0</HID><STIME>0</STIME><ETIME>0</ETIME><PSTIME>0</PSTIME><PETIME>0</PETIME><RSTIME>0</RSTIME><RETIME>0</RETIME><ESTIME>0</ESTIME><EETIME>0</EETIME><REASON>0</REASON></HISTORY></VM><VM><ID>2</ID><UID>0</UID><USERNAME>one_user_test</USERNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><LAST_SEQ>1</LAST_SEQ><HISTORY><SEQ>1</SEQ><HOSTNAME>C_hostname</HOSTNAME><HID>2</HID><STIME>0</STIME><ETIME>0</ETIME><PSTIME>0</PSTIME><PETIME>0</PETIME><RSTIME>0</RSTIME><RETIME>0</RETIME><ESTIME>0</ESTIME><EETIME>0</EETIME><REASON>0</REASON></HISTORY></VM></VM_POOL>";
|
"<VM_POOL><VM><ID>0</ID><UID>0</UID><USERNAME>one_user_test</USERNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><LAST_SEQ>-1</LAST_SEQ><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[128]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[0]]></VMID></TEMPLATE></VM><VM><ID>1</ID><UID>0</UID><USERNAME>one_user_test</USERNAME><NAME>Second VM</NAME><LAST_POLL>0</LAST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><LAST_SEQ>0</LAST_SEQ><TEMPLATE><CPU><![CDATA[2]]></CPU><MEMORY><![CDATA[256]]></MEMORY><NAME><![CDATA[Second VM]]></NAME><VMID><![CDATA[1]]></VMID></TEMPLATE><HISTORY><SEQ>0</SEQ><HOSTNAME>A_hostname</HOSTNAME><HID>0</HID><STIME>0</STIME><ETIME>0</ETIME><PSTIME>0</PSTIME><PETIME>0</PETIME><RSTIME>0</RSTIME><RETIME>0</RETIME><ESTIME>0</ESTIME><EETIME>0</EETIME><REASON>0</REASON></HISTORY></VM><VM><ID>2</ID><UID>0</UID><USERNAME>one_user_test</USERNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><LAST_SEQ>1</LAST_SEQ><TEMPLATE><CPU><![CDATA[1]]></CPU><MEMORY><![CDATA[1024]]></MEMORY><NAME><![CDATA[VM one]]></NAME><VMID><![CDATA[2]]></VMID></TEMPLATE><HISTORY><SEQ>1</SEQ><HOSTNAME>C_hostname</HOSTNAME><HID>2</HID><STIME>0</STIME><ETIME>0</ETIME><PSTIME>0</PSTIME><PETIME>0</PETIME><RSTIME>0</RSTIME><RETIME>0</RETIME><ESTIME>0</ESTIME><EETIME>0</EETIME><REASON>0</REASON></HISTORY></VM></VM_POOL>";
|
||||||
|
|
||||||
|
|
||||||
const string replacement = "0000000000";
|
const string replacement = "0000000000";
|
||||||
|
|
||||||
@ -281,7 +282,7 @@ public:
|
|||||||
|
|
||||||
string result = oss.str();
|
string result = oss.str();
|
||||||
result.replace(152, 10, replacement);
|
result.replace(152, 10, replacement);
|
||||||
result.replace(449, 10, replacement);
|
result.replace(583, 10, replacement);
|
||||||
|
|
||||||
CPPUNIT_ASSERT( result == xml_dump );
|
CPPUNIT_ASSERT( result == xml_dump );
|
||||||
}
|
}
|
||||||
@ -403,8 +404,8 @@ public:
|
|||||||
string result = oss.str();
|
string result = oss.str();
|
||||||
|
|
||||||
result.replace(159, 10, replacement);
|
result.replace(159, 10, replacement);
|
||||||
result.replace(463, 10, replacement);
|
result.replace(597, 10, replacement);
|
||||||
result.replace(995, 10, replacement);
|
result.replace(1266,10, replacement);
|
||||||
|
|
||||||
CPPUNIT_ASSERT( result == xml_history_dump );
|
CPPUNIT_ASSERT( result == xml_history_dump );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user