mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-22 13:33:52 +03:00
feature #407: Minor changes for the VirtualMachine Pool
This commit is contained in:
parent
ed513e5b72
commit
ac6c5644fd
@ -43,10 +43,10 @@ public:
|
||||
int oid,
|
||||
int seq,
|
||||
int hid,
|
||||
string& hostname,
|
||||
string& vm_dir,
|
||||
string& vmm,
|
||||
string& tm);
|
||||
const string& hostname,
|
||||
const string& vm_dir,
|
||||
const string& vmm,
|
||||
const string& tm);
|
||||
|
||||
~History(){};
|
||||
|
||||
@ -75,8 +75,6 @@ private:
|
||||
|
||||
static const char * db_names;
|
||||
|
||||
static const char * extended_db_names;
|
||||
|
||||
static const char * db_bootstrap;
|
||||
|
||||
void non_persistent_data();
|
||||
@ -124,7 +122,12 @@ private:
|
||||
* @param db pointer to the database.
|
||||
* @return 0 on success.
|
||||
*/
|
||||
int insert(SqlDB * db, string& error_str);
|
||||
int insert(SqlDB * db, string& error_str)
|
||||
{
|
||||
error_str.clear();
|
||||
|
||||
return insert_replace(db, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the history record from the DB
|
||||
@ -138,7 +141,10 @@ private:
|
||||
* @param db pointer to the database.
|
||||
* @return 0 on success.
|
||||
*/
|
||||
int update(SqlDB * db);
|
||||
int update(SqlDB * db)
|
||||
{
|
||||
return insert_replace(db, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the all history records from the DB
|
||||
@ -170,7 +176,12 @@ private:
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int from_xml_node(const xmlNodePtr node);
|
||||
int from_xml_node(const xmlNodePtr node)
|
||||
{
|
||||
ObjectXML::update_from_node(node);
|
||||
|
||||
return rebuild_attributes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuilds the object from an xml formatted string
|
||||
@ -178,7 +189,12 @@ private:
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int from_xml(const string &xml_str);
|
||||
int from_xml(const string &xml_str)
|
||||
{
|
||||
ObjectXML::update_from_str(xml_str);
|
||||
|
||||
return rebuild_attributes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuilds the internal attributes using xpath
|
||||
|
@ -209,10 +209,10 @@ public:
|
||||
*/
|
||||
void add_history(
|
||||
int hid,
|
||||
string& hostname,
|
||||
string& vm_dir,
|
||||
string& vmm_mad,
|
||||
string& tm_mad);
|
||||
const string& hostname,
|
||||
const string& vm_dir,
|
||||
const string& vmm_mad,
|
||||
const string& tm_mad);
|
||||
|
||||
/**
|
||||
* Duplicates the last history record. Only the host related fields are
|
||||
@ -950,7 +950,7 @@ protected:
|
||||
//**************************************************************************
|
||||
|
||||
VirtualMachine(int id, int uid, string _user_name,
|
||||
VirtualMachineTemplate * _vm_template = 0);
|
||||
VirtualMachineTemplate * _vm_template);
|
||||
|
||||
virtual ~VirtualMachine();
|
||||
|
||||
@ -962,8 +962,6 @@ protected:
|
||||
|
||||
static const char * db_names;
|
||||
|
||||
static const char * extended_db_names;
|
||||
|
||||
static const char * db_bootstrap;
|
||||
|
||||
/**
|
||||
@ -978,21 +976,24 @@ protected:
|
||||
* @param db pointer to the db
|
||||
* @return 0 on success
|
||||
*/
|
||||
virtual int insert(SqlDB * db, string& error_str);
|
||||
int insert(SqlDB * db, string& error_str);
|
||||
|
||||
/**
|
||||
* Writes/updates the Virtual Machine data fields in the database.
|
||||
* @param db pointer to the db
|
||||
* @return 0 on success
|
||||
*/
|
||||
virtual int update(SqlDB * db);
|
||||
int update(SqlDB * db)
|
||||
{
|
||||
return insert_replace(db, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a VM from the database and all its associated information
|
||||
* @param db pointer to the db
|
||||
* @return -1
|
||||
*/
|
||||
virtual int drop(SqlDB * db)
|
||||
int drop(SqlDB * db)
|
||||
{
|
||||
NebulaLog::log("ONE",Log::ERROR, "VM Drop not implemented!");
|
||||
return -1;
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
int allocate (
|
||||
int uid,
|
||||
string user_name,
|
||||
VirtualMachineTemplate *vm_template,
|
||||
VirtualMachineTemplate * vm_template,
|
||||
int * oid,
|
||||
string& error_str,
|
||||
bool on_hold = false);
|
||||
|
@ -60,10 +60,10 @@ History::History(
|
||||
int _oid,
|
||||
int _seq,
|
||||
int _hid,
|
||||
string& _hostname,
|
||||
string& _vm_dir,
|
||||
string& _vmm,
|
||||
string& _tm):
|
||||
const string& _hostname,
|
||||
const string& _vm_dir,
|
||||
const string& _vmm,
|
||||
const string& _tm):
|
||||
oid(_oid),
|
||||
seq(_seq),
|
||||
hostname(_hostname),
|
||||
@ -131,30 +131,6 @@ void History::non_persistent_data()
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int History::insert(SqlDB * db, string& error_str)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = insert_replace(db, false);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int History::update(SqlDB * db)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = insert_replace(db, true);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int History::insert_replace(SqlDB *db, bool replace)
|
||||
{
|
||||
ostringstream oss;
|
||||
@ -309,28 +285,6 @@ string& History::to_xml(string& xml) const
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int History::from_xml_node(const xmlNodePtr node)
|
||||
{
|
||||
// Initialize the internal XML object
|
||||
ObjectXML::update_from_node(node);
|
||||
|
||||
return rebuild_attributes();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int History::from_xml(const string &xml_str)
|
||||
{
|
||||
// Initialize the internal XML object
|
||||
ObjectXML::update_from_str(xml_str);
|
||||
|
||||
return rebuild_attributes();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int History::rebuild_attributes()
|
||||
{
|
||||
int int_reason;
|
||||
|
@ -463,14 +463,6 @@ int VirtualMachine::parse_requirements()
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
int VirtualMachine::update(SqlDB * db)
|
||||
{
|
||||
return insert_replace(db, true);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
int VirtualMachine::insert_replace(SqlDB *db, bool replace)
|
||||
{
|
||||
ostringstream oss;
|
||||
@ -542,10 +534,10 @@ error_deploy:
|
||||
|
||||
void VirtualMachine::add_history(
|
||||
int hid,
|
||||
string& hostname,
|
||||
string& vm_dir,
|
||||
string& vmm_mad,
|
||||
string& tm_mad)
|
||||
const string& hostname,
|
||||
const string& vm_dir,
|
||||
const string& vmm_mad,
|
||||
const string& tm_mad)
|
||||
{
|
||||
ostringstream os;
|
||||
int seq;
|
||||
@ -1162,7 +1154,7 @@ int VirtualMachine::from_xml(const string &xml_str)
|
||||
}
|
||||
|
||||
// Virtual Machine template
|
||||
rc += vm_template->from_xml_node( content[0] );
|
||||
rc += vm_template->from_xml_node(content[0]);
|
||||
|
||||
// Last history entry
|
||||
content.clear();
|
||||
@ -1171,7 +1163,7 @@ int VirtualMachine::from_xml(const string &xml_str)
|
||||
if( !content.empty() )
|
||||
{
|
||||
history = new History(oid);
|
||||
rc += history->from_xml_node( content[0] );
|
||||
rc += history->from_xml_node(content[0]);
|
||||
}
|
||||
|
||||
if (rc != 0)
|
||||
|
Loading…
Reference in New Issue
Block a user