diff --git a/include/RequestManagerVirtualMachine.h b/include/RequestManagerVirtualMachine.h index 5c3bbc3872..f9c35fda30 100644 --- a/include/RequestManagerVirtualMachine.h +++ b/include/RequestManagerVirtualMachine.h @@ -80,7 +80,7 @@ protected: int get_ds_information( int ds_id, - int& ds_cluster_id, + set& ds_cluster_ids, string& tm_mad, RequestAttributes& att, bool& ds_migr); diff --git a/src/rm/RequestManagerVirtualMachine.cc b/src/rm/RequestManagerVirtualMachine.cc index a7fb8234c3..13bc5a971b 100644 --- a/src/rm/RequestManagerVirtualMachine.cc +++ b/src/rm/RequestManagerVirtualMachine.cc @@ -264,14 +264,16 @@ int RequestManagerVirtualMachine::get_default_ds_information( } } - return get_ds_information(ds_id, cluster_id, tm_mad, att, ds_migr); + set 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& 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 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 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);