From 34249544fdc5972597419ea5edcc01131aaa60b8 Mon Sep 17 00:00:00 2001 From: juanmont Date: Mon, 23 Apr 2018 18:29:38 +0200 Subject: [PATCH] B #1960: difference between allocate and clone/saveas --- src/image/Image.cc | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/image/Image.cc b/src/image/Image.cc index 3db053e597..43f23167c1 100644 --- a/src/image/Image.cc +++ b/src/image/Image.cc @@ -891,7 +891,8 @@ bool Image::test_set_persistent(Template * image_template, int uid, int gid, string per_oned; string conf_name; - bool persistent; + bool persistent = false; + bool tmpl_persis = false; if ( is_allocate ) { @@ -903,10 +904,8 @@ bool Image::test_set_persistent(Template * image_template, int uid, int gid, } int rc = nd.get_configuration_attribute(uid, gid, conf_name, per_oned); - - bool has_persistent = image_template->get("PERSISTENT", persistent); - - if ( rc == 0 && !has_persistent ) + + if ( rc == 0 ) { if ( one_util::toupper(per_oned) == "YES" ) { @@ -918,6 +917,23 @@ bool Image::test_set_persistent(Template * image_template, int uid, int gid, } } + bool has_persistent = image_template->get("PERSISTENT", tmpl_persis); + + if ( is_allocate ) + { + if ( has_persistent ) + { + persistent = tmpl_persis; + } + } + else + { + if (rc != 0 || ( rc == 0 && one_util::toupper(per_oned) == "" ) ) + { + persistent = tmpl_persis; + } + } + image_template->replace("PERSISTENT", persistent); return persistent;