mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
feature #282: Removed unneeded try, made VirtualMachineXML constructors as HostXML
This commit is contained in:
parent
7a6b9fc975
commit
4c4dfd6e88
@ -29,13 +29,18 @@ class VirtualMachineXML : public ObjectXML
|
||||
{
|
||||
public:
|
||||
|
||||
VirtualMachineXML(const string &xml_doc);
|
||||
VirtualMachineXML(const string &xml_doc):ObjectXML(xml_doc)
|
||||
{
|
||||
init_attributes();
|
||||
};
|
||||
|
||||
VirtualMachineXML(const xmlNodePtr node);
|
||||
VirtualMachineXML(const xmlNodePtr node):ObjectXML(node)
|
||||
{
|
||||
init_attributes();
|
||||
}
|
||||
|
||||
~VirtualMachineXML();
|
||||
|
||||
|
||||
int get_oid() const
|
||||
{
|
||||
return oid;
|
||||
@ -62,7 +67,7 @@ public:
|
||||
/**
|
||||
*
|
||||
*/
|
||||
int get_host(int& hid,
|
||||
int get_host(int& hid,
|
||||
HostPoolXML * hpool,
|
||||
map<int,int>& host_vms,
|
||||
int max_vms);
|
||||
@ -100,7 +105,7 @@ protected:
|
||||
/**
|
||||
* For constructors
|
||||
*/
|
||||
void init();
|
||||
void init_attributes();
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------
|
||||
|
@ -52,7 +52,7 @@ void HostPoolXML::add_object(xmlNodePtr node)
|
||||
NebulaLog::log("HOST",Log::ERROR,
|
||||
"XML Node does not represent a valid Host");
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
HostXML* host = new HostXML( node );
|
||||
|
@ -51,23 +51,12 @@ void VirtualMachinePoolXML::add_object(xmlNodePtr node)
|
||||
{
|
||||
NebulaLog::log("VM",Log::ERROR,
|
||||
"XML Node does not represent a valid Virtual Machine");
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
VirtualMachineXML* vm = new VirtualMachineXML( node );
|
||||
VirtualMachineXML* vm = new VirtualMachineXML(node);
|
||||
|
||||
objects.insert( pair<int,ObjectXML*>(vm->get_oid(), vm) );
|
||||
}
|
||||
catch(runtime_error& re)
|
||||
{
|
||||
ostringstream oss_re;
|
||||
|
||||
oss_re << re.what();
|
||||
NebulaLog::log("VM",Log::ERROR,oss_re);
|
||||
}
|
||||
objects.insert(pair<int,ObjectXML*>(vm->get_oid(),vm));
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -18,17 +18,7 @@
|
||||
|
||||
#include "VirtualMachineXML.h"
|
||||
|
||||
VirtualMachineXML::VirtualMachineXML(const string &xml_doc):ObjectXML(xml_doc)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
VirtualMachineXML::VirtualMachineXML(const xmlNodePtr node):ObjectXML(node)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
void VirtualMachineXML::init()
|
||||
void VirtualMachineXML::init_attributes()
|
||||
{
|
||||
vector<string> result;
|
||||
|
||||
@ -140,9 +130,9 @@ void VirtualMachineXML::set_priorities(vector<float>& total)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachineXML::get_host(int& hid,
|
||||
int VirtualMachineXML::get_host(int& hid,
|
||||
HostPoolXML * hpool,
|
||||
map<int,int>& host_vms,
|
||||
map<int,int>& host_vms,
|
||||
int max_vms)
|
||||
{
|
||||
vector<VirtualMachineXML::Host *>::reverse_iterator i;
|
||||
|
Loading…
x
Reference in New Issue
Block a user