mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-13 12:58:17 +03:00
Feature #4369: Use multiple clusters in VM deploy & migrate
This commit is contained in:
parent
f6d10bdec0
commit
73f5ceb644
@ -80,7 +80,7 @@ protected:
|
||||
|
||||
int get_ds_information(
|
||||
int ds_id,
|
||||
int& ds_cluster_id,
|
||||
set<int>& ds_cluster_ids,
|
||||
string& tm_mad,
|
||||
RequestAttributes& att,
|
||||
bool& ds_migr);
|
||||
|
@ -264,14 +264,16 @@ int RequestManagerVirtualMachine::get_default_ds_information(
|
||||
}
|
||||
}
|
||||
|
||||
return get_ds_information(ds_id, cluster_id, tm_mad, att, ds_migr);
|
||||
set<int> ds_cluster_ids;
|
||||
|
||||
return get_ds_information(ds_id, ds_cluster_ids, tm_mad, att, ds_migr);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int RequestManagerVirtualMachine::get_ds_information(int ds_id,
|
||||
int& ds_cluster_id,
|
||||
set<int>& ds_cluster_ids,
|
||||
string& tm_mad,
|
||||
RequestAttributes& att,
|
||||
bool& ds_migr)
|
||||
@ -280,7 +282,7 @@ int RequestManagerVirtualMachine::get_ds_information(int ds_id,
|
||||
|
||||
Datastore * ds = nd.get_dspool()->get(ds_id, true);
|
||||
|
||||
ds_cluster_id = -1;
|
||||
ds_cluster_ids.clear();
|
||||
|
||||
if ( ds == 0 )
|
||||
{
|
||||
@ -307,7 +309,7 @@ int RequestManagerVirtualMachine::get_ds_information(int ds_id,
|
||||
return -1;
|
||||
}
|
||||
|
||||
ds_cluster_id = ds->get_cluster_id();
|
||||
ds_cluster_ids = ds->get_cluster_ids();
|
||||
|
||||
tm_mad = ds->get_tm_mad();
|
||||
|
||||
@ -751,21 +753,22 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
}
|
||||
else //Get information from user selected system DS
|
||||
{
|
||||
int ds_cluster_id;
|
||||
bool ds_migr;
|
||||
set<int> ds_cluster_ids;
|
||||
bool ds_migr;
|
||||
|
||||
if (get_ds_information(ds_id, ds_cluster_id, tm_mad, att, ds_migr) != 0)
|
||||
if (get_ds_information(ds_id, ds_cluster_ids, tm_mad, att, ds_migr) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ds_cluster_id != cluster_id)
|
||||
if (ds_cluster_ids.count(cluster_id) == 0)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << object_name(PoolObjectSQL::DATASTORE) << " [" << ds_id << "] and "
|
||||
<< object_name(PoolObjectSQL::HOST) << " [" << hid
|
||||
<< "] are not in the same cluster.";
|
||||
<< "] are not in the same "
|
||||
<< object_name(PoolObjectSQL::CLUSTER) << " [" << cluster_id << "].";
|
||||
|
||||
att.resp_msg = oss.str();
|
||||
|
||||
@ -896,7 +899,8 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
string hostname;
|
||||
string vmm_mad;
|
||||
string vnm_mad;
|
||||
int cluster_id, ds_cluster_id;
|
||||
int cluster_id;
|
||||
set<int> ds_cluster_ids;
|
||||
string ds_location;
|
||||
bool is_public_cloud;
|
||||
PoolObjectAuth host_perms, ds_perms;
|
||||
@ -1121,7 +1125,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_ds_information(ds_id, ds_cluster_id, tm_mad, att, ds_migr) != 0)
|
||||
if (get_ds_information(ds_id, ds_cluster_ids, tm_mad, att, ds_migr) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -1133,14 +1137,15 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
return;
|
||||
}
|
||||
|
||||
if (c_cluster_id != ds_cluster_id)
|
||||
if (ds_cluster_ids.count(c_cluster_id) == 0)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << "Cannot migrate to a different cluster. VM running in a host"
|
||||
<< " in " << object_name(PoolObjectSQL::CLUSTER)
|
||||
<< " [" << c_cluster_id << "] , and new system datastore is in "
|
||||
<< object_name(PoolObjectSQL::CLUSTER) << " [" << ds_cluster_id << "]";
|
||||
<< object_name(PoolObjectSQL::CLUSTER)
|
||||
<< " [" << one_util::join(ds_cluster_ids, ',') << "]";
|
||||
|
||||
att.resp_msg = oss.str();
|
||||
failure_response(ACTION, att);
|
||||
|
Loading…
x
Reference in New Issue
Block a user