1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-11 05:17:41 +03:00

Feature #4238: Datastores can now be PERSISTENT_ONLY

This commit is contained in:
Jaime Melis 2015-12-22 14:06:12 +01:00
parent 253946558a
commit d7b8aa1cd3
6 changed files with 115 additions and 47 deletions

View File

@ -223,6 +223,12 @@ public:
return shared;
};
/**
* Returns true if the DS_MAD_CONF has PERSISTENT_ONLY = "YES" flag
* @return true if persistent only
*/
bool is_persistent_only();
/**
* Enable or disable the DS. Only for System DS.
* @param enable true to enable

View File

@ -202,7 +202,8 @@ private:
* Sets a the defaults for a DS
*/
void set_conf_ds(const std::string& name,
const std::string& required_attrs);
const std::string& required_attrs,
const std::string& persistent_only);
/**
* Sets a the defaults for a TM

View File

@ -628,7 +628,7 @@ VM_MAD = [
TM_MAD = [
executable = "one_tm",
arguments = "-t 15 -d dummy,lvm,shared,fs_lvm,qcow2,ssh,vmfs,ceph,dev"
arguments = "-t 15 -d dummy,lvm,shared,fs_lvm,qcow2,ssh,vmfs,ceph,dev,iscsi"
]
#*******************************************************************************
@ -647,7 +647,7 @@ TM_MAD = [
DATASTORE_MAD = [
executable = "one_datastore",
arguments = "-t 15 -d dummy,fs,vmfs,lvm,ceph,dev -s shared,ssh,ceph"
arguments = "-t 15 -d dummy,fs,vmfs,lvm,ceph,dev,iscsi -s shared,ssh,ceph"
]
#*******************************************************************************
@ -952,43 +952,48 @@ INHERIT_VNET_ATTR = "MTU"
#*******************************************************************************
TM_MAD_CONF = [
name = "dummy", ln_target = "NONE", clone_target = "SYSTEM", shared = "yes",
ds_migrate = "yes"
NAME = "dummy", LN_TARGET = "NONE", CLONE_TARGET = "SYSTEM", SHARED = "YES",
DS_MIGRATE = "YES"
]
TM_MAD_CONF = [
name = "lvm", ln_target = "NONE", clone_target = "SELF", shared = "yes"
NAME = "lvm", LN_TARGET = "NONE", CLONE_TARGET = "SELF", SHARED = "YES"
]
TM_MAD_CONF = [
name = "shared", ln_target = "NONE", clone_target = "SYSTEM", shared = "yes",
ds_migrate = "yes"
NAME = "shared", LN_TARGET = "NONE", CLONE_TARGET = "SYSTEM", SHARED = "YES",
DS_MIGRATE = "YES"
]
TM_MAD_CONF = [
name = "fs_lvm", ln_target = "SYSTEM", clone_target = "SYSTEM", shared="yes"
NAME = "fs_lvm", LN_TARGET = "SYSTEM", CLONE_TARGET = "SYSTEM", SHARED="YES"
]
TM_MAD_CONF = [
name = "qcow2", ln_target = "NONE", clone_target = "SYSTEM", shared = "yes"
NAME = "qcow2", LN_TARGET = "NONE", CLONE_TARGET = "SYSTEM", SHARED = "YES"
]
TM_MAD_CONF = [
name = "ssh", ln_target = "SYSTEM", clone_target = "SYSTEM", shared = "no",
ds_migrate = "yes"
NAME = "ssh", LN_TARGET = "SYSTEM", CLONE_TARGET = "SYSTEM", SHARED = "NO",
DS_MIGRATE = "YES"
]
TM_MAD_CONF = [
name = "vmfs", ln_target = "NONE", clone_target= "SYSTEM", shared = "yes"
NAME = "vmfs", LN_TARGET = "NONE", CLONE_TARGET= "SYSTEM", SHARED = "YES"
]
TM_MAD_CONF = [
name = "ceph", ln_target = "NONE", clone_target = "SELF", shared = "yes",
ds_migrate = "no"
NAME = "ceph", LN_TARGET = "NONE", CLONE_TARGET = "SELF", SHARED = "YES",
DS_MIGRATE = "NO"
]
TM_MAD_CONF = [
name = "dev", ln_target = "NONE", clone_target = "NONE", shared = "yes"
NAME = "iscsi", LN_TARGET = "NONE", CLONE_TARGET = "SELF", SHARED = "YES",
DS_MIGRATE = "NO"
]
TM_MAD_CONF = [
NAME = "dev", LN_TARGET = "NONE", CLONE_TARGET = "NONE", SHARED = "YES"
]
#*******************************************************************************
@ -1001,39 +1006,46 @@ TM_MAD_CONF = [
# DS_MAD section
# required_attrs : comma separated list of required attributes in the DS
# template
# persistent_only: specifies whether the datastore can only manage persistent
# images
#*******************************************************************************
DS_MAD_CONF = [
name = "ceph",
required_attrs = "DISK_TYPE,BRIDGE_LIST,CEPH_HOST,CEPH_USER,CEPH_SECRET"
NAME = "ceph",
REQUIRED_ATTRS = "DISK_TYPE,BRIDGE_LIST,CEPH_HOST,CEPH_USER,CEPH_SECRET",
PERSISTENT_ONLY = "NO"
]
DS_MAD_CONF = [
name = "dev",
required_attrs = "DISK_TYPE,ISCSI_HOST"
NAME = "dev", REQUIRED_ATTRS = "DISK_TYPE", PERSISTENT_ONLY = "YES"
]
DS_MAD_CONF = [
name = "dummy", required_attrs = ""
NAME = "iscsi", REQUIRED_ATTRS = "DISK_TYPE,ISCSI_HOST",
PERSISTENT_ONLY = "YES"
]
DS_MAD_CONF = [
name = "fs", required_attrs = ""
NAME = "dummy", REQUIRED_ATTRS = "", PERSISTENT_ONLY = "NO"
]
DS_MAD_CONF = [
name = "lvm", required_attrs = "DISK_TYPE"
NAME = "fs", REQUIRED_ATTRS = "", PERSISTENT_ONLY = "NO"
]
DS_MAD_CONF = [
name = "shared", required_attrs = ""
NAME = "lvm", REQUIRED_ATTRS = "DISK_TYPE", PERSISTENT_ONLY = "NO"
]
DS_MAD_CONF = [
name = "ssh", required_attrs = ""
NAME = "shared", REQUIRED_ATTRS = "", PERSISTENT_ONLY = "NO"
]
DS_MAD_CONF = [
name = "vmfs", required_attrs = "BRIDGE_LIST"
NAME = "ssh", REQUIRED_ATTRS = "", PERSISTENT_ONLY = "NO"
]
DS_MAD_CONF = [
NAME = "vmfs", REQUIRED_ATTRS = "BRIDGE_LIST", PERSISTENT_ONLY = "NO"
]

View File

@ -951,3 +951,27 @@ bool Datastore::get_avail_mb(long long &avail)
return check;
}
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
bool Datastore::is_persistent_only()
{
int rc;
bool persistent_only = false;
const VectorAttribute* vatt;
rc = Nebula::instance().get_ds_conf_attribute(ds_mad, vatt);
if ( rc != 0 )
{
// No DS_MAD_CONF is available for this DS_MAD.
// Assuming this DS is not PERSISTENT_ONLY
return false;
}
vatt->vector_value("PERSISTENT_ONLY", persistent_only);
return persistent_only;
};

View File

@ -104,15 +104,15 @@ void OpenNebulaTemplate::set_multiple_conf_default()
#*******************************************************************************
*/
set_conf_tm("dummy", "NONE", "SYSTEM", "yes", "yes");
set_conf_tm("lvm", "NONE", "SELF", "yes", "no");
set_conf_tm("shared", "NONE", "SYSTEM", "yes", "yes");
set_conf_tm("fs_lvm", "SYSTEM", "SYSTEM", "yes", "no");
set_conf_tm("qcow2", "NONE", "SYSTEM", "yes", "no");
set_conf_tm("ssh", "SYSTEM", "SYSTEM", "no", "yes");
set_conf_tm("vmfs", "NONE", "SYSTEM", "yes", "no");
set_conf_tm("ceph", "NONE", "SELF", "yes", "no");
set_conf_tm("dev", "NONE", "NONE", "yes", "no");
set_conf_tm("dummy", "NONE", "SYSTEM", "YES", "YES");
set_conf_tm("lvm", "NONE", "SELF", "YES", "NO");
set_conf_tm("shared", "NONE", "SYSTEM", "YES", "YES");
set_conf_tm("fs_lvm", "SYSTEM", "SYSTEM", "YES", "NO");
set_conf_tm("qcow2", "NONE", "SYSTEM", "YES", "NO");
set_conf_tm("ssh", "SYSTEM", "SYSTEM", "NO", "YES");
set_conf_tm("vmfs", "NONE", "SYSTEM", "YES", "NO");
set_conf_tm("ceph", "NONE", "SELF", "YES", "NO");
set_conf_tm("dev", "NONE", "NONE", "YES", "NO");
register_multiple_conf_default("TM_MAD_CONF");
@ -132,15 +132,17 @@ void OpenNebulaTemplate::set_multiple_conf_default()
#******
*/
set_conf_ds("dev", "DISK_TYPE", "YES");
set_conf_ds("iscsi", "DISK_TYPE,ISCSI_HOST", "YES");
set_conf_ds("dummy", "", "NO");
set_conf_ds("fs", "", "NO");
set_conf_ds("lvm", "DISK_TYPE", "NO");
set_conf_ds("shared", "", "NO");
set_conf_ds("ssh", "", "NO");
set_conf_ds("vmfs", "BRIDGE_LIST", "NO");
set_conf_ds("ceph",
"DISK_TYPE,BRIDGE_LIST,CEPH_HOST,CEPH_USER,CEPH_SECRET");
set_conf_ds("dev", "DISK_TYPE,ISCSI_HOST");
set_conf_ds("dummy", "");
set_conf_ds("fs", "");
set_conf_ds("lvm", "DISK_TYPE");
set_conf_ds("shared", "");
set_conf_ds("ssh", "");
set_conf_ds("vmfs", "BRIDGE_LIST");
"DISK_TYPE,BRIDGE_LIST,CEPH_HOST,CEPH_USER,CEPH_SECRET",
"NO");
register_multiple_conf_default("DS_MAD_CONF");
}
@ -236,13 +238,15 @@ void OpenNebulaTemplate::set_conf_single(const std::string& attr,
/* -------------------------------------------------------------------------- */
void OpenNebulaTemplate::set_conf_ds(const std::string& name,
const std::string& required_attrs)
const std::string& required_attrs,
const std::string& persistent_only)
{
VectorAttribute * vattribute;
map<string,string> vvalue;
vvalue.insert(make_pair("NAME", name));
vvalue.insert(make_pair("REQUIRED_ATTRS", required_attrs));
vvalue.insert(make_pair("PERSISTENT_ONLY", persistent_only));
vattribute = new VectorAttribute("DS_MAD_CONF", vvalue);
conf_default.insert(make_pair(vattribute->name(), vattribute));

View File

@ -303,6 +303,8 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
string ds_name;
string ds_data;
bool ds_persistent_only;
Datastore::DatastoreType ds_type;
int rc, id;
@ -327,6 +329,7 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
long long avail;
bool ds_check;
bool persistent_attr;
// ------------------------- Parse image template --------------------------
@ -372,9 +375,10 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
ds->get_permissions(ds_perms);
ds_name = ds->get_name();
ds_disk_type = ds->get_disk_type();
ds_check = ds->get_avail_mb(avail);
ds_name = ds->get_name();
ds_disk_type = ds->get_disk_type();
ds_check = ds->get_avail_mb(avail);
ds_persistent_only = ds->is_persistent_only();
ds->to_xml(ds_data);
@ -472,6 +476,23 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
}
}
// ------------------------- Check persistent only -------------------------
tmpl->get("PERSISTENT", persistent_attr);
if ( ds_persistent_only && persistent_attr == false )
{
ostringstream oss;
oss << "This Datastore only accepts persistent images.";
failure_response(INTERNAL, allocate_error(oss.str()), att);
delete tmpl;
return;
}
// ------------------------- Allocate --------------------------------------
rc = ipool->allocate(att.uid,
att.gid,
att.uname,