1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-02-02 09:47:00 +03:00

Feature #1678: Move TM_MAD ln and clone target definitions to oned.conf

This commit is contained in:
Carlos Martín 2013-10-23 16:15:18 +02:00
parent ed368ed225
commit 232482a97b
4 changed files with 146 additions and 3 deletions

View File

@ -328,6 +328,8 @@ private:
{
return new DatastoreTemplate;
}
int set_tm_mad(string &tm_mad, string &error_str);
};
#endif /*DATASTORE_H_*/

View File

@ -405,6 +405,37 @@ public:
nebula_configuration->Template::get(_name, value);
};
/**
* Gets a TM configuration attribute
*/
int get_tm_conf_attribute(
const string& tm_name,
VectorAttribute* &value) const
{
vector<Attribute*>::iterator it;
vector<Attribute*> values;
nebula_configuration->Template::get("TM_MAD_CONF", values);
for (it = values.begin(); it != values.end(); it ++)
{
value = dynamic_cast<VectorAttribute*>(*it);
if (value == 0)
{
continue;
}
if (value->vector_value("NAME") == tm_name)
{
return 0;
}
}
value = 0;
return -1;
};
/**
* Gets an XML document with all of the configuration attributes
* @return the XML

View File

@ -372,6 +372,69 @@ TM_MAD = [
arguments = "-t 15 -d dummy,lvm,shared,shared_lvm,qcow2,ssh,vmfs,iscsi,ceph"
]
TM_MAD_CONF = [
name = "dummy",
ln_target = "NONE",
clone_target= "SYSTEM",
shared = "yes"
]
TM_MAD_CONF = [
name = "lvm",
ln_target = "NONE",
clone_target= "SELF",
shared = "yes"
]
TM_MAD_CONF = [
name = "shared",
ln_target = "NONE",
clone_target= "SYSTEM",
shared = "yes"
]
TM_MAD_CONF = [
name = "shared_lvm",
ln_target = "SYSTEM",
clone_target= "SYSTEM",
shared = "yes"
]
TM_MAD_CONF = [
name = "qcow2",
ln_target = "NONE",
clone_target= "SYSTEM",
shared = "yes"
]
TM_MAD_CONF = [
name = "ssh",
ln_target = "SYSTEM",
clone_target= "SYSTEM",
shared = "no"
]
TM_MAD_CONF = [
name = "vmfs",
ln_target = "NONE",
clone_target= "SYSTEM",
shared = "yes"
]
TM_MAD_CONF = [
name = "iscsi",
ln_target = "NONE",
clone_target= "SELF",
shared = "yes"
]
TM_MAD_CONF = [
name = "ceph",
ln_target = "NONE",
clone_target= "SELF",
shared = "yes"
]
#*******************************************************************************
# Datastore Driver Configuration
#*******************************************************************************

View File

@ -145,6 +145,41 @@ Datastore::DatastoreType Datastore::str_to_type(string& str_type)
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int Datastore::set_tm_mad(string &tm_mad, string &error_str)
{
VectorAttribute* vatt;
int rc;
string st;
rc = Nebula::instance().get_tm_conf_attribute(tm_mad, vatt);
if (rc != 0)
{
ostringstream oss;
oss << "TM_MAD named \"" << tm_mad << "\" is not defined in oned.conf";
error_str = oss.str();
return -1;
}
// TODO: detect missing tm_mad conf? if (st.empty()){}
if (type == SYSTEM_DS)
{
st = vatt->vector_value("SHARED");
replace_template_attribute("SHARED", st);
}
else
{
st = vatt->vector_value("LN_TARGET");
replace_template_attribute("LN_TARGET", st);
st = vatt->vector_value("CLONE_TARGET");
replace_template_attribute("CLONE_TARGET", st);
}
return 0;
}
int Datastore::insert(SqlDB *db, string& error_str)
{
int rc;
@ -182,7 +217,12 @@ int Datastore::insert(SqlDB *db, string& error_str)
if ( tm_mad.empty() == true )
{
goto error_tm;
goto error_empty_tm;
}
if (set_tm_mad(tm_mad, error_str) != 0)
{
goto error_common;
}
erase_template_attribute("BASE_PATH", base_path);
@ -215,7 +255,7 @@ int Datastore::insert(SqlDB *db, string& error_str)
if ( tm_mad.empty() == true )
{
goto error_tm;
goto error_empty_tm;
}
//--------------------------------------------------------------------------
// Insert the Datastore
@ -233,7 +273,7 @@ error_ds:
error_str = "No DS_MAD in template.";
goto error_common;
error_tm:
error_empty_tm:
error_str = "No TM_MAD in template.";
goto error_common;
@ -574,6 +614,13 @@ int Datastore::replace_template(const string& tmpl_str, string& error_str)
if ( !new_tm_mad.empty() )
{
if (set_tm_mad(new_tm_mad, error_str) != 0)
{
replace_template_attribute("TM_MAD", tm_mad);
return -1;
}
tm_mad = new_tm_mad;
}
else