diff --git a/include/RequestManagerClone.h b/include/RequestManagerClone.h index 53a945bef7..c87811eab2 100644 --- a/include/RequestManagerClone.h +++ b/include/RequestManagerClone.h @@ -129,6 +129,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 c21aed43fe..b17ebc0a40 100644 --- a/src/rm/RequestManagerClone.cc +++ b/src/rm/RequestManagerClone.cc @@ -119,6 +119,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) { @@ -198,9 +201,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);