mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-25 02:50:08 +03:00
bug #2326
This commit is contained in:
parent
876c58e327
commit
4309d10c12
@ -242,8 +242,7 @@ private:
|
||||
int umask,
|
||||
DatastoreTemplate* ds_template,
|
||||
int cluster_id,
|
||||
const string& cluster_name,
|
||||
const string& ds_location);
|
||||
const string& cluster_name);
|
||||
|
||||
virtual ~Datastore(){};
|
||||
|
||||
|
@ -80,8 +80,6 @@ public:
|
||||
* @param oid the id assigned to the Datastore
|
||||
* @param cluster_id the id of the cluster this Datastore will belong to
|
||||
* @param cluster_name the name of the cluster this Datastore will belong to
|
||||
* @param ds_location for hosts in the cluster. defaults to oned.conf.
|
||||
* It will be modified to incude a trailing '/' if missing.
|
||||
* @param error_str Returns the error reason, if any
|
||||
*
|
||||
* @return the oid assigned to the object, -1 in case of failure
|
||||
@ -96,7 +94,6 @@ public:
|
||||
int * oid,
|
||||
int cluster_id,
|
||||
const string& cluster_name,
|
||||
string& ds_location,
|
||||
string& error_str);
|
||||
|
||||
/**
|
||||
@ -198,7 +195,7 @@ private:
|
||||
*/
|
||||
PoolObjectSQL * create()
|
||||
{
|
||||
return new Datastore(-1,-1,"","", 0, 0, -1, "", "");
|
||||
return new Datastore(-1,-1,"","", 0, 0, -1, "");
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -279,16 +279,6 @@ public:
|
||||
return var_location;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the default var location. When ONE_LOCATION is defined this path
|
||||
* points to $ONE_LOCATION/var, otherwise it is /var/lib/one.
|
||||
* @return the log location.
|
||||
*/
|
||||
const string& get_ds_location()
|
||||
{
|
||||
return ds_location;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the default vms location. When ONE_LOCATION is defined this path
|
||||
* points to $ONE_LOCATION/var/vms, otherwise it is /var/lib/one/vms. This
|
||||
@ -526,7 +516,6 @@ private:
|
||||
log_location = "/var/log/one/";
|
||||
var_location = "/var/lib/one/";
|
||||
remotes_location = "/var/lib/one/remotes/";
|
||||
ds_location = "/var/lib/one/datastores/";
|
||||
vms_location = "/var/lib/one/vms/";
|
||||
}
|
||||
else
|
||||
@ -543,7 +532,6 @@ private:
|
||||
log_location = nebula_location + "var/";
|
||||
var_location = nebula_location + "var/";
|
||||
remotes_location = nebula_location + "var/remotes/";
|
||||
ds_location = nebula_location + "var/datastores/";
|
||||
vms_location = nebula_location + "var/vms/";
|
||||
}
|
||||
};
|
||||
@ -680,7 +668,6 @@ private:
|
||||
string var_location;
|
||||
string hook_location;
|
||||
string remotes_location;
|
||||
string ds_location;
|
||||
string vms_location;
|
||||
|
||||
string hostname;
|
||||
|
@ -131,6 +131,10 @@ MAC_PREFIX = "02:00"
|
||||
# You can define a different DATASTORE_LOCATION in each cluster by updating
|
||||
# its properties with onecluster update.
|
||||
#
|
||||
# DATASTORE_BASE_PATH: This is the base path for the SOURCE attribute of
|
||||
# the images registered in a Datastore. This is a default value, that can be
|
||||
# changed when the datastore is created.
|
||||
#
|
||||
# DATASTORE_CAPACITY_CHECK: Checks that there is enough capacity before
|
||||
# creating a new imag. Defaults to Yes
|
||||
#
|
||||
@ -146,7 +150,9 @@ MAC_PREFIX = "02:00"
|
||||
# vd KVM virtual disk
|
||||
#*******************************************************************************
|
||||
|
||||
#DATASTORE_LOCATION = /var/lib/one/datastores
|
||||
#DATASTORE_LOCATION = /var/lib/one/datastores
|
||||
|
||||
#DATASTORE_BASE_PATH = /var/lib/one/datastores
|
||||
|
||||
DATASTORE_CAPACITY_CHECK = "yes"
|
||||
|
||||
|
@ -44,14 +44,13 @@ Datastore::Datastore(
|
||||
int umask,
|
||||
DatastoreTemplate* ds_template,
|
||||
int cluster_id,
|
||||
const string& cluster_name,
|
||||
const string& ds_location):
|
||||
const string& cluster_name):
|
||||
PoolObjectSQL(-1,DATASTORE,"",uid,gid,uname,gname,table),
|
||||
ObjectCollection("IMAGES"),
|
||||
Clusterable(cluster_id, cluster_name),
|
||||
ds_mad(""),
|
||||
tm_mad(""),
|
||||
base_path(ds_location),
|
||||
base_path(""),
|
||||
type(IMAGE_DS),
|
||||
total_mb(0),
|
||||
free_mb(0),
|
||||
@ -169,20 +168,12 @@ int Datastore::insert(SqlDB *db, string& error_str)
|
||||
goto error_tm;
|
||||
}
|
||||
|
||||
erase_template_attribute("BASE_PATH", base_path);
|
||||
|
||||
get_template_attribute("DATASTORE_LOCATION", datastore_location);
|
||||
|
||||
if (datastore_location.empty() == true )
|
||||
if (base_path.empty() == true )
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
nd.get_configuration_attribute("DATASTORE_LOCATION", datastore_location);
|
||||
}
|
||||
|
||||
// If default value provided, use it
|
||||
// If not, default to /var/lib/one (already present in base_path)
|
||||
if (datastore_location.empty() != true )
|
||||
{
|
||||
base_path = datastore_location;
|
||||
nd.get_configuration_attribute("DATASTORE_BASE_PATH", base_path);
|
||||
}
|
||||
|
||||
if ( base_path.at(base_path.size()-1) != '/' )
|
||||
@ -190,7 +181,7 @@ int Datastore::insert(SqlDB *db, string& error_str)
|
||||
base_path += "/";
|
||||
}
|
||||
|
||||
oss << base_path << oid; //base_path points to ds_location - constructor
|
||||
oss << base_path << oid;
|
||||
|
||||
base_path = oss.str();
|
||||
|
||||
|
@ -44,13 +44,9 @@ DatastorePool::DatastorePool(SqlDB * db):
|
||||
ostringstream oss;
|
||||
string error_str;
|
||||
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
if (get_lastOID() == -1) //lastOID is set in PoolSQL::init_cb
|
||||
{
|
||||
DatastoreTemplate * ds_tmpl;
|
||||
|
||||
string ds_location = nd.get_ds_location();
|
||||
int rc;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@ -78,7 +74,6 @@ DatastorePool::DatastorePool(SqlDB * db):
|
||||
&rc,
|
||||
ClusterPool::NONE_CLUSTER_ID,
|
||||
ClusterPool::NONE_CLUSTER_NAME,
|
||||
ds_location,
|
||||
error_str);
|
||||
|
||||
if( rc < 0 )
|
||||
@ -113,7 +108,6 @@ DatastorePool::DatastorePool(SqlDB * db):
|
||||
&rc,
|
||||
ClusterPool::NONE_CLUSTER_ID,
|
||||
ClusterPool::NONE_CLUSTER_NAME,
|
||||
ds_location,
|
||||
error_str);
|
||||
|
||||
if( rc < 0 )
|
||||
@ -148,7 +142,6 @@ DatastorePool::DatastorePool(SqlDB * db):
|
||||
&rc,
|
||||
ClusterPool::NONE_CLUSTER_ID,
|
||||
ClusterPool::NONE_CLUSTER_NAME,
|
||||
ds_location,
|
||||
error_str);
|
||||
|
||||
if( rc < 0 )
|
||||
@ -183,7 +176,6 @@ int DatastorePool::allocate(
|
||||
int * oid,
|
||||
int cluster_id,
|
||||
const string& cluster_name,
|
||||
string& ds_location,
|
||||
string& error_str)
|
||||
{
|
||||
Datastore * ds;
|
||||
@ -193,13 +185,8 @@ int DatastorePool::allocate(
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
if (*ds_location.rbegin() != '/' )
|
||||
{
|
||||
ds_location += '/';
|
||||
}
|
||||
|
||||
ds = new Datastore(uid, gid, uname, gname, umask,
|
||||
ds_template, cluster_id, cluster_name, ds_location);
|
||||
ds_template, cluster_id, cluster_name);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Check name & duplicates
|
||||
|
@ -240,6 +240,7 @@ void OpenNebulaTemplate::set_conf_default()
|
||||
# Datastore Configuration
|
||||
#*******************************************************************************
|
||||
# DATASTORE_LOCATION
|
||||
# DATASTORE_BASE_PATH
|
||||
# DATASTORE_CAPACITY_CHECK
|
||||
# DEFAULT_IMAGE_TYPE
|
||||
# DEFAULT_DEVICE_PREFIX
|
||||
@ -250,6 +251,11 @@ void OpenNebulaTemplate::set_conf_default()
|
||||
var_location + "/datastores");
|
||||
conf_default.insert(make_pair(attribute->name(),attribute));
|
||||
|
||||
//DATASTORE_BASE_PATH
|
||||
attribute = new SingleAttribute("DATASTORE_BASE_PATH",
|
||||
var_location + "/datastores");
|
||||
conf_default.insert(make_pair(attribute->name(),attribute));
|
||||
|
||||
//DATASTORE_CAPACITY_CHECK
|
||||
value = "YES";
|
||||
|
||||
|
@ -673,24 +673,8 @@ int DatastoreAllocate::pool_allocate(
|
||||
DatastorePool * dspool = static_cast<DatastorePool *>(pool);
|
||||
DatastoreTemplate * ds_tmpl = static_cast<DatastoreTemplate *>(tmpl);
|
||||
|
||||
Nebula& nd = Nebula::instance();
|
||||
string ds_location = nd.get_ds_location();
|
||||
|
||||
if ( cluster_id != ClusterPool::NONE_CLUSTER_ID )
|
||||
{
|
||||
ClusterPool * cpool = nd.get_clpool();
|
||||
Cluster * cluster = cpool->get(cluster_id, true);
|
||||
|
||||
if (cluster != 0)
|
||||
{
|
||||
ds_location = cluster->get_ds_location(ds_location);
|
||||
|
||||
cluster->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
return dspool->allocate(att.uid, att.gid, att.uname, att.gname, umask,
|
||||
ds_tmpl, &id, cluster_id, cluster_name, ds_location, error_str);
|
||||
ds_tmpl, &id, cluster_id, cluster_name, error_str);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
Loading…
x
Reference in New Issue
Block a user