mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-10 01:17:40 +03:00
Feature #4215: Perform TM:CONTEXT on prolog_resume
This commit is contained in:
parent
3ca02c27e2
commit
c83565fe56
@ -129,9 +129,7 @@ public:
|
||||
* @param vm The VM
|
||||
* @param token_password Owner user's token password
|
||||
* @param system_tm_mad The Transfer Manager for the system datastore
|
||||
* @param opennebula_hostname The front-end hostname
|
||||
* @param xfr Stream where the transfer command will be written
|
||||
* @param error Error reason, if any
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
@ -139,9 +137,7 @@ public:
|
||||
VirtualMachine * vm,
|
||||
const string& token_password,
|
||||
string& system_tm_mad,
|
||||
string& opennebula_hostname,
|
||||
ostream& xfr,
|
||||
ostringstream& error);
|
||||
ostream& xfr);
|
||||
|
||||
/**
|
||||
* Inserts a transfer command in the xfs stream
|
||||
|
@ -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);
|
||||
|
@ -2378,7 +2378,7 @@ void VirtualMachineManager::attach_nic_action(
|
||||
VirtualMachine * vm;
|
||||
const VirtualMachineManagerDriver * vmd;
|
||||
|
||||
ostringstream os, error_os;
|
||||
ostringstream os;
|
||||
|
||||
string vm_tmpl;
|
||||
string* drv_msg;
|
||||
@ -2441,15 +2441,11 @@ void VirtualMachineManager::attach_nic_action(
|
||||
{
|
||||
vm_tm_mad = vm->get_tm_mad();
|
||||
|
||||
opennebula_hostname = nd.get_nebula_hostname();
|
||||
|
||||
rc = tm->prolog_context_command(
|
||||
vm,
|
||||
token_password,
|
||||
vm_tm_mad,
|
||||
opennebula_hostname,
|
||||
os,
|
||||
error_os);
|
||||
os);
|
||||
|
||||
prolog_cmd = os.str();
|
||||
|
||||
@ -2509,7 +2505,7 @@ error_driver:
|
||||
|
||||
error_no_tm_command:
|
||||
os.str("");
|
||||
os << "Cannot set context disk to update it for VM: " << error_os.str();
|
||||
os << "Cannot set context disk to update it for VM " << vm->get_oid();
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
@ -2535,7 +2531,6 @@ void VirtualMachineManager::detach_nic_action(
|
||||
ostringstream os;
|
||||
string vm_tmpl;
|
||||
string * drv_msg;
|
||||
string opennebula_hostname;
|
||||
string error_str;
|
||||
|
||||
// Get the VM from the pool
|
||||
|
Loading…
Reference in New Issue
Block a user