1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-23 17:33:56 +03:00

Bug #2487: RM forces the system DS for stopped/undeployed VMs

This commit is contained in:
Carlos Martín 2013-11-21 18:28:49 +01:00
parent b17751a2d6
commit ab619a50f4
4 changed files with 84 additions and 27 deletions

View File

@ -496,7 +496,7 @@ public:
* function MUST be called before this one.
* @return the ds id
*/
string get_ds_id() const
string get_ds_id_st() const
{
ostringstream oss;
@ -505,6 +505,16 @@ public:
return oss.str();
};
/**
* Returns the datastore ID of the system DS for the host. The hasHistory()
* function MUST be called before this one.
* @return the ds id
*/
int get_ds_id() const
{
return history->ds_id;
};
/**
* Returns the datastore ID of the system DS for the previous host.
* The hasPreviousHistory() function MUST be called before this one.
@ -653,6 +663,16 @@ public:
return previous_history->reason;
};
/**
* Returns the action that closed the current history record. The hasHistory()
* function MUST be called before this one.
* @return the action that closed the current history record
*/
const History::VMAction get_action() const
{
return history->action;
};
/**
* Returns the action that closed the history record in the previous host
* @return the action that closed the history record in the previous host

View File

@ -660,6 +660,50 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
return;
}
// ------------------------------------------------------------------------
// Authorize request
// ------------------------------------------------------------------------
auth = vm_authorization(id, 0, 0, att, &host_perms, 0, auth_op);
if (auth == false)
{
return;
}
if ((vm = get_vm(id, att)) == 0)
{
return;
}
if (vm->hasHistory() &&
(vm->get_action() == History::STOP_ACTION ||
vm->get_action() == History::UNDEPLOY_ACTION ||
vm->get_action() == History::UNDEPLOY_HARD_ACTION))
{
int c_ds_id = vm->get_ds_id();
if (ds_id == -1)
{
ds_id = c_ds_id;
}
else if (ds_id != c_ds_id)
{
ostringstream oss;
oss << "VM can only be resumed in System Datastore "
<< "[" << c_ds_id << "]";
failure_response(ACTION, request_error(oss.str(),""), att);
vm->unlock();
return;
}
}
vm->unlock();
// ------------------------------------------------------------------------
// Get information about the system DS to use (tm_mad)
// ------------------------------------------------------------------------
@ -694,17 +738,6 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
}
}
// ------------------------------------------------------------------------
// Authorize request
// ------------------------------------------------------------------------
auth = vm_authorization(id, 0, 0, att, &host_perms, 0, auth_op);
if (auth == false)
{
return;
}
// ------------------------------------------------------------------------
// Check request consistency:
// - VM States are right
@ -748,6 +781,10 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
}
}
// ------------------------------------------------------------------------
// Add a new history record and deploy the VM
// ------------------------------------------------------------------------
@ -882,7 +919,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
// Get System DS information from current History record
istringstream iss(vm->get_ds_id());
istringstream iss(vm->get_ds_id_st());
iss >> c_ds_id;

View File

@ -384,7 +384,7 @@ int TransferManager::prolog_transfer_command(
int disk_id;
vm_ds_id = vm->get_ds_id();
vm_ds_id = vm->get_ds_id_st();
disk->vector_value("DISK_ID", disk_id);
@ -747,7 +747,7 @@ void TransferManager::prolog_action(int vid)
xfr << vm->get_hostname() << ":"
<< vm->get_remote_system_dir() << "/disk." << disk_id << " "
<< vm->get_oid() << " "
<< vm->get_ds_id()
<< vm->get_ds_id_st()
<< endl;
}
@ -829,7 +829,7 @@ void TransferManager::prolog_migr_action(int vid)
}
vm_tm_mad = vm->get_tm_mad();
vm_ds_id = vm->get_ds_id();
vm_ds_id = vm->get_ds_id_st();
tm_md = get();
if ( tm_md == 0 || vm_tm_mad.empty() || vm_ds_id.empty())
@ -969,7 +969,7 @@ void TransferManager::prolog_resume_action(int vid)
}
vm_tm_mad = vm->get_tm_mad();
vm_ds_id = vm->get_ds_id();
vm_ds_id = vm->get_ds_id_st();
tm_md = get();
if ( tm_md == 0 || vm_tm_mad.empty() || vm_ds_id.empty())
@ -1128,7 +1128,7 @@ void TransferManager::epilog_transfer_command(
if ( VirtualMachine::isVolatile(disk) == true )
{
tm_mad = vm->get_tm_mad();
ds_id = vm->get_ds_id();
ds_id = vm->get_ds_id_st();
}
else
{
@ -1188,7 +1188,7 @@ void TransferManager::epilog_action(int vid)
}
vm_tm_mad = vm->get_tm_mad();
vm_ds_id = vm->get_ds_id();
vm_ds_id = vm->get_ds_id_st();
tm_md = get();
if ( tm_md == 0 || vm_tm_mad.empty() || vm_ds_id.empty())
@ -1299,7 +1299,7 @@ void TransferManager::epilog_stop_action(int vid)
}
vm_tm_mad = vm->get_tm_mad();
vm_ds_id = vm->get_ds_id();
vm_ds_id = vm->get_ds_id_st();
tm_md = get();
if ( tm_md == 0 || vm_tm_mad.empty() || vm_ds_id.empty())
@ -1438,7 +1438,7 @@ int TransferManager::epilog_delete_commands(VirtualMachine *vm,
system_dir = vm->get_system_dir();
vm_tm_mad = vm->get_tm_mad();
vm_ds_id = vm->get_ds_id();
vm_ds_id = vm->get_ds_id_st();
}
else if (previous)
{
@ -1459,7 +1459,7 @@ int TransferManager::epilog_delete_commands(VirtualMachine *vm,
system_dir = vm->get_remote_system_dir();
vm_tm_mad = vm->get_tm_mad();
vm_ds_id = vm->get_ds_id();
vm_ds_id = vm->get_ds_id_st();
}
if ( vm_tm_mad.empty() || vm_ds_id.empty())
@ -1956,7 +1956,7 @@ void TransferManager::migrate_transfer_command(
<< vm->get_hostname() << " "
<< vm->get_remote_system_dir() << " "
<< vm->get_oid() << " "
<< vm->get_ds_id()
<< vm->get_ds_id_st()
<< endl;
}

View File

@ -276,19 +276,19 @@ int LibVirtDriver::deployment_description_vmware(
if ( type == "BLOCK" )
{
file << "\t\t<disk type='block' device='disk'>" << endl;
file << "\t\t\t<source file='[" << vm->get_ds_id() << "] "
file << "\t\t\t<source file='[" << vm->get_ds_id_st() << "] "
<< vm->get_oid() << "/disk." << disk_id << "'/>" << endl;
}
else if ( type == "CDROM" )
{
file << "\t\t<disk type='file' device='cdrom'>" << endl;
file << "\t\t\t<source file='[" << vm->get_ds_id() << "] "
file << "\t\t\t<source file='[" << vm->get_ds_id_st() << "] "
<< vm->get_oid() << "/disk." << disk_id << ".iso'/>" << endl;
}
else
{
file << "\t\t<disk type='file' device='disk'>" << endl
<< "\t\t\t<source file='[" << vm->get_ds_id() <<"] "
<< "\t\t\t<source file='[" << vm->get_ds_id_st() <<"] "
<< vm->get_oid() << "/disk." << disk_id << "/disk.vmdk'/>" << endl;
}
@ -337,7 +337,7 @@ int LibVirtDriver::deployment_description_vmware(
if ( !target.empty() )
{
file << "\t\t<disk type='file' device='cdrom'>" << endl;
file << "\t\t\t<source file='[" << vm->get_ds_id() <<"] "
file << "\t\t\t<source file='[" << vm->get_ds_id_st() <<"] "
<< vm->get_oid() << "/disk." << disk_id << ".iso'/>" << endl;
file << "\t\t\t<target dev='" << target << "'/>" << endl;
file << "\t\t\t<readonly/>" << endl;