[PATCH] Issue #753: Avoid store max_memory in Templates records

When Kimchi creates a new template, it is recording the value of max_memory. This value is related to host and guest memory assigned or updated. If the value remains in objectstore, Kimchi will always use it, what is wrong, since host total memory or guest memory can change, and this should update max_memory value as well. Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- model/templates.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/model/templates.py b/model/templates.py index 84cdd02..eb72ea1 100644 --- a/model/templates.py +++ b/model/templates.py @@ -95,6 +95,9 @@ class TemplatesModel(object): with self.objstore as session: if name in session.get_list('template'): raise InvalidOperation("KCHTMPL0001E", {'name': name}) + # It is not necessary to store max_memory in Template record + if 'max_memory' in t.info: + del t.info['max_memory'] session.store('template', name, t.info, get_kimchi_version()) except InvalidOperation: -- 2.1.0

Reviewed-by: Paulo Vital <pvital@linux.vnet.ibm.com> On 12/08/2015 02:15 PM, Rodrigo Trujillo wrote:
When Kimchi creates a new template, it is recording the value of max_memory. This value is related to host and guest memory assigned or updated. If the value remains in objectstore, Kimchi will always use it, what is wrong, since host total memory or guest memory can change, and this should update max_memory value as well.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- model/templates.py | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/model/templates.py b/model/templates.py index 84cdd02..eb72ea1 100644 --- a/model/templates.py +++ b/model/templates.py @@ -95,6 +95,9 @@ class TemplatesModel(object): with self.objstore as session: if name in session.get_list('template'): raise InvalidOperation("KCHTMPL0001E", {'name': name}) + # It is not necessary to store max_memory in Template record + if 'max_memory' in t.info: + del t.info['max_memory'] session.store('template', name, t.info, get_kimchi_version()) except InvalidOperation:

On 08/12/2015 14:15, Rodrigo Trujillo wrote:
When Kimchi creates a new template, it is recording the value of max_memory. This value is related to host and guest memory assigned or updated. If the value remains in objectstore, Kimchi will always use it, what is wrong, since host total memory or guest memory can change, and this should update max_memory value as well.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- model/templates.py | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/model/templates.py b/model/templates.py index 84cdd02..eb72ea1 100644 --- a/model/templates.py +++ b/model/templates.py @@ -95,6 +95,9 @@ class TemplatesModel(object): with self.objstore as session: if name in session.get_list('template'): raise InvalidOperation("KCHTMPL0001E", {'name': name})
+ # It is not necessary to store max_memory in Template record + if 'max_memory' in t.info: + del t.info['max_memory']
Instead of removing the max_memory when creating the Template, it should have never been there. We should remove it from osinfo and request the information when need.
session.store('template', name, t.info, get_kimchi_version()) except InvalidOperation:
participants (3)
-
Aline Manera
-
Paulo Vital
-
Rodrigo Trujillo