mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-25 02:50:08 +03:00
Feature #1112: Add TM_MAD to Datastores
This commit is contained in:
parent
98c5c246c2
commit
1e63b6ce4e
@ -51,7 +51,7 @@ public:
|
||||
int add_image(int id)
|
||||
{
|
||||
return add_collection_id(id);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Deletes this image's ID from the set.
|
||||
@ -61,7 +61,25 @@ public:
|
||||
int del_image(int id)
|
||||
{
|
||||
return del_collection_id(id);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves TM mad name
|
||||
* @return string tm mad name
|
||||
*/
|
||||
const string& get_tm_mad() const
|
||||
{
|
||||
return tm_mad;
|
||||
};
|
||||
|
||||
/**
|
||||
* Modifies the given VM disk attribute adding the relevant datastore
|
||||
* attributes
|
||||
*
|
||||
* @param disk
|
||||
* @return 0 on success
|
||||
*/
|
||||
int disk_attribute(VectorAttribute * disk);
|
||||
|
||||
private:
|
||||
|
||||
@ -80,6 +98,11 @@ private:
|
||||
*/
|
||||
string type;
|
||||
|
||||
/**
|
||||
* Name of the TM driver used to transfer file to and from the hosts
|
||||
*/
|
||||
string tm_mad;
|
||||
|
||||
/**
|
||||
* Base path for the storage
|
||||
*/
|
||||
|
@ -29,8 +29,10 @@ public:
|
||||
DatastorePool(SqlDB * db,
|
||||
const string& system_base_path,
|
||||
const string& system_type,
|
||||
const string& system_tm_mad,
|
||||
const string& default_base_path,
|
||||
const string& default_type);
|
||||
const string& default_type,
|
||||
const string& default_tm_mad);
|
||||
|
||||
~DatastorePool(){};
|
||||
|
||||
|
@ -107,12 +107,14 @@ MAC_PREFIX = "02:00"
|
||||
|
||||
SYSTEM_DS = [
|
||||
base_path = "/var/lib/one/system_ds",
|
||||
type = "fs"
|
||||
type = "fs",
|
||||
tm_mad = "tm_shared"
|
||||
]
|
||||
|
||||
DEFAULT_DS = [
|
||||
base_path = "/var/lib/one/images",
|
||||
type = "fs"
|
||||
type = "fs",
|
||||
tm_mad = "tm_shared"
|
||||
]
|
||||
|
||||
DEFAULT_IMAGE_TYPE = "OS"
|
||||
|
@ -38,6 +38,7 @@ Datastore::Datastore(int id,
|
||||
PoolObjectSQL(id,DATASTORE,"",-1,-1,"","",table),
|
||||
ObjectCollection("IMAGES"),
|
||||
type(""),
|
||||
tm_mad(""),
|
||||
base_path("")
|
||||
{
|
||||
if (ds_template != 0)
|
||||
@ -50,6 +51,22 @@ Datastore::Datastore(int id,
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
int Datastore::disk_attribute(VectorAttribute * disk)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << oid;
|
||||
|
||||
disk->replace("DATASTORE", get_name());
|
||||
disk->replace("DATASTORE_ID", oss.str());
|
||||
disk->replace("TM_MAD", get_tm_mad());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ************************************************************************ */
|
||||
/* Datastore :: Database Access Functions */
|
||||
/* ************************************************************************ */
|
||||
@ -65,7 +82,6 @@ int Datastore::insert(SqlDB *db, string& error_str)
|
||||
// Check default datastore attributes
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
|
||||
erase_template_attribute("NAME", name);
|
||||
// NAME is checked in DatastorePool::allocate
|
||||
|
||||
@ -76,6 +92,13 @@ int Datastore::insert(SqlDB *db, string& error_str)
|
||||
goto error_type;
|
||||
}
|
||||
|
||||
erase_template_attribute("TM_MAD", tm_mad);
|
||||
|
||||
if ( tm_mad.empty() == true )
|
||||
{
|
||||
goto error_tm;
|
||||
}
|
||||
|
||||
erase_template_attribute("BASE_PATH", base_path);
|
||||
|
||||
if ( base_path.empty() == true )
|
||||
@ -95,6 +118,10 @@ error_type:
|
||||
error_str = "No TYPE in template.";
|
||||
goto error_common;
|
||||
|
||||
error_tm:
|
||||
error_str = "No TM_MAD in template.";
|
||||
goto error_common;
|
||||
|
||||
error_base_path:
|
||||
error_str = "No BASE_PATH in template.";
|
||||
goto error_common;
|
||||
@ -207,6 +234,7 @@ string& Datastore::to_xml(string& xml) const
|
||||
"<ID>" << oid << "</ID>" <<
|
||||
"<NAME>" << name << "</NAME>" <<
|
||||
"<TYPE>" << type << "</TYPE>" <<
|
||||
"<TM_MAD>" << tm_mad << "</TM_MAD>" <<
|
||||
"<BASE_PATH>" << base_path << "</BASE_PATH>" <<
|
||||
collection_xml <<
|
||||
"</DATASTORE>";
|
||||
@ -231,6 +259,7 @@ int Datastore::from_xml(const string& xml)
|
||||
rc += xpath(oid, "/DATASTORE/ID", -1);
|
||||
rc += xpath(name, "/DATASTORE/NAME", "not_found");
|
||||
rc += xpath(type, "/DATASTORE/TYPE", "not_found");
|
||||
rc += xpath(tm_mad, "/DATASTORE/TM_MAD", "not_found");
|
||||
rc += xpath(base_path, "/DATASTORE/BASE_PATH", "not_found");
|
||||
|
||||
// Set the owner and group to oneadmin
|
||||
|
@ -38,8 +38,10 @@ const int DatastorePool::DEFAULT_DS_ID = 1;
|
||||
DatastorePool::DatastorePool(SqlDB * db,
|
||||
const string& system_base_path,
|
||||
const string& system_type,
|
||||
const string& system_tm_mad,
|
||||
const string& default_base_path,
|
||||
const string& default_type):
|
||||
const string& default_type,
|
||||
const string& default_tm_mad):
|
||||
PoolSQL(db, Datastore::table)
|
||||
{
|
||||
ostringstream oss;
|
||||
@ -55,7 +57,8 @@ DatastorePool::DatastorePool(SqlDB * db,
|
||||
|
||||
oss << "NAME = " << SYSTEM_DS_NAME << endl
|
||||
<< "BASE_PATH = " << system_base_path << endl
|
||||
<< "TYPE = " << system_type;
|
||||
<< "TYPE = " << system_type << endl
|
||||
<< "TM_MAD = " << system_tm_mad;
|
||||
|
||||
ds_tmpl = new DatastoreTemplate;
|
||||
rc = ds_tmpl->parse_str_or_xml(oss.str(), error_str);
|
||||
@ -78,7 +81,8 @@ DatastorePool::DatastorePool(SqlDB * db,
|
||||
|
||||
oss << "NAME = " << DEFAULT_DS_NAME << endl
|
||||
<< "BASE_PATH = " << default_base_path << endl
|
||||
<< "TYPE = " << default_type;
|
||||
<< "TYPE = " << default_type << endl
|
||||
<< "TM_MAD = " << default_tm_mad;
|
||||
|
||||
ds_tmpl = new DatastoreTemplate;
|
||||
rc = ds_tmpl->parse_str_or_xml(oss.str(), error_str);
|
||||
@ -103,6 +107,7 @@ DatastorePool::DatastorePool(SqlDB * db,
|
||||
return;
|
||||
|
||||
error_bootstrap:
|
||||
oss.str("");
|
||||
oss << "Error trying to create default datastore: " << error_str;
|
||||
NebulaLog::log("DATASTORE",Log::ERROR,oss);
|
||||
|
||||
|
@ -221,11 +221,14 @@ int ImagePool::disk_attribute(VectorAttribute * disk,
|
||||
string source;
|
||||
Image * img = 0;
|
||||
int rc = 0;
|
||||
int datastore_id;
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
Nebula& nd = Nebula::instance();
|
||||
ImageManager * imagem = nd.get_imagem();
|
||||
Nebula& nd = Nebula::instance();
|
||||
ImageManager * imagem = nd.get_imagem();
|
||||
DatastorePool * ds_pool = nd.get_dspool();
|
||||
Datastore * ds = 0;
|
||||
|
||||
if (!(source = disk->vector_value("IMAGE")).empty())
|
||||
{
|
||||
@ -287,11 +290,23 @@ int ImagePool::disk_attribute(VectorAttribute * disk,
|
||||
{
|
||||
img->disk_attribute(disk, index, img_type);
|
||||
|
||||
image_id = img->get_oid();
|
||||
|
||||
image_id = img->get_oid();
|
||||
datastore_id = img->get_ds_id();
|
||||
|
||||
update(img);
|
||||
|
||||
img->unlock();
|
||||
|
||||
ds = ds_pool->get(datastore_id, true);
|
||||
|
||||
if ( ds == 0 )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
ds->disk_attribute(disk);
|
||||
|
||||
ds->unlock();
|
||||
}
|
||||
|
||||
oss << disk_id;
|
||||
|
@ -278,10 +278,12 @@ void Nebula::start()
|
||||
vector<const Attribute *> system_ds;
|
||||
string system_ds_base_path;
|
||||
string system_ds_type;
|
||||
string system_tm_mad;
|
||||
|
||||
vector<const Attribute *> default_ds;
|
||||
string default_ds_base_path;
|
||||
string default_ds_type;
|
||||
string default_tm_mad;
|
||||
|
||||
vector<const Attribute *> vm_hooks;
|
||||
vector<const Attribute *> host_hooks;
|
||||
@ -328,6 +330,7 @@ void Nebula::start()
|
||||
|
||||
system_ds_base_path = ds_conf->vector_value("BASE_PATH");
|
||||
system_ds_type = ds_conf->vector_value("TYPE");
|
||||
system_tm_mad = ds_conf->vector_value("TM_MAD");
|
||||
|
||||
nebula_configuration->get("DEFAULT_DS", default_ds);
|
||||
|
||||
@ -335,10 +338,11 @@ void Nebula::start()
|
||||
|
||||
default_ds_base_path = ds_conf->vector_value("BASE_PATH");
|
||||
default_ds_type = ds_conf->vector_value("TYPE");
|
||||
default_tm_mad = ds_conf->vector_value("TM_MAD");
|
||||
|
||||
dspool = new DatastorePool(db,
|
||||
system_ds_base_path, system_ds_type,
|
||||
default_ds_base_path, default_ds_type);
|
||||
system_ds_base_path, system_ds_type, system_tm_mad,
|
||||
default_ds_base_path, default_ds_type, default_tm_mad);
|
||||
}
|
||||
catch (exception&)
|
||||
{
|
||||
|
@ -189,7 +189,8 @@ void OpenNebulaTemplate::set_conf_default()
|
||||
//SYSTEM_DS
|
||||
vvalue.clear();
|
||||
vvalue.insert(make_pair("BASE_PATH","/var/lib/one/system_ds"));
|
||||
vvalue.insert(make_pair("TYPE","fs"));
|
||||
vvalue.insert(make_pair("TYPE", "fs"));
|
||||
vvalue.insert(make_pair("TM_MAD", "tm_shared"));
|
||||
|
||||
vattribute = new VectorAttribute("SYSTEM_DS",vvalue);
|
||||
conf_default.insert(make_pair(vattribute->name(),vattribute));
|
||||
@ -197,7 +198,8 @@ void OpenNebulaTemplate::set_conf_default()
|
||||
//DEFAULT_DS
|
||||
vvalue.clear();
|
||||
vvalue.insert(make_pair("BASE_PATH","/var/lib/one/images"));
|
||||
vvalue.insert(make_pair("TYPE","fs"));
|
||||
vvalue.insert(make_pair("TYPE", "fs"));
|
||||
vvalue.insert(make_pair("TM_MAD", "tm_shared"));
|
||||
|
||||
vattribute = new VectorAttribute("DEFAULT_DS",vvalue);
|
||||
conf_default.insert(make_pair(vattribute->name(),vattribute));
|
||||
|
Loading…
x
Reference in New Issue
Block a user