mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-22 17:57:46 +03:00
Bug #1306: If the cluster has a SYSTEM_DS set, check that it is actually a system type ds. Do not allow image registration in any system type DS.
This commit is contained in:
parent
792dcf01b3
commit
fd28ff9d9f
@ -96,6 +96,7 @@ public:
|
||||
*/
|
||||
int add_datastore(int id, string& error_msg)
|
||||
{
|
||||
// TODO: should fail for any system DS?
|
||||
if ( id == DatastorePool::SYSTEM_DS_ID )
|
||||
{
|
||||
ostringstream oss;
|
||||
|
@ -91,6 +91,16 @@ public:
|
||||
{
|
||||
return disk_type;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if this is a system datastore
|
||||
* @return true if this is a system datastore
|
||||
*/
|
||||
bool is_system() const
|
||||
{
|
||||
return system_ds == 1;
|
||||
};
|
||||
|
||||
/**
|
||||
* Modifies the given VM disk attribute adding the relevant datastore
|
||||
* attributes
|
||||
|
@ -49,7 +49,8 @@ Datastore::Datastore(
|
||||
Clusterable(cluster_id, cluster_name),
|
||||
ds_mad(""),
|
||||
tm_mad(""),
|
||||
base_path("")
|
||||
base_path(""),
|
||||
system_ds(0)
|
||||
{
|
||||
group_u = 1;
|
||||
|
||||
@ -395,10 +396,15 @@ int Datastore::replace_template(const string& tmpl_str, string& error_str)
|
||||
get_template_attribute("DS_MAD", new_ds_mad);
|
||||
get_template_attribute("SYSTEM", s_system_ds);
|
||||
|
||||
TO_UPPER(s_system_ds);
|
||||
|
||||
if ( !s_system_ds.empty() )
|
||||
if ( oid == DatastorePool::SYSTEM_DS_ID )
|
||||
{
|
||||
system_ds = 1;
|
||||
}
|
||||
else if ( !s_system_ds.empty() )
|
||||
{
|
||||
TO_UPPER(s_system_ds);
|
||||
|
||||
system_ds = (s_system_ds == "YES");
|
||||
}
|
||||
|
||||
|
@ -322,17 +322,6 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
|
||||
|
||||
// ------------------------- Check Datastore exists ------------------------
|
||||
|
||||
if ( ds_id == DatastorePool::SYSTEM_DS_ID )
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << "New images cannot be allocated in the system datastore.";
|
||||
failure_response(INTERNAL, allocate_error(oss.str()), att);
|
||||
|
||||
delete tmpl;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((ds = dspool->get(ds_id,true)) == 0 )
|
||||
{
|
||||
failure_response(NO_EXISTS,
|
||||
@ -343,6 +332,20 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ds->is_system() )
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
ds->unlock();
|
||||
|
||||
oss << "New images cannot be allocated in a system datastore.";
|
||||
failure_response(INTERNAL, allocate_error(oss.str()), att);
|
||||
|
||||
delete tmpl;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ds->get_permissions(ds_perms);
|
||||
|
||||
ds_name = ds->get_name();
|
||||
|
@ -160,6 +160,24 @@ int RequestManagerVirtualMachine::get_host_information(int hid,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( ds->is_system() == false )
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
ds->unlock();
|
||||
|
||||
oss << object_name(PoolObjectSQL::CLUSTER)
|
||||
<< " [" << cluster_id << "] has its SYSTEM_DS set to "
|
||||
<< object_name(PoolObjectSQL::DATASTORE)
|
||||
<< " [" << ds_id << "], but it is not a system one.";
|
||||
|
||||
failure_response(INTERNAL,
|
||||
request_error(oss.str(),""),
|
||||
att);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
tm = ds->get_tm_mad();
|
||||
|
||||
ds->unlock();
|
||||
|
Loading…
x
Reference in New Issue
Block a user