1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-28 14:50:08 +03:00

feature #200: Slight modification of configuration attributes for the pool

This commit is contained in:
Ruben S. Montero 2010-06-30 17:08:11 +02:00
parent 5955da4dbe
commit 85fd79c029
3 changed files with 33 additions and 27 deletions

View File

@ -194,41 +194,47 @@ public:
return rc;
}
static string get_source_prefix()
static const string& source_prefix()
{
return source_prefix;
return _source_prefix;
};
static string get_default_type()
static const string& default_type()
{
return default_type;
return _default_type;
};
static string get_default_dev_prefix()
static const string& default_dev_prefix()
{
return default_dev_prefix;
return _default_dev_prefix;
};
private:
/**
* This map stores the association between IIDs and Image names
*/
map<string, int> image_names;
//--------------------------------------------------------------------------
// Configuration Attributes for Images
// -------------------------------------------------------------------------
/**
* Path to the image repository
**/
static string source_prefix;
static string _source_prefix;
/**
* Default image type
**/
static string default_type;
static string _default_type;
/**
* Default device prefix
**/
static string default_dev_prefix;
static string _default_dev_prefix;
//--------------------------------------------------------------------------
// Pool Attributes
// -------------------------------------------------------------------------
/**
* This map stores the association between IIDs and Image names
*/
map<string, int> image_names;
/**
* Factory method to produce Image objects

View File

@ -170,7 +170,7 @@ int Image::insert(SqlDB *db)
if ( type_att.empty() == true )
{
type_att = ImagePool::get_default_type();
type_att = ImagePool::default_type();
}
if (set_type(type_att) != 0)
@ -194,7 +194,7 @@ int Image::insert(SqlDB *db)
if( dev_prefix.empty() )
{
SingleAttribute * dev_att = new SingleAttribute("DEV_PREFIX",
ImagePool::get_default_dev_prefix());
ImagePool::default_dev_prefix());
image_template.set(dev_att);
}
@ -203,7 +203,7 @@ int Image::insert(SqlDB *db)
tmp_hashstream << uid << ":" << name;
tmp_sourcestream << ImagePool::get_source_prefix() << "/";
tmp_sourcestream << ImagePool::source_prefix() << "/";
tmp_sourcestream << sha1_digest(tmp_hashstream.str());
source = tmp_sourcestream.str();

View File

@ -22,9 +22,9 @@
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
string ImagePool::source_prefix;
string ImagePool::default_type;
string ImagePool::default_dev_prefix;
string ImagePool::_source_prefix;
string ImagePool::_default_type;
string ImagePool::_default_dev_prefix;
int ImagePool::init_cb(void *nil, int num, char **values, char **names)
{
@ -43,9 +43,9 @@ int ImagePool::init_cb(void *nil, int num, char **values, char **names)
ImagePool::ImagePool( SqlDB * db,
const string& _source_prefix,
const string& _default_type,
const string& _default_dev_prefix):
const string& __source_prefix,
const string& __default_type,
const string& __default_dev_prefix):
PoolSQL(db,Image::table)
{
@ -53,9 +53,9 @@ ImagePool::ImagePool( SqlDB * db,
int rc;
// Init static defaults
source_prefix = _source_prefix;
default_type = _default_type;
default_dev_prefix = _default_dev_prefix;
_source_prefix = __source_prefix;
_default_type = __default_type;
_default_dev_prefix = __default_dev_prefix;
// Set default type
if (_default_type != "OS" &&
@ -64,7 +64,7 @@ ImagePool::ImagePool( SqlDB * db,
{
NebulaLog::log("IMG", Log::ERROR,
"Bad default for image type, setting OS");
default_type = "OS";
_default_type = "OS";
}
// Read from the DB the existing images, and build the ID:Name map