Feature #4215: Perform TM:CONTEXT on prolog_resume

This commit is contained in:
Carlos Martín committed 2016-01-26 13:24:42 +01:00
1 parent 3ca02c27e2
commit c83565fe56
3 files changed
+46 -19

No files matched your search

+42 -6
View File
@@ -611,9 +611,7 @@ int TransferManager::prolog_context_command(
VirtualMachine * vm,
const string& token_password,
string& vm_tm_mad,
string& opennebula_hostname,
ostream& xfr,
ostringstream& os)
ostream& xfr)
{
string files;
int context_result;
@@ -815,9 +813,7 @@ void TransferManager::prolog_action(int vid)
rc = prolog_context_command( vm,
token_password,
vm_tm_mad,
opennebula_hostname,
xfr,
os);
xfr);
if ( rc == -1 )
{
@@ -1013,9 +1009,11 @@ void TransferManager::prolog_resume_action(int vid)
const VectorAttribute * disk;
string tm_mad;
string vm_tm_mad;
string token_password;
int ds_id;
int disk_id;
int rc;
vector<const Attribute *> attrs;
int num;
@@ -1035,6 +1033,24 @@ void TransferManager::prolog_resume_action(int vid)
return;
}
int uid = vm->get_created_by_uid();
vm->unlock();
User * user = Nebula::instance().get_upool()->get(uid, true);
if (user != 0)
{
user->get_template_attribute("TOKEN_PASSWORD", token_password);
user->unlock();
}
vm = vmpool->get(vid,true);
if (vm == 0)
{
return;
}
if (!vm->hasHistory())
{
goto error_history;
@@ -1107,6 +1123,20 @@ void TransferManager::prolog_resume_action(int vid)
<< vm->get_oid() << " "
<< vm->get_ds_id() << endl;
// -------------------------------------------------------------------------
// Generate context file
// -------------------------------------------------------------------------
rc = prolog_context_command( vm,
token_password,
vm_tm_mad,
xfr);
if ( rc == -1 )
{
goto error_context;
}
xfr.close();
tm_md->transfer(vid,xfr_name);
@@ -1129,6 +1159,12 @@ error_file:
os << "prolog_resume, could not open file: " << xfr_name;
goto error_common;
error_context:
os << "prolog_resume, could not write context file for VM " << vid;
xfr.close();
goto error_common;
error_common:
(nd.get_lcm())->trigger(LifeCycleManager::PROLOG_FAILURE,vid);
vm->log("TM", Log::ERROR, os);