diff --git a/include/Datastore.h b/include/Datastore.h index 181dbdeba1..cd53d48bf5 100644 --- a/include/Datastore.h +++ b/include/Datastore.h @@ -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(){}; diff --git a/include/DatastorePool.h b/include/DatastorePool.h index 37d3d3b2ec..0892c8bd9a 100644 --- a/include/DatastorePool.h +++ b/include/DatastorePool.h @@ -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, ""); }; }; diff --git a/include/Nebula.h b/include/Nebula.h index ffe4316e21..3c54369f03 100644 --- a/include/Nebula.h +++ b/include/Nebula.h @@ -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; diff --git a/share/etc/oned.conf b/share/etc/oned.conf index bb0bb4f69a..5c39ab3628 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -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" diff --git a/src/datastore/Datastore.cc b/src/datastore/Datastore.cc index 1c1dac90db..c20a11b3da 100644 --- a/src/datastore/Datastore.cc +++ b/src/datastore/Datastore.cc @@ -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(); diff --git a/src/datastore/DatastorePool.cc b/src/datastore/DatastorePool.cc index a903a4ed14..c0f60e459f 100644 --- a/src/datastore/DatastorePool.cc +++ b/src/datastore/DatastorePool.cc @@ -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 diff --git a/src/nebula/NebulaTemplate.cc b/src/nebula/NebulaTemplate.cc index 215ac0a14f..672dc7a36e 100644 --- a/src/nebula/NebulaTemplate.cc +++ b/src/nebula/NebulaTemplate.cc @@ -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"; diff --git a/src/rm/RequestManagerAllocate.cc b/src/rm/RequestManagerAllocate.cc index e14ba8f7e1..a69243ed7e 100644 --- a/src/rm/RequestManagerAllocate.cc +++ b/src/rm/RequestManagerAllocate.cc @@ -673,24 +673,8 @@ int DatastoreAllocate::pool_allocate( DatastorePool * dspool = static_cast(pool); DatastoreTemplate * ds_tmpl = static_cast(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); } /* -------------------------------------------------------------------------- */