From bbd1aff5e307912b5b74a162495f2604efc83f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 5 Mar 2014 17:33:57 +0100 Subject: [PATCH] Feature #2554: Allow to update the DS base_path --- src/datastore/Datastore.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/datastore/Datastore.cc b/src/datastore/Datastore.cc index 84ab5f2ed1..46d893a136 100644 --- a/src/datastore/Datastore.cc +++ b/src/datastore/Datastore.cc @@ -308,6 +308,8 @@ int Datastore::insert(SqlDB *db, string& error_str) base_path += "/"; } + add_template_attribute("BASE_PATH", base_path); + oss << base_path << oid; base_path = oss.str(); @@ -571,6 +573,7 @@ int Datastore::replace_template(const string& tmpl_str, string& error_str) string new_tm_mad; string s_ds_type; string new_disk_type_st; + string new_base_path; Image::DiskType new_disk_type; @@ -704,6 +707,28 @@ int Datastore::replace_template(const string& tmpl_str, string& error_str) replace_template_attribute("TM_MAD", tm_mad); } + /* ---------------------------------------------------------------------- */ + /* Set the BASE_PATH of the Datastore (class & template) */ + /* ---------------------------------------------------------------------- */ + + erase_template_attribute("BASE_PATH", new_base_path); + + if ( !new_base_path.empty()) + { + ostringstream oss; + + if ( new_base_path.at(new_base_path.size()-1) != '/' ) + { + new_base_path += "/"; + } + + add_template_attribute("BASE_PATH", new_base_path); + + oss << new_base_path << oid; + + base_path = oss.str(); + } + return 0; }