diff --git a/include/RequestManagerClone.h b/include/RequestManagerClone.h index 85cf0aa9d8..a0a5f0e29a 100644 --- a/include/RequestManagerClone.h +++ b/include/RequestManagerClone.h @@ -126,6 +126,8 @@ protected: return vm_instantiate.merge(tmpl, s_a, att); }; + + static const std::vector REMOVE_DISK_ATTRS; }; /* ------------------------------------------------------------------------- */ diff --git a/src/rm/RequestManagerClone.cc b/src/rm/RequestManagerClone.cc index de2c0eb598..be57e41b79 100644 --- a/src/rm/RequestManagerClone.cc +++ b/src/rm/RequestManagerClone.cc @@ -117,6 +117,9 @@ Request::ErrorCode RequestManagerClone::clone(int source_id, const string &name, /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +const std::vector VMTemplateClone::REMOVE_DISK_ATTRS = { + "IMAGE", "IMAGE_UNAME", "IMAGE_UID", "OPENNEBULA_MANAGED"}; + Request::ErrorCode VMTemplateClone::clone(int source_id, const string &name, int &new_id, bool recursive, const string& s_uattr, RequestAttributes& att) { @@ -196,9 +199,10 @@ Request::ErrorCode VMTemplateClone::clone(int source_id, const string &name, goto error_images; } - (*disk)->remove("IMAGE"); - (*disk)->remove("IMAGE_UNAME"); - (*disk)->remove("IMAGE_UID"); + for (auto attr : REMOVE_DISK_ATTRS) + { + (*disk)->remove(attr); + } (*disk)->replace("IMAGE_ID", new_img_id);