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

Bug #1306: Use the System DS id to generate the VM system dir

This commit is contained in:
Carlos Martín 2012-06-29 16:48:43 +02:00
parent fd28ff9d9f
commit 1327f28fab
6 changed files with 33 additions and 13 deletions

View File

@ -47,6 +47,7 @@ public:
const string& vmm, const string& vmm,
const string& vnm, const string& vnm,
const string& tmm, const string& tmm,
int ds_id,
const string& vm_info); const string& vm_info);
~History(){}; ~History(){};
@ -92,6 +93,8 @@ private:
string vnm_mad_name; string vnm_mad_name;
string tm_mad_name; string tm_mad_name;
int ds_id;
time_t stime; time_t stime;
time_t etime; time_t etime;

View File

@ -57,7 +57,8 @@ protected:
AuthRequest::Operation op); AuthRequest::Operation op);
int get_host_information(int hid, string& name, string& vmm, string& vnm, int get_host_information(int hid, string& name, string& vmm, string& vnm,
string& tm, RequestAttributes& att, PoolObjectAuth& host_perms); string& tm, int& ds_id, RequestAttributes& att,
PoolObjectAuth& host_perms);
int add_history(VirtualMachine * vm, int add_history(VirtualMachine * vm,
int hid, int hid,
@ -65,6 +66,7 @@ protected:
const string& vmm_mad, const string& vmm_mad,
const string& vnm_mad, const string& vnm_mad,
const string& tm_mad, const string& tm_mad,
int ds_id,
RequestAttributes& att); RequestAttributes& att);
VirtualMachine * get_vm(int id, RequestAttributes& att); VirtualMachine * get_vm(int id, RequestAttributes& att);

View File

@ -243,7 +243,8 @@ public:
const string& hostname, const string& hostname,
const string& vmm_mad, const string& vmm_mad,
const string& vnm_mad, const string& vnm_mad,
const string& tm_mad); const string& tm_mad,
int ds_id);
/** /**
* Duplicates the last history record. Only the host related fields are * Duplicates the last history record. Only the host related fields are

View File

@ -100,6 +100,7 @@ int RequestManagerVirtualMachine::get_host_information(int hid,
string& vmm, string& vmm,
string& vnm, string& vnm,
string& tm, string& tm,
int& ds_id,
RequestAttributes& att, RequestAttributes& att,
PoolObjectAuth& host_perms) PoolObjectAuth& host_perms)
{ {
@ -111,7 +112,6 @@ int RequestManagerVirtualMachine::get_host_information(int hid,
Datastore * ds; Datastore * ds;
int cluster_id; int cluster_id;
int ds_id;
host = hpool->get(hid,true); host = hpool->get(hid,true);
@ -213,6 +213,7 @@ int RequestManagerVirtualMachine::add_history(VirtualMachine * vm,
const string& vmm_mad, const string& vmm_mad,
const string& vnm_mad, const string& vnm_mad,
const string& tm_mad, const string& tm_mad,
int ds_id,
RequestAttributes& att) RequestAttributes& att)
{ {
string vmdir; string vmdir;
@ -220,7 +221,7 @@ int RequestManagerVirtualMachine::add_history(VirtualMachine * vm,
VirtualMachinePool * vmpool = static_cast<VirtualMachinePool *>(pool); VirtualMachinePool * vmpool = static_cast<VirtualMachinePool *>(pool);
vm->add_history(hid,hostname,vmm_mad,vnm_mad,tm_mad); vm->add_history(hid,hostname,vmm_mad,vnm_mad,tm_mad,ds_id);
rc = vmpool->update_history(vm); rc = vmpool->update_history(vm);
@ -366,13 +367,15 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
string vmm_mad; string vmm_mad;
string vnm_mad; string vnm_mad;
string tm_mad; string tm_mad;
int ds_id;
int id = xmlrpc_c::value_int(paramList.getInt(1)); int id = xmlrpc_c::value_int(paramList.getInt(1));
int hid = xmlrpc_c::value_int(paramList.getInt(2)); int hid = xmlrpc_c::value_int(paramList.getInt(2));
bool auth = false; bool auth = false;
if (get_host_information(hid,hostname,vmm_mad,vnm_mad,tm_mad,att, host_perms) != 0) if (get_host_information(
hid,hostname,vmm_mad,vnm_mad,tm_mad, ds_id, att, host_perms) != 0)
{ {
return; return;
} }
@ -399,7 +402,7 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
return; return;
} }
if ( add_history(vm,hid,hostname,vmm_mad,vnm_mad,tm_mad,att) != 0) if ( add_history(vm,hid,hostname,vmm_mad,vnm_mad,tm_mad,ds_id,att) != 0)
{ {
vm->unlock(); vm->unlock();
return; return;
@ -428,6 +431,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
string vmm_mad; string vmm_mad;
string vnm_mad; string vnm_mad;
string tm_mad; string tm_mad;
int ds_id;
int id = xmlrpc_c::value_int(paramList.getInt(1)); int id = xmlrpc_c::value_int(paramList.getInt(1));
int hid = xmlrpc_c::value_int(paramList.getInt(2)); int hid = xmlrpc_c::value_int(paramList.getInt(2));
@ -435,7 +439,8 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
bool auth = false; bool auth = false;
if (get_host_information(hid,hostname,vmm_mad,vnm_mad,tm_mad,att, host_perms) != 0) if (get_host_information(
hid,hostname,vmm_mad,vnm_mad,tm_mad,ds_id, att, host_perms) != 0)
{ {
return; return;
} }
@ -464,7 +469,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
return; return;
} }
if ( add_history(vm,hid,hostname,vmm_mad,vnm_mad,tm_mad,att) != 0) if ( add_history(vm,hid,hostname,vmm_mad,vnm_mad,tm_mad,ds_id,att) != 0)
{ {
vm->unlock(); vm->unlock();
return; return;

View File

@ -45,6 +45,7 @@ History::History(
vmm_mad_name(""), vmm_mad_name(""),
vnm_mad_name(""), vnm_mad_name(""),
tm_mad_name(""), tm_mad_name(""),
ds_id(0),
stime(0), stime(0),
etime(0), etime(0),
prolog_stime(0), prolog_stime(0),
@ -66,6 +67,7 @@ History::History(
const string& _vmm, const string& _vmm,
const string& _vnm, const string& _vnm,
const string& _tmm, const string& _tmm,
int _ds_id,
const string& _vm_info): const string& _vm_info):
oid(_oid), oid(_oid),
seq(_seq), seq(_seq),
@ -74,6 +76,7 @@ History::History(
vmm_mad_name(_vmm), vmm_mad_name(_vmm),
vnm_mad_name(_vnm), vnm_mad_name(_vnm),
tm_mad_name(_tmm), tm_mad_name(_tmm),
ds_id(_ds_id),
stime(0), stime(0),
etime(0), etime(0),
prolog_stime(0), prolog_stime(0),
@ -126,7 +129,7 @@ void History::non_persistent_data()
os.str(""); os.str("");
nd.get_configuration_attribute("DATASTORE_LOCATION", ds_location); nd.get_configuration_attribute("DATASTORE_LOCATION", ds_location);
os << ds_location << "/" << DatastorePool::SYSTEM_DS_ID << "/" << oid; os << ds_location << "/" << ds_id << "/" << oid;
vm_rhome = os.str(); vm_rhome = os.str();
@ -296,6 +299,7 @@ string& History::to_xml(string& xml, bool database) const
"<VMMMAD>" << vmm_mad_name << "</VMMMAD>"<< "<VMMMAD>" << vmm_mad_name << "</VMMMAD>"<<
"<VNMMAD>" << vnm_mad_name << "</VNMMAD>"<< "<VNMMAD>" << vnm_mad_name << "</VNMMAD>"<<
"<TMMAD>" << tm_mad_name << "</TMMAD>" << "<TMMAD>" << tm_mad_name << "</TMMAD>" <<
"<DS_ID>" << ds_id << "</DS_ID>" <<
"<PSTIME>" << prolog_stime << "</PSTIME>"<< "<PSTIME>" << prolog_stime << "</PSTIME>"<<
"<PETIME>" << prolog_etime << "</PETIME>"<< "<PETIME>" << prolog_etime << "</PETIME>"<<
"<RSTIME>" << running_stime << "</RSTIME>"<< "<RSTIME>" << running_stime << "</RSTIME>"<<
@ -335,6 +339,7 @@ int History::rebuild_attributes()
// TODO: add TMMAD element in onedb migrator // TODO: add TMMAD element in onedb migrator
rc += xpath(tm_mad_name , "/HISTORY/TMMAD", "not_found"); rc += xpath(tm_mad_name , "/HISTORY/TMMAD", "not_found");
rc += xpath(ds_id , "/HISTORY/DS_ID", 0);
rc += xpath(prolog_stime , "/HISTORY/PSTIME", 0); rc += xpath(prolog_stime , "/HISTORY/PSTIME", 0);
rc += xpath(prolog_etime , "/HISTORY/PETIME", 0); rc += xpath(prolog_etime , "/HISTORY/PETIME", 0);

View File

@ -827,7 +827,8 @@ void VirtualMachine::add_history(
const string& hostname, const string& hostname,
const string& vmm_mad, const string& vmm_mad,
const string& vnm_mad, const string& vnm_mad,
const string& tm_mad) const string& tm_mad,
int ds_id)
{ {
ostringstream os; ostringstream os;
int seq; int seq;
@ -853,6 +854,7 @@ void VirtualMachine::add_history(
vmm_mad, vmm_mad,
vnm_mad, vnm_mad,
tm_mad, tm_mad,
ds_id,
vm_xml); vm_xml);
history_records.push_back(history); history_records.push_back(history);
@ -880,6 +882,7 @@ void VirtualMachine::cp_history()
history->vmm_mad_name, history->vmm_mad_name,
history->vnm_mad_name, history->vnm_mad_name,
history->tm_mad_name, history->tm_mad_name,
history->ds_id,
vm_xml); vm_xml);
previous_history = history; previous_history = history;
@ -910,6 +913,7 @@ void VirtualMachine::cp_previous_history()
previous_history->vmm_mad_name, previous_history->vmm_mad_name,
previous_history->vnm_mad_name, previous_history->vnm_mad_name,
previous_history->tm_mad_name, previous_history->tm_mad_name,
previous_history->ds_id,
vm_xml); vm_xml);
previous_history = history; previous_history = history;
@ -1984,7 +1988,7 @@ string VirtualMachine::get_remote_system_dir() const
Nebula& nd = Nebula::instance(); Nebula& nd = Nebula::instance();
nd.get_configuration_attribute("DATASTORE_LOCATION", ds_location); nd.get_configuration_attribute("DATASTORE_LOCATION", ds_location);
oss << ds_location << "/" << DatastorePool::SYSTEM_DS_ID << "/" << oid; oss << ds_location << "/" << history->ds_id << "/" << oid;
return oss.str(); return oss.str();
} }
@ -1997,7 +2001,7 @@ string VirtualMachine::get_system_dir() const
ostringstream oss; ostringstream oss;
Nebula& nd = Nebula::instance(); Nebula& nd = Nebula::instance();
oss << nd.get_ds_location() << DatastorePool::SYSTEM_DS_ID << "/"<< oid; oss << nd.get_ds_location() << history->ds_id << "/"<< oid;
return oss.str(); return oss.str();
}; };