From 3e8db30a9dcd56ef14892f2a606b3fd6673689e5 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Wed, 8 Sep 2010 13:27:00 +0200 Subject: [PATCH] feature #336: Preserve SOURCE if present in the template file --- src/image/Image.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/image/Image.cc b/src/image/Image.cc index 5a19ed6b24..2a8e837254 100644 --- a/src/image/Image.cc +++ b/src/image/Image.cc @@ -156,9 +156,6 @@ int Image::insert(SqlDB *db, string& error_str) string persistent_attr; string dev_prefix; - ostringstream tmp_hashstream; - ostringstream tmp_sourcestream; - // --------------------------------------------------------------------- // Check default image attributes // --------------------------------------------------------------------- @@ -230,13 +227,20 @@ int Image::insert(SqlDB *db, string& error_str) // ------------ SOURCE (path to store the image)-------------------- - tmp_hashstream << uid << ":" << name; + get_template_attribute("SOURCE", source); - tmp_sourcestream << ImagePool::source_prefix() << "/"; - tmp_sourcestream << sha1_digest(tmp_hashstream.str()); + if (source.empty()) + { + ostringstream tmp_hashstream; + ostringstream tmp_sourcestream; - source = tmp_sourcestream.str(); + tmp_hashstream << uid << ":" << name; + tmp_sourcestream << ImagePool::source_prefix() << "/"; + tmp_sourcestream << sha1_digest(tmp_hashstream.str()); + + source = tmp_sourcestream.str(); + } state = DISABLED;